Recipe · one DGX Spark · Zig engine
Qwen4 35B-A3B FP8 on one DGX Spark, with TensorFold's Zig engine.
Serve Qwen/Qwen4-35B-A3B-FP8 (plus opt-in BF16 and Blackfrost-AI/Cyber-Frost-35B-FP8) from a single DGX Spark (GB10, sm_121) through an OpenAI-compatible API, using TensorFold (flashnext) with custom Blackwell CUDA kernels, DFlash2 speculative drafting on by default, 512K default context (1M max supported) across 16 concurrent streams (~3.89M total KV tokens), vision (up to 50 images), and opt-in Looped recurrent depth. 79.4 tok/s prose for one request, 233.2 tok/s for sixteen at once, and 5,377.7 tok/s prefill on a 32K prompt.
Performance
Measured, not promised.
Measured with sparkDash on 1× NVIDIA DGX Spark (GB10 sm_121): Qwen4-35B-FP8, 512K context, FP8 KV cache, temperature=0.7, top_k=20, thinking on. DFlash2 (DFLASH=1) is the default; set DFLASH=0 for the built-in MTP drafter.
Decode, prose
DFlash2 (default) vs. built-in MTP: aggregate tok/s, per-stream tok/s, and time to first token.
| Streams | DFlash2 (per str) | TTFT | MTP (per str) | TTFT |
|---|---|---|---|---|
| ×1 | 79.4 (79.4) | 93 ms | 70.9 (70.9) | 83 ms |
| ×2 | 104.6 (53.8) | 140 ms | 107.8 (58.0) | 133 ms |
| ×4 | 146.2 (39.6) | 234 ms | 155.1 (41.0) | 222 ms |
| ×8 | 190.1 (27.9) | 424 ms | 231.4 (32.2) | 397 ms |
| ×16 | 233.2 (15.5) | 812 ms | — | — |
Decode, code
Same machine and settings on code generation, DFlash2 vs. built-in MTP.
| Streams | DFlash2 (per str) | TTFT | MTP (per str) | TTFT |
|---|---|---|---|---|
| ×1 | 86.1 (86.1) | 136 ms | 85.0 (85.0) | 131 ms |
| ×2 | 148.7 (80.0) | 198 ms | 111.5 (61.1) | 194 ms |
| ×4 | 172.7 (49.2) | 345 ms | 156.7 (44.1) | 321 ms |
| ×8 | 202.6 (31.5) | 607 ms | 223.5 (31.4) | 583 ms |
Prefill — 4K to 256K context
Prompt processing throughput and time to first token across context lengths, DFlash2 (default) vs. MTP.
| Context | Prompt tokens | DFlash2 prefill (TTFT) | MTP prefill (TTFT) |
|---|---|---|---|
| 4K | ~4,145 | 6,443.8 tok/s (764 ms) | 6,534.8 tok/s (757 ms) |
| 8K | 8,243 | 5,775.9 tok/s (1.55 s) | 5,707.8 tok/s (1.57 s) |
| 16K | ~16,430 | 5,550.6 tok/s (3.08 s) | 5,387.6 tok/s (3.17 s) |
| 32K | ~32,820 | 5,377.7 tok/s (6.22 s) | 5,288.7 tok/s (6.33 s) |
| 64K | ~65,585 | 5,064.7 tok/s (13.07 s) | 4,939.8 tok/s (13.40 s) |
| 128K | 131,121 | 4,953.1 tok/s (26.59 s) | 4,802.7 tok/s (27.42 s) |
| 256K | ~262,195 | 4,654.9 tok/s (56.45 s) | 4,526.9 tok/s (58.04 s) |
Speed preview
What 79.4 tok/s feels like.
Sample text played at the measured speed, at about four characters a token: one request at 79.4 tok/s, or four at once at 39.6 tok/s each (146.2 combined), with DFlash2 on. Switch between them in the window.
Models and modes
FP8 by default, Cyber and Looped opt-in.
By default the recipe serves Qwen/Qwen4-35B-A3B-FP8 with RadixArk/Qwen4-35B-A3B-Dflash2 (~0.75 GiB, block-8 causal speculative drafter) enabled, --vision on (up to 50 images), and SSD-backed Engram/PLE using 0 B of VRAM. You can switch checkpoints, drafters, or enable Looped-Qwen4-35B-A3B recurrent depth (~23 MB BF16 sidecar, zero duplicate base weights) with environment variables — no rebuild required.
| Start with | What it serves |
|---|---|
./start.sh | Qwen/Qwen4-35B-A3B-FP8 with DFlash2 drafter (DFLASH=1), 512K context, 16 concurrent streams, FP8 KV |
DFLASH=0 ./start.sh restart | Same FP8 model with the built-in MTP drafter instead of DFlash2 (faster at ×2–×8 prose concurrency) |
MODEL_PRECISION=bf16 ./start.sh restart | Opt-in BF16 weights (Qwen/Qwen4-35B-A3B) |
CYBER=1 ./start.sh restart | Opt-in Blackfrost-AI/Cyber-Frost-35B-FP8; auto-detects bundled dflash2/ drafter if present |
LOOP_PASSES=2 ./start.sh restart | Opt-in Looped recurrent depth T=2 (56 effective layers) via the ~23 MB Looped-Qwen4-35B-A3B sidecar |
LOOP_PASSES=3 ./start.sh restart | Opt-in Looped recurrent depth T=3 (72 effective layers); add LOOP_CD_OMEGA=0.15 for LoopCD-Hidden |
The engine
Powered by TensorFold.
TensorFold, by Ash Hart, is an open-source Zig + CUDA/Metal inference engine (flashnext). This recipe pairs it with custom Blackwell (sm_121) CUDA kernels, fine-grained 1×64 FP8G quantization, DFlash2 speculative drafting, and verified quality gates.
~3.89M KV tokens
512K default context (1M max with CONTEXT=1048576) and 16 streams in 55.43 GiB of FP8 KV (14.82 KiB/token): 524,288 contiguous tokens (7.80 GiB) on stream 0 + 13,160 × 256-token shared pages (47.63 GiB) across streams 1–15.
1×64 FP8G & W8A8 prefill
Load-time 1×64 E4M3 quantization with FP32 scales for dense projections, lm_head, Hyper-Connections, and pooled layers — 256× finer than 128×128 routed experts — plus BM=128/BK=64 3-stage MoE prefill.
Blackwell cluster kernels
2-CTA Cluster Split-K Hyper-Connections (K=8192 → 2×4096, −5.70 GB/chunk), single-kernel chunked WY Tensor-Core GDN prefill (2.14× faster), and hardened 128K–1M QSA sparse attention (~100× fewer global atomics).
DFlash2 & single-pass MTP
RadixArk/Qwen4-35B-A3B-Dflash2 enabled by default for faster ×1 decode, faster 8K–256K prefill, and ~530 MiB less draft KV per stream — plus bit-exact 1-pass MTP readout (1.29×–1.58× faster) when using DFLASH=0.
Quality & verification
Every wave gated on real checks.
| Verification suite | Result | Details |
|---|---|---|
scripts/quality_check.py | 7 / 7 PASS | Executable coding, math, and reasoning checks (88–98 tok/s) |
scripts/hard_quality_eval.py | 19 / 21 (20 / 21 semantic) | Hard math, 5 executable Python algorithms, logic, JSON/SQL constraints, 8K 3-needle recall, temp=0.6 prose (dist2=0.957, dist3=0.995) |
| Long-context needle recall | 100% PASS | Exact recall at 4.3K, 18.5K, 68.1K, 82.9K, and 127.1K tokens |
| Zig host test suites | 11 / 11 PASS | Rank graphs, draw/MTP, fused split, readout fused, MoE tiles, TP sync, non-finite guards, runtime, score, contract, and KV pool |
| PTXAS audit | 0 B spills | Verified sm_121 via cuobjdump -lelf and nvcc 13.0 |
What you need
One Spark, CUDA 13.0+, and Docker.
One DGX Spark
One NVIDIA DGX Spark (GB10, sm_121) with 128 GB unified memory and CUDA 13.0+ driver.
KV memory
The default 512K context and 16 streams use 55.43 GiB for FP8 KV (~3.89M tokens). SSD-backed Engram/PLE uses 0 B VRAM.
Docker
Docker with the NVIDIA Container Toolkit (docker --gpus all).
Weights
Qwen/Qwen4-35B-A3B-FP8 (or BF16) plus RadixArk/Qwen4-35B-A3B-Dflash2 (~0.75 GiB) in ~/.cache/huggingface.
Quick start
Clone, and start serving.
Clone and start
git clone https://github.com/MiaAI-Lab/Qwen4-35B-FP8-DGX-Spark.git
cd Qwen4-35B-FP8-DGX-Spark
./start.sh
Automatically downloads the selected weights (Qwen/Qwen4-35B-A3B-FP8 when CYBER=0, or Blackfrost-AI/Cyber-Frost-35B-FP8 when CYBER=1) and the RadixArk/Qwen4-35B-A3B-Dflash2 drafter (~0.75 GiB) into ~/.cache/huggingface if missing, then starts the OpenAI-compatible server on http://0.0.0.0:8888/v1. Use ./scripts/rebuild.sh to build or incrementally recompile CUDA fatbins and Zig after edits.
Talk to it
curl http://127.0.0.1:8888/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen4-35B-FP8",
"messages": [{"role": "user", "content": "Explain Blackwell cluster split-K in 3 bullets."}],
"max_tokens": 256
}'
./start.sh restart # Restart with current config.sh or .env
DFLASH=0 ./start.sh restart # Switch to built-in MTP drafter
CYBER=1 ./start.sh restart # Load Blackfrost-AI/Cyber-Frost-35B-FP8
./stop.sh # Stop and remove container
Settings
The ones you might change.
All defaults live in scripts/config.sh and can be overridden via environment variables or a local .env file without rebuilding.
| Setting | Default | Meaning |
|---|---|---|
MODEL_PRECISION | fp8 | fp8 (Qwen/Qwen4-35B-A3B-FP8) or bf16 (Qwen/Qwen4-35B-A3B) |
CYBER | 0 | 1 loads Blackfrost-AI/Cyber-Frost-35B-FP8 instead |
PORT / HOST | 8888 / 0.0.0.0 | Server bind port and address |
CONTEXT | 524288 | 512K default context window (up to 1048576 / 1M max supported) |
KV_DTYPE | fp8 | KV cache precision (fp8 or bf16) |
PARALLEL | 16 | Max concurrent request streams |
KV_PAGES / KV_PAGES_ALL | 256 / 0 | Page size (tokens) and contiguous lane-0 + paged lanes 1–15 pool (~3.89M tokens / 55.43 GiB) |
DFLASH / DFLASH_TAP | 1 / 6 | DFlash2 speculative drafter (RadixArk/Qwen4-35B-A3B-Dflash2); 0 for built-in MTP |
VISION / VISION_MAX_IMAGES | 1 / 50 | Multimodal vision support, up to 50 images |
LOOP_PASSES / LOOP_CD_OMEGA | unset | Opt-in Looped recurrent depth (2 or 3 passes; optional LoopCD-Hidden) |
DENSE_FP8 / HEAD_FP8 / HC_FP8 | 1 / 1 / 1 | Load-time 1×64 FP8G quantization for dense projections, lm_head, and Hyper-Connections |
CHUNK | 4352 | Prefill chunk size (tokens) |
Licenses
Free and open.
- The repository, its scripts, benchmarks, and TensorFold modifications are licensed under Apache License 2.0.
- Third-party components in
TensorFold/LICENSES/and upstream model weights (Qwen/Qwen4-35B-A3B-FP8,RadixArk/Qwen4-35B-A3B-Dflash2,Looped-Qwen4-35B-A3B,Cyber-Frost-35B-FP8) remain subject to their respective licenses.
Credits
Built on the work of others.
- TensorFold by Ash Hart (@tensorfold_dev) — the Zig + CUDA/Metal inference engine (
flashnext) this work builds on. - Qwen Team — for
Qwen/Qwen4-35B-A3BandQwen/Qwen4-35B-A3B-FP8. - Looped-Qwen4-35B-A3B by Jason Titus (
sliderforthewin) — for the Open-Channel v4 pure-recurrence looped-depth adapter (MIT). - keys-TF-Qwen4-35B-NVFP4-DFlash2-DGX-Spark by drowzeys (Apache-2.0) & RadixArk/Qwen4-35B-A3B-Dflash2 by RadixArk — for the TensorFold DFlash2 FlashNext adaptation patches and DFlash2 drafter weights.
- MiaAI-Lab — DGX Spark (
sm_121) CUDA kernel optimizations, serving recipes, benchmarks, and quality verification suite. - Upstream Inference Community — kernel design inspiration from vLLM, FlashInfer, and ExLlamaV3.
Run it on your DGX Spark.
Free and open, Apache-2.0, with reproducible benchmarks and quality checks.