Add GLM-5.2 contrib model (FP8 on trn2.48xlarge)#177
Open
qingzwang wants to merge 1 commit into
Open
Conversation
NeuronX Distributed Inference port of GLM-5.2 (zai-org/GLM-5.2-FP8), a ~753B
glm_moe_dsa MoE model (MLA attention + 256-expert MoE). Runs the FP8 checkpoint
on a single trn2.48xlarge (TP=64, lnc=2, seq_len=2048) via the fused MoE TKG +
MLP NKI kernels.
- modeling_glm5.py + mla_attention_nki*.py adapted from the community GLM-5
contribution (github.com/jimburtoft, branch contrib/GLM-5); config-driven, so
GLM-5.2's nested rope_theta (8e6) is read automatically.
- DSA indexer disabled (dsa_enabled=False): GLM-5.2 has heterogeneous per-layer
indexers and the indexer is a no-op for seq_len <= index_topk (2048), so it
runs as standard full MLA.
- FP8 required: BF16 weights (~1506 GB) do not fit the 1536 GB HBM.
- examples/{compile,benchmark}.py; unit tests 11/11 pass.
Measured BS=1: TTFT 6377 ms, ITL 241.5 ms/tok, 2.96 tok/s; output coherent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
NeuronX Distributed Inference port of GLM-5.2 (zai-org/GLM-5.2-FP8), a ~753B glm_moe_dsa MoE model (MLA attention + 256-expert MoE). Runs the FP8 checkpoint on a single trn2.48xlarge (TP=64, lnc=2, seq_len=2048) via the fused MoE TKG + MLP NKI kernels.
Measured BS=1: TTFT 6377 ms, ITL 241.5 ms/tok, 2.96 tok/s; output coherent.
Note: The below template includes items meant for model contributions only. For other contributions such as bug fixes, features, etc., only fill out the relevant portions of the form.
Description
Add GLM-5.2 contrib model — NeuronX Distributed Inference port of zai-org/GLM-5.2-FP8, a ~753B-parameter
glm_moe_dsaMoE model (MLA attention + 256-expert MoE with sigmoid routing). Runs the FP8 checkpoint on a single trn2.48xlarge (TP=64, lnc=2, seq_len=2048) via the fused MoE TKG + MLP NKI kernels.Key implementation details:
modeling_glm5.py+mla_attention_nki*.py) adapted from the community GLM-5 contribution (github.com/jimburtoft, branchcontrib/GLM-5); config-driven, so GLM-5.2's nestedrope_theta(8e6) is read automatically.dsa_enabled=False): GLM-5.2 has heterogeneous per-layer indexers; for seq_len ≤index_topk(2048), the indexer is a no-op, so we run standard full MLA.examples/{compile,benchmark}.py; unit tests and integration test (11/11 pass).Model Information
Model Name: GLM-5.2
Model Architecture:
glm_moe_dsa— Decoder-only MoE transformer with Multi-head Latent Attention (MLA) + 256-expert sigmoid-routed MoE + DeepSparse Attention (DSA) indexer (disabled in this contribution)Purpose: Text generation (autoregressive LLM)
Checklist
Required Components
test/integration/test_model.py)zai-org/GLM-5.2-FP8on HuggingFacesrc/)modeling_glm5.py— full model implementation (~117 KB)mla_attention_nki.py+mla_attention_nki_kernel.py— MLA NKI kerneltest_mla_attention_nki.py— kernel validation script__init__.py— module entry pointOptional Components
test/unit/test_config.py— config parsing teststest/unit/test_weight_conversion.py— weight shard/conversion testsFolder Structure
Testing
How did you test this change?
Tested on a single trn2.48xlarge instance with:
examples/compile.py)examples/benchmark.py)pytest test/unit/ -v)pytest test/integration/test_model.py -v)python src/test_mla_attention_nki.py --cpu-only)Test Results:
Output is coherent and factually correct (e.g. "The capital of France is Paris... the Ile-de-France... where the French language was born").
Compatibility
Tested with:
Additional Information
selection_biasandrouted_scaling_factorsupport in the NKI fused-MoE router. Install fromgithub.com/jimburtoft/nki-library, branchfeature/selection-bias-routing.Related Issues
N/A — first contribution of this model architecture.
vLLM Integration
vLLM integration is future work — the current contribution focuses on the core NxDI modeling and compilation path.
By submitting this PR, I confirm that: