Repository navigation
[diffusion] Skip zero blocks when hashing large conditioning inputs - #42748
Merged
mickqian merged 2 commits intoOct 6, 2026
Merged
Conversation
niehen6174
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
kevin-mii,
mickqian,
ping1jing2 and
yichiche
as code owners
October 6, 2026 10:07
Collaborator
Author
|
/tag-and-rerun-ci |
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.
Motivation
Since the conditioning cache (#40470), every single-GPU image-to-video request spends 0.4–1 s hashing its VAE input, even when the cache misses. Diffusion CI shows this as a flaky stage check on
longlive2_i2v.ImageVAEEncodingStagepassesvae.encodea video tensor made of the image followed bynum_frames - 1zero frames. For thelonglive2_i2vCI case this is a 652 MB fp32 tensor ([1, 3, 61, 928, 960])._fingerprintcopied all of it to pageable host memory and ran sha256 over it:LongLive2ImageVAEEncodingStage--disable-conditioning-cacheIn CI every request misses, so this is pure overhead. On a hit, the hash alone still costs about as much as the encode it saves on H100.
CI impact. The stage baseline is 920 ms and the PR limit is 1657 ms (80% + 120 ms pad).
Other CI cases were not affected.
cached_vae_encodebypasses the cache when world size > 1, and the Wan I2V cases run on 2 GPUs. Single-GPU Wan I2V outside CI pays the same cost: +0.42 s at 480P and +0.96 s at 720P with 81 frames.Modifications
_tensor_digest: for CUDA tensors of at least 16 MiB, find the nonzero 64 KiB blocks with oneamaxon the device. Hash the block bitmap plus the bytes of the nonzero blocks only.-0.0is not treated as0.0. Together with dtype, shape and stride, the key still identifies every byte. Cache semantics are unchanged.-0.0in a zero frame, for a change in the last byte, and for a frame shift.Validation
RTX 5090, real
ConditioningCache, LongLive2 and Wan2.1 VAEs, a new image per request as in CI. Times are synced medians of 4 runs.test_conditioning_cache.py34 passed.test_text_encoding_cache.py,test_conditioning_model_boundaries.pyandtest_multi_output_grouping.py: 98 passed, 1 skipped._fingerprintcost for the CI shape is the same on H100 CI (710 ms) and on the RTX 5090 (711 ms). I expectLongLive2ImageVAEEncodingStageon CI to return to about 930 ms, but this has not been measured on H100 yet.CI States
Latest PR Test (Base): ✅ Run #37447684529
Latest PR Test (Extra): ❌ Run #37448281811
Latest PR Test (AMD ROCm 10): ⏳ Run #37447684513