Commit 25d960f
[None][feat] Add AD custom model for GLM-4 MoE family (#231)
* [None][feat] Add AD custom model for GLM-4 MoE family (glm4_moe)
Add AutoDeploy custom model implementation for the GLM-4 MoE architecture
(model_type: glm4_moe), covering zai-org/GLM-4.6 and zai-org/GLM-4.7.
Key architectural features:
- GQA attention (96 Q heads, 8 KV heads, head_dim=128)
- Partial rotary embeddings (partial_rotary_factor=0.5)
- Per-head QK normalization (RMSNorm)
- MoE with sigmoid gating, group top-k routing (160 experts, top-8)
- First 3 layers dense, rest MoE with shared experts
Uses AD canonical ops: torch_attention, torch_rope_with_explicit_cos_sin,
torch_moe, torch_rmsnorm.
Includes hierarchical unit tests (19 tests): block, layer, full model
equivalence against HF reference, plus torch.export test.
Signed-off-by: Lucas Liebenwein <lliebenwein@nvidia.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
* [None][feat] Add glm4_moe registry config with reduced layers and expert export limit
Add glm4_moe.yaml config for GLM-4 MoE family models (GLM-4.6, GLM-4.7):
- num_hidden_layers: 5 (reduce from 92 for CI/testing)
- num_moe_experts_for_export: 2 (reduce from 160 for export)
Update registry entries for both GLM-4.6 and GLM-4.7 to use the new config.
Signed-off-by: Lucas Liebenwein <lliebenwein@nvidia.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
* [None][fix] Fix device mismatch in GLM4 MoE gate buffer for export
Fix e_score_correction_bias buffer to not hardcode dtype, and cast
to match scores tensor device/dtype in forward. This prevents a
device mismatch (cpu vs meta) during the MoE expert reduction
pre-trace in export_to_gm.
Signed-off-by: Lucas Liebenwein <lliebenwein@nvidia.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
* [None][feat] Use noaux_tc_op for GLM4 MoE gate and split registry configs
Address reviewer feedback:
- Use torch.ops.trtllm.noaux_tc_op for fused sigmoid + bias + group
top-k routing instead of vanilla PyTorch
- Move num_hidden_layers out of glm4_moe.yaml, use num_hidden_layers_5.yaml
separately in models.yaml entries
- Ensure e_score_correction_bias is passed as float32 to noaux_tc_op
Signed-off-by: Lucas Liebenwein <lliebenwein@nvidia.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>
---------
Signed-off-by: Lucas Liebenwein <lliebenwein@nvidia.com>
Signed-off-by: Lucas Liebenwein <11156568+lucaslie@users.noreply.github.com>1 parent 74f4f97 commit 25d960f
5 files changed
Lines changed: 1073 additions & 2 deletions
File tree
- examples/auto_deploy/model_registry
- configs
- tensorrt_llm/_torch/auto_deploy/models/custom
- tests/unittest/auto_deploy/singlegpu/models
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
0 commit comments