2× DGX Spark DeepSeek-V4-Flash-Vision-Exp: TP=2, RoCE, DSpark K=5 experiment, and CodeWhale long-agent observations

2× DGX Spark DeepSeek-V4-Flash-Vision-Exp: TP=2, RoCE, DSpark K=5 experiment, and CodeWhale long-agent observations

I have been testing DeepSeek-V4-Flash-Vision-Exp on 2× NVIDIA DGX Spark and now have a configuration that is stable enough for real CodeWhale repo/agent workloads.

This post summarizes:

  • the working 2-node TP=2 setup,

  • RoCE / UCX / NCCL bindings,

  • the Vision-specific runtime image,

  • why stock Vision-Exp ends up using speculative depth K=6,

  • a minimal experimental DSpark-only validator patch allowing K=5,

  • K=5 performance,

  • long-context/KV behavior,

  • and an important limitation: runtime stability is good, but very long agent chains are still less predictable than my mature 0731 setup.

This is a local experimental configuration, not an NVIDIA- or vLLM-supported K=5 recipe.


Hardware

Two DGX Spark systems:

Master: 192.168.10.10
Worker: 192.168.10.20

Current stable rail:

Linux interface: enp1s0f0np0
RoCE HCA:        rocep1s0f0
UCX device:      rocep1s0f0:1

Worker mapping:

rocep1s0f0 port 1 ==> enp1s0f0np0 (Up)
rocep1s0f1 port 1 ==> enp1s0f1np1 (Down)

roceP2p1s0f0 port 1 ==> enP2p1s0f0np0 (Up)
roceP2p1s0f1 port 1 ==> enP2p1s0f1np1 (Down)

I am intentionally using only one confirmed-stable rail for now.


Model and runtime

Model:

DeepSeek-V4-Flash-Vision-Exp

Runtime image:

aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision

One important clarification:

production-3.75
→ my regular DeepSeek-V4-Flash / 0731 path

production-3.73-vision
→ Vision-Exp-specific path

So I do not treat 3.75 as a direct replacement for 3.73-vision.

For Vision-Exp, the working image in my setup is:

production-3.73-vision

The model is recognized as:

DeepseekV4ForCausalLM
DeepSeekV4MTPModel

which is expected for this checkpoint/runtime combination.


Network configuration

Current working environment:

GLOO_SOCKET_IFNAME=enp1s0f0np0
NCCL_SOCKET_IFNAME=enp1s0f0np0
TP_SOCKET_IFNAME=enp1s0f0np0

NCCL_IB_HCA=rocep1s0f0
NCCL_IB_GID_INDEX=3
UCX_NET_DEVICES=rocep1s0f0:1

NCCL_IB_DISABLE=0
NCCL_NET_GDR_LEVEL=0
NCCL_CROSS_NIC=1
NCCL_CUMEM_ENABLE=0

NCCL_ASYNC_ERROR_HANDLING=1
NCCL_IGNORE_CPU_AFFINITY=1

UCX_RCACHE_MAX_UNRELEASED=1024
UCX_MEM_MMAP_HOOK_MODE=none

Master:

NODE_RANK=0
NNODES=2
TP_SIZE=2

MASTER_ADDR=192.168.10.10
MASTER_PORT=29500

VLLM_HOST_IP=192.168.10.10

Worker:

NODE_RANK=1
NNODES=2
TP_SIZE=2

MASTER_ADDR=192.168.10.10
MASTER_PORT=29500

VLLM_HOST_IP=192.168.10.20


Main runtime settings

MODEL_PATH=/model
SERVED_MODEL_NAME=DeepSeek-V4-Flash

MAX_MODEL_LEN=393216
MAX_NUM_SEQS=6
MAX_NUM_BATCHED_TOKENS=8192

GPU_MEMORY_UTILIZATION=0.85

VLLM_ENABLE_DSPARK=1
VLLM_ENABLE_MTP=0

