Skip to content

[AMD] [GLM-5.3-Flash Day 0] Enable FP8 and Quark MXFP4 MoE on gfx950 - #37629

Merged
Fridge003 merged 4 commits into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
Raiden-Makoto:RM/glm53-moe-enablement
Sep 3, 2026
Merged

Fridge003 merged 4 commits into
sgl-project:xinyuan/glm-5.3-flash-supportfrom
Raiden-Makoto:RM/glm53-moe-enablement

Conversation

@Raiden-Makoto

@Raiden-Makoto Raiden-Makoto commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GLM-5.3-Flash ships two gfx950 MoE checkpoint paths that share one model architecture but use different quantization contracts:

  • zai-org/GLM-5.3-Flash: routed, shared, and MTP experts use block FP8 [128,128] with dynamic FP8 activations.
  • amd/GLM-5.3-Flash-Quark-MXFP4: routed and shared experts in layers 3-44 use OCP MXFP4 1×32; MTP layer 45 remains block FP8.

Both paths load gate and up projections into separate contiguous halves and require clamped SwiGLU (swiglu_limit=10.0). The support branch preshuffles the weights but lets AITER infer gate/up semantics from the global interleave setting. Quark also drops clamp/padding metadata and does not make preshuffle ownership explicit.

Contract Before With this PR
block-FP8 layout tile-only preshuffle, no physical layout metadata records and forwards GateMode.SEPARATED
Quark MXFP4 layout global interleave default can override checkpoint ordering pins separated mode; AITER preserves explicit quant-method mode
SwiGLU FP8 forwards the limit; Quark omits it both forward swiglu_limit=10.0
preshuffle Quark can preshuffle without owning the selected runner requires an owned AITER runner
unsupported Quark runner fails later with an unset runner fails during construction
padding Quark padding is not forwarded hidden/intermediate padding is recorded and forwarded

Scope

Three production files:

  • fp8.py: record block-FP8's physical gate/up ordering after AITER preshuffle and forward it with the existing clamp/scales/padding metadata.
  • quark_w4a4_mxfp4_moe.py: own AITER preshuffle, preserve separated ordering, and forward clamp/padding metadata.
  • aiter.py: preserve a quantization method's explicit gate mode instead of overwriting it with the global default.

Three test files cover CPU contracts, synthetic gfx950 FP8/MXFP4 numerics, and both real checkpoints. DSA, k-pool, MLA, mHC backend selection, model registration, CUDA graphs, EP/A2A, and full-model serving are untouched.

Shared experts are tested both separately and as a ninth uniform-precision expert slot. This PR validates the representation and math but does not turn on shared-expert fusion in the official launch recipe.

Test plan

Docker: rocm/sgl-dev:v0.5.18-rocm720-mi35x-20260901.
Base: xinyuan/glm-5.3-flash-support @ 545bd6f839.
Checkpoints: zai-org/GLM-5.3-Flash@03eb536628 and amd/GLM-5.3-Flash-Quark-MXFP4@b5688f2549.
The same three new test files were run in both arms; the three production files are the only variables.

Arm Result
Baseline FP8 and MXFP4 suites fail: separated weights are consumed through the global interleave default; Quark also lacks ownership/padding/clamp handoff and early runner rejection. Synthetic and real-checkpoint numerical agreement collapses for affected expert paths.
This PR CPU contracts: 6 passed; synthetic gfx950 FP8/MXFP4: 3 passed; dual-checkpoint validation: 6 passed. Existing Quark regression remains green.

Synthetic gfx950 coverage uses Flash dimensions (hidden_size=4096, intermediate_size=2048), block-FP8 and MXFP4 expert banks, token counts 1/8/17/32/64/128, top-1/top-8/top-9 routing, both activation-quantization formats, clamp-boundary inputs, deterministic top-1 output, and BF16-equivalent atomic reduction.

Checkpoint coverage verifies and executes:

  • source block-FP8 routed experts, shared expert, and MTP routed/shared experts;
  • AMD MXFP4 routed and shared experts plus its FP8 MTP layer;
  • real expert IDs 0/143/287 across KDA/DSA-adjacent layers;
  • the complete mHC-pre/MoE/mHC-post BF16 boundary, including zero tokens.
Check Detail
Registration CPU contracts use register_cpu_ci(suite="base-a-test-cpu"); gfx950 numerics use register_amd_ci(suite="stage-b-test-1-gpu-small-amd-mi35x")
Formatting file-scoped isort, Ruff, Black, syntax, and registered-test validation pass; the local whole-tree checker separately sees an unrelated ignored test file outside this PR
Accuracy not measured — remaining attention Day-0 work must land before server-level accuracy is meaningful
Speed not measured — fusion, overlap, EP/A2A, and tuning are outside this correctness PR

CI States

Latest PR Test (Base): ❌ Run #33768400586
Latest PR Test (Extra): ❌ Run #33768400367
Latest PR Test (AMD ROCm 7.2): ❌ Run #33768400582

@Raiden-Makoto Raiden-Makoto changed the title [AMD] [GLM-5.3-Flash Day 0] Enable mixed Quark MXFP4 MoE on gfx950 [AMD] [GLM-5.3-Flash Day 0] Enable Quark MXFP4 MoE on gfx950 Sep 2, 2026
Route the official uniform-MXFP4 expert bank through AITER with clamped SwiGLU, explicit separated layout ownership, and checkpoint-driven MoE-to-mHC correctness coverage.
@Raiden-Makoto
Raiden-Makoto force-pushed the RM/glm53-moe-enablement branch from fab3f3d to 58a30de Compare September 2, 2026 18:33
Make the physical separated gate/up layout explicit for AITER and validate source FP8 routed, shared, and MTP experts alongside Quark MXFP4.
@Raiden-Makoto Raiden-Makoto changed the title [AMD] [GLM-5.3-Flash Day 0] Enable Quark MXFP4 MoE on gfx950 [AMD] [GLM-5.3-Flash Day 0] Enable FP8 and Quark MXFP4 MoE on gfx950 Sep 2, 2026
@Fridge003

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T03:35:46.096253Z 90e43ae Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90e43ae781

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Fridge003
Fridge003 merged commit 2d7606b into sgl-project:xinyuan/glm-5.3-flash-support Sep 3, 2026
79 of 89 checks passed
@Fridge003

Fridge003 commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Sorry @Raiden-Makoto , I just merged this PR by mistake. Can you please open this PR again, thanks

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