Repository navigation
[Perf] diffusion: Remove per-step and per-request host syncs in Cosmos3 and Qwen-Image-2.1 - #45967
Merged
Merged
Conversation
The denoising loop checked the CFG window with `t.item()` on the device timestep every step, so the host waited for each step's kernels before launching the next one. Read the window from one host copy of the schedule instead; the per-step decisions and kernels are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The edit path built the VAE latent mean/std with `new_tensor` on every request, right after launching the condition-image VAE encode. That blocking upload made the host wait for the encode before it could start the prompt's image preprocessing. Keep the device tensors per (dtype, device) so the preprocessing overlaps the encode; the normalization is bit-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mickqian
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
kevin-mii,
niehen6174,
ping1jing2 and
yichiche
as code owners
October 23, 2026 04:27
Collaborator
Author
|
/tag-and-rerun-ci |
This was referenced Oct 23, 2026
Merged
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
Two blocking device reads sit on the host's critical path:
t.item()on the device timestep. So the host waited for each step's kernels to finish before it launched the next step.new_tensorright after launching the condition-image VAE encode. That pageable upload made the host wait for the encode before it could start the prompt's image preprocessing.Modifications
cosmos3.py: the loop takes one host copy of the timestep schedule (timesteps.tolist()), and_cfg_active_atreads the window from those floats. The per-step decisions and kernels are unchanged.qwen_image21.py:QwenImage21EncodingStageuploads the latent mean/std once per(dtype, device)and reuses them, so the preprocessing overlaps the encode. The normalization is bit-identical.Tests:
test_cosmos3_rollout.py::test_cfg_window_check_reads_host_timesteps: runs the denoising loop with a[400, 1000]CFG window over timesteps whoseitem()/float()/bool()raise. The window must still choose batched CFG at 999, 700 and 400, and the cond branch alone at 399 and 100. It fails on main.test_qwen_image21.py::test_condition_latents_reuse_uploaded_latent_stats: two edit requests must produce the reference-normalized condition latents bitwise, and the second request must reuse the first one's mean/std tensors (checked by identity).No files are shared with #45942, #45943, #45944 or #45948.
Accuracy Tests
The output pixels are identical across arms for both models.
Speed Tests and Profiling
Server benchmark, 2 interleaved rounds x 5 repeats, e2e. Each commit was measured on its own against the same base.
Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #39900393237
Latest PR Test (Extra): ❌ Run #39900393310
Latest PR Test (AMD ROCm 10): ⏳ Run #39900393090