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

Unifies SD pipeline APIs, adds sd3 support, punet integration #706

Merged
merged 175 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
b72ebfb
Small fixes to SDXL compilation and SD unet script fix.
monorimet Apr 17, 2024
ccbe1dd
Formatting and compile flag fixes.
monorimet Apr 17, 2024
76cc4db
Enable e2e sdxl test on mi250.
monorimet Apr 17, 2024
5feaf4d
Don't decompose attention in sdxl tests by default.
monorimet Apr 17, 2024
15c46f0
Remove xfails for rocm on submodels.
monorimet Apr 17, 2024
452ff7c
Change default attention spec path string in unet script.
monorimet Apr 17, 2024
9e3a153
Move attn spec and simplify parsing.
monorimet Apr 18, 2024
e97421c
Fix attn spec handling a bit more.
monorimet Apr 18, 2024
21f71cd
compile VAE last and disable decomp_attn entirely by default.
monorimet Apr 18, 2024
4a18301
Update SDXL readme.
monorimet Apr 18, 2024
7918824
Remove print statement.
monorimet Apr 18, 2024
d8839bb
Add flags to compile step for gfx90a
monorimet Apr 18, 2024
73a6328
Add support table for gfx targets to sdxl readme.
monorimet Apr 19, 2024
ead97cf
Switch MI250 run to cfg B
monorimet Apr 19, 2024
1915ad9
Update xfails
monorimet Apr 19, 2024
b582ef0
formatting
monorimet Apr 19, 2024
110a648
tolerance adjust for vae test and flag tweaks
monorimet Apr 20, 2024
3461f91
Remove --decomp_attn from mi250 CI job.
monorimet Apr 20, 2024
ed6eca5
Reduce number of sdxl inference steps for CPU CI
monorimet Apr 20, 2024
2a182aa
turn off const eval on cpu
monorimet Apr 20, 2024
b8efd3c
Remove xfails from rocm sdxl unet+t2i tests
monorimet Apr 20, 2024
a709214
xfails
monorimet Apr 21, 2024
65a1cb6
Update README.md
monorimet Apr 22, 2024
3d94c81
Update sdxl_test.py
monorimet Apr 22, 2024
a827c9a
Remove vector distribution, pad to intrinsics for now
monorimet Apr 23, 2024
cd223e4
Update flags, deepcopy decomposition defaults
monorimet Apr 23, 2024
46925c6
Formatting
monorimet Apr 23, 2024
b831643
xfail t2i test on rocm for now.
monorimet Apr 23, 2024
4120122
add return_imgs option to sdxl pipeline image generate fn.
monorimet Apr 24, 2024
5ba3c35
Fix default ireec flags.
monorimet Apr 24, 2024
29e2506
Tweak scheduler names in utils
monorimet Apr 24, 2024
0d6486c
Inline pipeline .mlir in python scripts for pip package inclusion.
monorimet Apr 24, 2024
13b068d
Add attention decomposition option to stateless_llama.py
monorimet Apr 24, 2024
f1e150c
Remove old rocm flags
monorimet Apr 24, 2024
0577d55
Add a few options for argmax to stateless_llama
monorimet Apr 25, 2024
b44cd16
Remove --verify=false from VAE compilation flags and move pipeline IRs
monorimet Apr 25, 2024
f23f56d
Remove unused import and revert change to sdxl unet correctness toler…
monorimet Apr 25, 2024
6577345
Formatting
monorimet Apr 25, 2024
393bfe3
Relax unet numerics tolerance in sdxl tests.
monorimet Apr 25, 2024
1b0bff6
Update sdxl compile flags.
monorimet May 1, 2024
1cb45b0
Update default_mfma_attn_spec.mlir
monorimet May 1, 2024
d59b909
Reorganize some compile flags.
monorimet May 1, 2024
660b563
formatting
monorimet May 1, 2024
c3cbf93
Update spec for nod-ai/SHARK-TestSuite@072e8b7f3140b31669257e6042dc1f…
monorimet May 1, 2024
54c5283
Update README.md
monorimet May 1, 2024
30469fe
(WIP) Unifies SD/SDXL pipelines
monorimet Apr 30, 2024
b7a3f7b
(WIP): More refactoring, setup for split schedulers implementation
monorimet May 1, 2024
3df8532
Update test_models.yml
monorimet May 1, 2024
bd851e3
Update requirements.txt
monorimet May 1, 2024
66e19f6
Try only pinning brevitas in requirements.
monorimet May 1, 2024
aab85d5
DNM: remove brevitas from models requirements
monorimet May 3, 2024
e449bb2
DNM: Remove brevitas from setup.py
monorimet May 3, 2024
49b1937
Update utils.py
monorimet May 3, 2024
cd44eec
use np.testing.assert_allclose in unet_runner
monorimet May 8, 2024
ef53b08
fixup typo.
monorimet May 8, 2024
c85b00a
update tolerances
monorimet May 8, 2024
25fd6c4
formatting
eagarvey-amd May 11, 2024
7f84246
Enable multiple batch size test.
eagarvey-amd May 11, 2024
12ca4c6
Simplify test_shark setup.
monorimet May 12, 2024
af3fc0c
Update requirements.txt
monorimet May 13, 2024
82363c5
Fix batch size configurability for submodels.
monorimet May 13, 2024
f1f37e3
Revert change to clip export function signature
monorimet May 17, 2024
86561e0
TD spec fixes
eagarvey-amd May 19, 2024
8309b68
Small fixes.
monorimet May 22, 2024
7646f42
Shore up SD1.5/2.1 implementations to match SDXL pipeline API / struc…
monorimet May 23, 2024
7e80dd7
Updates to cpu scheduling fallback.
monorimet May 23, 2024
ed52227
Fix arg parsers
monorimet May 23, 2024
7d30d31
Formatting.
monorimet May 23, 2024
f6e1d8e
Fix scheduler api in test.
monorimet May 23, 2024
c6767fd
Black version fix.
monorimet May 23, 2024
93ab363
add scipy and fix scheduler init
monorimet May 23, 2024
c8014fc
Small fixes
monorimet May 23, 2024
0ad9050
Fixes to match test function calls.
monorimet May 23, 2024
dd13911
Enable fetch of wmma spec.
monorimet May 23, 2024
bd222b8
Small fixes.
monorimet May 23, 2024
5a83242
Fixes for gfx1100, WIP sd1/2 pipe fixes
monorimet May 25, 2024
815da51
turbo fixes
eagarvey-amd May 25, 2024
8348ff7
various sd1.5/2.1 fixes
monorimet May 25, 2024
11430ee
Turbo support #2
monorimet May 26, 2024
b8a39fe
Disable CFG-free turbo exports, small fixes
monorimet May 27, 2024
10a8ceb
Fix test instantiation of scheduling model.
monorimet May 28, 2024
253a14e
fixes to sd tests
monorimet May 29, 2024
3986a1e
fixup commented attr
monorimet May 29, 2024
50c6c0d
Add DpmSolverSDE scheduler and fix formatting
monorimet May 29, 2024
4424d99
Remove one more CFG conditional from unet export.
eagarvey-amd May 29, 2024
e94b8dd
Remove breakpoint
eagarvey-amd May 29, 2024
ecf824b
Get wmma spec for gfx1150
eagarvey-amd May 29, 2024
45040bf
Make sizes dynamic for some in pipeline IR
eagarvey-amd May 29, 2024
5ddd898
Fixes for inlined weights
eagarvey-amd May 30, 2024
2def6fb
Fixes to inlined weights, llm compilation flexibility
eagarvey-amd May 30, 2024
5df2716
Add default triple to stateless_llama
eagarvey-amd May 30, 2024
68c7a57
Switch vecdist back on for instinct
eagarvey-amd May 30, 2024
258be08
Workaround prompt/neg prompt switching for turbo mode
eagarvey-amd May 30, 2024
a4f2391
Inlined weights fix for sd1.5/2.1
eagarvey-amd May 30, 2024
d7dabfa
Fix inline weights again.
eagarvey-amd May 31, 2024
e8dcd8a
Make getter for static pipeline IRs.
eagarvey-amd May 31, 2024
5dc4e3c
Fix pipeline ir import from sdxl_scheduled_unet script
eagarvey-amd May 31, 2024
c75ebe4
fix format() issue with pipeline IRs
eagarvey-amd May 31, 2024
a6796b2
Turn on const eval for triples for which we inline weights.
eagarvey-amd May 31, 2024
88b8df8
More fixes to pipeline IR
eagarvey-amd Jun 1, 2024
75cd61c
Add flag to disable transform dialect jit for llvmgpu
monorimet Jun 2, 2024
f246282
Add znver4 compile options.
monorimet Jun 2, 2024
76c9f23
Disable consteval.
monorimet Jun 2, 2024
5bb12ba
QOL fixes to unet scripts.
eagarvey-amd Jun 5, 2024
1993b0c
Adds batch size to prompt encoder and fixes
IanNod Jun 4, 2024
a126867
formatting
eagarvey-amd Jun 5, 2024
b262081
Fix resnet test.
monorimet Jun 5, 2024
036179e
Add a very simple gfx1100 resnet test.
monorimet Jun 5, 2024
81181fa
A few more resnet fixups for testing hip numerics, add winograd flags…
monorimet Jun 5, 2024
0d1a4b9
Updates to scheduled unet runner
monorimet Jun 5, 2024
df896a6
More sched unet runner fixes, remove bf16/winograd flags from default…
monorimet Jun 5, 2024
7e250c7
Remove SDE scheduler for now, model fixes
monorimet Jun 6, 2024
667282d
Establish support for split scheduling.
monorimet Jun 7, 2024
8817f5c
Add cpu scheduling to schedulers.py and runner, small fixes
monorimet Jun 10, 2024
9b97666
Bump diffusers fork version.
monorimet Jun 10, 2024
2500d14
Fixes for cpu schedulers, add split scheduler support to sdxl pipeline
monorimet Jun 11, 2024
52473eb
Start fixing tests
monorimet Jun 11, 2024
9798fd7
SD3 text encoding and diffusion modeling.
monorimet Jun 13, 2024
d3f06f6
Achieve basic functionality for sd3 txt2img
monorimet Jun 13, 2024
ac5fd3f
Update mmdit runner inputs, small attn reproducer, pad attention flag
monorimet Jun 14, 2024
cd50bbe
SD3 small tweaks for numerics
monorimet Jun 17, 2024
81ee093
Attn debugging tools
monorimet Jun 17, 2024
b793686
Attn debugging, piping for multi-device in sd3
monorimet Jun 17, 2024
7754609
Fixes for multi-device (SD3)
monorimet Jun 17, 2024
9656135
comment trace tensor
monorimet Jun 17, 2024
f6ab086
Multi-device support (SDXL)
monorimet Jun 17, 2024
7b861a7
Fix formatting
monorimet Jun 17, 2024
8048683
adds PEFT req. for lora scaling export issue and fix diffusers
monorimet Jun 17, 2024
05660c0
Add scheduler_id to sd3 api for unified signature
monorimet Jun 17, 2024
4692e11
Remove sentencepiece from reqs.
monorimet Jun 17, 2024
8b775aa
Temporarily comment out create_hal_driver usage for old iree version …
monorimet Jun 18, 2024
fd2a2ba
Fixes for vae precision/attn decomposition, numerics validation
monorimet Jun 18, 2024
b1f20f1
Fix numerics, add some features to VAE runner, add cpu scheduling opt…
monorimet Jun 19, 2024
618d01f
Point to azure links for specs and fix timesteps dim in gpu scheduler.
monorimet Jun 19, 2024
92be65b
Fixes to filename handling and model loading.
monorimet Jun 19, 2024
fd1543b
add clip test poc
dan-garvey Jun 19, 2024
fc6833d
add it to workflow to test
dan-garvey Jun 19, 2024
4e2c3cc
add tests for mmdit and vae
dan-garvey Jun 19, 2024
3c83a21
Allow schedulers to load/reload at generate_images
monorimet Jun 20, 2024
9bbbafc
Update linter and reformat.
monorimet Jun 20, 2024
7388e14
SDXL: fix scheduled unet modes
monorimet Jun 20, 2024
fd2185b
Make pipeline mode names mutually exclusive and fixes to weights loa…
monorimet Jun 21, 2024
3786061
Add new keys to weights skip
monorimet Jun 21, 2024
37c3368
xfail llama test.
monorimet Jun 21, 2024
5846d10
Add a base class for turbine-models pipelines.
monorimet Jun 23, 2024
7fabc3c
Flag-guard padded attention preprocessing instruction, start adding t…
monorimet Jun 24, 2024
74f677f
Add missing comma.
monorimet Jun 24, 2024
bac7c63
propagate change to pipeline wrapper names.
monorimet Jun 24, 2024
4eca3b2
Add paths to downloads for specs without masked attention.
monorimet Jun 24, 2024
4906549
Add test to and fixes for pipeline base
monorimet Jun 24, 2024
9eff443
Flag-guard pad attention for instinct as well.
monorimet Jun 24, 2024
df40309
Verify metadata results exactly and fix pass invocation to match upst…
monorimet Jun 25, 2024
39d8551
Bug fix for specified device when exporting submodels
IanNod Jun 28, 2024
2da9215
Missed device specified when exporting pipeline models
IanNod Jun 28, 2024
f330d25
Adds option for prompt encoder to use batched inputs
aviator19941 Jul 1, 2024
79a094f
Minor bug fix in batching
IanNod Jul 1, 2024
d534cd4
Consolidates SD pipelines and adds support for sharktank unet. (#766)
monorimet Jul 10, 2024
8cec78d
Merge branch 'main' into ean-unify-sd
monorimet Jul 10, 2024
323ecf4
[SD3] Fix text encoder impls import in text encoder runner.
eagarvey-amd Jul 11, 2024
4bef98b
Minor fixes for SDXL/unet (#770)
saienduri Jul 11, 2024
027b615
[WIP] add SDXL ml-perf harness model directory to choose correct mode…
aviator19941 Jul 10, 2024
08a1488
[WIP] Fix naming issue for punet external weights file
aviator19941 Jul 10, 2024
8a1bda1
Fix is_sdxl not checking the base_model_name properly
aviator19941 Jul 10, 2024
beb2c13
Fix sd_inference/vae case for SDXL
aviator19941 Jul 11, 2024
672f3e6
Update SD3 tests and exports.
eagarvey-amd Jul 11, 2024
021948f
Only setup export weights filepath if weights need to be created.
eagarvey-amd Jul 11, 2024
6396df1
Add a model map attribute for models that need weights for exports.
eagarvey-amd Jul 11, 2024
4814c92
Only pop pipeline wrappers from model map if they exist.
eagarvey-amd Jul 11, 2024
4468ed8
Fix gpu scheduling for sdxl, fixup for batched clip metadata
eagarvey-amd Jul 12, 2024
f922d05
Use amd-shark/sdxl-quant-models for F16 VAE weights
eagarvey-amd Jul 12, 2024
ec4bc05
small fixes to ensure specs are used where needed
eagarvey-amd Jul 12, 2024
931b70c
fix typo
eagarvey-amd Jul 12, 2024
7e580c9
Update models/requirements.txt to install editable sharktank package
aviator19941 Jul 12, 2024
b58d16a
Fix guidance conditional on cpu scheduler init.
eagarvey-amd Jul 12, 2024
c035f61
Use the correct variable in input metdata for prompt encoder with bs>1
eagarvey-amd Jul 12, 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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: git fetch --no-tags --prune --depth=1 origin "${GITHUB_BASE_REF?}:${GITHUB_BASE_REF?}"
- name: Install black
run: |
python3 -m pip install black==23.3
python3 -m pip install black
- name: Check if modified files are formatted
run: |
# The filter lowercase `d` means to exclude deleted files.
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
# from non default locations first. Installing the PyTorch CPU
# wheels saves multiple minutes and a lot of bandwidth on runner setup.
pip install --no-compile -r ${{ github.workspace }}/iree-turbine/pytorch-cpu-requirements.txt
pip install --no-compile --pre --upgrade -r ${{ github.workspace }}/iree-turbine/requirements.txt
pip install --pre --upgrade -r ${{ github.workspace }}/iree-turbine/requirements.txt
pip install --no-compile --pre -e ${{ github.workspace }}/iree-turbine[testing]
pip install --upgrade --pre --no-cache-dir iree-compiler iree-runtime -f https://iree.dev/pip-release-links.html
pip install --no-compile --pre --upgrade -e models -r models/requirements.txt
Expand All @@ -69,7 +69,8 @@ jobs:
source turbine_venv/bin/activate

pytest -v models/turbine_models/tests/sd_test.py
pytest -v models/turbine_models/tests/sdxl_test.py --device cpu --rt_device local-task --iree_target_triple x86_64-linux-gnu
pytest -v models/turbine_models/tests/sdxl_test.py --device cpu --rt_device local-task --iree_target_triple x86_64-linux-gnu --num_inference_steps 5
pytest -v models/turbine_models/tests/sdxl_test.py --device vulkan --rt_device vulkan --iree_target_triple rdna3-unknown-linux
pytest -v models/turbine_models/tests/sdxl_test.py --device rocm --rt_device hip --iree_target_triple gfx90a --precision fp16

pytest -v models/turbine_models/tests/sdxl_test.py --device rocm --rt_device hip --iree_target_triple gfx90a --precision fp16 --attn_spec default
pytest -v models/turbine_models/tests/sdxl_test.py --device rocm --rt_device hip --iree_target_triple gfx90a --precision fp16 --attn_spec default --batch_size 2
pytest -v models/turbine_models/tests/sd3_test.py --device cpu --rt_device local-task --iree_target_triple x86_64-linux-gnu --num_inference_steps 5
3 changes: 1 addition & 2 deletions .github/workflows/test_shark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
version: [3.11]
os: [nodai-ubuntu-builder-large]
os: [nodai-amdgpu-mi250-x86-64]

runs-on: ${{matrix.os}}
steps:
Expand Down Expand Up @@ -49,7 +49,6 @@ jobs:
cd $GITHUB_WORKSPACE/SHARK
python${{ matrix.version }} -m venv shark.venv
source shark.venv/bin/activate
sed -i 's/SHARK-Turbine#/SHARK-Turbine.git@${{github.sha}}#/g' requirements.txt
pip install -r requirements.txt --no-cache-dir
pip install -e .
python apps/shark_studio/tests/api_test.py
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ wheelhouse
*.safetensors
*.gguf
*.vmfb
*.mlir
*.npy
*.png
*tmp*
11 changes: 8 additions & 3 deletions models/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
protobuf
sentencepiece
shark_turbine
gguf
transformers==4.37.1
torchsde
accelerate
diffusers @ git+https://github.com/nod-ai/[email protected]
peft
diffusers @ git+https://github.com/nod-ai/[email protected]
brevitas @ git+https://github.com/Xilinx/brevitas.git@6695e8df7f6a2c7715b9ed69c4b78157376bb60b
# turbine tank downloading/uploading
azure-storage-blob
# microsoft/phi model
einops
pytest
scipy
shark-turbine @ git+https://github.com/iree-org/iree-turbine.git@main
-e git+https://github.com/nod-ai/sharktank.git@main#egg=sharktank&subdirectory=sharktank
5 changes: 2 additions & 3 deletions models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ def load_version_info():
),
install_requires=[
"Shark-Turbine",
"brevitas @ git+https://github.com/Xilinx/brevitas.git@6695e8df7f6a2c7715b9ed69c4b78157376bb60b",
"protobuf",
"sentencepiece",
"transformers==4.37.1",
"transformers>=4.37.1",
"accelerate",
"diffusers==0.24.0",
"diffusers==0.29.0.dev0",
"azure-storage-blob",
"einops",
],
Expand Down
169 changes: 169 additions & 0 deletions models/turbine_models/custom_models/llama_argmax_td_spec.mlir

Large diffs are not rendered by default.

Loading
Loading