Repository navigation
[diffusion] hold VAE decoder weights in their decode dtype from load - #35967
Merged
mickqian merged 1 commit intoAug 22, 2026
Merged
Conversation
The decode stage already persists these frozen weights in the autocast compute dtype on first use (prepare_autocast_linear_weights), so the rounding is part of every output today; it just happens after residency plans, host pins, and per-tile host-to-device copies were all sized for the checkpoint dtype. Rounding at load makes them carry the compute size: MiniMax-H3's video decoder drops from 9.7 to ~4.9 GiB, the difference between restreaming a third of it per tile and holding all 36 blocks on a 12 GiB card for the decode. SGLANG_DIFFUSION_DISABLE_EARLY_VAE_DECODER_CAST restores the old placement; disable_autocast and fp32 decode precisions are untouched. Co-Authored-By: Claude Fable 5 <[email protected]>
mickqian
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
ping1jing2 and
yichiche
as code owners
August 22, 2026 09:04
mickqian
added a commit
to mickqian/sglang
that referenced
this pull request
Aug 22, 2026
… cap Rewrites the ComfyUI comparison for the fp16-held decoder (sgl-project#35967): video_vae=36 fits 12 GB, the decode drops to ~10 s, and Recipe A wins the whole request at 32/48/64 GB hosts (235/218/180 s vs 276-302 / 246-267 / 194-195 s). Both engines are hard-capped at 12 GiB with set_per_process_memory_fraction -- ComfyUI's --reserve-vram alone is soft and peaked at 13.5 GiB, which a real 12 GB card cannot give it. Output equivalence is bit-level. Builder flags and hints carry the measured tiers. Depends on sgl-project#35967; do not merge before it. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Aug 22, 2026
This was referenced Aug 23, 2026
3 tasks done
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
The decode stage already rounds VAE decoder weights to the autocast compute dtype on first use (
prepare_autocast_linear_weights, whose docstring notes the persisted rounding is numerically equivalent). This PR performs that rounding at load instead, so residency plans, host pins, and every host-to-device copy carry the compute size rather than the checkpoint size. A kill switch (SGLANG_DIFFUSION_DISABLE_EARLY_VAE_DECODER_CAST) restores the old placement;--disable-autocastand fp32 decode precisions are untouched.Measured (MiniMax-H3, RTX 4090, 12 GiB cap + 32 GiB host convention, 5s/480p/20 steps)
video_vaeresidencyDenoise is unchanged (11.17 s/it, inside the 10.5–11.3 baseline band). No OOM; the run stays inside the 12 GiB cap.
Bit-identity holds because the decode already computed in fp16: casting fp32→fp16 at load lands on the same round-to-nearest-even values the stage produced per call. The embedding and output projections stay fp32 (their calls explicitly disable autocast), as does the encoder.
This also aligns the storage dtype with ComfyUI's H3 pipeline, which stages this VAE as fp16 (4965 MB); its decode-side advantage on 12 GB cards came entirely from that.
Notes
prepare_decoder_autocast_weights(duck-typed); others are untouched.🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #32563976293
Latest PR Test (Extra): ❌ Run #32564000895
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32563976139