Repository navigation
Studio ROCm: explicit W8A8 only on gfx1151, fold the VAE upsample in strips - #18995
Merged
Merged
Conversation
rdna_explicit_w8a8_reason (FLUX.3 Klein image, and LTX-2.5 through
rdna_video_explicit_w8a8_reason, resident and offloaded) now also needs the
target card's own gfx arch, read by its ordinal, to be in
RDNA_EXPLICIT_W8A8_ARCHS = {gfx1151}. The RDNA W8A8 kernels accept every
gfx11xx / gfx12xx card, but the explicit W8A8 rows were only measured on
gfx1151; gfx1100 / gfx1101 / gfx1201 and an unreadable arch keep the
weight-only explicit int8 build. The weight-only compiled tier is unchanged.
…oder's retry On gfx1151 one whole-map transposed conv (MIOpen) doubled the FLUX.2 1024 px full-map decode peak (1.55 -> 3.10 GiB), which full_map_decode_mib does not price. ROCm now folds strip by strip (full_max = strip_elems), the shape the 2048 px decode already used with its peak unchanged. CUDA keeps the whole-map limit. A decoder whose strip decode failed now retries (and keeps decoding) on the torch ops without the fold, so a failing fold is not run a second time before the tiles take over. The fold is not tied to the portable mode itself: ROCm and no-Triton hosts run every strip decode portable and keep the fold.
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. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
[skip ci]
danielhanchen
added a commit
that referenced
this pull request
Nov 23, 2026
…p retrying a failed portable VAE fold (#19012) ## Summary Two small follow-ups on main for the diffusion stack. ### 1. A fine-tune named like the official repo no longer loads the official prequantised weights `_same_base_model` (`studio/backend/core/inference/diffusion_prequant.py`) accepted any two ids whose last path segment matched. So `someone/Qwen-Image-2.1` counted as `Qwen/Qwen-Image-2.1`, and every hosted prequant reader that runs this check (the torchao prequant loader, the text encoder prequant check, the converted single-file check and the fp8 training seed) could load the official prequantised DiT in place of the fine-tune's own weights. Now: - Both sides are still normalised through `canonical_base` (the `unsloth/*` mirrors), and the retired full copies (`unsloth/flux-3-image-klein[-base]`) map to their upstream too. - The compare is case-insensitive on the full id. - Two Hub repo ids must name the same repo. A different owner with the same repo name is refused, so the loader falls back to quantising the fine-tune's own dense weights. - A local path (`/models/Qwen-Image-2.1`, `C:\models\Qwen-Image-2.1`, or a relative directory that exists) still uses the name compare as before. `family_prequant_repo` depends on that for a local copy of the base, and so does its test. Every `base_model_id` value I could find in the hosted files was checked against its official id, every case spelling, its declared mirror and its retired copy. These are the ids in the `unsloth_metadata` header of each root `.safetensors` in every `unsloth/*` repo Studio names, read from the live Hub headers. All of them still match. The new test lists them, along with every pair in `_ALL_MIRROR_PAIRS` and `_RETIRED_FULL_COPIES`. ### 2. A failed upsample fold on the portable VAE path is not retried on every decode On the portable whole-map decode (no fused kernels: ROCm, MPS, CPU, or CUDA when the kernels are not usable), a non-OOM failure with the upsample fold engaged was re-raised to the tiles without marking the decoder. Every later decode tried the fold again before it fell back. Now `full_map_decode` marks the decoder (`_unsloth_vae_fold_failed`) when a portable run fails while the fold is engaged. It then retries that decode once with the fold off, and later decodes skip the fold. This is the same pattern the kernels path already uses with `_unsloth_vae_strips_failed`. Since #18995, that strips mark also turns the fold off. Now both marks feed the same `fold` switch and every retry runs with the fold off, so the decoder has one fold-off path, not two. Other behaviour does not change: - OOM still goes to the tiles, with no mark. - A portable failure with the fold not engaged still raises to the tiles. - The kernels path still marks `_unsloth_vae_strips_failed` and retries on the torch ops without the fold, as in #18995. - ROCm still folds strip by strip (`_fold_full_max`) until the fold fails on that decoder. ## Tests - `tests/test_diffusion_prequant_same_base.py` (new, 85 cases): on main, 7 fail (the same-name fine-tune cases and the text encoder / fp8 training readers). With the fix, all 85 pass. The 78 positive cases pass on both. - `tests/test_diffusion_vae_fold_failure.py` (new, 3 cases): on main, the fold-failure case fails because the decode raises and the fold is tried on every call. With the fix, all 3 pass. The OOM case and the failure-outside-the-fold case pass on both. - `tests/test_video_h3_te_quant.py::test_the_index_compare_has_no_tail_name_tolerance`: its precondition asserted that `te_base_equivalent` accepts `someone/MiniMax-H3`, which was the hole being closed. It now asserts that the Hub fine-tune is refused and that a local path is still tolerated. - Wider runs on CPU: - The 146 test files that touch the prequant / TE prequant / converted single-file / fp8 training / prequant cache / native cache paths: 6834 passed, 268 skipped, 25 failed, 4 errors. Only the H3 test above differed from main. The other 24 failures and 4 errors also fail on main, with the same test IDs, so they predate this change on this host. The ones inspected are host environment issues: the installed huggingface_hub lacks `get_cached_repo_tree`, and diffusers 0.40 is older than some families need. - The 14 test files that touch the VAE strips / tiling / whole-map decode: 3245 passed, 49 skipped, 2 xfailed, 4 failed. All 4 fail the same way on main, for the same `get_cached_repo_tree` import reason. ## Not covered here - No GPU run. The fold change was checked on CPU with a tiny AutoencoderKL and an injected failure. A real ROCm or MPS fold failure was not reproduced. - The prequant cache key (`base_identity`) still uses the repo name, so it is coarser than the new compare. Two bases share a key only when their dense source bytes are also identical, so the cached weights are the same either way. The key is left unchanged so existing local caches stay valid.
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.
Summary
Two follow-ups on merged ROCm work, found while re-checking the gfx1151 int8 and VAE changes:
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_reasonalso needs the target card's own gfx arch, read by its ordinal throughrocm_bf16._device_gfx_arch, to be inRDNA_EXPLICIT_W8A8_ARCHS = {"gfx1151"}. That covers: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 keepsFOLD_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.pyandtest_video_rocm_hosted_int8.pycheck 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.pycovers 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.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 ismax_memory_allocatedabove what was allocated before the decodes. Estimate is the tree's ownfull_map_decode_mib.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
_rocm_cuda, and_fold_full_maxreturns the old limit on non-ROCm devices. Not rerun on hardware.Test plan
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.pypasstests/test_diffusion_native_quant.py,tests/test_diffusion_vae_tiling_general.py: one pre-existing failure each, which fails the same way on main