Repository navigation
Studio diffusion: VAE upsample fold on by default on gfx1151 - #18854
Merged
Merged
Conversation
…le-map strip decode 1.06-1.08x on Linux and Windows ROCm)
Member
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
3 tasks done
danielhanchen
added a commit
that referenced
this pull request
Nov 23, 2026
…strips (#18995) ## Summary Two follow-ups on merged ROCm work, found while re-checking the gfx1151 int8 and VAE changes: 1. #18903 (and the FLUX.3 explicit W8A8 row before it) turned an explicit int8 pick into W8A8 on every RDNA3 / RDNA4 card, but only gfx1151 was ever measured. The W8A8 rows now apply only on gfx1151; other RDNA cards keep the weight-only explicit int8 build they used before. 2. #18854's VAE upsample fold on gfx1151 ran one whole-map transposed conv at 1024 px, which doubled the full-map decode peak (1.55 -> 3.10 GiB in that PR's own table) while `full_map_decode_mib`, the estimate the admission check uses, has no term for it. ROCm now folds strip by strip, the shape the 2048 px decode already used with its peak unchanged. A decoder whose strip decode failed also no longer re-runs the fold in its retry. ## Changes - `diffusion_transformer_quant.py`: `rdna_explicit_w8a8_reason` also needs the target card's own gfx arch, read by its ordinal through `rocm_bf16._device_gfx_arch`, to be in `RDNA_EXPLICIT_W8A8_ARCHS = {"gfx1151"}`. That covers: - FLUX.3 Klein explicit int8 (image); - LTX-2.5 explicit int8 through `rdna_video_explicit_w8a8_reason`, both the resident hosted read (`_video_rocm_hosted_scheme`) and the offloaded native build (`_video_int8_act`). The RDNA W8A8 kernels still accept every gfx11xx / gfx12xx card (`_ROCM_FUSED_W8A8_ARCH`), and the weight-only compiled explicit int8 tier (`rdna_explicit_int8_reason`) is unchanged on all of them. gfx1100 / gfx1101 / gfx1201 and an unreadable arch lose only the unmeasured W8A8 switch. AUTO (`rdna_auto_w8a8_reason`) is not touched here. - `diffusion_vae_strips.py`: - `_fold_full_max(x)`: on ROCm the fold's whole-map limit is one strip (`strip_elems`), so MIOpen's transposed conv runs per strip with a bounded workspace. CUDA keeps `FOLD_FULL_MAX_ELEMS`. - `full_map_decode`: a decoder whose strip decode failed retries, and keeps decoding, on the torch ops without the fold, so a failing fold does not run twice before the tiles take over. The fold is not tied to the portable mode itself, because ROCm and no-Triton hosts run every strip decode in portable mode and must keep the fold. - Tests: - `test_diffusion_flux3_rdna_shared_quant.py` and `test_video_rocm_hosted_int8.py` check the arch gate: gfx1151 on, gfx1100 / gfx1101 / gfx1201 / "" off, the arch read by the target ordinal, and an unreadable arch treated as off. The video test covers the resident spec and the offloaded spec. - `test_diffusion_vae_upsample_fold.py` covers the ROCm strip limit and the fold call count per strip, and checks that a portable decode keeps the fold while the failed-decoder retry drops it. - The existing RDNA fixtures pin the arch to gfx1151. ## Results (gfx1151, ROCm 7.13, torch 2.11) Base = main 1446c1d, head = base + this branch, same runner and job, Linux ROCm 7.13. FLUX.2 VAE (`unsloth/flux-3-image-klein`), whole-map strip decode (`full_map_decode`), bf16, fixed latents. Fresh process per arm, fold off / on in ABBA order, decode time is the median of 3 decodes after a warm one. Peak is `max_memory_allocated` above what was allocated before the decodes. Estimate is the tree's own `full_map_decode_mib`. | px | arm | base s | head s | base peak MiB | head peak MiB | estimate MiB | |---|---|---|---|---|---|---| | 1024 | fold off | 2.506 | 2.509 | 1409 | 1409 | 2322 | | 1024 | fold on | 2.372 | **2.289** | 2997 | **1427** | 2322 | | 2048 | fold off | 11.380 | 11.442 | 3370-3497 | 3370 | 4682 | | 2048 | fold on | 10.535 | 10.539 | 3388 | 3388 | 4682 | - Base's 1024 px fold peak (2997 MiB) is above its own estimate (2322 MiB), which is the under-pricing this fixes. Head's is 1427 MiB, within 18 MiB of the fold-off peak. - Fold speedup over fold off is unchanged or better: 1024 px 1.056x -> 1.096x, 2048 px 1.080x -> 1.086x. At 1024 px the strip fold is also faster than the whole-map fold measured inside the head tree (2.289 vs 2.384 s). - The fold still runs: 12 fold calls per run in both trees. The head runs 104 transposed convs (strips) where base ran 12. - Output: the fold-off images are byte-identical between base and head. Base's whole-map fold re-run inside the head tree is byte-identical to base. The head strip fold against the base whole-map fold differs only at rounding (max abs 0.031, PSNR 66.6 dB), closer than fold against no fold (64.8 dB, the tolerance #18854 shipped with). - LTX-2.5 explicit int8 (512x320, 17 frames, 8 steps): both arms log `read 480 int8 ConvRot layers of transformer from the hosted checkpoint as native Linears`, 15.83 / 15.93 s per clip, and the clips are byte-identical. The gate still allows gfx1151. ## Not covered - gfx1100 / gfx1101 / gfx1201: no such runner was available, so the refusal on those archs is proven on CPU only (the gate's arch read is mocked per arch). - Windows ROCm: not run here. The arch gate is platform-neutral. The VAE strip fold matches the 2048 px shape that #18854 measured on Windows 7.14. - CUDA: unchanged by construction. The arch gate sits behind `_rocm_cuda`, and `_fold_full_max` returns the old limit on non-ROCm devices. Not rerun on hardware. ## Test plan - [x] `tests/test_diffusion_flux3_rdna_shared_quant.py`, `tests/test_video_rocm_hosted_int8.py`, `tests/test_video_hosted_int8_fit.py`, `tests/test_diffusion_vae_upsample_fold.py`, `tests/test_diffusion_vae_strips.py`, `tests/test_diffusion_vae_full_map.py`, `tests/test_diffusion_vae_tiling.py` pass - [x] `tests/test_diffusion_native_quant.py`, `tests/test_diffusion_vae_tiling_general.py`: one pre-existing failure each, which fails the same way on main - [x] gfx1151 hardware run, base (main) vs head: VAE criteria CONFIRMED (defect at base, cleared at head), LTX-2.5 NO_REGRESSION (byte-identical)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #18792. The VAE upsample fold, one stride-2 transposed conv in place of nearest 2x plus conv3x3, turns on by default only on the measured CUDA cards. On ROCm it stayed off because MIOpen's transposed conv had not been measured. This turns it on by default on gfx1151 (Radeon 8060S), the AMD arch it was measured on.
Change
_fold_onalso arms on ROCm when the device'sgcnArchNameis in_FOLD_ROCM_ARCHS(gfx1151). Other ROCm archs, MPS and CPU keep the 2x path.UNSLOTH_VAE_UPSAMPLE_FOLD=0still turns it off, and=1still forces it anywhere.On ROCm the fold can only engage in
full_map_decode, the whole-map strip decode the tile planner uses when the stock decode would not fit. The per-module strip install is refused on ROCm, so this change does not touch any other decode.Measured on gfx1151
FLUX.2 VAE whole-map decode, fold off vs on (12 fold calls per decode), fresh process per arm, order off-on-on-off, median of 3 after a warm-up:
The fold is the same rounding-level change as on CUDA. On Linux the whole-map decode, with the fold on or off, stays 7-8e-5 LPIPS from the stock decode.
Tests
test_diffusion_vae_upsample_fold.py::test_auto_arms_only_the_measured_cuda_cardsnow covers ROCm. gfx1151, with or without feature suffixes, arms the fold. gfx942, gfx1100 and an empty arch name do not, and the kill switch still wins on gfx1151. It fails on main and passes here; the other 10 tests in the file are unchanged.Not proven here