Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves training performance and code quality by removing dead code and avoiding unnecessary GPU→CPU synchronization points, while also fixing a dtype typo and simplifying a small comparison.
Changes:
- Removed unused variables (and associated
.item()calls) that introduced GPU→CPU syncs in Qwen2.5-VL and Qwen2.5-VL attention/forward paths. - Removed redundant/dead assignments and a duplicate helper function definition.
- Fixed an invalid dtype reference (
torch.torch.int32→torch.int32) and simplified a layer-index bounds check.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/lmms_engine/models/sequence_packing_utils.py |
Removes duplicate _get_unpad_data definition and fixes torch.int32 dtype usage in _unpad_input. |
src/lmms_engine/models/qwen3_vl/qwen3_vl_ops.py |
Simplifies deepstack layer gating condition to avoid range(...) membership check. |
src/lmms_engine/models/qwen3_vl/qwen3_vl_liger.py |
Removes a redundant hidden_states = outputs[0] assignment. |
src/lmms_engine/models/qwen2_5_vl/qwen2_5_vl_ops.py |
Removes unused variables that computed torch.max(position_ids).item() (sync point) inside attn_forward. |
src/lmms_engine/models/qwen2_5_vl/qwen2_5_vl_liger.py |
Removes unused token counting variables that called .item() in lce_forward. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kcz358
approved these changes
Apr 1, 2026
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
During code review, identified several issues that hurt training performance and code quality:
.item()calls causing GPU→CPU synchronization barriers in the forward passtorch.torch.int32) and a suboptimal comparison patternModifications
Eliminate unnecessary GPU-CPU syncs
qwen2_5_vl_liger.py: Removed 4 unused variables (tokens_count,n_image_tokens,n_video_tokens,visual_tokens)that each called
.item(), causing GPU-CPU sync every forward passqwen2_5_vl_ops.py: Removed 3 unused variables (bsz,q_len,kv_seq_len) inattn_forward, wheretorch.max(position_ids).item()also triggered GPU-CPU syncRemove dead code
qwen3_vl_liger.py: Removed redundanthidden_states = outputs[0](already assigned on the line above)sequence_packing_utils.py: Removed duplicate_get_unpad_datafunction definition (identical copy)Fix typo and optimize comparison
sequence_packing_utils.py: Fixedtorch.torch.int32→torch.int32in_unpad_inputqwen3_vl_ops.py: Changedlayer_idx in range(len(deepstack_visual_embeds))→layer_idx < len(deepstack_visual_embeds)(logically equivalent, avoids creating a range object each iteration)
Verification
Verified with actual GPU training on 2x A100 (FSDP2 + Liger + rmpad):
blackandisort