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.

Get the free recipe

Install with an AI agent

Install this model

Paste this into an AI coding agent that can run commands on the machine that will serve the model (the head node, for a Spark cluster), such as Claude Code or Codex. It reads the recipe, adapts it to your setup, starts the server and checks that it works.


        
Cyber Ablitirated Qwen4 35B DGX Spark Looped (Opt-in) in bright silver and white lettering on black beside a monochrome glass geometric sculpture

Performance

Measured, not promised.

One request79.4tok/s, prose (DFlash2)
Sixteen at once233.2tok/s combined
Prefill5,377.7tok/s, 32K prompt
Context512Kdefault · 1M max, 16 streams

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.

StreamsDFlash2 (per str)TTFTMTP (per str)TTFT
×179.4 (79.4)93 ms70.9 (70.9)83 ms
×2104.6 (53.8)140 ms107.8 (58.0)133 ms
×4146.2 (39.6)234 ms155.1 (41.0)222 ms
×8190.1 (27.9)424 ms231.4 (32.2)397 ms
×16233.2 (15.5)812 ms——

Decode, code

Same machine and settings on code generation, DFlash2 vs. built-in MTP.

StreamsDFlash2 (per str)TTFTMTP (per str)TTFT
×186.1 (86.1)136 ms85.0 (85.0)131 ms
×2148.7 (80.0)198 ms111.5 (61.1)194 ms
×4172.7 (49.2)345 ms156.7 (44.1)321 ms
×8202.6 (31.5)607 ms223.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.

ContextPrompt tokensDFlash2 prefill (TTFT)MTP prefill (TTFT)
4K~4,1456,443.8 tok/s (764 ms)6,534.8 tok/s (757 ms)
8K8,2435,775.9 tok/s (1.55 s)5,707.8 tok/s (1.57 s)
16K~16,4305,550.6 tok/s (3.08 s)5,387.6 tok/s (3.17 s)
32K~32,8205,377.7 tok/s (6.22 s)5,288.7 tok/s (6.33 s)
64K~65,5855,064.7 tok/s (13.07 s)4,939.8 tok/s (13.40 s)
128K131,1214,953.1 tok/s (26.59 s)4,802.7 tok/s (27.42 s)
256K~262,1954,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.

TensorFold Zig · Qwen4-35B-FP8 · 1× DGX Spark
79.4 tok/sSample text, played at the measured speed

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 withWhat it serves
./start.shQwen/Qwen4-35B-A3B-FP8 with DFlash2 drafter (DFLASH=1), 512K context, 16 concurrent streams, FP8 KV
DFLASH=0 ./start.sh restartSame FP8 model with the built-in MTP drafter instead of DFlash2 (faster at ×2–×8 prose concurrency)
MODEL_PRECISION=bf16 ./start.sh restartOpt-in BF16 weights (Qwen/Qwen4-35B-A3B)
CYBER=1 ./start.sh restartOpt-in Blackfrost-AI/Cyber-Frost-35B-FP8; auto-detects bundled dflash2/ drafter if present
LOOP_PASSES=2 ./start.sh restartOpt-in Looped recurrent depth T=2 (56 effective layers) via the ~23 MB Looped-Qwen4-35B-A3B sidecar
LOOP_PASSES=3 ./start.sh restartOpt-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 suiteResultDetails
scripts/quality_check.py7 / 7 PASSExecutable coding, math, and reasoning checks (88–98 tok/s)
scripts/hard_quality_eval.py19 / 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 recall100% PASSExact recall at 4.3K, 18.5K, 68.1K, 82.9K, and 127.1K tokens
Zig host test suites11 / 11 PASSRank graphs, draw/MTP, fused split, readout fused, MoE tiles, TP sync, non-finite guards, runtime, score, contract, and KV pool
PTXAS audit0 B spillsVerified 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.

1

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.

2

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.

SettingDefaultMeaning
MODEL_PRECISIONfp8fp8 (Qwen/Qwen4-35B-A3B-FP8) or bf16 (Qwen/Qwen4-35B-A3B)
CYBER01 loads Blackfrost-AI/Cyber-Frost-35B-FP8 instead
PORT / HOST8888 / 0.0.0.0Server bind port and address
CONTEXT524288512K default context window (up to 1048576 / 1M max supported)
KV_DTYPEfp8KV cache precision (fp8 or bf16)
PARALLEL16Max concurrent request streams
KV_PAGES / KV_PAGES_ALL256 / 0Page size (tokens) and contiguous lane-0 + paged lanes 1–15 pool (~3.89M tokens / 55.43 GiB)
DFLASH / DFLASH_TAP1 / 6DFlash2 speculative drafter (RadixArk/Qwen4-35B-A3B-Dflash2); 0 for built-in MTP
VISION / VISION_MAX_IMAGES1 / 50Multimodal vision support, up to 50 images
LOOP_PASSES / LOOP_CD_OMEGAunsetOpt-in Looped recurrent depth (2 or 3 passes; optional LoopCD-Hidden)
DENSE_FP8 / HEAD_FP8 / HC_FP81 / 1 / 1Load-time 1×64 FP8G quantization for dense projections, lm_head, and Hyper-Connections
CHUNK4352Prefill 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.

Run it on your DGX Spark.

Free and open, Apache-2.0, with reproducible benchmarks and quality checks.