Skip to content

Add GLM-5 model support (glm_moe_dsa) - #881

Closed
iamadalek wants to merge 1 commit into
ml-explore:mainfrom
iamadalek:feature/glm-moe-dsa-879
Closed

Add GLM-5 model support (glm_moe_dsa)#881
iamadalek wants to merge 1 commit into
ml-explore:mainfrom
iamadalek:feature/glm-moe-dsa-879

Conversation

@iamadalek

Copy link
Copy Markdown

Summary

  • Adds mlx_lm/models/glm_moe_dsa.py for the GLM-5 (glm_moe_dsa) architecture
  • Combines DeepSeek V3.2 DSA sparse attention indexer with GLM-4 MoE Lite MLA attention and PipelineMixin
  • Dual cache (CacheList) with CacheList-aware pipeline integration
  • Both MLA and Indexer RoPE use traditional=True (interleaved)
  • Handles rope_parameters nested config via __post_init__
  • Expert stacking, kv_b_proj decomposition, and multi-token prediction layer exclusion in sanitize
  • Indexer stays unsharded in distributed mode
  • Adds test config to test_all_models with index_topk=2 to exercise the sparse attention path

Closes #879

Test plan

  • python -m unittest discover tests/ — all 157 tests pass
  • Standalone forward pass validation (prompt, cached, generation step, batch)
  • pre-commit run --files — black + isort clean

🤖 Generated with Claude Code

Combines DeepSeek V3.2 DSA sparse attention indexer with GLM-4 MoE Lite
MLA attention and PipelineMixin. Key design decisions:
- Dual cache (CacheList) with CacheList-aware pipeline integration
- Both MLA and Indexer RoPE use traditional=True (interleaved)
- rope_parameters nested config extraction via __post_init__
- No FP8 dequantization (BF16 model)
- Indexer stays unsharded in distributed mode

Closes ml-explore#879

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@iamadalek
iamadalek force-pushed the feature/glm-moe-dsa-879 branch from 01965ad to bd732d6 Compare February 12, 2026 02:55
@iamadalek

Copy link
Copy Markdown
Author

Closes #879. Works in conjunction with #878 (chunked conversion) for memory-constrained conversion of the full 744B model.

@Goekdeniz-Guelmez

Copy link
Copy Markdown
Contributor

A PR already exists #867

@iamadalek

Copy link
Copy Markdown
Author

A PR already exists #867

A apologies - I missed that. Thank you for doing it.

@iamadalek iamadalek closed this Feb 12, 2026
@Goekdeniz-Guelmez

Copy link
Copy Markdown
Contributor

@iamadalek no worries, happens to the best of us. cheers

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.

Add model support for GLM-5 (glm_moe_dsa architecture)

2 participants