Add Spark2.5 model support - #1809
Closed
simple-zheng wants to merge 1 commit into
Closed
simple-zheng wants to merge 1 commit into
simple-zheng wants to merge 1 commit into
Conversation
|
Seems to be working here, integrated with 0.31.3 (though would work better if my mlx_lm had rotating kv support/4bit!). |
|
After further checking of mixed quant conversion, GLM-5.3 indicates that there is a "spark2_5.py:63 sanity check that wrongly assumes hidden_size == n_heads * head_dim" and recommends either just removing it (checked fine on my system), or perhaps replacing the check instead with some sort of check of kv width vs q width. |
Collaborator
|
superseded by #1891 |
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.
Summary
This PR adds native Spark2.5 inference support to MLX LM.
The implementation supports checkpoints with:
model_type: spark2_5Implementation
A new model implementation has been added at:
Since the filename matches the checkpoint's
model_type, Spark2.5 checkpoints are discovered through the existing MLX LM model-loading mechanism without additional loader registration.The implementation includes:
Supported Checkpoint
The implementation was verified with a local safetensors checkpoint of:
The tested checkpoint uses 28 decoder layers, mixed sliding/full attention, a vocabulary size of 131,072, and tied input/output embeddings.
Test Coverage
A Spark2.5 model test has been added to
tests/test_models.py.The test covers:
RotatingKVCachefor sliding-attention layersKVCachefor full-attention layersTargeted test command:
python -m unittest discover \ -s tests \ -p 'test_models.py' \ -k spark2_5Result: passed.
Formatting check:
Result: passed.
Real Checkpoint Verification
Command:
Output:
The checkpoint loaded successfully, generated the expected deterministic answer, and stopped normally.
Scope and Limitations
AI Usage Disclosure
Codex was used to assist with adapting the standalone Spark2.5 implementation to the MLX LM model interface, adding unit-test coverage.The implementation and verification results were reviewed and validated by the contributor.