Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end2end example for SD3 #3618

Merged
merged 25 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
642e718
initial progress NOT FUNCTIONAL
kahmed10 Sep 17, 2024
96712fb
add impl file
kahmed10 Sep 17, 2024
0c01ba1
continued progress
kahmed10 Sep 20, 2024
6483a96
continued progress
kahmed10 Sep 20, 2024
d076d83
update steps
kahmed10 Sep 20, 2024
aea9648
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Sep 20, 2024
7dd2d1f
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Sep 27, 2024
cecf24e
update script
kahmed10 Sep 28, 2024
b3d031c
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Oct 1, 2024
cb037e4
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Oct 23, 2024
13ddaf9
update requirements
kahmed10 Oct 31, 2024
1d1b3d8
update and cleanup files
kahmed10 Nov 1, 2024
e008254
formatting
kahmed10 Nov 1, 2024
c410d67
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Nov 1, 2024
5665e2e
updated version of script using optimum transformer
kahmed10 Nov 6, 2024
e635094
formatting
kahmed10 Nov 6, 2024
54da005
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Nov 6, 2024
991e016
fix external files
kahmed10 Nov 7, 2024
efd7fd1
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Nov 13, 2024
cf1ffad
update readme
kahmed10 Nov 13, 2024
f247f38
update reference image
kahmed10 Nov 13, 2024
fd81085
remove export function
kahmed10 Nov 13, 2024
e64ddeb
update README
kahmed10 Nov 19, 2024
bbe4ae2
Merge branch 'develop' of https://github.com/ROCm/AMDMIGraphX into sd…
kahmed10 Nov 19, 2024
d6d68ff
remove import
kahmed10 Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions examples/diffusion/python_stable_diffusion_3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Stable Diffusion 3

This version was tested with [rocm 6.2](https://github.com/ROCmSoftwarePlatform/AMDMIGraphX/tree/rocm-6.2.0) revision.

## Console application

To run the console application, follow these steps below.

Setup python environment

```bash
# this will require the python venv to installed (e.g. apt install python3.8-venv)
python3 -m venv sd_venv
. sd_venv/bin/activate
```

Install dependencies

```bash
pip install -r torch_requirements.txt
pip install -r requirements.txt
```

Use MIGraphX Python Module

```bash
export PYTHONPATH=/opt/rocm/lib:$PYTHONPATH
```

Get models:

Make sure you have permission to download and use stabilityai/stable-diffusion-3.
```bash
huggingface-cli login
```

Export the models to onnx.
Currently, optimum does not have the changes required in their latest version. For this reason, please follow the steps to build optimum from scratch.
```bash
git clone --single-branch --branch diffusers-transformer-export https://github.com/huggingface/optimum.git
cd optimum
make build_dist_install_tools
make build_dist
cd dist
pip install *.whl
cd ../..
```
Once optimum is built, use the following command to export the models:
```bash
optimum-cli export onnx --model stabilityai/stable-diffusion-3-medium-diffusers models/sd3
```

Run the text-to-image script with the following example prompt and seed (optionally, you can change the batch size / number of images generated for that prompt)

```bash
MIGRAPHX_DISABLE_REDUCE_FUSION=1 python txt2img.py --prompt "a photograph of an astronaut riding a horse" --steps 50 --output astro_horse.jpg
```
> [!NOTE]
> The first run will compile the models and cache them to make subsequent runs faster. New batch sizes will result in the models re-compiling.*

The result should look like this:

![example_output.jpg](./example_output.jpg)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading