Skip to content

[Fix] glm5_3: Set SGLANG_ENABLE_EMBED_REPLICATION automatically again - #95

Merged
YAMY1234 merged 3 commits into
sgl-project:mainfrom
mattteochen:glm5_3-embed-replication-env
Nov 29, 2026
Merged

YAMY1234 merged 3 commits into
sgl-project:mainfrom
mattteochen:glm5_3-embed-replication-env

Conversation

@mattteochen

Copy link
Copy Markdown
Contributor

Motivation

Follow-up from the review of #75. Since #19, a GLM-5.3 / GLM-5.2 server with the NextN draft does not start with --enable-nvidia-megakernel alone. It stops at startup with SGLANG_ENABLE_EMBED_REPLICATION False is not True unless the user sets the variable.

  • [Feat] [RUBIN] glm5_3/sm107: GLM-5.2 TP16 bs=1 megakernels and EAGLE v2 step CUDA graph (spec_step) #19 moved the spec's environment pins out of Requirements.env and checks them per TP size: ENV at TP8 / TP4, glm5_3/sm107's at TP16.
  • SGLang's FLAG_SETS_ENV sets only variables that a spec declares in Requirements.env, so it no longer sets SGLANG_ENABLE_EMBED_REPLICATION for GLM-5.3.
  • The variable cannot simply go back into Requirements.env. SGLang would then also set it, and require it, at TP16, where the draft reads the vocab-sharded embedding.

Modifications

  • glm5_3/spec.py: at argument resolution, config_disable_reasons sets the variables of ENV that are listed in the spec's FLAG_SETS_ENV (SGLANG_ENABLE_EMBED_REPLICATION) to their pinned value when they are unset. This is what SGLang does for Requirements.env.
    • It applies only at TP8 / TP4, and only when slot draft is on (ENV pins the variable only then). TP16 is unchanged.
    • It logs --enable-nvidia-megakernel: set SGLANG_ENABLE_EMBED_REPLICATION=True for GLM-5.3 / GLM-5.2.
    • A value the user set is kept and checked: 0 still stops the server, naming it.
    • A refused setup leaves the environment as it was.
    • The per-TP-size check (pinned_reasons) is unchanged.
  • docs/models/glm5_3.md: the flag turns embedding replication on again, so the launch command needs no variable.
  • test/unit/test_glm5_3_flag_env.py (new, CPU), checking that:
    • slot draft pins the variable per TP size, outside Requirements.env (target and draft) and outside TP16's environment;
    • the flag sets it at TP8 and TP4 and logs it;
    • a value the user set is kept (1) or refused (0);
    • a refused setup leaves it unset;
    • TP16 leaves it alone;
    • no other variable of ENV is set.

Accuracy Tests

GB300, one tray, TP4 aggregated, MTP 5/1/6 with natural acceptance, SGLANG_ENABLE_EMBED_REPLICATION unset, 2026-11-21 SGLang nightly image (the latest that accepts megakernel plugin API version 2, which main declares), Mega f352ad0:

  • The server starts without the variable and logs --enable-nvidia-megakernel: set SGLANG_ENABLE_EMBED_REPLICATION=True for GLM-5.3 / GLM-5.2. On main the same launch stops at startup with SGLANG_ENABLE_EMBED_REPLICATION False is not True.
  • Every TP rank logs NVIDIA megakernel: active for the TP4 kernel units and the NextN draft. No tracebacks.
  • GSM8K-1319 (5-shot, greedy, 512 tokens, 2 in flight): 0.9424, AL 4.05. For comparison, [Feat] [VR200] glm5_3: Serve the TP4 kernel units on Rubin (SM107) #75's rerun with the variable set by hand scored 0.9447, AL 4.04.

Speed Tests and Profiling

Not applicable: the served path is the same as with the variable set by hand.

Checklist

  • pre-commit run passes on the changed files.
  • Tests under test/ cover the change: test/unit/test_glm5_3_flag_env.py. CPU unit at the pinned SGLang (cf6133a): 1460 passed, 59 skipped vs 1452 / 59 on main; the 8 new tests pass. On the 2026-11-21 SGLang nightly image: 1396 passed vs 1388 on main, with the same failures on both (SGLang drift against the pin).
  • Required SGLang bindings passed normal SGLang CI and are merged, or no binding change is needed: no binding change.
  • The tested SGLang and Mega SHAs are named above (run by hand; no integration run link).
  • Accuracy and performance E2E results against the matched baseline: not applicable (startup fix); a GSM8K sanity run is above.
  • Required E2E cases ran on the appropriate hardware: GB300 TP4 above. TP8 and TP16 were not run; TP16's path does not change.
  • A new model adds one line to .github/CODEOWNERS: not applicable.

🤖 Generated with Claude Code

@YAMY1234 YAMY1234 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Logic matches SGLang's set_flag_env and looks good; one test fix needed so it does not leak the variable into later test files.

Comment thread test/unit/test_glm5_3_flag_env.py Resolved
mattteochen and others added 2 commits November 27, 2026 11:21
Since sgl-project#19 the GLM-5.3 spec pins its environment per TP size (pinned_reasons on
ENV at TP8 / TP4, glm5_3/sm107's at TP16) and leaves Requirements.env empty, so
SGLang's FLAG_SETS_ENV no longer sets SGLANG_ENABLE_EMBED_REPLICATION, and a
server with the NextN draft (slot draft) stopped at startup with
"SGLANG_ENABLE_EMBED_REPLICATION False is not True" unless the user set it.

config_disable_reasons now sets the variables of ENV listed in the spec's own
FLAG_SETS_ENV to their pinned value when they are unset, at argument
resolution, as SGLang does for Requirements.env: only at TP8 / TP4 and only
when slot draft is on. It logs what it set, keeps and checks a value the user
set, and clears what it set when the setup is refused. TP16 is unchanged: its
draft reads the vocab-sharded embedding, which is why the variable cannot go
back into Requirements.env. The docs say again that the flag turns it on.

Tests: test/unit/test_glm5_3_flag_env.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tests

monkeypatch.delenv(raising=False) records nothing when the variable is
absent, so the value the spec writes with envs.X.set() in the TP8/TP4 test
stayed in os.environ for the rest of the test session. Set it to an empty
value first so that monkeypatch records it and restores the original state
at teardown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mattteochen
mattteochen force-pushed the glm5_3-embed-replication-env branch from f352ad0 to abc73ea Compare November 27, 2026 11:03
@mattteochen
mattteochen requested a review from YAMY1234 November 27, 2026 11:17
@YAMY1234
YAMY1234 merged commit 1d81c63 into sgl-project:main Nov 29, 2026
4 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