Repository navigation
Enable Spark-X2.5 export and runner support for MLX - #23523
dongjiang1989 wants to merge 1 commit into
Conversation
This PR needs a
|
|
cc @nil-is-all PTAL, thanks |
|
@dongjiang1989 could you rebase and ping for review? A branch update with main should resolve CI failures |
nil-is-all
left a comment
There was a problem hiding this comment.
README and .yaml look good and simple enough to run. Hyperparams in test python file match 7B and 4B models.
Rebase and updated. |
ad09b3f to
d3f0b2d
Compare
|
@claude review this code |
|
Claude finished @metascroy's task in 4m 49s —— View job This needs changes: the MLX attention swap drops Spark-X2.5's headwise output gate, so MLX exports give wrong output from the first token; it also ignores the 512-token sliding window, and the EOS/BOS metadata appears to have been copied from LFM2. Detailed reviewPR Review: #23523SummaryThis PR adds an MLX 4-bit export config, a Code Quality
Testing
RecommendationRequest Changes The MLX export is numerically wrong for this architecture: the output gate is missing at every layer, and sliding layers ignore the window past 512 tokens. The EOS/BOS metadata also appears to be copied from LFM2. Smoke generation doesn't catch either problem, so please validate the fix against eager logits. |
d3f0b2d to
addd6b5
Compare
|
@nil-is-all @metascroy Fix claude review. Please re-check it, thanks |
|
@claude review this code |
|
Claude finished @metascroy's task in 3m 15s —— View job The headwise output gate is fixed now, but this still needs changes. On the real export path the sliding-window fix never takes effect, so Spark-X2.5 MLX exports still attend to the full history past 512 tokens. Other Detailed reviewPR Review: #23523SummaryThe new commit adds three things to
Code Quality
Testing
RecommendationRequest Changes On the actual export path, sliding layers still ignore the window: |
712517e to
9fcaf85
Compare
|
@claude review this code |
|
Thx @nil-is-all Fixed. Please review it 😄 |
Thx for the ping. Could you update the out-of-date branch? |
|
@claude review this code |
|
Claude finished @metascroy's task in 2m 14s —— View job This still needs changes: Detailed reviewPR Review: #23523SummaryThis revision adds checks that reject unsupported options, takes the sliding window from the eager Code Quality
Testing
RecommendationRequest Changes The conflict markers break MLX export for every model and must be removed. After that, fix the tests so they actually run (pass real rope freqs and the correct per-layer |
Add MLX backend support for Spark-X2.5 models with 4-bit quantization. Key changes: - Add MLX config (spark_x2_5_mlx_4w.yaml) with 4w quantization - Add comprehensive numerical tests (test_spark_x2_5_mlx.py) - Update Makefile with MLX build targets - Update README with MLX export instructions - Fix sliding window detection from RingKVCache - Add unsupported options validation (use_attn_o_norm, scale_query_by) - Fix sdpa_start calculation to avoid export guards - Fix Rope constructor usage in tests - Ensure validation consistency between __init__ and from_attention_mha Key features implemented: - Sliding window attention with ring buffer cache - Headwise output gate (per-head sigmoid) - Per-layer RoPE parameters (partial rotary factor) - Numerical tests comparing MLX vs eager attention - Support for positions past sliding window boundary - Prefill KV cache before testing past-window positions Spark-X2.5 models now support both XNNPACK and MLX backends. Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
d9603af to
1221f15
Compare
Summary
Add MLX backend support for Spark-X2.5 models (1.7B and 4B variants), enabling efficient inference on Apple Silicon.
make spark_x2_5-mlxto build the shared Llama C++ runner with MLX enabledSpark-X2.5 is a compact, efficient language model series with hybrid attention (3 sliding-window + 1 full-attention layer), supporting context windows up to 1M tokens and 200+ languages.
Test plan
pytest -q examples/models/spark_x2_5/test_spark_x2_5_mlx.pymake -n spark_x2_5-mlxmake spark_x2_5-mlxspark_x2_5_1_7b_mlx_4w.ptespark_x2_5_4b_mlx_4w.ptellama_mainsmoke generation with MLX exportscc @mergennachin @iseeyuan @lucylq @helunwencser @tarun292 @kimishpatel @jackzhxng @nil-is-all @metascroy