Skip to content

[megatron][vlm] GLM-5.3-Flash vision-language model on Megatron (CP=1, packing) - #2432

Draft
xinyuangui2 wants to merge 3 commits into
NovaSky-AI:mainfrom
xinyuangui2:glm5-flash-vlm
Draft

xinyuangui2 wants to merge 3 commits into
NovaSky-AI:mainfrom
xinyuangui2:glm5-flash-vlm

Conversation

@xinyuangui2

@xinyuangui2 xinyuangui2 commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Depends on #2357 / #2404 at runtime (VLM packing gate, model_owns_packing). This PR contains only the GLM-5.3-Flash changes; CI may fail until those land.

Trains GLM-5.3-Flash with its vision tower (language_model_only=false) on Megatron.

  • glm5_next/vl_model.py (Glm5NextVLModel): the HF Glm5NextVisionModel, replicated across TP, in front of the existing GPTModel. Image features replace <|image|> embeddings before the SP scatter. It's a port of GLM53FlashModel from feat(model): add GLM-5.3-Flash support NVIDIA-NeMo/Megatron-Bridge#6044 (open).
  • Packing: the language model has no position encoding, so a packed stream needs no position rebuild. The model sets model_owns_packing=True to pass the [megatron][vlm] Allow sequence packing for VLMs incl. Qwen3.5-VL (CP=1) #2357 gate.
  • Not yet supported: CP>1 (KDA CP is [megatron] Context parallelism for GLM-5.3-Flash (head-wise KDA, all-gather DSA) #2418) and video both raise.
  • Glm5NextVLBridge: language-model mappings under language_model., plus visual.** ↔ model.visual.**. It is selected through a sentinel architecture only when language_model_only=false; the text-only bridge and its names are unchanged.
  • New config: megatron_config.freeze_vision_model / freeze_vision_projection.
  • Tests (4xH100, 4-layer slice, TP2/EP4; all pass at 5c0cb53):
    • vs HF: mean |dlogprob| 0.103 (bar 0.15).
    • Cross-sample leak check: with the microbatch shape fixed, swapping a neighbour's image moves a text sample by 0.007; the swapped image row itself moves by 0.48.
    • Text-only parity with language_model_only=true: 0.017 (bar 0.03).
    • CPU mapping-coverage test passes.
  • Note: packed-vs-alone isn't a usable check on this slice. A microbatch-shape change moves logprobs about 0.13, on the existing text-only path too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NrJwn14CQRnnMYja3jPNxb

xinyuangui2 and others added 3 commits October 12, 2026 20:19
…, packing)

- glm5_next/vl_model.py: Glm5NextVLModel, the HF Glm5NextVisionModel (replicated across TP)
  in front of the existing GPTModel; image features replace <|image|> embeddings before the SP
  scatter. Port of Megatron-Bridge#6044's GLM53FlashModel. model_owns_packing=True (NoPE LM,
  so a packed stream needs no position rebuild). CP>1 and video raise.
- Glm5NextVLModelProvider / Glm5NextVLBridge: language-model mappings under language_model.,
  plus visual.** <-> model.visual.**. Selected via a sentinel architecture only when
  language_model_only=false; the text-only path is unchanged.
- megatron_config.freeze_vision_model / freeze_vision_projection.
- Tests: CPU mapping checks; GPU (h100) HF parity, packed-vs-alone, text-only parity on the
  4-layer slice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NrJwn14CQRnnMYja3jPNxb
Signed-off-by: xgui <xgui@anyscale.com>
… test config

- Image-free microbatches carry an empty [0, D] pixel_values tensor; skip the vision tower.
- Test config: no colocation, no ref model, ETP=1 (ETP x EP must divide the world size).
- Text-only parity: mean bar at the MoE run-to-run noise level instead of bitwise.

Found by the first GPU run on 4xH100.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NrJwn14CQRnnMYja3jPNxb
Signed-off-by: xgui <xgui@anyscale.com>
…a fixed-shape leak check

Packed-vs-alone measures this slice's MoE sensitivity to microbatch shape (~0.13 mean
|dlogprob|, reproduced on the text-only GPTModel path with length-matched rows), not
cross-sample leakage. The new test keeps the shape fixed and swaps only the neighbour's
image pixels (4xH100: 0.005-0.013 vs 0.47 on the swapped image itself). HF bar 0.1 -> 0.15
for the same reason (packed 0.10, alone 0.08 from HF).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NrJwn14CQRnnMYja3jPNxb
Signed-off-by: xgui <xgui@anyscale.com>

This branch has not been deployed

No deployments
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.

1 participant