Repository navigation
Add GLM-5/5.1/5.2 (744B MoE) LoRA RL support #1559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yushengsu-thu
merged 92 commits into
radixark:main
from
yushengsu-thu:miles-dev-2026-06-16-merging
Jul 7, 2026
Merged
Changes from 89 commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
12e4e88
lora: map DSA indexer modules across sglang↔megatron-bridge names
yushengsu-thu 7e5de94
lora: include MLA + DSA indexer modules in all-linear expansion
yushengsu-thu cb84455
lora: register dsa experimental-attention-variant spec for bridge LoR…
yushengsu-thu 655608d
examples,scripts: add GLM-5.1 LoRA launcher, example, and 6-layer reg…
yushengsu-thu 37a7cf1
lora: move dsa spec registration to Megatron-Bridge (drop caller-side…
yushengsu-thu 9f08173
scripts: add GLM-5.2 LoRA registries + extend run_glm5_lora.py
yushengsu-thu 96064c3
examples,tests: add GLM-5.1/5.2 LoRA e2e CI tests; drop ad-hoc example
yushengsu-thu a3f6efc
scripts,tests: rename GLM-5.1-specific files to glm5.1/glm5_1 for ver…
yushengsu-thu 06b6416
utils: add --dsa-attention-backend arg (GLM DSA fused/unfused selection)
yushengsu-thu 86edaea
backends: wire --dsa-attention-backend onto the GLM bridge provider
yushengsu-thu ab23877
scripts: surface --dsa-attention-backend in run_glm5_lora + document …
yushengsu-thu 899d6cb
scripts,tests: align GLM-5.2 LoRA example + CI to the canonical GLM-5…
yushengsu-thu 5e1cd0d
scripts,utils: default --dsa-attention-backend=slime + enable R3 in r…
yushengsu-thu 2689e6b
backends,scripts: honor --dsa-attention-backend on the bridge LoRA bu…
yushengsu-thu f10c293
utils: add MILES_RAY_SUBMIT_NO_WAIT to detach ray job submit from the…
yushengsu-thu a868606
utils: add MILES_R3_DIAG replay-check diagnostic + cap mismatch warnings
yushengsu-thu 03720b4
scripts: add run_glm5_lora_multinode.sh for multi-node GLM-5 LoRA RL
yushengsu-thu 761558a
scripts: add dapo-math example task to run_glm5_lora.py
yushengsu-thu eb089cf
scripts: support --task (gsm8k/dapo-math) in run_glm5_lora_multinode.sh
yushengsu-thu 7c018f7
GLM-5.2 LoRA rollout: fix DSA-indexer gibberish + dense-gate_up sglan…
yushengsu-thu 99ef33a
GLM-5.2 744B LoRA-RL: full-scale slime e2e launcher + host-OOM knobs
yushengsu-thu ff5f2d2
GLM-5.2 LoRA-RL: default dapo-math seq-length to 4096 (validated swee…
yushengsu-thu 42fb843
GLM-5.2 LoRA-RL full preset: default DAPO_DYNAMIC_SAMPLING=off
yushengsu-thu 14bc26f
GLM-5.2 LoRA-RL: R3 = routing replay ONLY (drop DSA indexer replay)
yushengsu-thu ccc944b
run_glm5_lora.py: fix stale use_r3 docstring (R3 = routing replay only)
yushengsu-thu 683a57d
R3: default use_rollout_routing_replay ON (BooleanOptionalAction)
yushengsu-thu da74f00
full preset: --lora-base-cpu-backup ON (required for correct colocate…
yushengsu-thu f07d114
colocate LoRA: stop dropping q_b_proj/kv_b_proj from the sglang rollo…
yushengsu-thu 1631adc
GLM-5.2 multinode LoRA: add 5layer-like-full 2-node wrapper, full-mod…
yushengsu-thu 96ce6c5
gsm8k: default SEQ/RESP_LEN to 256 (short-answer task)
yushengsu-thu 83959d2
lora rl: drop SEQ default (auto-derive window), response-len dapo=409…
yushengsu-thu 144b0ec
lora rl: dapo seq window = 8192 (hard-bound prompt+response); gsm8k s…
yushengsu-thu 38777bf
lora rl: gsm8k response-len default 256 -> 512
yushengsu-thu c5051fe
lora rl: add periodic held-out eval (interval default 5)
yushengsu-thu c378269
fix: window eval submission to avoid dp-attention colocate hang
yushengsu-thu d4f0431
Revert "fix: window eval submission to avoid dp-attention colocate hang"
yushengsu-thu ff8b4fe
add NVSHMEM_DISABLE_NCCL to avoid cuda graph hang
yueming-yuan d79e27c
lora rl: enable MoE/MLP LoRA by default + select per-expert vs shared…
yushengsu-thu 0e5851e
glm5 lora: default MoE-expert LoRA on + always-paired shared-outer/vi…
yushengsu-thu eb636e9
glm5 lora: add MOE_LORA_LAYERS knob to restrict MoE-expert LoRA to a …
yushengsu-thu 2061379
glm5 lora: default MOE_LORA_LAYERS to ALL MoE layers (toy + full GLM-…
yushengsu-thu 67bd92c
glm5 lora: default-on CPU-Adam (optimizer-cpu-offload) + disable MOE_…
yushengsu-thu fed3f1c
glm5 lora: default sglang LoRA kernel backend to triton
yushengsu-thu f402c4d
Revert "lora rl: add periodic held-out eval (interval default 5)"
yushengsu-thu d888950
glm5 lora: add launch_glm_rl.sh (full GLM-5.2 attention-only LoRA-RL …
yushengsu-thu 7d75076
glm5 lora: one-command launch_glm_rl.sh + pre-run cleanup + 4x16 batch
yushengsu-thu b14acdc
glm5 lora: enable MoE-expert LoRA (gate/up/down) + lora-rank 4
yushengsu-thu 1d93245
glm5 lora: lora-rank 8 (rank 4 invalid under TP=8 / moe_router_topk=8)
yushengsu-thu 60b746f
glm5 lora: fix step-0 OOM — MoE LoRA last-N layers + NVSHMEM_DISABLE_…
yushengsu-thu 1ce9f53
glm5 lora: bump --num-rollout to 10000 for a long MoE-LoRA RL run
yushengsu-thu f0562bd
[LoRA] add --check-lora-weight-update-equal (default ON when LoRA): L…
yushengsu-thu 81e9df3
Revert "[LoRA] add --check-lora-weight-update-equal (default ON when …
yushengsu-thu f3888fe
[launch] bump rollout-batch-size 4->8; fix miles_dev->miles_lora paths
yushengsu-thu 815b691
[launch] split launcher: rename to att_fused_moe; add att_unfused_moe…
yushengsu-thu 61b555f
Merge remote-tracking branch 'radixark/main' into miles-dev-2026-06-1…
yushengsu-thu 49c9158
[lora] fix review regressions: R3 default-off, all-linear scope, expe…
yushengsu-thu c4d9d49
[lora] fix: tag refactor-rollout generate requests with lora_path
yushengsu-thu 986c2a9
[lora] chore: move ad-hoc GLM dev launchers out of the repo
yushengsu-thu 38473dc
[lora] refactor: split run_glm5_lora.py into per-model PR-style run s…
yushengsu-thu 9c1d2fd
[lora] fix: default --lora-base-cpu-backup ON in the GLM-5.x LoRA run…
yushengsu-thu 44293db
tiny fix
yushengsu-thu 697cd8a
[lora] refactor: rename DSA backend values to megatron-bridge-native …
yushengsu-thu 7327504
Merge remote-tracking branch 'radixark/main' into miles-dev-2026-06-1…
yushengsu-thu 90c3372
nit fix
yushengsu-thu ac48ea7
fix lora ci: arch-gate all-linear MLA targets; make weight-update che…
yushengsu-thu e1c4ad5
fix: update stale SlimeMLASelfAttention references after DSA backend …
yushengsu-thu 2eb0ed0
docs: trim redundant comments in GLM-5.1/5.2 LoRA runners, registries…
yushengsu-thu 2427faa
docs: second-pass comment cleanup across the GLM-5 LoRA PR
yushengsu-thu 46092b2
revert --use-rollout-routing-replay to action=store_true
yushengsu-thu c1d163c
[lora] refactor: rename --dsa-attention-backend choices to megatron /…
yushengsu-thu 1dc86b4
[lora] refactor: move the LoRA weight-check skip-list out of argument…
yushengsu-thu 7834d72
docs: drop the dsa_attention_backend override comments
yushengsu-thu 33cd2df
[lora] refactor: drop the post-build dsa_attention_backend force loop
yushengsu-thu 96df315
[lora] refactor: centralize the MoE-expert LoRA layout handling in ar…
yushengsu-thu fb218e5
Merge branch 'main' into miles-dev-2026-06-16-merging
yueming-yuan aeb1a85
[lora] feat: auto-enable sglang virtual-experts serving for MoE-exper…
yushengsu-thu cf9ca2f
Merge remote-tracking branch 'origin/miles-dev-2026-06-16-merging' in…
yushengsu-thu 22ef339
[lora] refactor: pass only experts_shared_outer_loras to Megatron-Bridge
yushengsu-thu fbe1e1a
[lora] refactor: default --sglang-lora-use-virtual-experts ON
yushengsu-thu 6aedd89
revert: drop the MILES_RAY_SUBMIT_NO_WAIT ray-submit option from comm…
yushengsu-thu 18538c0
[lora] refactor: resolve all-linear MLA gating via load_hf_config
yushengsu-thu ee8d650
[lora] test: run the MoE-expert LoRA combination matrix in the GLM-5 …
yushengsu-thu 2299d88
docs: drop the resolved-target-modules info log
yushengsu-thu 5941746
[lora] refactor: drop the MILES_R3_DIAG block; cap R3 mismatch dumps …
yushengsu-thu 3504271
docs: align PR-added comments with the core codebase style
yushengsu-thu 4c665ee
Merge remote-tracking branch 'radixark/main' into miles-dev-2026-06-1…
yushengsu-thu 6f9877c
Replace weight-checker comment with TODO
yueming-yuan 4d940be
Remove obsolete comments
yueming-yuan 2c4e33a
Move backend-neutral LoRA helpers out of megatron_utils
yueming-yuan aeff684
Remove comment in generate_endpoint_utils
yueming-yuan e079735
Repoint LORA_ADAPTER_NAME imports to miles.utils.lora; fix pre-commit
yueming-yuan cfac946
Fix test imports of LORA_ADAPTER_NAME after move to miles.utils.lora
yueming-yuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from argparse import Namespace | ||
|
|
||
| LORA_ADAPTER_NAME = "miles_lora" | ||
|
|
||
|
|
||
| def is_lora_enabled(args: Namespace) -> bool: | ||
| """Check if LoRA is enabled based on arguments.""" | ||
| return getattr(args, "lora_rank", 0) > 0 or getattr(args, "lora_adapter_path", None) is not None |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -197,7 +197,7 @@ def check_replay_result(self, old_topk_fn, scores, topk, top_indices, *args, **k | |
| threshold = float(os.environ.get("MILES_TEST_R3_THRESHOLD", self.replay_check_max_mismatch_fraction)) | ||
| mismatch_threshold = threshold * orig_flat.shape[0] | ||
| mismatch_indices = is_mismatch.nonzero(as_tuple=False).squeeze(1) | ||
| for idx in mismatch_indices: | ||
| for idx in mismatch_indices[:10]: | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still modify here. |
||
| i = idx.item() | ||
| lines = [] | ||
| for j in range(max(0, i - 3), min(len(orig_flat), i + 4)): | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd)" | ||
| source "${SCRIPT_DIR}/glm5-744B-A40B.sh" | ||
|
|
||
| # Override for the 6-layer pruned GLM-5.1 toy (jybsuper/GLM-5.1-6layer): | ||
| # first 6 layers = 3 dense + 3 MoE. | ||
| N_MOE_LAYERS=3 | ||
|
|
||
| for ((i=0; i<${#MODEL_ARGS[@]}; i++)); do | ||
| case "${MODEL_ARGS[$i]}" in | ||
| --num-layers) MODEL_ARGS[$((i+1))]=$((N_DENSE_LAYERS + N_MOE_LAYERS)) ;; | ||
| --moe-layer-freq) MODEL_ARGS[$((i+1))]="[0]*${N_DENSE_LAYERS}+[1]*${N_MOE_LAYERS}" ;; | ||
| esac | ||
| done | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd)" | ||
| source "${SCRIPT_DIR}/glm5.1-744B-A40B_lora.sh" | ||
|
|
||
| # Override for the 6-layer pruned GLM-5.1 toy (jybsuper/GLM-5.1-6layer): | ||
| # first 6 layers = 3 dense + 3 MoE. | ||
| N_MOE_LAYERS=3 | ||
|
|
||
| for ((i=0; i<${#MODEL_ARGS[@]}; i++)); do | ||
| case "${MODEL_ARGS[$i]}" in | ||
| --num-layers) MODEL_ARGS[$((i+1))]=$((N_DENSE_LAYERS + N_MOE_LAYERS)) ;; | ||
| --moe-layer-freq) MODEL_ARGS[$((i+1))]="[0]*${N_DENSE_LAYERS}+[1]*${N_MOE_LAYERS}" ;; | ||
| esac | ||
| done |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| MOE_ROUTED_EXPERTS=256 | ||
| MOE_ACTIVE_ROUTED_EXPERTS=8 | ||
| MOE_SHARED_EXPERTS=1 | ||
|
|
||
| NHIDDEN=6144 | ||
| MOE_FFN_HIDDEN=2048 | ||
| MOE_SHARED_EXPERT_INTERMEDIATE_SIZE=$(($MOE_FFN_HIDDEN * $MOE_SHARED_EXPERTS)) | ||
| FFN_HIDDEN=12288 | ||
| N_DENSE_LAYERS=3 | ||
| N_MOE_LAYERS=75 | ||
| NHEADS=64 | ||
|
|
||
| # GLM-5.1 744B-A40B (zai-org/GLM-5.1, glm_moe_dsa). Identical to glm5-744B-A40B.sh; the only | ||
| # architecture difference vs the glm5.2-744B-A40B* registries is --rotary-base (5.2 uses 8e6). | ||
| MODEL_ARGS=( | ||
| --spec "miles_plugins.models.glm5.glm5" "get_glm5_spec" | ||
| --moe-layer-freq "[0]*${N_DENSE_LAYERS}+[1]*${N_MOE_LAYERS}" | ||
| --num-experts $MOE_ROUTED_EXPERTS | ||
| --moe-shared-expert-intermediate-size $MOE_SHARED_EXPERT_INTERMEDIATE_SIZE | ||
| --moe-router-topk $MOE_ACTIVE_ROUTED_EXPERTS | ||
| --moe-grouped-gemm | ||
| --moe-permute-fusion | ||
| --moe-ffn-hidden-size $MOE_FFN_HIDDEN | ||
| --moe-router-score-function sigmoid | ||
| --moe-router-pre-softmax | ||
| --moe-router-enable-expert-bias | ||
| --moe-router-bias-update-rate 0 | ||
| --moe-router-load-balancing-type seq_aux_loss | ||
| --moe-router-topk-scaling-factor 2.5 | ||
| --moe-aux-loss-coeff 0 | ||
| --moe-router-dtype fp32 | ||
| --make-vocab-size-divisible-by 16 | ||
| --num-layers $((N_DENSE_LAYERS + N_MOE_LAYERS)) | ||
| --hidden-size $NHIDDEN | ||
| --ffn-hidden-size $FFN_HIDDEN | ||
| --num-attention-heads $NHEADS | ||
| --disable-bias-linear | ||
| --swiglu | ||
| --untie-embeddings-and-output-weights | ||
| --position-embedding-type rope | ||
| --no-position-embedding | ||
| --normalization RMSNorm | ||
| --qk-layernorm | ||
| --multi-latent-attention | ||
| --q-lora-rank 2048 | ||
| --kv-lora-rank 512 | ||
| --qk-head-dim 192 | ||
| --v-head-dim 256 | ||
| --kv-channels 192 | ||
| --qk-pos-emb-head-dim 64 | ||
| --vocab-size 154880 | ||
| --rotary-base 1000000 | ||
| --enable-experimental | ||
| ) | ||
|
|
||
| # LoRA registry for scripts/run_glm5_1_744b_a40b_lora.py: MODEL_ARGS carries the architecture only | ||
| # (identical to glm5-744B-A40B.sh); every LoRA / run-mode flag lives in the runner, which | ||
| # always wins (argparse last-occurrence). --spec above is inert under bridge LoRA. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd)" | ||
| source "${SCRIPT_DIR}/glm5.2-744B-A40B_lora.sh" | ||
|
|
||
| # Override for the 5-layer pruned model (first 5 layers: 3 dense + 2 MoE). Keeps at least | ||
| # one computing + one skip layer so the DSA cross-layer index sharing path is exercised. | ||
| N_MOE_LAYERS=2 | ||
|
|
||
| for ((i=0; i<${#MODEL_ARGS[@]}; i++)); do | ||
| case "${MODEL_ARGS[$i]}" in | ||
| --num-layers) MODEL_ARGS[$((i+1))]=$((N_DENSE_LAYERS + N_MOE_LAYERS)) ;; | ||
| --moe-layer-freq) MODEL_ARGS[$((i+1))]="[0]*${N_DENSE_LAYERS}+[1]*${N_MOE_LAYERS}" ;; | ||
| esac | ||
| done |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.