[Perf][Bagel] Avoid per-step device syncs in Bagel img2img#3987
Merged
Gaohan123 merged 3 commits intoJun 2, 2026
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Contributor
Author
|
@princepride PTAL |
Cache the VAE-mask flags and iterate host-side values so the AR MoT routing and the DiT denoise loop stop forcing GPU->CPU syncs on every layer/step. Signed-off-by: natureofnature <wzliu@connect.hku.hk>
1e68110 to
8ddca2e
Compare
86MaxCao
pushed a commit
to 86MaxCao/vllm-omni
that referenced
this pull request
Jun 4, 2026
…ect#3987) Signed-off-by: natureofnature <wzliu@connect.hku.hk>
akshatvishu
pushed a commit
to akshatvishu/vllm-omni
that referenced
this pull request
Jun 13, 2026
…ect#3987) Signed-off-by: natureofnature <wzliu@connect.hku.hk> Signed-off-by: akshatvishu <akshatnayak197@gmail.com>
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.
PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
Purpose
AR
The Bagel img2img path forces implicit GPU→CPU synchronizations in two hot loops, leaving the GPU idle while the CPU stalls:

DIT
model_executor/models/bagel/bagel.py) — the MoT routing callsvae_mask.any()/~vae_mask.any()(each is an implicit.item()device sync), and_adjust_positions_for_img2imgindexes the CUDApositionstensor element-by-element in a Python loop (one sync per token).diffusion/models/bagel/bagel_transformer.py) — the denoise loops iteratefor t in timestepswheretimestepsis a CUDA tensor (sotis a 0-d tensor → building the timestep tensor and thecfg_intervalcomparison sync eachstep), and attention uses Pythonmax()/sum()over length tensors (one sync per element).Fix
.any().positionsto the host once before the boundary loop.timesteps.tolist()sotis a Python float (timesteps[i]tensor is still used for the scheduler).query_lens.max(),query_lens.sum()) instead of Pythonmax()/sum()over tensors.Test Plan
metrics.stage_durations(stage_0_gen_ms/stage_1_gen_ms) baseline vs patched.Test Result
Split serving (RDMA connector, 15 steps, i2i),
stage_0= AR,stage_1= DiT, All changes are numerically identical — outputs are byte-for-byte unchanged (md5 of generated images matches before/after at both 256² and 1024²).mean of 5 measured runs (H800, AR/DIT disaggregation):
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model. Please runmkdocs serveto sync the documentation editions to./docs.BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)