mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #539] [BUG] [DS4] ds4 2-GPU TP=2 (2×A100, Linux): prompt prefill wedges after client aborts — one GPU 100%, the other idle, only restart recovers #218
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#218
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 @zhangxiaoxing on GitHub (Oct 27, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/539
Summary
I run DeepSeek-V4.1-Flash-1017 EXL3 3.5 bpw with Maya's
ds4engine,--tp 2, on two A100 80GB PCIe cards under Linux. Occasionally a prompt read stops and never advances again:nvidia-smishows GPU 0 at 100% and GPU 1 at 0%, with no disk or CPU work to speak of;reading the prompt ...line forever, with the token count constant — in four cases in theX of Yform at the first chunk's width, in the fifth with noof Yprogress at all;SIGINT+ restart recovers, after which retries read normally.I have five episodes in the log. Four share a precise fingerprint: a 57,123-, 110,769-, 19,541- or 184,804-token prompt reaches exactly the width of its first chunk and then stops for 39 s to 11,006 s; the frozen value is exactly the first chunk's width in each case. The fifth episode is a related degradation: after a mid-prefill abort and a 162-token request that decoded at 6.7 tok/s, three small prompts never reached a chunk-progress line at all; the first two clients disconnected after 60–80 s, the third was still waiting when
SIGINTended it. Every one of the five is preceded by a client abort that the engine logged asstopped while reading the prompt ...followed bydone: 0 tokens ... (disconnect, cancel=True). For the four chunk-boundary cases this puts the stall in the second chunk, not in tokenization or the first chunk.This is not the NUMA-node OOM at load that I reported separately. The process here is alive for hours; there is no OOM kill, and the engine never logs a CUDA error. The server's post-
SIGINTmessage about “running out of RAM” is misleading: the process was killed manually.First observed on v1.1.24, which was the first version installed on this box; also observed on v1.1.27 (current) and during a short trial of v1.1.28. It may predate v1.1.24. It is infrequent but recurring: 72 client cancels and 26 mid-prefill stops in the log, five episodes.
Environment
6.8.0-136-generic615.71.09; engine built with CUDA 13.0 (nvcc13.0.48)GA100,sm_80), 80 GiB each, PCIe 4.0 x16, no NVLink0000:4b:00.0, NUMA node 0; GPU 1 at0000:ca:00.0, NUMA node 1 (cross-socket)ds4-0.1), also seen on v1.1.28; first seen on v1.1.24maya-ds4pack--max-context 262144 --tp 2 --mmap-experts off --dspark noneDS4_ENGRAM_RAM=1CUDA0 layers [0, 39] (tensor parallel 2, part 0) + head: weights 3.97 GB, experts 76.50 GB (8592 of 15360 in VRAM), caches 0.24 GB, 357 MiB free;CUDA1 layers [0, 39] (tensor parallel 2, part 1): weights 3.97 GB, experts 76.50 GB, caches 0.24 GB, 721 MiB freeDS4_ENGRAM_RAM=1:2 complete tables ... 202.758 GB locked; reads use memcpy; 6,768 routed experts on the CPU lane (106.3 GB RAM, 2 NUMA parts), 52 threadsCUDA0/CUDA1 prompt attention on the tensor cores (sm_80)Both GPUs are normally busy during a healthy decode: an authenticated
/metricssample during decode reportedgpus: [(0, 99, ...), (1, 98, ...)], combinedgpu_util 98.5. The one-GPU-busy/one-GPU-idle state during the hang is therefore abnormal, not the normal TP=2 load pattern.The engine log has no wall-clock timestamps. All times below are the engine's own
N s so farcounters; line numbers refer to the localmaya-ds4.log(≈135k lines at the time of writing, append-only).What the hang looks like
A typical occurrence (prompt 57,123 tokens, log lines 71,910–97,935):
There is no further prompt progress, no decode line, and no
DONEbetween the first frozen line and theSIGINT. The 57,123-token prompt produced 25,985 progress lines across 7 attempts; the longest single attempt held at3,890for 11,019 s.The same pattern repeats at four different prompt sizes:
The 184,804-token prompt is especially telling: the client retried it 11 times, and every attempt froze at exactly
4,048(11,000 progress lines in total). It never got past4,048in any attempt; only a restart cleared the state.The fifth episode, at the end of the log, has a different signature and is described below: after
stopped while reading the prompt of 73246 tokens, after 3407 ms, a 162-token request read in 23 s and decoded at 6.7 tok/s, and the next three prompts (6,397, 6,417 and 2,579 tokens) never printed anX of Yprogress line at all; the first two clients disconnected after 60–80 s, and the third was still waiting whenSIGINTended it.Rough reproduction: run the engine with
--tp 2; start a long prompt (tens of thousands of tokens); abort the client during prefill or during the stream (STOP/disconnect); then send another prompt, usually another long one. Sometimes the second prompt stops at its first chunk's width and never advances. It is not deterministic: five episodes over several days, with 72 client cancels and 26 mid-prefill stops in the log; some aborts are followed by many healthy requests.Evidence 1: the frozen value is exactly the first chunk's width
ds4splits a long prompt into chunks. For a 40-layer model with the prompt skip at layer 20 and a 128-token window,forward_chunks()keeps the lastrows for the full pass and chunks the early part
a = n - 2,668into equal chunks of at most 4,096:The first chunk's width is
w. The progress callback reports the cumulative end of the last chunk whose completion event fired, so a frozen value ofwmeans chunk 0 completed and chunk 1 never completed. The arithmetic matches every freeze exactly:na = n − 2,668nc = ceil(a/4096)w = ceil(a/nc)The same formula, applied to healthy reads, predicts the observed progress increments:
nancwThe healthy 73,246-token prompt advances in steps of 3,921, exactly the predicted first-chunk width:
This is a strong indication that the engine is not stuck in the prompt reader, tokenizer, or the first chunk: the first chunk completed and its completion event fired. The stall is somewhere in the second chunk. The progress line cannot narrow it further than that, because progress only advances per completed chunk.
Relevant code (v1.1.27):
src/ds4/ds4_model.cu:10894(keep),:10901(part),:10912and:10916(part(0, a)thenpart(a, n)),:11011(progress from completed chunks).Evidence 2: each first freeze follows a client abort
The engine logs the abort as
stopped while reading the prompt ...and the server logsdone: 0 tokens ... (disconnect, cancel=True). In every episode, the first freeze is preceded by such a stop within a few hundred to ~1,200 log lines:stopped while reading the prompt of 179963 tokensstopped while reading the prompt of 7726 tokensstopped while reading the prompt of 176938 tokensstopped while reading the prompt of 18887 tokensExcerpts:
The aborts include very large prompts stopped after 80.8 s and 94.2 s (
stopped while reading the prompt of 176938 tokens, after 80830 ms;... of 187836 tokens, after 94250 ms), i.e. the client closed the dialog while the engine was well into prefill. This matches the pattern that a mid-stream/mid-prefill client close may make the next occurrence more likely. I cannot prove that every occurrence has the same trigger — some aborts are followed by many healthy requests — but the correlation holds for the four chunk-boundary cases, and the fifth follows the same abort→degraded→wedge pattern.There is also a clear “abort → degraded → wedge” cascade at the end of the log:
Note the 162-token prompt after the abort: it took 23 s to read and decoded at 6.7 tok/s, where the same box normally reads short prompts in ~1 s and decodes at ~43 tok/s. The engine was already degraded before the next prompts stopped advancing at all; the 6.7 tok/s decode is about six times slower than normal.
Evidence 3: no self-recovery, no engine error, and the queue piles up
ds4:error line, no CUDA error, noillegal memory access, no watchdog message, and no engine restart before the manualSIGINT. I searched the five freeze segments forerror|CUDA|watchdog|stall|timeout|assert|illegal|fatal|exceptionand found 0 matches.done: 0 tokens ... (disconnect, cancel=True)and then the next request starts, but the GPU stays pinned. The server keeps1 of 1 place(s) in useand reportsreading the prompt, 0 tokens so far(even when the engine has already reported 3,375 of 19,541).WARNING: 6 request(s) have waited ... up to 2,101 s; after the kill, the six queued requests report waits of 2,154, 1,925, 1,852, 1,623, 1,321 and 107 s.SIGINTand reload, retries read at normal prefill speed; for example, a 110,373-token retry read in 27 chunks of 3,990 at 1,768 tok/s. In the fifth episode, even the immediate 73,246-token retry after the abort completed at 2,040 tok/s, but the engine degraded afterward (the 162-token prompt at 6.7 tok/s), so a successful retry right after an abort does not mean the state is clean.The engine did not run out of RAM; it was alive with plenty of RAM free (~182 GiB at the time of writing) and was killed by
SIGINT. This message actively obscures the diagnosis.Evidence 4: the server's watchdogs cannot see this state
The server has two relevant watchdog mechanisms, and neither fires here:
STRATA_ENGINE_STALL_S, default 90 s) only counts a stall when there is no CPU/disk work and no GPU work.STALL_GPU_BUSY = 5.0means any GPU at ≥5% utilization is treated as “working”. A GPU spinning at 100% therefore keeps_stall_check()from ever ending the engine, even though the engine produces no token and no prompt progress. In this hang, GPU 0 at 100% is exactly what keeps the watchdog quiet.STRATA_REQUEST_QUIET_S, default 900 s) is implemented for the multi-request path, but theds4single-request serve path only has the engine-stall check; I could not find the request-quiet bound applied to it. The server's own warning text says “STRATA_REQUEST_QUIET_S / STRATA_DRAIN_S bound those waits”, but in this state the request is “running” from the server's point of view and the queue is never released.The engine-side heartbeat watchdog (
start_serve_watchdog,STRATA_WATCHDOG_S) is wired into the GLM serve paths (src/program/generate.cpp:3849,:6974) but not into theds4serve loop (src/ds4/ds4_main.cpp:883). So there is no “no PP for N seconds → print a stall report and exit” safety net for this engine.Relevant code (v1.1.27):
serve/server.py:396(_stall_seconds),:433(STALL_GPU_BUSY),:676(_stall_check);src/program/generate.cpp:751(start_serve_watchdog),:3849,:6974;src/ds4/ds4_main.cpp:883(serve loop).Where the stall is, and what I think causes it
Measured facts:
stopped while reading the promptandcancel=True.Inference (not yet proven by a flag dump):
The second chunk is the first one that never completes. Both chunks require both devices, so the likely shape is that one device's worker (or its hand-off sequence/acknowledgement) was left behind by the cancelled run, while the other device was still able to finish chunk 0 and then could not get past the first cross-device wait of chunk 1. The healthy device spins on a host-mapped flag that the other device will never publish; the other device is idle from the host's point of view (0% GPU, no kernel). Because the per-device sequence/ack state is not reset by
reset()/restore(), the same gap is still there on every retry, so every attempt freezes at the same chunk boundary. Only a process restart recreates the state.Concretely, the suspicious state is:
arb_seq(src/ds4/ds4_model.cu:636): a per-device unsigned counter for the group's chunk all-reduces, initialized once (unsigned arb_seq = 0), incremented at:9450and:9802, and never reset; I found no assignment other than the initializer and++c.arb_seq.reset()(:5728) clears the window rings and compressor state but notarb_seq; I did not find a reset ofarb_seqor the hand-off flags inrestore()(:5815) either. If a cancel/early return leaves one device with a different count, the next run starts with the two members out of lockstep.wait_at_least()(src/ds4/ds4_kernels.cu:2419): an unbounded device-side spin:It has no timeout, no counter, and no diagnostic.
xfer_get_kernel,wait_flags_kernel,ar_sum_kerneland the chunk hand-off all use it. A missing flag means an eternal spin, not an error.Chunk hand-off acks (
src/ds4/ds4_model.cu:633–635,:10186,:10232):hand_ackandhand_flag[2]are host-mapped, allocated once, and never cleared at run start. Before sending chunkk's hand-off, the sender waits for the next group's acknowledgements of chunkk − 2(wait_flags(c.hand_ack + slot * 8 * 32, nnext, 32, wp.win - 2, s)). For the second chunk (k = 1) this wait is skipped (k >= 2is false), so the chunk-ack path is not the blocker at the first frozen boundary; the per-layer all-reduce or a KV/Engram hand-off in chunk 1 remains. The ack path is the analogous hazard for later chunks and worth fixing at the same time.halt_end()(src/ds4/ds4_model.cu:965): on a Stop it drains the flow's in-flight reads (if the flow is on) and then callscudaStreamSynchronize()on the device's streams. If a kernel already queued on that stream is spinning on a peer flag, this host call never returns; the worker never becomes idle. The chunk-aligned stop protocol (“none starts chunkhalt_kor later”) prevents new chunks, but it does not drain a hand-off that is already in flight.xfer_put_kernel's per-device counter (src/ds4/ds4_kernels.cu:2407): the last block to finish doesatomicAdd(cnt, 1u) == gridDim.x - 1, then resets*cnt = 0and sets the flag. This is correct only if twoxfer_putgrids never overlap on the same device. In TP=2 allxfer_putcalls I found are on the main stream, so this is probably not the trigger here; it is another place where an overlapped grid would leavecntnonzero and a flag unset forever.The one-GPU-busy/one-GPU-idle pattern is important: if both devices were spinning in a symmetric all-reduce, both would likely show GPU work. A device sampled at 0% has no kernel active, which points to a host-side stuck or never-scheduled worker on that device, with the other device spinning on the flag/ack it expects. That is consistent with
halt_end()blocking, or with a worker that returned early from the cancelled run and never joined the new one.Alternative suspect: the sm_80 prompt-attention kernel. v1.1.24 added
sparse_attn_mma_kernelfor sm_80+ (src/ds4/ds4_kernels.cu:1810, selected at:3336), and these A100s use it (prompt attention on the tensor cores (sm_80)). A rare barrier/warp-sync deadlock in that kernel would also freeze inside chunk 1, with one GPU spinning and the other finished or waiting on the host. Since v1.1.24 was the first version on this box, I cannot rule it out from version history. An A/B withDS4_ATTN_MMA=0would separate it from the hand-off path. I have not run that A/B yet because the hang is infrequent and the service is in production use.Workarounds
SIGINTthe engine and let the server restart it. This is the only reliable recovery I have. The prompt (or its retry) then reads normally.@mw00 commented on GitHub (Oct 27, 2026):
Thank you for this report. Pinning the freeze to the first chunk's width, and lining each one up with a client abort, is what led us to the bug.
What we found: in a tensor-parallel group, one member reads the Engram rows and the other waits for them. If a Stop came while the waiting member was at the start of a chunk the group had already begun, that member left the chunk. Another device ending its run early could cause the same exit. Its partner stayed in the chunk and waited for the member's sums forever, which is the "one GPU at 100%, the other idle" state you saw. v1.1.34 makes every member finish a chunk the group has started, and stop only at a chunk boundary. We reproduced it on our V100s with a tensor-parallel pair: a Stop during a long prompt left the earlier version wedged in exactly that state. With the fix, the same test ran clean every time.
v1.1.34 also adds an engine watchdog for DeepSeek. If a request makes no progress for 10 minutes (no prompt chunk, no token), the engine writes where each GPU's thread was and exits, and the server starts it again for the next request.
MAYA_DS4_WATCHDOG_Ssets the time, and0turns it off. A long prompt that is still moving never triggers it. Also, a SIGINT/SIGTERM exit is no longer reported as "running out of RAM".Could you run v1.1.34 with your usual traffic? If anything hangs again, the log line starting with
maya ds4 serve: where it stopped:tells us exactly where. We'll keep this open until you've had a few days on it.Released in v1.1.34: https://github.com/mw00/project-maya/releases/tag/v1.1.34
@zhangxiaoxing commented on GitHub (Oct 29, 2026):
With the same traffic pattern, the last 24 hrs is totally eventless, which is great! I'll keep an eye on it for a few more days but my feeling is it's already been fixed. Many praise for the project and a lot of thanks!