DSPARK_DRAFT_SAMPLE_METHOD=probabilistic
DSPARK_DRAFT_ATTENTION_BACKEND=B12X_MLA_SPARSE

ENABLE_PREFIX_CACHING=1
ENABLE_FLASHINFER_AUTOTUNE=0

CUDA_MODULE_LOADING=LAZY
VLLM_ENABLE_V1_MULTIPROCESSING=0

VLLM_PREFIX_CACHE_RETENTION_INTERVAL=4096

TORCH_DISTRIBUTED_TIMEOUT=1800

Effective runtime values include:

max_model_len = 393216
tensor_parallel_size = 2
nnodes = 2

attention_backend = B12X_MLA_SPARSE
moe_backend = b12x
linear_backend = b12x

kv_cache_dtype = fp8

enable_prefix_caching = True
enable_chunked_prefill = True
async_scheduling = True

max_num_batched_tokens = 8192
max_num_seqs = 6
gpu_memory_utilization = 0.85


Startup note for 3.73-vision

Do not add:

vllm serve /model

to the compose command:.

The image entrypoint already launches vLLM.

Adding it again produced:

main.py: error: unrecognized arguments: vllm serve

The configuration is primarily driven through environment variables.

I also found these required in practice:

NODE_RANK
MASTER_ADDR
MASTER_PORT
MODEL_PATH
UCX_NET_DEVICES


Why stock Vision-Exp uses K=6

The checkpoint/runtime combination exposes:

n_predict = 3
dspark_block_size = 5

The generic speculative/MTP validator contains a divisibility rule equivalent to:

elif (
    self.num_speculative_tokens > n_predict
    and self.num_speculative_tokens % n_predict != 0
):
    raise ValueError(...)

Therefore K=5 fails:

5 % 3 != 0

with:

num_speculative_tokens:5 must be divisible by n_predict=3

DSpark then has a separate safety requirement:

num_speculative_tokens >= dspark_block_size

So stock behavior is:

K=3  rejected: below dspark_block_size=5
K=4  rejected: below dspark_block_size=5
K=5  rejected: generic n_predict divisibility validator
K=6  accepted

Therefore K=6 is the smallest stock-legal value in this setup.


Why I tested K=5

K=6 works correctly and can be fast when draft acceptance is high.

I have observed intervals around:

58 tok/s
64 tok/s
69 tok/s
73 tok/s

However, my main workload is CodeWhale, which constantly alternates between:

reasoning
code
JSON/tool calls
PowerShell
repo inspection
error analysis
natural language

In these workloads, the later speculative positions often have low marginal acceptance.

This made me suspect that K=6 was over-drafting for part of the workload.

I then inspected the actual DSpark execution path in 3.73-vision.

The speculator uses dynamic values such as:

num_speculative_steps
num_speculative_tokens

for query shape, capacity and rejection-sampling logic.

I did not find an execution-side assumption requiring:

K % 3 == 0

inside the DSpark path.

That suggested the K=5 rejection was coming from a generic MTP validator rather than from DSpark execution itself.


Experimental K=5 validator patch

I changed only the validator condition.

Stock:

elif (
    self.num_speculative_tokens > n_predict
    and self.num_speculative_tokens % n_predict != 0
):

Experimental local patch:

elif (
    self.method != "dspark"
    and self.num_speculative_tokens > n_predict
    and self.num_speculative_tokens % n_predict != 0
):

This means:

regular MTP:
still requires divisibility by n_predict

DSpark:
skips this generic divisibility rule

Importantly, I kept the existing DSpark block-size safety guard:

K >= dspark_block_size

So:

K=3 remains rejected
K=4 remains rejected
K=5 becomes allowed
K=6 remains allowed

I do not recommend treating K=4 the same way.

K=5 only bypasses the generic divisibility check.

K=4 would require bypassing the DSpark/checkpoint block-size guard itself, which is a different correctness risk.


Patch deployment

I did not modify the Docker image permanently.

I extracted:

/usr/local/lib/python3.12/dist-packages/vllm/config/speculative.py

created a patched copy:

speculative_k5.py

verified syntax and SHA256 on both nodes, and bind-mounted it:

volumes:
  - /home/hxfhd/models/DeepSeek-V4-Flash-Vision-Exp:/model:ro
  - ./speculative_k5.py:/usr/local/lib/python3.12/dist-packages/vllm/config/speculative.py:ro

Then:

NUM_SPECULATIVE_TOKENS=5

This makes rollback straightforward.

Remove the bind mount and return to stock K=6.


Shared-expert patch note

I also checked the current 3.73-vision DSpark implementation.

It already contains shared-expert mapping logic such as:

stacked_params_mapping = [
    ("gate_up_proj", "w1", 0),
    ("gate_up_proj", "w3", 1),
    ("attn.fused_wqa_wkv", "attn.wq_a", 0),
    ("attn.fused_wqa_wkv", "attn.wkv", 1),
]

and:

if ".shared_experts.w2" in name:
    name = name.replace(
        ".shared_experts.w2",
        ".shared_experts.down_proj"
    )

So I would not apply older shared-expert / proposer patches on top of this runtime.

The key file hashes are identical on both nodes.

dspark.py:

05fb2c4b7cfe5d295d8206f7304be123dfe415a42bbd93e0b3bd3e29b3161f96

mtp.py:

ee2813a60f7d70ebd3854716e2f1f4713fec0378d08852053f397e4a1bd9a7bc


K=5 execution confirmation

With the patch active:

Current speculative depth: 5

and the metrics expose exactly five per-position acceptance values.

So this is not just a configuration value being ignored.

The DSpark execution path is actually running at depth 5.


K=5 performance

For recent pure decode intervals, filtering for:

Avg prompt throughput = 0
Running = 1
Waiting = 0

I observe approximately:

Average generation throughput: ~47.5 tok/s
Median: ~44.5 tok/s
P90: ~60 tok/s
Peak observed: ~65.6 tok/s

Examples:

Low draft acceptance:

Mean acceptance length: 2.54
Draft acceptance: 30.8%
Generation: 36.8 tok/s

Higher:

Mean acceptance length: 4.20
Draft acceptance: 64.1%
Generation: 59.7 tok/s

Very high:

Mean acceptance length: 4.75
Draft acceptance: 75.1%
Generation: 65.6 tok/s

The correlation between acceptance and generation throughput is very clear.


K=5 vs K=6

The main benefit of K=5 is not a dramatic increase in peak tok/s.

K=6 can still win in very predictable output.

The more useful difference in my workload is speculative efficiency.

Typical drafted throughput:

K=6: ~75–85 tok/s
K=5: ~60–72 tok/s

while accepted throughput and final generation throughput remain in roughly the same performance class.

In some A/B windows, draft work decreased by around:

15–20%

without a comparable reduction in useful generation throughput.

For mixed CodeWhale workloads, K=5 therefore looks like a better efficiency point than stock K=6.


Long-context / KV behavior

I also observed a real long-context prefill event.

During prefill:

Prompt throughput: ~1633 tok/s
GPU KV usage: ~56.8%

then:

Prompt throughput: ~2450 tok/s
GPU KV usage: ~57.7%

After prefill completed:

GPU KV usage: ~2.4%

and decode resumed around:

57 tok/s

Throughout the sequence:

Waiting = 0

Prefix cache later reached:

97%+

I have not observed:

KV ratcheting
persistent KV leakage
scheduler backlog
tensor shape mismatch
CUDA illegal memory access
decode failing to recover

So at the runtime level, this configuration is behaving well.


Real CodeWhale workloads

My main use case is not benchmarking.

I am using the model as a local execution layer for real engineering projects.

A typical task includes:

Git baseline verification
branch / HEAD / staged checks
SHA256 authority checks
cross-file repo inspection
PowerShell 5.1
Python
synthetic fixtures
positive/negative testing
evidence packaging
report generation
long-chain reasoning

The model is capable of completing this type of work.

