Inference enginesImplementation 01 / 01

Infernix on the DGX Spark

An inference engine built for exactly one machine: Infernix gets more than 200 tokens per second out of NVIDIA's DGX Spark with Qwen4-35B-A3B. Measurements, setup, three fixes for production use - and a fork that holds all of it.

Implementations

One data sheet per system that implements this part - always the same grid.

Most inference engines want to run everywhere. vLLM on any NVIDIA card, llama.cpp on almost anything. Infernix goes the other way: one engine for exactly one machine, the NVIDIA DGX Spark with its GB10 chip, tuned to this hardware down to the CUDA kernels. This page describes running it as the working model for agents since late November 2026 - first with Qwen3.8-Flash-Next, since 2026-12-04 with Qwen4-35B-A3B.

State of this page: 2026-12-05. The author's engine at 90a49a5a plus three fixes in the fork KI-Gilde/infernix-dgx-sparkExternal - Opens in a new tab. Every number below was measured on a real Spark, not copied from a README.

What is it

An inference server in C++20 and CUDA by Eugene KamenevExternal - Opens in a new tab, open source (Apache 2.0), grown out of Infernix and NInfer. One process, one GPU, no Python runtime. From the outside it looks like any other engine: OpenAI-compatible (/v1/chat/completions, /v1/responses), plus the Anthropic format (/v1/messages), with streaming, tool calls, reasoning levels, JSON Schema and images. An agent that talks to a cloud API won't notice the difference.

Models don't come as safetensors but as .infernix artifacts that the author publishes on Hugging Face: pre-quantised (NVFP4, "FastQ-RHT16") and matched to the kernels.

How does it work

The GB10 is unusual: CPU and GPU share 128 GB of unified memory, attached at a little over 250 GB/s. Plenty of room, little bandwidth. A dense 27B model has to read ~19 GiB of weights for every token and ends up at ~13 tokens per second. The arithmetic behind that is in the concept Hardware.

So Infernix pulls three levers:

  • Mixture of experts with few active parameters. Qwen4-35B-A3B has 35 B parameters but computes each token with only ~3 B. Only a fraction of the weights is read.
  • Speculative decoding, twice. An MTP head inside the model proposes several tokens at once. On top of that, an n-gram table (~19 GiB) predicts recurring text: code, JSON, tool calls. The model checks the proposals in a single pass.
  • Kernels for sm_121a. NVFP4 matrices, tiled for the GB10's 24 MiB L2 cache, experts in unified memory.

On top sits a hybrid prefix cache: KV blocks on the GPU, behind them a host tier in RAM holding intermediate states. It can be saved to disk and survives restarts. For agents that come back every few seconds with 50,000 tokens of history, that is the real win. Why it pays off so much is shown in the aha Prefix cache.

Measurements

Both models on the same Spark, measured the same way:

Measurement · DGX Spark (GB10) · 2026-12-04

Qwen4-35B-A3B vs. Qwen3.8-Flash-Next, both on Infernix

Qwen4-35B-A3BQwen3.8-Flash-Next

Decode throughput

1 request
123.5 tok/s
100.7 tok/s
×1.23better
2 concurrent
184.3 tok/s total
88.5 tok/s total
×2.08better
4 concurrent
215.6 tok/s total
102.6 tok/s total
×2.10better

Prefill (reading the prompt)

8K context
5,870 tok/s
3,580 tok/s
×1.64better
32K context
5,780 tok/s
3,530 tok/s
×1.64better

Time to first token

8K contextlower is better
1.4 s
2.3 s
×0.61better
32K contextlower is better
5.7 s
9.3 s
×0.61better

Speculation and memory

MTP acceptance
51.2 %
70.5 %
×0.73worse
Memory footprintlower is better
63 GiB
85 GiB
×0.74better

llama-benchy 0.4.0, pp2048 / tg128, 3 runs per level, no prefix cache. Prefill from the engine log. Flash-Next with our production settings (n-gram from NVMe), Qwen4 with the author's defaults.

Qwen3.8-Flash-NextQwen4-35B-A3B
Decode, 1 request100.7 tok/s123.5 tok/s
Decode, 2 concurrent (total)88.5 tok/s184.3 tok/s
Decode, 4 concurrent (total)102.6 tok/s215.6 tok/s
Prefill 8K / 32K3.58k / 3.53k tok/s5.87k / 5.78k tok/s
First token at 32K context9.3 s5.7 s
MTP acceptance70.5 %51.2 %
Memory (defaults)~85 GiB~63 GiB

For comparison: the same box managed 18.5 tok/s on prose and 33.8 on code with vLLM and the dense Qwen3.8-27B, MTP included.

Three things stand out. First, Qwen4 scales with load, Flash-Next doesn't. With four agents at once Qwen4 delivers twice as much. Second, Qwen4 accepts fewer MTP drafts and is still faster. At 3 B active parameters a rejected draft is cheap. Third, Qwen4 needs 22 GiB less memory, and that can be turned into cache (see resource requirements).

A warning about the measurement: llama-benchy's prefill column is wrong for Infernix, because the first stream chunk arrives before prefill ends. The prefill numbers above therefore come from the engine log. The script is in the fork at kigilde/bench/bench.sh.

What it is good for

For one DGX Spark serving many agents: long contexts, tool calls, several requests at once, data that should stay in-house. The measured setup: Infernix behind a LiteLLM gateway, with coding and office agents sending requests of 30,000 to 90,000 tokens of context.

Not for: other GPUs (the kernels are built for sm_121a), arbitrary models (only the author's artifacts), multi-GPU, or setups that need a large community and release cycles. Infernix is a single author's project and only a few weeks old. If you just want something running on the Spark quickly, Ollama or vLLM serve you better. If you want the last bit of speed, you end up here.

Setup

Everything you need is in the fork. Building and running happens inside a container, because the Spark host lacks ninja and the ffmpeg headers.

git clone https://github.com/KI-Gilde/infernix-dgx-spark.git
cd infernix-dgx-spark
docker build -t infernix-deps:local -f kigilde/Dockerfile.deps kigilde
kigilde/build.sh                       # ~840 build steps, a good hour

The model (~41 GiB: artifact plus n-gram table) comes from Hugging Face:

export HF_HUB_DISABLE_XET=1            # xet occasionally hangs
export HF_TOKEN=…                      # ~1.3 MB/s without a token, ~28 MB/s with
hf download eugene-kamenev/Qwen4-35B-A3B-NVFP4-FastQ-RHT16-Infernix \
  --local-dir /data/models/qwen4

Start it with the compose file from the fork, as it runs in production:

INFERNIX_REPO=$PWD MODELS=/data/models/qwen4 CACHE=/data/cache/qwen4 \
  docker compose -f kigilde/compose.qwen4.yaml up -d
python3 kigilde/bench/smoke.py http://127.0.0.1:8000 qwen4-35b-a3b /tmp/smoke.json

After ~35 seconds the engine answers. The smoke test checks the reasoning levels, reads an invoice from an image and makes a tool call. kigilde/compose.flashnext.yaml is right next to it for Flash-Next.

The settings that matter, and why:

  • --prefill-chunk 4096 and INFERNIX_TMP_DECODE_SHARE=0.5: without these two, running answers stall for seconds as soon as another agent sends a long prompt.
  • --kv-capacity 1048576 --host-context-mib 24576: 1M tokens of KV cache on the GPU, 24 GiB host tier behind it.
  • --prefix-cache-file … --prefix-cache-save-mins 30: the cache survives restarts.
  • --max-concurrency 8 --max-pending-requests 32: eight requests compute, the rest wait in the queue for up to five minutes instead of being rejected.

Let Claude Code set it up

If you would rather not set up the Spark yourself, hand the job to a coding agent. Paste the following prompt into Claude Code (or another agent with shell access) on the Spark. It stops before touching anything that is already running, and it asks for the Hugging Face token instead of storing it.

Build prompt
You are working on an NVIDIA DGX Spark (GB10, 128 GB unified memory). Set up the Infernix inference engine with the Qwen4-35B-A3B model, using the fork https://github.com/KI-Gilde/infernix-dgx-spark. After cloning, read kigilde/README.md first: it is the guide you follow (it is in German).

Steps:
1. Check the prerequisites: nvidia-smi shows the GB10; Docker runs and sees the GPU (a CUDA container with --gpus all can run nvidia-smi); at least 120 GB free disk; free -g. If a large engine is already running (vLLM, Ollama, llama.cpp, SGLang, another Infernix), stop and ask me whether you may shut it down. Two large engines do not fit into memory at the same time.
2. Clone the repo to ~/infernix-dgx-spark, build the image from kigilde/Dockerfile.deps (tag infernix-deps:local), then start kigilde/build.sh in the background, writing to a log file. The build has ~840 steps and takes a good hour. Watch the log. If it fails for lack of memory, restart with JOBS=4; ninja continues where it stopped.
3. While it builds, download the model: ask me for a Hugging Face token (without one, HF throttles heavily). Set HF_HUB_DISABLE_XET=1 and download the Infernix artifact for Qwen4-35B-A3B, whose exact repo name is given in the author's README (github.com/eugene-kamenev/Infernix-dgx-spark-gb10), to /data/models/qwen4 or a folder I name. Do not write the token to any file.
4. Start with kigilde/compose.qwen4.yaml, with INFERNIX_REPO, MODELS and CACHE set. The engine binds to 127.0.0.1:8000 only. Wait until /health answers.
5. Verify with python3 kigilde/bench/smoke.py http://127.0.0.1:8000 qwen4-35b-a3b /tmp/smoke.json and python3 kigilde/bench/image_cache.py http://127.0.0.1:8000 qwen4-35b-a3b. If I agree: kigilde/bench/bench.sh for the throughput numbers.
6. Finally report: endpoint and model name, the measurements compared with the table in the README, memory in use (free -g), and how I stop and restart the engine.

Rules: change nothing on the host except the repo folder and the model and cache folders. No restart: always; after a crash the engine must not start automatically into full memory. Do not expose the port. If something looks different from the README, stop and tell me what you see instead of guessing.

Dependencies

  • Hardware: NVIDIA DGX Spark or another GB10 system, Linux aarch64.
  • Software: Docker with the NVIDIA Container Toolkit, CUDA 13.0.3 (included in the build image).
  • Models: the author's .infernix artifacts on Hugging Face. Other models can be converted with his converter (not tried here).
  • In front: for keys, budgets and several model names, a gateway such as LiteLLM. Infernix itself knows only an optional API key and one model name (--model-id), no aliases.

Resource requirements

On the Spark, memory is the only limit that matters. CPU and GPU share 121 GiB usable, and once it is full, swap looms. The measured Qwen4 configuration:

ItemMemory
Weights (NVFP4)21 GiB
n-gram table (in RAM)19 GiB
KV cache, 1M tokens int812 GiB
Host tier prefix cache24 GiB
Other, system~26 GiB
used / free~102 / ~19 GiB

That fits four full 256K contexts on the GPU at once. Behind them the host tier keeps ~2 M tokens of prefixes, roughly 20 agents with ~100,000 tokens of history each. Count ~12 KB of KV cache per token and ~66 MiB per intermediate state (snapshot). To start smaller: with the author's defaults Qwen4 uses ~63 GiB.

What it buys: a 55,000-token prompt took 10 seconds to the first token the first time and 0.5 the second time. After a restart the engine loaded 10 GiB of saved cache in 1.4 seconds.

Where it breaks in operation

Three problems showed up in operation; the fork fixes them:

  1. One tool call takes down the whole engine. One night two agent requests with tools arrived at the same time. Infernix reported committed tool grammar and parameter decoder disagree, an internal inconsistency while assembling the tool call. Instead of failing just that request, the server exited (exit status 2). Because the GPU container deliberately does not auto-restart, every agent was down for seven hours. Fix: the error now takes the path Infernix already has for "this one output cannot continue". The affected requests fail, the engine keeps serving.
  2. Thinking can't be switched off for Qwen4. The API rejected reasoning_effort: "off", the Qwen4 template rejected "none". Only chat_template_kwargs: {"enable_thinking": false} worked. Fix: off and none both work, for Qwen4 as for Qwen3.x.
  3. Images aren't cached. The typical agent call is: N images, then the question. Infernix put the automatic cache boundary behind the question, which changes every time. With 23 images only 79 of ~4,600 tokens came from the cache, the system prompt. Fix: an extra boundary right after the last image. Measured with 23 images: 6,972 of 6,990 tokens from the cache, second answer after 0.2 instead of 1.9 seconds, with no change on the client side.

Still open:

  • The prefix cache isn't saved on stop. Under Docker the process exits immediately on docker stop, although the code intends an orderly save. Only the periodic save counts, so at worst 30 minutes of cache are lost.
  • Reasoning levels get rounded. The Qwen4 template knows off, low, high, xhigh. A client sending medium thinks at high.
  • Never two large engines side by side. Flash-Next (~85 GiB) and Qwen4 exclude each other. Building next to a running engine fails too: nvcc needs several GiB per job.

Experience

From the first days under agent load: around 700 requests in three night hours, contexts up to 92,000 tokens. Cache hit rates above 95 % for ongoing agent sessions, first token mostly under a second. Under load, decode ran at 80 to 110 tok/s per request and ~180 tok/s total with two agents in parallel.

Limitation: what was measured is speed and function, not quality systematically. Without thinking, Qwen4 once got a lookup question in a 55K document wrong. If you use off in production, check it with your own tasks. How to measure that properly is covered in the concept Benchmarks.

Fork, compose files, measurement scripts and changelog: github.com/KI-Gilde/infernix-dgx-sparkExternal - Opens in a new tab.