Repository navigation
feat: add DeepSeek V4.1 Flash with DSpark MTP and Engram SSD offload - #3574
Merged
Merged
Conversation
jundot
added a commit
that referenced
this pull request
Sep 11, 2026
1 of 4 tasks
monroewilliams
added a commit
to monroewilliams/omlx
that referenced
this pull request
Sep 11, 2026
Both V4.1 export writers wrote safetensors without __metadata__, so
model_discovery._is_hf_cache_mlx_compatible() had no signal to accept the
checkpoint and silently filtered every oQ V4.1 release out of the model
list. The repo name carries 'mtp' rather than a standalone 'mlx' token and
model_type is deepseek_v41, so neither the name fallback nor the
speculative-decoding helper path rescues it either.
- ShardWriter._flush(): pass metadata={"format": "mlx"}. finish() only
renames the .model-shard-NNNNN temporaries, so the published
model-NNNNN-of-NNNNN names inherited the omission (61 of 65 shards).
- quantize_engram(): the hand-rolled header now emits __metadata__ after
the tensor entries (the 4 engram shards). Padding and data_start derive
from the encoded length, so the longer header needs no offset changes.
Every mx.save_safetensors site in omlx/oq.py already declared the format;
deepseek_v41/sharding.py is the only writer added by jundot#3574 that did not,
and deepseek_v4 has no export code at all -- which is why the earlier V4
release enumerated fine while V4.1 stayed invisible.
Bit width is orthogonal: quantize() accepts oq_level 3 and 4 through one
unconditional ShardWriter and one quantize_engram(bits=oq_level), so both
published quantizations are affected. The test is parametrized over
bits=[3, 4] to pin that down, and asserts DiskEngramEmbedding still
resolves its tensor entries from the enlarged header (TensorFile reads by
explicit key only; nothing iterates header keys).
Verified to fail against the pre-fix writers at both the projection shard
and the engram shard, so neither assertion is vacuous.
kaushikvira
pushed a commit
to kaushikvira/omlx
that referenced
this pull request
Sep 12, 2026
kaushikvira
pushed a commit
to kaushikvira/omlx
that referenced
this pull request
Sep 12, 2026
This was referenced Sep 12, 2026
jundot
pushed a commit
that referenced
this pull request
Sep 14, 2026
Both V4.1 export writers wrote safetensors without __metadata__, so
model_discovery._is_hf_cache_mlx_compatible() had no signal to accept the
checkpoint and silently filtered every oQ V4.1 release out of the model
list. The repo name carries 'mtp' rather than a standalone 'mlx' token and
model_type is deepseek_v41, so neither the name fallback nor the
speculative-decoding helper path rescues it either.
- ShardWriter._flush(): pass metadata={"format": "mlx"}. finish() only
renames the .model-shard-NNNNN temporaries, so the published
model-NNNNN-of-NNNNN names inherited the omission (61 of 65 shards).
- quantize_engram(): the hand-rolled header now emits __metadata__ after
the tensor entries (the 4 engram shards). Padding and data_start derive
from the encoded length, so the longer header needs no offset changes.
Every mx.save_safetensors site in omlx/oq.py already declared the format;
deepseek_v41/sharding.py is the only writer added by #3574 that did not,
and deepseek_v4 has no export code at all -- which is why the earlier V4
release enumerated fine while V4.1 stayed invisible.
Bit width is orthogonal: quantize() accepts oq_level 3 and 4 through one
unconditional ShardWriter and one quantize_engram(bits=oq_level), so both
published quantizations are affected. The test is parametrized over
bits=[3, 4] to pin that down, and asserts DiskEngramEmbedding still
resolves its tensor entries from the enlarged header (TensorFile reads by
explicit key only; nothing iterates header keys).
Verified to fail against the pre-fix writers at both the projection shard
and the engram shard, so neither assertion is vacuous.
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.
Add DeepSeek V4.1 Flash to oMLX's model loading, serving, model settings, and Web UI quantization paths. Original FP4/FP8 checkpoints load with automatic packed repacking; converted checkpoints support vision, Engram RAM/SSD modes, and single-stream Lightning MTP.
Memory required to run (Engram SSD offload)
These budgets include the language backbone, vision components, and DSpark MTP weights, with Engram tables offloaded to SSD. They are calculated from checkpoint headers as resident weights × 1.05 + 32 MiB; they are loader estimates, not measured peaks or total system RAM requirements. The oQ4e runtime peaks are listed in the benchmarks below.
Benchmarks
Benchmarked on M3 Ultra (512 GiB) with oQ4e,
code_python, temperature 1, top_p 1, and top_k 0. Prefix caching is off; each configuration uses a 4K warm-up, up to 2K prefill chunks, and 128 generated tokens.Speeds are tok/s; peak memory is GiB. PP pairs show MTP OFF → ON; peak memory uses MTP ON. Each row is one sampled run, excluding model loading.
Engram RAM
Engram SSD offload
Changes
-mtpcheckpoints, and retain original vision tensor precision.Validation
A real-image smoke test passed and original vision weights are preserved; broader vision and 1M-context validation remain pending, with single-stream Lightning MTP and sequential per-row execution.
Acknowledgements
Thanks to DeepSeek and the mlx-vlm contributors for the code adapted in this implementation:
Original copyright and license notices are retained with adapted code.