Tool use remains functional, and I have not seen evidence that K=5 introduces output corruption.


Important caveat: long-agent stability

This is the biggest limitation I have found so far.

Runtime stability is good. Long-agent-chain stability is mixed.

Vision-Exp can solve difficult implementation problems, but over very long CodeWhale tasks I see more:

implement
→ test
→ find defect
→ patch
→ retest
→ discover another edge case
→ patch again
→ retest

For example, one long A-Quant-CN task encountered issues involving:

PowerShell quoting
Object[] vs string handling
Hashtable normalization
regex extraction
multiline metrics parsing
packaging disposition
Windows CRLF / byte-read behavior

The model was generally able to diagnose and fix these issues.

However:

self-correction ability is not the same as high first-pass implementation accuracy.

That difference matters a lot for total wall-clock time.


CodeWhale context compaction

One long task grew to approximately:

261k tokens

before CodeWhale performed an emergency compaction:

143 messages → 3 messages
~261,382 tokens → ~18,025 tokens

After compaction the model had to restore task state from the handoff and reverify part of the working state.

So end-to-end task time is not determined only by:

47 tok/s vs 52 tok/s

It also includes:

generation
file reads
shell execution
tests
bug analysis
patches
retests
context growth
compaction
state recovery

This is why raw inference speed and agent wall-clock time can diverge substantially.


Runtime stability vs agent stability

I now separate these two explicitly.

Runtime stability

Current status: good.

TP=2 stable
RoCE stable
K=5 stable
KV recycling normal
Waiting=0
Prefix cache healthy
HTTP requests normal
No CUDA/tensor-shape failures observed

Long-agent stability

Current status: still needs improvement.

first-pass implementation accuracy varies
more test/fix loops than I would like
context can grow very large
long tasks may trigger compaction
wall-clock time can become high

So:

Vision-Exp successfully runs on 2× DGX Spark

does not automatically imply:

Vision-Exp is already the best model for every long CodeWhale workflow


Comparison with my 0731 setup

My current split is roughly:

Vision-Exp + production-3.73-vision + K=5

Strengths:

higher capability ceiling
Vision support
strong repo/code reasoning
functional tool use
good K=5 speculative efficiency
~45–50 tok/s-class real decode
can recover from complex implementation failures

Weaknesses:

long chains are less predictable
first-pass coding accuracy varies
more test/fix cycles
higher context-growth risk
more compaction risk

0731 + production-3.75

Strengths:

more mature runtime
more long-term CodeWhale experience
more predictable behavior
long engineering chains currently feel more stable
usually slightly higher decode speed

So I am currently keeping both.

My current policy is:

Vision-Exp + K=5
→ medium-length, high-capability tasks
→ Vision-required tasks
→ difficult repo/code reasoning

0731 + 3.75
→ very long engineering chains
→ tasks where predictability matters more than maximum capability


Current configuration summary

Hardware:
2 × NVIDIA DGX Spark

Model:
DeepSeek-V4-Flash-Vision-Exp

Runtime:
aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision

Parallel:
NNODES=2
TP_SIZE=2

Network:
single stable RoCE rail

Socket interface:
enp1s0f0np0

RoCE HCA:
rocep1s0f0

UCX:
rocep1s0f0:1

MAX_MODEL_LEN:
393216

MAX_NUM_SEQS:
6

MAX_NUM_BATCHED_TOKENS:
8192

GPU_MEMORY_UTILIZATION:
0.85

KV:
FP8

Attention:
B12X_MLA_SPARSE

MoE:
B12X

Prefix cache:
enabled

Speculative decoding:
DSpark

Speculative depth:
K=5

K=5 implementation:
local DSpark-only validator bypass
bind-mounted, reversible


Current conclusion

For me, 2× DGX Spark has moved DeepSeek-V4-Flash-Vision-Exp from “technically bootable” to genuinely usable.

The most useful findings are:

  1. production-3.73-vision is the working Vision-Exp path in my setup.
    I use production-3.75 for my regular Flash/0731 configuration.

  2. Stock Vision-Exp ends up at K=6 because of:

