[megatron] GLM-5.3-Flash (glm5_next) support + 4-layer GPU CI entry - #2156
Closed
erictang000 wants to merge 8 commits into
Closed
[megatron] GLM-5.3-Flash (glm5_next) support + 4-layer GPU CI entry#2156erictang000 wants to merge 8 commits into
erictang000 wants to merge 8 commits into
Conversation
…layers, bridge, 4-layer GPU CI entry WIP progress commit. Megatron side validated against HF transformers on the CharyZeng/GLM-5.3-Flash-4layer slice (TP1, TP2/EP2, PP2, and the >2048-token sparse-indexer path all at the bf16 noise floor). vLLM side (commit wheel with GLM-5.3 support + torch-2.11 DeepGEMM build) still being brought up. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…; note vLLM dev flashinfer pin Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…verflow at 1024 seqs) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…ers (with fallback) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…r vLLM's GLM-5.3 DSA indexer Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…LLM >= 0.28.1) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…s gated in vLLM >= 0.28.1) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@gmail.com>
…ise floor of the truncated slice) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Eric Tang <erictang000@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.
What
Adds GLM-5.3-Flash (
glm5_next) to the Megatron backend and atest_megatron_modelsCI entry forthe 4-layer slice
CharyZeng/GLM-5.3-Flash-4layer. Neither the pinned megatron-core nor Megatron-Bridge know thearchitecture (45 layers = 34 KDA linear-attention + 11 DSA sparse-MLA with a kpool-compressed indexer,
288-expert sigmoid MoE, mHC hyper-connections on every block, NoPE MLA, VL checkpoint), so everything
model-specific lives in a new package
skyrl/backends/skyrl_train/workers/megatron/glm5_next/:mhc.pycomb, stream collapse/expand) in the HF parameter layoutlayer.pyGlm5NextTransformerLayer: megatron-coreTransformerLayerwith the n-stream mHC residual update; expands streams in layer 1 and mean-contracts in the last layer soGPTModelsees[s, b, C]kda.pychunk_kda/fused_kda_gate/ShortConvolution) built from TE linearsdsa.py+kpool_indexer.pyindex_topk(2048) are exact causal attention and run throughTEDotProductAttention(packed thd, FA2/cuDNN); longer sequences use a torch indexer + masked SDPA (exact, O(L²), CI-oriented)layer_specs.py/provider.pyget_gpt_decoder_block_spec,Glm5NextModelProvider(MLAModelProvider)bridge.py/hf_config.pyGlm5NextBridge(registered forGlm5NextForConditionalGeneration,model.language_model.*prefixes, 1:1 mappings — separateq/k/v_conv1d,hc_*_scalekept as[3]), plus anAutoConfigshim for transformers < 5.16Done on top of upstream megatron-core: upstream's
HyperConnectionTransformerLayerrejects MoE sub-layers(mHC + MoE is only supported via
HybridModelthere), so the mHC layer is SkyRL-owned.Other changes:
workers/megatron/__init__.py+patches/megatron/patch_fa4_cute_import.py: flash-attn 2.8.x's FA4flash_attn.cutemodule is incompatible with the cutlass DSL that vLLM ≥ 0.28 pins(
cutlass.cute.core.ThrMmamissing →AttributeError, which megatron-core'sexcept ImportErrorprobe does not catch), so
import megatron.bridgecurrently fails in the locked megatron env. Theguard marks
flash_attn.cuteunavailable only when it is actually broken.test_megatron_models.py:glm-5.3-flash-4layer_h100_tp2_ep4(TP2 EP4 ETP1 → DP2, vLLM TP4colocated,
language_model_only, packed sequences, FA2,inference_only_init,max_num_seqs=512).Glm5NextTextIndexer.supported_models.mdx,.claude/docs/backends/megatron.md).Dependencies
0.28.1rc1.dev359+g98ed0856f([Model] add GLM-5.3-Flash support vllm-project/vllm#53906, the GLM-5.3model). Main binaries are stable-libtorch-ABI so they load against our torch 2.11, as with 0.28.0.
deep_gemm._Cislinked against torch 2.13 (
undefined symbol: c10::ValueError…) under torch 2.11. Addeddeep-gemmbuilt from deepseek-ai/DeepGEMM@8b1392b (vLLM's pinned commit) against torch 2.11 + CUDA 13.
Hosted at https://github.com/erictang000/DeepGEMM/releases/tag/v2.6.1-8b1392b-cu13torch2.11 (same
pattern as the
fast-hadamard-transformwheels). Verified: vLLM logsDeepGEMM PDL enabledand theDSA indexer runs; without it
has_deep_gemm()is False and the GLM-5.3 engine refuses to start.glm5_nextconfig; also required by the vLLM commit,>=5.10.4). Same pins as [deps] bump transformers to 5.16.1 #2155, so this stacks cleanly on it.Validation
Megatron vs HF
transformers(5.16.1, eager) logits on the 4-layer slice, 117-token GSM8Kprompt+response (
scratchpad/parity.py, torchrun):i.e. the Megatron model is at the bf16 noise floor, including the >2048-token sparse-indexer path
and under TP/EP/PP sharding. All 3050 language-model tensors of the checkpoint map (no dropped
conversion tasks).
SkyRL
test_logprobs_matching_roundtrip[glm-5.3-flash-4layer_h100_tp2_ep4]on 4×B200 (samemesh as the CI entry: Megatron TP2 EP4, vLLM TP4 colocated), with the new lock:
Standalone vLLM (same wheel, torch 2.11 + DeepGEMM) vs HF-bf16 on the reference sequence: token-logprob
|Δ| mean 0.062 — i.e. vLLM and Megatron are each one bf16-noise-floor away from HF and ~0.06 from each other.
vLLM 0.28.0 → 0.28.1rc1.dev359 fallout fixed in this PR (all CPU suites green:
-m "not vllm"1568 passed,
-m vllm192 passed):vllm.entrypoints.openai.cli_argsmoved tovllm.entrypoints.launchers.cli_args(import with fallback)./inference/v1/generate(SkyRL's generation endpoint) is now gated behindVLLM_ENABLE_SCALE_OUT_ENDPOINTS=1; set invllm_server_actorbeforebuild_app.sharded_rdtweight-transfer engine; SkyRL's shim already no-ops in thatcase, the unit test was asserting the shim's class. Whether vLLM's native engine is wire-compatible with
SkyRL's vendored trainer side was not checked here (the
sharded_rdtbackend is not used by this test).vllm.entrypoints.openai.api_serveris now a deprecated re-export shim (warning only).Not run here: the other
megatron_models/h100entries under the new lock (transformers 5.16.1 +vLLM dev wheel) — please let the label-gated GPU workflows run on this PR.
Notes / follow-ups
not a bug), but because the weights are real the logprob distribution is peaked (std ≈ 4.6 vs ≈ 0.5
for a random-init tiny model), which is what makes the vLLM/Megatron logprob comparison sensitive.
num_seqs * 64 headsin CUDA grid dim y;max_num_seqs=1024overflows the 65535 limit →
Triton Error [CUDA]: invalid argumentduring CUDA-graph capture(reproduced identically on torch 2.13 / triton 3.7.1, so it is not a torch-2.11 artifact). Worth an
upstream vLLM issue; SkyRL caps
max_num_seqsfor this model.fused(cuDNN) attention was not exercised on this box (libcudart 12/13 clash in the local env);the CI entry uses FA2.
frozen indexer) but only forward + weight-sync is exercised by this test.
🤖 Generated with Claude Code