Instructions to use TensorFold/DeepSeek-V4-Flash-MTP-MLX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use TensorFold/DeepSeek-V4-Flash-MTP-MLX with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] hf download TensorFold/DeepSeek-V4-Flash-MTP-MLX --local-dir DeepSeek-V4-Flash-MTP-MLX
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
DeepSeek-V4-Flash MTP layer converted for MLX
Browse files- LICENSE +21 -0
- README.md +73 -0
- SHA256SUMS +4 -0
- config.json +3 -0
- model.safetensors +3 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2023 DeepSeek
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: mlx
|
| 4 |
+
base_model: deepseek-ai/DeepSeek-V4-Flash
|
| 5 |
+
base_model_relation: quantized
|
| 6 |
+
tags:
|
| 7 |
+
- mlx
|
| 8 |
+
- deepseek_v4
|
| 9 |
+
- speculative-decoding
|
| 10 |
+
- tensorfold
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# DeepSeek-V4-Flash MTP for MLX
|
| 14 |
+
|
| 15 |
+
This is DeepSeek-V4-Flash's own multi-token-prediction (MTP) layer, converted for Apple Silicon. The mlx-community
|
| 16 |
+
4-bit conversion leaves it out. It drafts tokens for
|
| 17 |
+
[mlx-community/DeepSeek-V4-Flash-4bit](https://huggingface.co/mlx-community/DeepSeek-V4-Flash-4bit) on
|
| 18 |
+
[TensorFold](https://github.com/ashhart/TensorFold)'s lane engine, which verifies every draft against the target.
|
| 19 |
+
|
| 20 |
+
- Source: [deepseek-ai/DeepSeek-V4-Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash) at revision
|
| 21 |
+
`60d8d70770c6776ff598c94bb586a859a38244f1`. The layer is the `mtp.0.*` tensors of
|
| 22 |
+
`model-00046-of-00046.safetensors`.
|
| 23 |
+
- License: MIT, DeepSeek's (see `LICENSE`, copyright 2023 DeepSeek). The conversion adds no terms.
|
| 24 |
+
- Files: `model.safetensors` (3.52 GB), `config.json`, `LICENSE`, `SHA256SUMS`.
|
| 25 |
+
|
| 26 |
+
## Use
|
| 27 |
+
|
| 28 |
+
TensorFold 0.3.6.4 or later on a Mac with 256 GB:
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
tensorfold pull mlx-community/DeepSeek-V4-Flash-4bit Vontra/DeepSeek-V4-Flash-MTP-MLX
|
| 32 |
+
tensorfold serve mlx-community/DeepSeek-V4-Flash-4bit --drafter Vontra/DeepSeek-V4-Flash-MTP-MLX
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
The layer drafts up to three tokens a round, one pass each, from the target's streams at the last verified row. A
|
| 36 |
+
drafted reply equals the same request sent with `"draft": false`. Drafts change speed, never tokens. TensorFold's
|
| 37 |
+
default draft head is DeepSeek's DSpark module,
|
| 38 |
+
[Vontra/DeepSeek-V4-Flash-DSpark-MLX](https://huggingface.co/Vontra/DeepSeek-V4-Flash-DSpark-MLX) (10.67 GB).
|
| 39 |
+
|
| 40 |
+
## What the conversion does
|
| 41 |
+
|
| 42 |
+
- The layer's dense projections, `e_proj` and `h_proj` included, are FP8 (E4M3) with an E8M0 scale per 128 x 128
|
| 43 |
+
block. They are dequantized to bf16, which is exact, then quantized to MLX affine 4-bit in groups of 64. That step
|
| 44 |
+
is lossy, and it is the format the mlx-community target stores for its own dense projections.
|
| 45 |
+
- The routed experts keep DeepSeek's mxfp4 bytes and E8M0 scales unchanged.
|
| 46 |
+
- Norms (`enorm`, `hnorm` and the block's own), attention sinks, router weights and biases and hyper-connection
|
| 47 |
+
tensors are copied as stored.
|
| 48 |
+
- Block `mtp.0` becomes `mtp`, and its tensors take the names the mlx-community target uses for its own layers
|
| 49 |
+
(`attn.wq_a`, `ffn.switch_mlp.gate_proj` and so on). `config.json` names the head with
|
| 50 |
+
`"model_type": "deepseek_v4_mtp"`.
|
| 51 |
+
|
| 52 |
+
TensorFold's converter reproduces `model.safetensors` byte for byte from the source:
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
python -m tensorfold.families.deepseek_v4.convert mtp model-00046-of-00046.safetensors DeepSeek-V4-Flash-MTP-MLX
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Measured
|
| 59 |
+
|
| 60 |
+
On an M3 Ultra (60-core GPU, 256 GB) with MLX 0.32.2, TensorFold's lane engine served four short chat prompts (a
|
| 61 |
+
Fibonacci function, how a GPU runs matrix multiplication, primes, a translation), 64 generated tokens each. Decode
|
| 62 |
+
tok/s with this drafter and with `"draft": false`; sampled is temperature 1.0 with seed 1234:
|
| 63 |
+
|
| 64 |
+
| Prompt | Greedy, drafted | Greedy, no drafts | Sampled, drafted | Sampled, no drafts |
|
| 65 |
+
| --- | --- | --- | --- | --- |
|
| 66 |
+
| 1 | 60.9 | 46.5 | 53.6 | 45.8 |
|
| 67 |
+
| 2 | 53.0 | 46.4 | 48.1 | 45.7 |
|
| 68 |
+
| 3 | 64.2 | 46.6 | 59.5 | 45.8 |
|
| 69 |
+
| 4 | 58.7 | 46.4 | 60.7 | 45.7 |
|
| 70 |
+
|
| 71 |
+
Each drafted reply equals its `"draft": false` reply. For comparison, mlx-lm PR #1797's server decodes 23.0-23.5
|
| 72 |
+
tok/s greedy and 28.7-29.4 sampled on the same machine and weights with its defaults, measured on a chat and code
|
| 73 |
+
fixture rather than these four prompts.
|
SHA256SUMS
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
f2c6c602815669d292889e5be8c802f2ed950653b77999b1584e8e6aed25d040 LICENSE
|
| 2 |
+
bccbcaaa23b9ecd802f526cd9ba0b0b44736385084f253d09e43f822a82df650 README.md
|
| 3 |
+
b760dd370e395fc731c9dc0b484f7f5aa2a1221cfc21e489280f712512d3cb3e config.json
|
| 4 |
+
86238539c7c0b4a4f1916806fc2eb280843413a52e91fac7cb8e2ed32628b89e model.safetensors
|
config.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_type": "deepseek_v4_mtp"
|
| 3 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:86238539c7c0b4a4f1916806fc2eb280843413a52e91fac7cb8e2ed32628b89e
|
| 3 |
+
size 3521300333
|