mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #609] ds4: DS4_RING_MB=128 instead of the default 400 reads prompts 6-12 % faster on 2x 64 GB cards (and leaves ~33 more experts a card in VRAM). Should the prompt ring be sized by VRAM / link speed? #253
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#253
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SeriousRising on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/609
Platform-specific: we measured this on one rig only: 2x CMP 170HX 64 GB, card 1 on PCIe Gen2 x4. The gain may come
from the slow link. This is a finding with a question, not a patch.
Finding
The prompt flow's expert ring is a fixed
DS4_RING_MB(default 400) of slots inChunk::kPartsbatches, allocated oneach flow device before expert placement (
ds4_model.cu:4287-4292in v1.1.34). Unchanged in v1.1.35 per its releasenotes, which list no DeepSeek changes; not checked in source. At ~8.8-9 MB an expert blob, 400 MiB is roughly 48
slots, and 128 MiB is 16, still in 4 batches.
Setting
DS4_RING_MB=128made every prompt length faster in all our arms. The 272 MiB a card it frees also goes to theexperts at placement: 6811 vs 6775 experts in VRAM on CUDA0, 6762 vs 6731 on CUDA1.
Measured
Hardware: 2x CMP 170HX 64 GB (sm_80, CUDA 12.8); card 0 is PCIe Gen2 x16 (6.2 GB/s measured), card 1 Gen2 x4
(1.63 GB/s). Host VM: 16 vCPU Xeon E5-2697 v4 (AVX2), 106 GiB DDR4-2133. Model: DeepSeek-V4.1-Flash-1017 GSQ-RCO
IQ2_XXS, layer split, 64K context,
--dspark on,--cpu-threads 14, default--prefill-chunk. About 2200 expertson the CPU lane, so every prompt chunk streams many experts.
How measured: Strata's community speed suite through the server (fresh 4K / 16K / 32K prompts, prompt tok/s; an
agent session with prefix reuse, time to first token), plus our own 8K prefill. Each pair runs the same binary and
env; only
DS4_RING_MBdiffers.--dspark none24.13 vs 24.28 ms a step (-0.6 %). The DSpark text changes because placement changes, soits ms a window is not matched work.
What we did not isolate
The extra experts alone cannot explain this. ~33 more a card is ~3 % fewer of the ~1100 a card that a chunk
streams. That bounds their share near 3 % on a link-bound card, below the 12 % at 4K. Our own audit estimated well
under 1 % for decode from them. The gain also shrinks with prompt length
(12 % at 4K, 6 % at 32K). That fits a fixed per-chunk or per-layer start-up cost of the larger ring better: for
example, the first batch of ~12 blobs must arrive before compute starts, against ~4. The x4 link makes that wait
longest. This is a guess. We did not run
DS4_FLOW_STATSon the pair, nor try 128 at a fixed placement.Question / proposal
every prompt length we tried.
include
DS4_RING_MBin--calibrate's prompt tuning. Or simply default to fewer slots where a card's link isslow.
@talisp commented on GitHub (Oct 28, 2026):
A data point from a different case: one GPU, with big MXFP4 expert blobs and most of them on the CPU lane. Here
DS4_RING_MB=128makes long prompts ~10% slower. So we'd size the ring in slots (blob size), not in MB.Why it differs from yours: our experts are DeepSeek's MXFP4 (unsloth's UD-Q8_K_XL), ~19.4 MB a blob against your ~8.8 MB. With the code in
ds4_model.cu:4287-4292, 400 MiB is 20 slots (5 a batch), but 128 MiB is only 4, thekPartsminimum, one slot a batch. Yours kept 16.Measured (1× L40S 48 GB, Xeon Platinum 8580 VM with 32 vCPUs, ~504 GB RAM, Maya v1.1.34,
--tp 2 --threads on --cpu-threads 28 --mmap-experts off --dspark on, 262K context; ~91% of the experts on the CPU lane). Four starts in the order A B A B, page cache dropped before each; fresh prompts, prompt tok/s from the server's timings:DS4_RING_MBSo on your question: sizing by link speed might explain your slow Gen2 x4 card. Sizing by blob size would avoid our case, where 128 MiB drops the ring to one slot a batch. Something like "N slots a batch" (yours: 4 a batch at 128 MiB) rather than a fixed MB could get you your gain without costing big-blob packs theirs.
@SeriousRising commented on GitHub (Oct 28, 2026):
Thanks - that pins the unit down. Confirming your reading of the code on v1.1.35 (
ds4_model.cu:4287-4292):ring_n = max(kParts, ((mb << 20) / stride) / kParts * kParts)withkParts = 4andstride= the device'slargest trunk-layer expert blob. One correction to my numbers above: on the GSQ-RCO pack the largest blob is
8.97 MiB (CUDA0's layers) / 9.76 MiB (CUDA1's), so 128 MiB is 12 slots = 3 a batch here, not 16 / 4.
The slot curve on this rig
Same setup as the issue (2x CMP 170HX 64 GB, card 1 on PCIe Gen2 x4 at 1.63 GB/s measured, DeepSeek-V4.1-Flash-1017
GSQ-RCO IQ2_XXS, layer split, ~2200 experts on the CPU lane), one binary, one run each except 128 and 72 MiB,
which ran twice. Fresh prompts:
our 8K prefill plus the community suite's 4K / 16K / 32K, prompt tok/s.
DS4_RING_MBThe repeats: 128 MiB 724.9 / 1189.4 / 1746.0 / 1876.4 and 72 MiB 725.3 / 1205.8 / 1764.9 / 1886.4 (8K / 4K / 16K /
32K) - 72 MiB stays 0.5-1.6 % ahead of 128 on prompts across both pairs and 0.6-1.3 % behind on decode, inside our
spread at the long end. Experts in VRAM move very little across the sweep (CUDA1: 6731 at 400 MiB -> 6771 at 72, of
7680 a card), so the prompt gain is not the freed VRAM; and decode shows no trend (52.0-53.7).
So the two rigs sit at opposite ends: yours (one fast-link card, 19.4 MB blobs, ~91 % streamed) wants ~5 a batch
and loses ~10 % at 1; this one (the second card on Gen2 x4, ~9 MB blobs, ~14 % streamed) keeps gaining down to
1 a batch on the slow card (+16 % at 4K, +7 % at 32K against the default). I have not isolated why - smaller
batches presumably let a layer's first experts compute while the slow link is still delivering the rest, where on
a fast link the same small batch only serializes copy against compute. That part is a guess.
Either way MB is the wrong unit for the setting: the default 400 lands at 1 a batch on a hypothetical 25 MB-blob
pack and at 11 here. Sizing in slots a batch, as you suggest, with the MB derived from the stride, would make the
default mean the same thing on every pack; something like 4 a batch (16 slots) would be ~140-155 MiB on this pack
and ~310 MiB on yours - close to both measured good regions (this rig gains only 1-2 % more below 3 a batch).
@talisp commented on GitHub (Oct 29, 2026):
Two more points, on v1.1.36 (same box and pack as my table above; one start each, page cache dropped before each), in case they help size the ring in slots. Slots from
ring_n = max(4, (mb<<20) / stride / 4 * 4)with our 18,800,640 B blobs:DS4_RING_MBOn this pack, every ring below the default reads long prompts slower (-4% at 174K with 3-4 a batch, -13% with 1), while decode gains only 1-3% from the 4-16 extra experts. Short prompts are noisy here (the 400 starts ranged 563-712 at 10.4K). So a fixed slot count wouldn't settle it either: 4 a batch is about what you gained with, and it costs us ~4%. The link and the CPU lane seem to matter as much as the blob size, so maybe it could be measured at start, as
lane-times.txtis.