canada-quant/DeepSeek-V4-Flash-W4A16-FP8
canada-quant/DeepSeek-V4-Flash-W4A16-FP8
Mixed-precision quantization of `deepseek-ai/DeepSeek-V4-Flash` — W4A16 INT4 on routed experts + FP8 block 128×128 on attention — that loads cleanly on Hopper datacenter GPUs and on consumer-grade Blackwell. Recipe topology mirrors `RedHatAI/DeepSeek-V4-Flash-NVFP4-FP8`; routed-expert format is W4A16 (Marlin) instead of NVFP4 for compatibility with SM 9.x / SM 12.x kernels.
TL;DR
Family / related artifacts
Why this exists
DeepSeek-V4-Flash launched April 24, 2026 (284 B total / 13 B active, hybrid CSA + HCA attention, hash-routed experts). At release, no merged path through transformers + llm-compressor + vLLM existed for V4 quantization on Hopper or on SM 12.x Blackwell. `RedHatAI/DeepSeek-V4-Flash-NVFP4-FP8` covered Blackwell datacenter (B100/B200, SM 10.x) via NVFP4 tcgen05 kernels, and `Intel/DeepSeek-V4-Flash-W4A16-AutoRound` covered W4A16 but explicitly excluded vLLM and SGLang. This artifact fills the gap: W4A16 GPTQ routed experts + FP8 block attention that serves on vLLM at TP=2 on H200 (Hopper SM 9.0a), DGX Spark (Blackwell SM 12.1a), and RTX PRO 6000 (Blackwell SM 12.0) — same weights, three SKUs.
Architecture & precision
Base model
Component precisions
Hardware validated
All three SKUs serve cuda graphs ON (no --enforce-eager). Same artifact, no weight changes between SKUs — only vLLM build flags and a few env vars differ.
Benchmarks
Quality
Sampling: greedy, temperature 0. lm-eval-harness via OpenAI-compatible backend pointing at the local vLLM. Methodology disclosed per row.
¹ The H200 GSM8K strict-match of 42.61% was a chat-format extraction artifact, not a quality regression. The flexible-extract number (92.87%) is the comparable figure. Cross-checked on DGX Spark / RTX PRO 6000 with corrected extraction (95.07–95.45%).
² ³ HumanEval pass@1 on H200 was initially reported as 54.27% under regex-based extraction. The harness was later corrected to use --confirm_run_unsafe_code (executes generated code), which raised the same-artifact score to 80.49%. The Spark and RTX PRO 6000 runs use the corrected methodology; the H200 number is the same artifact re-scored. See Changes for the dated correction.
⁴ Spark toolcall15 is scored across 3 thinking modes (45 cases); H200 / RTX PRO 6000 are single-round (30 cases). Scores normalized to %.
Comparison caveat: the H200 numbers come from an older vLLM build (harness HEAD85aca32,jasl/vllm@428e08e). Spark and RTX PRO 6000 numbers are on today'sds4-sm120-experimentaltip. The valid same-software comparison is DGX Spark ↔ RTX PRO 6000; H200 ↔ Blackwell deltas are informational.
Throughput
vllm bench serve random 1024-in / 1024-out, cuda graphs ON, MTP-spec n/a (this artifact ships without MTP).
Per-stream decode rate on RTX PRO 6000 is rock-stable across concurrency (TPOT mean stays at 21 ms, p99 only 23 ms). Aggregate input+output throughput at bs=2 reaches 420 tok/s.
Quick start
vllm serve canada-quant/DeepSeek-V4-Flash-W4A16-FP8 \
--served-model-name DSV4-W4A16-FP8 \
--tensor-parallel-size 2 \
--kv-cache-dtype fp8 \
--block-size 256 \
--max-model-len 16384 \
--max-num-seqs 4 \
--gpu-memory-utilization 0.92 \
--tokenizer-mode deepseek_v4 \
--tool-call-parser deepseek_v4 \
--enable-auto-tool-choice \
--reasoning-parser deepseek_v4 \
--trust-remote-codeRequired env vars on SM 12.x sparse-MLA path: set VLLM_TRITON_MLA_SPARSE=1 and VLLM_TRITON_MLA_SPARSE_HEAD_BLOCK_SIZE=4. Without _HEAD_BLOCK_SIZE=4 the sparse-MLA Triton kernel crashes during warmup with RuntimeError: Triton Error [CUDA]: an illegal memory access was encountered in _dequantize_and_gather_k_kernel (kernel falls back to a default block size that doesn't match V4-Flash's head dim). Full env block at `findings/QUICKSTART_DUAL_SPARK.md §4`.
Long-context (1M tokens, single stream): drop --max-num-seqs to 1, --gpu-memory-utilization to 0.90, set --max-model-len 1048576 --max-num-batched-tokens 8192 --compilation-config '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"]}'.
Tensor parallelism: TP=2 is the only validated configuration. TP=1 OOMs on a single 141 GB H200; TP≥4 hits an upstream W4A16 MoE scale-sharding bug (`vllm-project/vllm#41511`).
RTX PRO 6000 (SM 12.0) only: set VLLM_USE_FLASHINFER_SAMPLER=0 — vLLM's FlashInfer-based top-p / top-k sampler JIT mis-parses the TORCH_CUDA_ARCH_LIST=12.0a token and incorrectly raises RuntimeError: FlashInfer requires GPUs with sm75 or higher.
Quantization recipe
Required calibration environment
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
export TORCH_NCCL_HEARTBEAT_TIMEOUT_SEC=3600
export TORCH_NCCL_BLOCKING_WAIT=0
export NCCL_TIMEOUT=3600
export TORCH_CUDA_ARCH_LIST=9.0a
sudo mount -o remount,size=1800G /dev/shmexpandable_segments is calibration-only — must not be set during vLLM serving.
What didn't work (recorded so others don't waste cycles)
Recipe
from llmcompressor.modifiers.quantization import GPTQModifier
from compressed_tensors.quantization.quant_scheme import FP8_BLOCK, W4A16, QuantizationScheme
recipe = GPTQModifier(
config_groups={
"attention": QuantizationScheme(
targets=[
r"re:.*self_attn\.(q_a_proj|q_b_proj|kv_proj|o_a_proj|o_b_proj)$",
r"re:.*self_attn\.compressor\.(gate_proj|kv_proj)$",
r"re:.*self_attn\.compressor\.indexer\.(gate_proj|kv_proj|q_b_proj|weights_proj)$",
],
**FP8_BLOCK,
),
"experts": QuantizationScheme(
targets=[r"re:.*mlp\.experts\.\d+\.(gate_proj|up_proj|down_proj)$"],
**W4A16,
),
},
ignore=["lm_head"],
offload_hessians=True,
dampening_frac=0.1,
)
oneshot(
model=model,
dataset=ds,
recipe=recipe,
max_seq_length=512,
num_calibration_samples=768,
sequential_targets=["DeepseekV4DecoderLayer"],
batch_size=4,
)vLLM build
This artifact does not load on vanilla vLLM. Stack:
Single-file bootstrap script for dual DGX Spark: `scripts/bootstrap_dsv4_spark.sh` — does the whole stack zero-to-serving.
Upstream tracker: original PR `#40991` (where Spark validation was posted) closed 2026-05-06; current tracker is PR `#41834` — "[New Model][Nvidia] Add SM12x support for DeepSeek V4 Flash with essential fixes", branch codex/ds4-sm120-min-enable.
Honest limitations
- No MTP —
transformers5.8.1's_keys_to_ignore_on_load_unexpected = [r"(^|\.)mtp\..*"]silently strips MTP keys during calibration load. Speculative decoding cannot fire with this artifact. The W4A16-FP8-MTP successor retains MTP via a patched calibration path and delivers 1.49× spec-decode speedup at bs=1. - TP > 2 blocked by `vllm-project/vllm#41511` — W4A16 MoE scale-sharding bug.
- H200 numbers from older vLLM build — H200 baseline was scored on
jasl/vllm@428e08e(harness HEAD85aca32). Same-software comparison is DGX Spark ↔ RTX PRO 6000; H200 → Blackwell deltas are informational. - toolcall15 TC-06 (Multi-Value Extraction) and TC-08 (Conditional Branching) also fail on the native FP4/FP8 baseline — V4-Flash model-architecture limits, not quantization defects.
- *2026-05-25: artifact has shipping issues on current upstream vLLM. Two problems were surfaced when attempting to load this artifact on `jasl/vllm@a02a3778f` (the post-PR-#40923 build the sibling [`W4A16-MTP card`](https://huggingface.co/canada-quant/DeepSeek-V4-Flash-W4A16-FP8-MTP) now uses): (1) Same FP8_BLOCK compressor/indexer shipping bug as the MTP sibling — current vLLM constructs those modules as plain BF16 (`quant_config=None`) and the artifact fails with `KeyError: 'layers.10.attn.mla_attn.compressor.fused_wkv_wgate.weight_scale'`. The MTP sibling fixed this by dequantizing those weights in-artifact to BF16; this artifact has not yet had that fix applied. (2) A separate architecture-drift issue: the artifact lacks the `layers.N.ffn.gate.e_score_correction_bias` tensor that current upstream vLLM's DSV4 loader requires (`KeyError`). Either re-calibration that emits this tensor, or a defensive `.get()` loader patch upstream is needed. The published H200/Spark/RTX PRO 6000 numbers above remain valid for their original `jasl/vllm@ds4-sm120-experimental@abad5dc71` build* (2026-05-05); they do not currently reproduce on bleeding-edge vLLM. Tracking and re-verification deferred to the next session.
Reproduction
Full toolchain, scripts, patches, mission report: `canada-quant/dsv4-flash-w4a16-fp8`.
Single-file bootstrap (dual DGX Spark, idempotent, SSH-orchestrated):
curl -fsSLO https://raw.githubusercontent.com/canada-quant/dsv4-flash-w4a16-fp8/main/scripts/bootstrap_dsv4_spark.sh
chmod +x bootstrap_dsv4_spark.sh
./bootstrap_dsv4_spark.sh --head-host spark-a --worker-host spark-bUpstream contributions filed during this work
Changes
Files in the artifact
- ~30 sharded
model-*.safetensorsfiles +model.safetensors.index.json(~143 GB total) config.json— vLLM-compatible quantizationconfig (W4A16 + FP8BLOCK groups)tokenizer.json,tokenizer_config.json,generation_config.json— upstream DSV4-Flashrecipe.yaml— the llm-compressor calibration recipechat_template.jinja— upstream DSV4-Flash (unchanged)README.md— this file
Citation
@misc{canada-quant-dsv4-flash-w4a16-fp8-2026,
title = {DeepSeek-V4-Flash W4A16-FP8 for vLLM on Hopper and Blackwell},
author = {Canada Quant},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/canada-quant/DeepSeek-V4-Flash-W4A16-FP8}
}License
MIT, inherited from upstream deepseek-ai/DeepSeek-V4-Flash.
Acknowledgments
- @jasl — DeepSeek-V4 vLLM SM12x base support (PR `#40991` → `#41834`); memory-pressure-release fix
e734ace5that resolved the Blackwell 256K×2 stall. - @kylesayrs — compressed-tensors V4 attention path (PR `#41276`).
- @aabbccddwasd — indexer KV cache layout fix.
- @bbbearxyz — SM12x Triton fallback kernels.
- @wuwenthink — SM12x harness validation.
- `RedHatAI/DeepSeek-V4-Flash-NVFP4-FP8` — published reference for V4 mixed-precision attention topology.
