Text Generation
Transformers
Safetensors
deepseek_v4
Mixture of Experts
compressed-tensors
w4a8
int4
fp8
vllm
quantization
Instructions to use endnai/DeepSeek-V4-Flash-W4A8-FP8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use endnai/DeepSeek-V4-Flash-W4A8-FP8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="endnai/DeepSeek-V4-Flash-W4A8-FP8")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("endnai/DeepSeek-V4-Flash-W4A8-FP8") model = AutoModelForCausalLM.from_pretrained("endnai/DeepSeek-V4-Flash-W4A8-FP8") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use endnai/DeepSeek-V4-Flash-W4A8-FP8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "endnai/DeepSeek-V4-Flash-W4A8-FP8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "endnai/DeepSeek-V4-Flash-W4A8-FP8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/endnai/DeepSeek-V4-Flash-W4A8-FP8
- SGLang
How to use endnai/DeepSeek-V4-Flash-W4A8-FP8 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "endnai/DeepSeek-V4-Flash-W4A8-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "endnai/DeepSeek-V4-Flash-W4A8-FP8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "endnai/DeepSeek-V4-Flash-W4A8-FP8" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "endnai/DeepSeek-V4-Flash-W4A8-FP8", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use endnai/DeepSeek-V4-Flash-W4A8-FP8 with Docker Model Runner:
docker model run hf.co/endnai/DeepSeek-V4-Flash-W4A8-FP8
card: correct throughput framing (best-measured TP2 config; ties W4A16, beats FP4 ~9-13%); note TP4 pending
Browse files
README.md
CHANGED
|
@@ -20,7 +20,7 @@ pipeline_tag: text-generation
|
|
| 20 |
|
| 21 |
A **W4A8** quantization of DeepSeek-V4-Flash: **INT4 group-quantized MoE expert weights** with **FP8 (e4m3) dynamic per-token activations**, plus FP8 block-quantized attention/dense layers. Produced as a **zero-cost config transformation** of [`canada-quant/DeepSeek-V4-Flash-W4A16-FP8-MTP`](https://huggingface.co/canada-quant/DeepSeek-V4-Flash-W4A16-FP8-MTP) — the INT4 weight bytes are **identical**; only the activation quantization scheme in `config.json` changed (experts `input_activations`: `null` → FP8 dynamic-token).
|
| 22 |
|
| 23 |
-
> **⚠️ Honest headline first:** on H200 (Hopper / SM90) this
|
| 24 |
|
| 25 |
> **📦 This is a config / recipe repository — the weight shards are NOT included.** Because the W4A8 transformation reuses the base's INT4 weights **byte-for-byte**, duplicating ~159 GB here would be pure waste. This repo ships the W4A8 `config.json`, tokenizer, weight index, and this card. To get a runnable checkpoint, pull the weights from the base and drop in this `config.json` — see **[Getting the weights](#getting-the-weights)** (one command).
|
| 26 |
|
|
@@ -93,17 +93,25 @@ vllm serve ./dsv4-w4a8 \
|
|
| 93 |
|
| 94 |
This checkpoint was built to test a hypothesis: *the DeepSeek-V4-Flash prefill bottleneck is the INT4→BF16 Marlin MoE GEMM, so a W4A8 path (native FP8 activation GEMM) should be ~1.5–2× faster.* **The hypothesis was refuted.** Full sweep on 2–8×H200 (TP2 unless noted), single-request prefill ladder (c=1), long-context (ISL up to 24k):
|
| 95 |
|
| 96 |
-
### Headline: W4A8
|
| 97 |
|
| 98 |
| Config | Engine | TP | Prefill TTFT @24k | Prefill tok/s/GPU @24k |
|
| 99 |
|---|---|---|---|---|
|
| 100 |
-
| **W4A8** (this model) | vLLM | 2 | **1658 ms** | **7410** |
|
| 101 |
| W4A16 (base) | vLLM | 2 | 1691 ms | 7267 |
|
| 102 |
| FP4 (marlin) | vLLM | 2 | 1824 ms | 7090 |
|
| 103 |
| FP4 (marlin) | sglang | 2 | 1894 ms | 6832 |
|
| 104 |
-
| FP8 (native) | sglang | 4 | 892 ms | 6888 |
|
| 105 |
|
| 106 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
### Why the activation-precision lever doesn't help
|
| 109 |
|
|
@@ -122,7 +130,11 @@ At prefill batch sizes, the DeepSeek-V4-Flash MoE (top-6 of 256 small experts) i
|
|
| 122 |
|
| 123 |
### Bottom line
|
| 124 |
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
## Reproducibility
|
| 128 |
|
|
|
|
| 20 |
|
| 21 |
A **W4A8** quantization of DeepSeek-V4-Flash: **INT4 group-quantized MoE expert weights** with **FP8 (e4m3) dynamic per-token activations**, plus FP8 block-quantized attention/dense layers. Produced as a **zero-cost config transformation** of [`canada-quant/DeepSeek-V4-Flash-W4A16-FP8-MTP`](https://huggingface.co/canada-quant/DeepSeek-V4-Flash-W4A16-FP8-MTP) — the INT4 weight bytes are **identical**; only the activation quantization scheme in `config.json` changed (experts `input_activations`: `null` → FP8 dynamic-token).
|
| 22 |
|
| 23 |
+
> **⚠️ Honest headline first:** on H200 (Hopper / SM90) this was the **fastest single-config in our sweep** — best TP2 prefill TTFT (1658 ms @24k) *and* highest per-GPU prefill throughput (7410 tok/s/GPU) of every cell tested. It **ties its W4A16 parent** (~2%, within run-to-run noise — the "W4A8 should be ~2× faster than W4A16" hypothesis was refuted), but it **beats the FP4-marlin config by ~9–13%** on the same 2×H200 footprint (int4→Marlin > nvfp4→Marlin). One caveat: it is **vLLM-only** (sglang can't load this checkpoint format), so it isn't a drop-in for an sglang deployment. See **[Investigation & findings](#investigation--findings)**.
|
| 24 |
|
| 25 |
> **📦 This is a config / recipe repository — the weight shards are NOT included.** Because the W4A8 transformation reuses the base's INT4 weights **byte-for-byte**, duplicating ~159 GB here would be pure waste. This repo ships the W4A8 `config.json`, tokenizer, weight index, and this card. To get a runnable checkpoint, pull the weights from the base and drop in this `config.json` — see **[Getting the weights](#getting-the-weights)** (one command).
|
| 26 |
|
|
|
|
| 93 |
|
| 94 |
This checkpoint was built to test a hypothesis: *the DeepSeek-V4-Flash prefill bottleneck is the INT4→BF16 Marlin MoE GEMM, so a W4A8 path (native FP8 activation GEMM) should be ~1.5–2× faster.* **The hypothesis was refuted.** Full sweep on 2–8×H200 (TP2 unless noted), single-request prefill ladder (c=1), long-context (ISL up to 24k):
|
| 95 |
|
| 96 |
+
### Headline: W4A8 leads the TP2 matrix, but ties W4A16
|
| 97 |
|
| 98 |
| Config | Engine | TP | Prefill TTFT @24k | Prefill tok/s/GPU @24k |
|
| 99 |
|---|---|---|---|---|
|
| 100 |
+
| **W4A8** (this model) | vLLM | 2 | **1658 ms** ⭐ | **7410** ⭐ |
|
| 101 |
| W4A16 (base) | vLLM | 2 | 1691 ms | 7267 |
|
| 102 |
| FP4 (marlin) | vLLM | 2 | 1824 ms | 7090 |
|
| 103 |
| FP4 (marlin) | sglang | 2 | 1894 ms | 6832 |
|
| 104 |
+
| FP8 (native) | sglang | **4** | 892 ms | 6888 |
|
| 105 |
|
| 106 |
+
**W4A8 is the fastest TP2 config and the highest per-GPU throughput of every cell measured.** Two things to read carefully:
|
| 107 |
+
|
| 108 |
+
- **vs W4A16 (its parent): a tie** — 1658 vs 1691 ms is ~2%, within run-to-run noise. The specific hypothesis this checkpoint was built to test — *"FP8-activation MoE GEMM should be ~1.5–2× faster than W4A16"* — was **refuted**. At prefill batch-M the MoE is weight-bandwidth-bound, so activation precision doesn't move it and Marlin-W4A16 already matches Cutlass-W4A8.
|
| 109 |
+
- **vs FP4-marlin: a real ~9–13% win** — int4→Marlin beats nvfp4→Marlin, so W4A8 (and W4A16) beat the FP4 base. FP4-marlin is what production currently runs, so W4A8/W4A16 are meaningfully faster than the deployed config *on the same 2-GPU footprint*.
|
| 110 |
+
- The FP8-TP4 cell's low absolute TTFT (892 ms) is **tensor-parallel scaling** (2× the GPUs); **per-GPU, W4A8-TP2 still wins** (7410 > 6888).
|
| 111 |
+
|
| 112 |
+
Per-GPU throughput spans a narrow ~6.8–7.4k tok/s/GPU band across all cells — the architecture sets a ceiling — but within that band W4A8 sits at the top.
|
| 113 |
+
|
| 114 |
+
> **TP4 for this checkpoint is not yet benched** — see [To-do](#to-do). Given W4A8-TP2 already leads on both TTFT and per-GPU, W4A8-TP4 is the most likely config to beat the FP8-TP4 892 ms absolute latency.
|
| 115 |
|
| 116 |
### Why the activation-precision lever doesn't help
|
| 117 |
|
|
|
|
| 130 |
|
| 131 |
### Bottom line
|
| 132 |
|
| 133 |
+
W4A8 is the **best-measured DeepSeek-V4-Flash config on Hopper** at TP2 — top prefill TTFT and top per-GPU throughput. It **ties** its W4A16 sibling (so the ~2× hypothesis failed), but it **beats the FP4-marlin config that ships in production by ~9–13%** on the same footprint. The practical catch is that this checkpoint format loads on **vLLM only**, so capturing that win over an sglang FP4 deployment means an engine switch, not a config swap. The dominant serving lever remains prefix caching (~55% radix hit in prod); larger absolute-latency wins beyond this need Blackwell (native NVFP4 + FP4 indexer).
|
| 134 |
+
|
| 135 |
+
## To-do
|
| 136 |
+
|
| 137 |
+
- **Bench TP4** for this checkpoint. W4A8-TP2 already leads the matrix on TTFT and per-GPU; W4A8-TP4 is the strongest candidate to beat the FP8-TP4 892 ms absolute TTFT while keeping INT4 weight footprint. (Not yet run.)
|
| 138 |
|
| 139 |
## Reproducibility
|
| 140 |
|