n_predict=3
dspark_block_size=5

plus the generic divisibility validator.

  1. A very small DSpark-only validator bypass allows K=5 while preserving the actual block-size guard.

  2. K=5 reduces speculative draft work by roughly 15–20% in some workloads without a comparable loss in useful generation throughput.

  3. Pure decode is roughly:

~45–50 tok/s average
60+ tok/s at high draft acceptance

  1. Runtime behavior currently looks healthy, including long-prefill KV recovery.

  2. The remaining bottleneck is increasingly not VRAM or raw tok/s.

It is:

first-pass agent implementation accuracy
long-chain stability
test/fix iteration count
context growth
compaction behavior

For now I am keeping:

Vision-Exp + 3.73-vision + K=5

and:

0731 + 3.75

side by side.

I would be very interested to compare results with anyone running Vision-Exp on 2× DGX Spark, especially K=5/K=6 acceptance distributions, long-context behavior, or multi-agent/CodeWhale-style workloads.

compose.yaml.worker.txt (2.4 KB)

compose.yaml.host.txt (2.3 KB)

We’re all over here.

yeah, I applaud the effort made, but how many will find it useful comparing to just doing a gh repo for easy reproduce?

Building official vllm now with native vision patches, as per PicoThink’s scripts. Will see. MiaAI stack just crashed on my, first time. In one of the monkey-patch modules. Good timing. If works good - will upload the image to dockerhum - expect 3h build time.

My ds4flash, when asked just now to look at PicoThink’s repo and see if it’s worth spinning up.

Let 0rand install it, he’ll tell us if it’s worth it

Can’t disagree with that. :)

Yeah I think its smart - we are two hours into the build (I only build with 4 cpu cores) and most of it still building flashinfer and cuda. It should be around 3h total I expect. Will smoke it and push to dockerhub for others to play with

Just to clarify, this is based on Aiden’s mature Vision image, not the MiaAI monkey-patch setup. No vLLM/FlashInfer/CUDA rebuild is required—only minor script/config changes and the K=5 modification.

The inference stack itself ran overnight with stable KV-cache and system-resource usage. Also, I reproduced the same long-agent behavior with the older 0731 image, so that issue may be related to CodeWhale/agent orchestration rather than the Vision image or K=5.

I’ll publish the small script/config diff to make the setup easier to reproduce.

Do you mean his experimental vision image on his webpages? When I looked at it - it did not support prefix caching. Something has changed?

Yes. I was using Aiden’s
aidendle94/sparkrun-vllm-ds4-gb10:production-3.73-vision,
not an older Vision image that lacked prefix caching.

I checked my original runtime logs. They explicitly report:

vLLM 0.11.2.dev279
enable_prefix_caching=True
tensor_parallel_size=2
nnodes=2
max_model_len=393216
kv_cache_dtype=fp8
max_num_seqs=6

This was not merely a Compose setting. During actual Vision/CodeWhale runs, the runtime metrics reported non-zero prefix-cache hits—approximately 97.1%–97.9% in several logged intervals, and about 59.9% in another longer baseline run.

KV-cache usage rose with the active workload to roughly 57%–59%, then returned to approximately 1.8%–2.4% after completion, with Waiting=0. The service remained stable during the extended run.

My Compose configuration explicitly contained:

ENABLE_PREFIX_CACHING=1
VLLM_PREFIX_CACHE_RETENTION_INTERVAL=4096

So either the image/configuration changed after the version you examined, or we were looking at different Aiden Vision builds.

I checked the K=5 validator in the vLLM source; I have not run this checkpoint. Your image is not an upstream release, so match the spans below by the surrounding code rather than by line offset.

