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:
-
production-3.73-visionis the working Vision-Exp path in my setup.
I useproduction-3.75for my regular Flash/0731 configuration. -
Stock Vision-Exp ends up at K=6 because of:
n_predict=3
dspark_block_size=5
plus the generic divisibility validator.
-
A very small DSpark-only validator bypass allows K=5 while preserving the actual block-size guard.
-
K=5 reduces speculative draft work by roughly 15–20% in some workloads without a comparable loss in useful generation throughput.
-
Pure decode is roughly:
~45–50 tok/s average
60+ tok/s at high draft acceptance
-
Runtime behavior currently looks healthy, including long-prefill KV recovery.
-
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)