Downloads · 30 days
27
29% of all-time downloads
ludo-tech/DeepSeek-V4-Flash-REAP-145B-A13B
DeepSeek-V4-Flash-REAP-145B-A13B is a machine learning model from ludo-tech. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
DeepSeek Flash, optimized to run on a single NVIDIA DGX Spark.
Downloads · 30 days
27
29% of all-time downloads
All-time downloads
94
Public
Parameters
146B
82.4 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors82.4 GB · 100%
How the weights are stored.
I8139B · 95%
From the Hugging Face model README
DeepSeek Flash, optimized to run on a single NVIDIA DGX Spark.
This is DeepSeek-V4-Flash-0731 (284B, 256 routed experts per layer, about 167 GB) with half of the experts removed (256 to 128 per layer) using REAP, a pruning method that keeps the experts the router actually uses. The result loads and serves on one DGX Spark (GB10, 128 GB unified memory) with stock vLLM. No source patches needed.
topk_softplus_sqrt router kernelNot affiliated with DeepSeek. This is a community compression experiment. Expect some quality loss versus the original model (see Evaluation).
# create a venv and install vllm (torch cu130 wheels)
uv venv vllm-env
uv pip install --python vllm-env/bin/python vllm --index-url https://download.pytorch.org/whl/cu130
# FlashInfer needs prebuilt kernels when nvcc is absent.
# Both packages must match the flashinfer-python version that vllm installed:
uv pip install --python vllm-env/bin/python "flashinfer-cubin==<flashinfer version>" --index-url https://flashinfer.ai/whl
uv pip install --python vllm-env/bin/python "flashinfer-jit-cache==<flashinfer version>" --index-url https://flashinfer.ai/whl/cu130
vllm-env/bin/vllm serve <this-repo> \
--served-model-name v4-flash-k128 \
--max-model-len 32768 \
--gpu-memory-utilization 0.80 \
--kv-cache-dtype fp8 # required: DeepSeek-V4 fp8_ds_mla KV layout
Prompts must use the official DeepSeek-V4 encoding (encoding/ in this repo, no Jinja template):
from encoding_dsv4 import encode_messages
prompt = encode_messages([{"role": "user", "content": "1+1は?"}], thinking_mode="chat")
# then use the /v1/completions endpoint with stop=["<|end▁of▁sentence|>"]
Calibration ran on the DGX Spark itself. The unpruned model never fits in memory, so
each of the 43 decoder layers was rebuilt one at a time (FP4/FP8 dequantized to bf16 into
transformers DeepseekV4DecoderLayer) while the hidden states [N, L, 4, 4096] lived in
a disk memmap. Correctness gate: full-pipeline perplexity 4.73 on held-out samples of the
calibration mix (2048 tokens each).
REAP scores each expert as S_e = mean over tokens routed to e of (w_e(x) · ‖f_e(x)‖₂),
where w_e is the routing weight actually applied to the expert output (renormalized after
top-k). Calibration mix: 512 samples of 2048 tokens. 35% English chat (ultrachat_200k),
30% code (evol-codealpaca-v1), 20% Japanese prose (wikimedia/wikipedia 20231101.ja),
15% Japanese instructions (kunishou/databricks-dolly-15k-ja).
The calibration language mix decides which experts survive. A first attempt calibrated on English and code only. Its Japanese output was garbled beyond use. Re-calibrating with 35% Japanese changed about 11 of the 128 kept experts per layer (up to 27) and restored coherent Japanese. If you re-run this pipeline for another language, put that language in the mix.
Pruning is structural. Per layer, the top-128 experts by S_e are kept and renumbered,
and the router rows (gate.weight and the gate.bias correction) are sliced to match.
Layers 0 to 2 route by token hash through a frozen tid2eid table; removed ids there are
remapped to the most similar kept expert (cosine of router rows), keeping each token's
6 experts distinct. The MTP block (mtp.0.*) is dropped (num_nextn_predict_layers: 0).
Kept expert tensors are byte-identical to the original checkpoint.
router_mapping.json (which original expert ids each layer kept) ships in this repo.
The full pipeline (inventory, calibration, plan, rewrite, validate) is in tools/.
Small eval, greedy decoding, official chat encoding (non-thinking mode), on one DGX Spark. Numbers in parentheses are the same eval on the earlier checkpoint that was calibrated on English and code only. The Japanese gain comes from the calibration mix, not extra capacity:
| category | items | pass | notes |
|---|---|---|---|
| code (Python, executed tests) | 12 | 12 (12) | includes JA-language instructions |
| math (exact numeric) | 14 | 13 (12) | |
| Japanese (kana-verified JA output) | 12 | 11 (8) | coherent; rare-kanji dropouts remain |
| English | 12 | n/a | recorded for side-by-side review |
Runtime smoke: 0 failures, 0 empty outputs, decode about 17 tok/s median on one DGX Spark. This is not a benchmark suite. Expect measurable degradation on knowledge-heavy and long-tail tasks. The original model outperforms this checkpoint.
tid2eid remap is a heuristic.