The rule you patched is the generic MTP one: vllm/config/speculative.py lines 1011-1019 on v0.27.1, 1073-1081 on v0.28.0, 1436-1444 on main (06334fae), comment “Ensure divisibility for MTP module reuse”. DeepSeek-V4 DSpark inherits n_predict=3 from the target config (hf_config_override copies num_nextn_predict_layers) while the draft’s block is dspark_block_size=5, hence the 5 % 3. One detail in your table: on stock code K=4 dies on this same rule first (4 % 3), before the block-size guard is reached; your bypass is what turns the guard into the only thing standing between you and K=4.

Upstream has an open PR that takes the other route, not yet reviewed by a maintainer: vllm-project/vllm#54631 sets n_predict = dspark_block_size inside the DeepSeek-V4 DSpark branch (three lines), so K=5 satisfies the unchanged rule with no bypass. The same derivation already exists for the Gemma4 DSpark draft (v0.27.1 978-982, main 1413-1417), but in a branch keyed on Gemma4DSparkModel and only when n_predict is unset, so it never fires here.

If that PR lands as written, n_predict becomes 5 and the same rule rejects K=6 (6 % 5 != 0) while accepting 5, any multiple of it, and anything below 5, since it only fires when K > n_predict. So the stock K=6 fallback stops being legal, and on v0.28.0 or main nothing rejects K=4 any more: the block-size guard you kept (K >= dspark_block_size) is v0.27.1-only (speculative.py 1035-1058), dropped in v0.28.0 with no equivalent check elsewhere. Keep it in your patch. Your bind mount covers the gap until then.

Reproducibility update — DSpark K=5

Following the source-level discussion in this thread and 0rand’s suggestion to make the setup easier to reproduce, I have published a small GitHub repository for the K=5 workaround used in my 2× DGX Spark test:

The repo includes:

  • the minimal speculative.py validator diff used for K=5;
  • sanitized host/worker Compose files derived from the actual TP=2 deployment;
  • a helper that copies speculative.py from the exact running image and applies the narrow patch locally;
  • verification steps for the bind mount, K=5 configuration and runtime behavior;
  • rollback instructions that leave the Docker image unchanged.

One correction to my earlier interpretation, based on the source-level review by @jahnclawdmonet:

In the stock code used by this image, K=4 fails the same generic MTP divisibility rule first (4 % 3 != 0), before the older DSpark block-size guard is reached. My local DSpark bypass is what allows execution to proceed to that guard.

The underlying mismatch is:


n_predict = 3
dspark_block_size = 5

so stock K=5 fails because:


5 > 3
5 % 3 != 0

K=6 happens to satisfy the old rule (6 % 3 == 0), but I no longer interpret that as evidence that K=6 is the intended DSpark depth.

The related upstream vLLM PR #54631 takes the cleaner approach: for DeepSeek-V4 DSpark, derive n_predict from dspark_block_size rather than bypassing the generic validator.

As of 2026-09-09 that PR is still open/unmerged, so I am keeping my workaround explicitly scoped to the tested production-3.73-vision image. I would retire the local bypass once an equivalent upstream fix reaches the runtime and has been revalidated.

I also deliberately did not publish a complete patched speculative.py. The helper copies that file from the user’s own target container, verifies that the expected source context occurs exactly once, and then applies the small transformation. This avoids treating a file from this non-upstream image as portable across different vLLM versions.

For reference, the original K=5 TP=2 observations remain:


pure decode average: ~47.5 tok/s
median:              ~44.5 tok/s
P90:                 ~60 tok/s
peak:                ~65.6 tok/s

accepted length 2.54 | acceptance 30.8% | ~36.8 tok/s
accepted length 4.20 | acceptance 64.1% | ~59.7 tok/s
accepted length 4.75 | acceptance 75.1% | ~65.6 tok/s

These are field observations from this specific 2× DGX Spark environment, not upstream vLLM benchmark numbers.

Thanks to @jahnclawdmonet for tracing the validator behavior and upstream context, and to @0rand for pushing me to turn the experiment into something reproducible rather than leaving it only as a forum report.

If anyone reproduces this on another DGX Spark pair, vLLM revision, or image, especially with different K values, I would be interested in comparing the results.

I’ve added it to my stack: