Skip to content

[model] feat: Sync qwen_vl tree with upstream main, keep CP pre-shard fix - #19

Merged
yushengsu-thu merged 1 commit into
bridgefrom
qwen35-vl-sync-upstream
Jul 8, 2026
Merged

[model] feat: Sync qwen_vl tree with upstream main, keep CP pre-shard fix#19
yushengsu-thu merged 1 commit into
bridgefrom
qwen35-vl-sync-upstream

Conversation

@yushengsu-thu

Copy link
Copy Markdown
Collaborator

What

Sync the Qwen VL model tree with NVIDIA-NeMo/Megatron-Bridge main (bfc4b418), following up on #18:

  • models/qwen_vl/ (13 files): qwen35_vl_bridge.py now derives from the text-only Qwen35(MoE)Bridge (from [model] feat: Add text-only Qwen3.5 bridges (port from upstream main) #18); modelling_qwen3_vl/* picks up upstream's restructured forward (packed-CP partition path, MTP spec builders, rope/text-model updates)
  • tests/unit_tests/models/qwen_vl/ (7 files) synced to match
  • Additive-only ports into shared utils (existing code byte-identical): 4 packed-seq helpers into packed_seq_utils.py, accumulate_flops_metadata (+private helpers) into flop_utils.py
  • Preserved the local CP fix eeb84d7f (_cp_local_vision_embed_indices + positional AllGatherVisionEmbeddings.apply), re-applied onto the restructured model.py with a new packed_input_pre_sharded gate: upstream's new partition path must not double-slice inputs that a training framework (miles) already pre-sharded across CP ranks (cu_seqlens_q[-1] == cp_size * len(input_ids))

Deliberately NOT synced

  • qwen_vl/data/ (new upstream energon collate stack) — depends on data/sequence_batching.py, data/vlm_processing.py, and a GenericVisualInputs field this branch does not have; nothing here references it
  • recipes/ and shared conversion files (param_mapping.py, peft_bridge.py, model_bridge.py, bulk of flop_utils.py) — out of scope; audited that the synced tree only needs symbols that already exist here

GLM5 impact: none (verified)

  • Zero import coupling between models/glm5/ and models/qwen_vl/ (both directions)
  • Shared conversion files untouched; shared-util changes are strictly additive
  • GLM bridge unit tests pass; GLM-5.2 5-layer LoRA e2e smoke (rollout→train→save) passes (rc=0) on the miles stack with this tree

Validation

  • ruff check clean on all changed files
  • Import chain + bridge registration OK on the miles image (transformers 5.8.1)
  • pytest tests/unit_tests/models/{qwen_vl,qwen,glm,glm_vl}351 passed, 2 skipped
  • mcore-pin compatibility spot-checked on the runtime mcore: pp_rank= kwarg on the experimental-attention spec, scatter_to_sequence_parallel_region(group=), get_tensor_model_parallel_group_if_none — all present
  • Recipes API surface: every provider attr the qwen_vl recipes set/read still exists (upstream changes additive); recipe files unchanged

… fix

Sync src/megatron/bridge/models/qwen_vl/ (13 files) and its unit tests
(7 files) to NVIDIA-NeMo/Megatron-Bridge main (bfc4b41): the Qwen3.5-VL
bridge now derives from the text-only Qwen35(MoE)Bridge, and the
modelling_qwen3_vl stack picks up upstream's restructured forward with
its own packed-CP partition path.

Additive-only changes to shared files (existing code untouched):
- packed_seq_utils.py: add get_packed_seq_q_cu_seqlens,
  get_packed_seq_cp_partition_indices, unpack_mcore_thd_tensor_for_
  position_ids, repack_mcore_thd_position_ids (upstream versions);
  keep this branch's get_packed_seq_params as-is
- flop_utils.py: add accumulate_flops_metadata and its private helpers

Re-apply the local CP fix eeb84d7 onto the restructured model.py:
_cp_local_vision_embed_indices verbatim, AllGatherVisionEmbeddings.apply
positional args, and a new packed_input_pre_sharded gate so upstream's
partition path does not double-slice inputs a framework already sharded
across CP ranks (cu_seqlens_q[-1] == cp_size * len(input_ids)).

Deliberately NOT synced: qwen_vl/data/ (new upstream energon collate
stack; depends on data/sequence_batching.py, data/vlm_processing.py and
a GenericVisualInputs field this branch does not have), recipes, and the
shared conversion files (param_mapping/peft_bridge/model_bridge).

Signed-off-by: Yusheng Su <yushengsu.thu@gmail.com>
Copilot AI review requested due to automatic review settings July 8, 2026 05:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yushengsu-thu
yushengsu-thu merged commit 07d61e1 into bridge Jul 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants