# DeepSeek-V4-Flash-Vision on 4× DGX Spark

Status: production. Measured: 2026-09-03 (page updated 2026-09-06). Web page: https://aidenle.com/recipes/deepseek-v4-flash-vision-4x-dgx-spark/
Image: `aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision`

This recipe serves DeepSeek-V4-Flash-Vision-Exp, a model that also reads images, on four DGX Spark GB10 nodes with vLLM. It writes 66–71 tokens per second, each request can hold 393K tokens, and the fleet holds 3.45M tokens of conversation at once.

**Time:** About 30 min per node, plus about 10 min per boot

**Result:** A 4-node fleet: 66–71 tok/s decode, 393K tokens of context, a 3.45M-token KV pool, image input and reasoning on

## What you need

- 4× DGX Spark GB10 nodes, linked by a 200G RoCE network
- The container image aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision (Docker Hub)
- The deepseek-ai/DeepSeek-V4-Flash-Vision-Exp weights (they include the draft model)
- About 120 GB of free disk space per node
- Root access on every node
- earlyoom or another out-of-memory guard on every node

## Overview

This recipe serves DeepSeek-V4-Flash-Vision-Exp, a model that also reads images, on four DGX Spark GB10 nodes with vLLM. It runs tensor parallel across the four nodes (TP4) with decode context parallel (DCP2) and DSpark speculative decoding. Reasoning is on by default.

Image handling matches the vision support of upstream vLLM ([PR #54566](https://github.com/vllm-project/vllm/pull/54566)). The kernels are the sparkinfer B12X kernels.

## Build

### Memory settings

- Leave `KV_CACHE_MEMORY_BYTES=` empty, or an inherited value caps the pool at about 26 GB per rank.
- On every node, set this memory floor and persist it in `/etc/sysctl.d/`: `vm.min_free_kbytes=1048576`, `vm.dirty_bytes=536870912`, `vm.dirty_background_bytes=134217728`, `vm.dirty_expire_centisecs=500`, `vm.dirty_writeback_centisecs=100`, `vm.swappiness=10`.

### Per-node deployment

Each node runs one container with its own `.env` file.

.env · per node (production values):

```bash
IMAGE=aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision
MODEL_HOST_PATH=<path-to>/models--deepseek-ai--DeepSeek-V4-Flash-Vision-Exp
CACHE_HOST_PATH=<writable-jit-cache-dir>
SERVED_MODEL_NAME=deepseek-v4-vision
API_PORT=8300
NNODES=4  TP_SIZE=4
MASTER_ADDR=<head-fabric-ip>  MASTER_PORT=29511
VLLM_HOST_IP=<this-node-fabric-ip>          # differs per node
FABRIC_IFACE=<fabric-iface>  IB_HCA=<rdma-device>  IB_GID_INDEX=<resolved-at-boot>

# layout: TP4 across the nodes, DCP2 inside it
DCP_SIZE=2
DCP_COMM_BACKEND=ag_rs                       # +12% KV over a2a, decode within noise
KV_CACHE_MEMORY_BYTES=                       # empty on purpose: unpins the ~26 GB cap
GPU_MEMORY_UTILIZATION=0.75                  # 0.82 gets a worker killed by earlyoom
MAX_MODEL_LEN=393216  MAX_NUM_SEQS=8  MAX_NUM_BATCHED_TOKENS=8192

# speculative decoding
VLLM_ENABLE_DSPARK=1  VLLM_ENABLE_MTP=0
NUM_SPECULATIVE_TOKENS=6
DSPARK_DRAFT_SAMPLE_METHOD=greedy  DSPARK_SPS_CURVE=auto
MAX_CUDAGRAPH_CAPTURE_SIZE=56                # = MAX_NUM_SEQS × (spec tokens + 1)
VLLM_CUDAGRAPH_MODE=FULL_AND_PIECEWISE

# prefill gather (required for images under DCP)
VLLM_DSV4_CKV_GATHER=1
VLLM_DSV4_CKV_GATHER_MAX_TOKENS=393216
VLLM_DSV4_CKV_ALLOW_IMAGES=1

ENABLE_PREFIX_CACHING=1
VLLM_DSV4_DCP_PREFIX_CACHE=1                 # unset = 3.72 behaviour
VISION_MHC=1
```

vllm serve · what the launcher generates:

```bash
vllm serve <model-snapshot> \
  --served-model-name deepseek-v4-vision --host 0.0.0.0 --port 8300 \
  --trust-remote-code --distributed-executor-backend mp \
  --nnodes 4 --node-rank $RANK --master-addr $HEAD_IP --master-port 29511 \
  --tensor-parallel-size 4 \
  --decode-context-parallel-size 2 --dcp-comm-backend ag_rs \
  --attention-backend B12X_MLA_SPARSE --moe-backend b12x --linear-backend b12x \
  --kv-cache-dtype fp8 --block-size 256 \
  --gpu-memory-utilization 0.75 \
  --max-model-len 393216 --max-num-seqs 8 --max-num-batched-tokens 8192 \
  --max-cudagraph-capture-size 56 \
  --compilation-config '{"cudagraph_mode":"FULL_AND_PIECEWISE","custom_ops":["all"],"cudagraph_capture_sizes":[1,2,3,4,5,6,7,11,15,...,56]}' \
  --async-scheduling --no-scheduler-reserve-full-isl --enable-chunked-prefill --enable-prefix-caching \
  --tokenizer-mode deepseek_v4 \
  --tool-call-parser deepseek_v4 --enable-auto-tool-choice \
  --reasoning-parser deepseek_v4 \
  --reasoning-config '{"reasoning_parser":"deepseek_v4","reasoning_start_str":"","reasoning_end_str":""}' \
  --default-chat-template-kwargs.thinking=true \
  --speculative-config '{"method":"dspark","num_speculative_tokens":6,"draft_sample_method":"greedy", ...}' \
  --disable-chunked-mm-input --limit-mm-per-prompt '{"image": 4}'
```

1. Drop the page cache on every node. Start the three workers, then the head. The server is healthy after about 10 minutes.
2. Check rank 0: `GPU KV cache size` about 3.5M tokens, acceptance length 3.5–3.8 tokens per step.
3. The first image request compiles a kernel for about 6 s. Later ones take about a second.
4. Send one long prompt twice. `vllm:prefix_cache_hits_total` in `/metrics` should rise by about the prompt length. Zero hits means that the container did not receive `VLLM_DSV4_DCP_PREFIX_CACHE=1`.

image request · OpenAI-compatible:

```python
{"model": "deepseek-v4-vision",
 "messages": [{"role": "user", "content": [
   {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}},
   {"type": "text", "text": "What animal is this? Two sentences."}]}],
 "max_tokens": 160, "temperature": 0,
 "chat_template_kwargs": {"thinking": false}}

# The answer (352 prompt tokens, 1.2 s once the partition kernel is compiled):
# "This is a brown and black tabby cat with striking green eyes. It is sitting
#  upright on a textured white ledge, with blurred bare branches visible in the
#  background."
```

## Performance

| Layout | Decode | Cold prefill of a 334K-token prompt | KV pool |
|---|---|---|---|
| DSpark, DCP off (as in the text-only deployment) | 73.8–75.2 tok/s | 2,170 tok/s | 1,769,706 tokens (4.5×) |
| DCP2 without speculative decoding | 34 tok/s | 2,119 tok/s | 4,041,732 tokens (10.3×) |
| **DSpark + DCP2 (shipped)** | **66–71 tok/s** | **2,088 tok/s** | **3,508,513 tokens (8.9×)** |

Three 400-token code completions at temperature 0 on 3.72-vision. (×) = full 393,216-token contexts in the pool.

Measured: 2026-09-04

The model runs on four nodes (TP4) with the KV cache split two ways (DCP2), DSpark decoding, images and prefix caching on.

| Measurement | Value | Note |
|---|---|---|
| Decode | 67.9 tok/s | One stream, code prompts |
| Cold prefill | 2,380 tok/s | A new 92K-token prompt takes 38.8 s |
| Warm prefill | 60,249 tok/s | The same 92K-token prompt sent again takes 1.5 s |
| KV pool | 3.45M tokens | Room for 8.78 full-length contexts at once |
| Context | 393K tokens | 3 streams of 56K tokens at once passed the coherence check |
| Prefix-cache hit | 95–100 % | An identical prompt of 9K–92K tokens sent again |
| Image request | ~1.2 s | An image prompt of 200–350 tokens, once the kernel is compiled |

**Prefill by prompt size, cold and warm** (tok/s · higher is better)

|  | cold (first send) | warm (prefix already in the cache) |
|---|---|---|
| 2.6K tokens | 1245 | 1956 |
| 9.2K tokens | 1979 | 6530 |
| 33K tokens | 2350 | 23377 |
| 92K tokens | 2380 | 60249 |

Each prompt was sent twice.

**Changelog: production-3.72-vision → production-3.73-vision**

|  | production-3.72-vision | production-3.73-vision |
|---|---|---|
| Prefix caching | Off | Opt-in with `VLLM_DSV4_DCP_PREFIX_CACHE=1`, hits on 512-token boundaries |
| Decode, cold prefill | 66–71 tok/s decode | Unchanged |
| Warm prefill (repeated prefix) | None | 6,530 / 23,377 / 60,249 tok/s at 9K / 33K / 92K tokens |
| KV pool | 3,508,513 tokens | 3,452,405 tokens (−1.6%) |
| Validation | Decode, long-context, vision and stress tests | The same, without the long stress suite |
| Known open items | — | One warm answer differed from its cold one, one cache hit one block short |

## Notes

#### Known problems

- **An image request without the gather stops the whole engine.** Pass `VLLM_DSV4_CKV_ALLOW_IMAGES` through the compose file into the container on every node.
- **Do not copy a `.env` file from one node to another.** A worker with the head's file binds to the wrong address.
- **Benchmark prefill with new text every time.** With prefix caching on, a repeated prompt comes from the cache.
- **Stop processes by PID file, never by pattern.** `pkill -f` can stop its own shell.
- **A hot GPU can reset its node during a long prefill, without a trace.** A clock cap at 2,176 MHz cooled one such GPU from 87–89 °C to 69 °C, at 1.2% of prefill speed.
- **Image padding differs from the reference.** This port always puts 3 padding tokens before an image. The reference uses `3 − position mod 4`.
