[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

Open
opened 2026-10-29 21:22:47 +07:00 by bsakaguchi · 2 comments
Owner

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 ds4 engine, --tp 2, on two A100 80GB PCIe cards under Linux. Occasionally a prompt read stops and never advances again:

  • the engine process stays alive and the HTTP server keeps answering;
  • nvidia-smi shows GPU 0 at 100% and GPU 1 at 0%, with no disk or CPU work to speak of;
  • the log repeats the same reading the prompt ... line forever, with the token count constant — in four cases in the X of Y form at the first chunk's width, in the fifth with no of Y progress at all;
  • no token is produced, and every request queued behind it waits until its client gives up or the engine is restarted;
  • a client disconnect does not clear it, and retries freeze at the same point;
  • only 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 SIGINT ended it. Every one of the five is preceded by a client abort that the engine logged as stopped while reading the prompt ... followed by done: 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-SIGINT message 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

Host 2× Intel Xeon Gold 5320 (2 sockets, 2 NUMA nodes, 104 threads)
RAM 503 GiB total; ~182 GiB free at the time of writing
OS / kernel Ubuntu 24.04.5 LTS, 6.8.0-136-generic
Driver / CUDA NVIDIA open kernel module 615.71.09; engine built with CUDA 13.0 (nvcc 13.0.48)
GPUs 2× NVIDIA A100 80GB PCIe (GA100, sm_80), 80 GiB each, PCIe 4.0 x16, no NVLink
GPU topology GPU 0 at 0000:4b:00.0, NUMA node 0; GPU 1 at 0000:ca:00.0, NUMA node 1 (cross-socket)
Maya v1.1.27 (ds4-0.1), also seen on v1.1.28; first seen on v1.1.24
Model DeepSeek-V4.1-Flash-1017 EXL3 3.5 bpw, maya-ds4 pack
Engine args --max-context 262144 --tp 2 --mmap-experts off --dspark none
Config env DS4_ENGRAM_RAM=1
Startup layout CUDA0 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 free
Engram DS4_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 threads
Prompt attention CUDA0/CUDA1 prompt attention on the tensor cores (sm_80)

Both GPUs are normally busy during a healthy decode: an authenticated /metrics sample during decode reported gpus: [(0, 99, ...), (1, 98, ...)], combined gpu_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 far counters; line numbers refer to the local maya-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):

[maya] done: 32768 tokens in 933 s (35.4 tok/s) (length, cancel=False), expert cache 98.5% hit
[maya] reading the prompt: 57,123 tokens, 10 s so far
[maya] reading the prompt: 3,890 of 57,123 tokens, 13 s so far
[maya] reading the prompt: 3,890 of 57,123 tokens, 14 s so far
...
[maya] reading the prompt: 3,890 of 57,123 tokens, 11019 s so far
[maya] stopping (SIGINT): the engine ends
[maya] done: 0 tokens in 11023 s (0.0 tok/s) (error, cancel=False)

There is no further prompt progress, no decode line, and no DONE between the first frozen line and the SIGINT. The 57,123-token prompt produced 25,985 progress lines across 7 attempts; the longest single attempt held at 3,890 for 11,019 s.

The same pattern repeats at four different prompt sizes:

Prompt tokens Frozen at First appearance Last appearance Duration held Attempts Max queued wait
57,123 3,890 13 s 11,019 s 11,006 s (3 h 3 m) 7 640 s
110,769 4,004 19 s 235 s 216 s 5 — (client gave up)
19,541 3,375 7 s 1,859 s 1,852 s (30 m 52 s) 1 2,154 s
184,804 4,048 10 s 49 s (last attempt) 39 s–1,762 s per attempt 11 53 s

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 past 4,048 in 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 an X of Y progress line at all; the first two clients disconnected after 60–80 s, and the third was still waiting when SIGINT ended 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

ds4 splits 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 last

keep = (nl - yoco) * (win - 1) + win
     = (40 - 20) * (128 - 1) + 128
     = 2,668

rows for the full pass and chunks the early part a = n - 2,668 into equal chunks of at most 4,096:

nc = ceil(a / 4096)
w  = ceil(a / nc)

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 of w means chunk 0 completed and chunk 1 never completed. The arithmetic matches every freeze exactly:

Prompt n a = n − 2,668 nc = ceil(a/4096) w = ceil(a/nc) Frozen value in log
57,123 54,455 14 3,890 3,890
110,769 108,101 27 4,004 4,004
19,541 16,873 5 3,375 3,375
184,804 182,136 45 4,048 4,048

The same formula, applied to healthy reads, predicts the observed progress increments:

Healthy prompt n a nc predicted w observed increment
73,246 70,578 18 3,921 3,921
29,879 27,211 7 3,888 3,888
110,373 107,705 27 3,990 3,990
90,618 87,950 22 3,998 3,998

The healthy 73,246-token prompt advances in steps of 3,921, exactly the predicted first-chunk width:

[maya] reading the prompt: 3,921 of 73,246 tokens, 3 s so far
[maya] reading the prompt: 7,842 of 73,246 tokens, 4 s so far
[maya] reading the prompt: 11,763 of 73,246 tokens, 6 s so far
...

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), :10912 and :10916 (part(0, a) then part(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 logs done: 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:

Frozen prompt First freeze line Nearest preceding stop Aborted prompt Stop duration Cancel line Gap (lines)
184,804 19,874 stopped while reading the prompt of 179963 tokens 179,963 3,558 ms 18,805 1,069
57,123 71,926 stopped while reading the prompt of 7726 tokens 7,726 2,806 ms 70,671 1,255
110,769 109,148 stopped while reading the prompt of 176938 tokens 176,938 80,830 ms 108,601 547
19,541 125,747 stopped while reading the prompt of 18887 tokens 18,887 3,557 ms 125,221 526

Excerpts:

maya ds4 serve: stopped while reading the prompt of 179963 tokens, after 3558 ms
[maya] done: 0 tokens in 4 s (0.0 tok/s) (disconnect, cancel=True)
...
[maya] reading the prompt: 4,048 of 184,804 tokens, 10 s so far
[maya] reading the prompt: 4,048 of 184,804 tokens, 11 s so far
... (11,000 such lines over 11 attempts)
maya ds4 serve: stopped while reading the prompt of 18887 tokens, after 3557 ms
[maya] done: 0 tokens in 4 s (0.0 tok/s) (disconnect, cancel=True)
...
[maya] reading the prompt: 3,375 of 19,541 tokens, 7 s so far
[maya] reading the prompt: 3,375 of 19,541 tokens, 8 s so far
... (1,857 lines, up to 1,859 s)

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:

[maya] reading the prompt: 3,921 of 73,246 tokens, 2 s so far
maya ds4 serve: stopped while reading the prompt of 73246 tokens, after 3407 ms
[maya] done: 0 tokens in 3 s (0.0 tok/s) (disconnect, cancel=True)
...
[maya] reading the prompt: 162 tokens, 10 s so far
[maya] reading the prompt: 162 tokens, 20 s so far
[maya] reading the prompt: 162 of 162 tokens, 23 s so far
[maya] thinking: 8 of max 4096 tokens, 7.8 tok/s, 24 s
...
maya ds4 serve: prompt 162 tokens = 0 reused + 162 read in 23377 ms (6.9 tok/s), 54 generated in 8021 ms (6.73 tok/s)
[maya] reading the prompt: 6,397 tokens, 10 s so far
[maya] reading the prompt: 6,397 tokens, 20 s so far
[maya] stopped, and the engine did not say the request had ended within 60 s (STRATA_DRAIN_S) - going on; ...
[maya] done: 0 tokens in 80 s (0.0 tok/s) (disconnect, cancel=True)
[maya] reading the prompt: 6,417 tokens, 10 s so far
[maya] reading the prompt: 6,417 tokens, 20 s so far
[maya] stopped, and the engine did not say the request had ended within 60 s (STRATA_DRAIN_S) - going on; ...
[maya] done: 0 tokens in 80 s (0.0 tok/s) (disconnect, cancel=True)
[maya] reading the prompt: 2,579 tokens, 10 s so far
[maya] reading the prompt: 2,579 tokens, 20 s so far
[maya] reading the prompt: 2,579 tokens, 30 s so far
[maya] reading the prompt: 2,579 tokens, 40 s so far
[maya] stopping (SIGINT): the engine ends

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

  • The process stays alive in each episode. There is no ds4: error line, no CUDA error, no illegal memory access, no watchdog message, and no engine restart before the manual SIGINT. I searched the five freeze segments for error|CUDA|watchdog|stall|timeout|assert|illegal|fatal|exception and found 0 matches.
  • Client disconnects do not release the engine. They produce done: 0 tokens ... (disconnect, cancel=True) and then the next request starts, but the GPU stays pinned. The server keeps 1 of 1 place(s) in use and reports reading the prompt, 0 tokens so far (even when the engine has already reported 3,375 of 19,541).
  • The queue accumulates. During the 19,541-token wedge the log shows 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.
  • Retries do not help. The 184,804-token prompt was retried 11 times and froze at 4,048 every time; the 57,123-token prompt has 7 attempts; the 110,769-token prompt has 5.
  • A restart fixes it. After SIGINT and 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 post-kill message is wrong about the cause:
[maya] the engine stopped unexpectedly (exit code -2). The usual cause is running out of RAM ...

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:

  1. Engine stall (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.0 means 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.
  2. Request quiet (STRATA_REQUEST_QUIET_S, default 900 s) is implemented for the multi-request path, but the ds4 single-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 the ds4 serve 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:

  1. The last completed chunk is chunk 0; chunk 1 never completes. The frozen value is exactly chunk 0's width, in all four prompts.
  2. The engine is alive, one GPU is at 100%, the other at 0%, no kernel error is reported, and no watchdog acts.
  3. The condition survives client disconnects and repeats on retry; a process restart clears it.
  4. The preceding event is a client abort during prefill/stream, logged by the engine as a clean stopped while reading the prompt and cancel=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 :9450 and :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 not arb_seq; I did not find a reset of arb_seq or the hand-off flags in restore() (: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:

    __device__ __forceinline__ void wait_at_least(const unsigned* flag, unsigned seq) {
        while ((int) (*(volatile const unsigned*) flag - seq) < 0) {
    #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700
            __nanosleep(100);
    #endif
        }
    }
    

    It has no timeout, no counter, and no diagnostic. xfer_get_kernel, wait_flags_kernel, ar_sum_kernel and 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_ack and hand_flag[2] are host-mapped, allocated once, and never cleared at run start. Before sending chunk k's hand-off, the sender waits for the next group's acknowledgements of chunk k − 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 >= 2 is 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 calls cudaStreamSynchronize() 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 chunk halt_k or 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 does atomicAdd(cnt, 1u) == gridDim.x - 1, then resets *cnt = 0 and sets the flag. This is correct only if two xfer_put grids never overlap on the same device. In TP=2 all xfer_put calls I found are on the main stream, so this is probably not the trigger here; it is another place where an overlapped grid would leave cnt nonzero 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_kernel for 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 with DS4_ATTN_MMA=0 would 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

SIGINT the engine and let the server restart it. This is the only reliable recovery I have. The prompt (or its retry) then reads normally.

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 `ds4` engine, `--tp 2`, on two A100 80GB PCIe cards under Linux. Occasionally a prompt read stops and never advances again: - the engine process stays alive and the HTTP server keeps answering; - `nvidia-smi` shows **GPU 0 at 100% and GPU 1 at 0%**, with no disk or CPU work to speak of; - the log repeats the same `reading the prompt ...` line forever, with the token count constant — in four cases in the `X of Y` form at the first chunk's width, in the fifth with no `of Y` progress at all; - no token is produced, and every request queued behind it waits until its client gives up or the engine is restarted; - a client disconnect does not clear it, and retries freeze at the same point; - only `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 `SIGINT` ended it. Every one of the five is preceded by a client abort that the engine logged as `stopped while reading the prompt ...` followed by `done: 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-`SIGINT` message 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 | | | |---|---| | Host | 2× Intel Xeon Gold 5320 (2 sockets, 2 NUMA nodes, 104 threads) | | RAM | 503 GiB total; ~182 GiB free at the time of writing | | OS / kernel | Ubuntu 24.04.5 LTS, `6.8.0-136-generic` | | Driver / CUDA | NVIDIA open kernel module `615.71.09`; engine built with CUDA 13.0 (`nvcc` 13.0.48) | | GPUs | 2× **NVIDIA A100 80GB PCIe** (`GA100`, `sm_80`), 80 GiB each, **PCIe 4.0 x16, no NVLink** | | GPU topology | GPU 0 at `0000:4b:00.0`, NUMA node 0; GPU 1 at `0000:ca:00.0`, NUMA node 1 (cross-socket) | | Maya | v1.1.27 (`ds4-0.1`), also seen on v1.1.28; first seen on v1.1.24 | | Model | DeepSeek-V4.1-Flash-1017 EXL3 3.5 bpw, `maya-ds4` pack | | Engine args | `--max-context 262144 --tp 2 --mmap-experts off --dspark none` | | Config env | `DS4_ENGRAM_RAM=1` | | Startup layout | `CUDA0 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 free` | | Engram | `DS4_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 threads | | Prompt attention | `CUDA0/CUDA1 prompt attention on the tensor cores (sm_80)` | Both GPUs are normally busy during a healthy decode: an authenticated `/metrics` sample during decode reported `gpus: [(0, 99, ...), (1, 98, ...)]`, combined `gpu_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 far` counters; line numbers refer to the local `maya-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): ``` [maya] done: 32768 tokens in 933 s (35.4 tok/s) (length, cancel=False), expert cache 98.5% hit [maya] reading the prompt: 57,123 tokens, 10 s so far [maya] reading the prompt: 3,890 of 57,123 tokens, 13 s so far [maya] reading the prompt: 3,890 of 57,123 tokens, 14 s so far ... [maya] reading the prompt: 3,890 of 57,123 tokens, 11019 s so far [maya] stopping (SIGINT): the engine ends [maya] done: 0 tokens in 11023 s (0.0 tok/s) (error, cancel=False) ``` There is no further prompt progress, no decode line, and no `DONE` between the first frozen line and the `SIGINT`. The 57,123-token prompt produced 25,985 progress lines across 7 attempts; the longest single attempt held at `3,890` for 11,019 s. The same pattern repeats at four different prompt sizes: | Prompt tokens | Frozen at | First appearance | Last appearance | Duration held | Attempts | Max queued wait | |---:|---:|---|---|---:|---:|---:| | 57,123 | 3,890 | 13 s | 11,019 s | **11,006 s** (3 h 3 m) | 7 | 640 s | | 110,769 | 4,004 | 19 s | 235 s | **216 s** | 5 | — (client gave up) | | 19,541 | 3,375 | 7 s | 1,859 s | **1,852 s** (30 m 52 s) | 1 | **2,154 s** | | 184,804 | 4,048 | 10 s | 49 s (last attempt) | **39 s–1,762 s** per attempt | 11 | 53 s | 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 past `4,048` in 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 an `X of Y` progress line at all; the first two clients disconnected after 60–80 s, and the third was still waiting when `SIGINT` ended 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 `ds4` splits 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 last ``` keep = (nl - yoco) * (win - 1) + win = (40 - 20) * (128 - 1) + 128 = 2,668 ``` rows for the full pass and chunks the early part `a = n - 2,668` into equal chunks of at most 4,096: ``` nc = ceil(a / 4096) w = ceil(a / nc) ``` 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 of `w` means **chunk 0 completed and chunk 1 never completed**. The arithmetic matches every freeze exactly: | Prompt `n` | `a = n − 2,668` | `nc = ceil(a/4096)` | `w = ceil(a/nc)` | Frozen value in log | |---:|---:|---:|---:|---:| | 57,123 | 54,455 | 14 | **3,890** | 3,890 | | 110,769 | 108,101 | 27 | **4,004** | 4,004 | | 19,541 | 16,873 | 5 | **3,375** | 3,375 | | 184,804 | 182,136 | 45 | **4,048** | 4,048 | The same formula, applied to healthy reads, predicts the observed progress increments: | Healthy prompt `n` | `a` | `nc` | predicted `w` | observed increment | |---:|---:|---:|---:|---:| | 73,246 | 70,578 | 18 | 3,921 | 3,921 | | 29,879 | 27,211 | 7 | 3,888 | 3,888 | | 110,373 | 107,705 | 27 | 3,990 | 3,990 | | 90,618 | 87,950 | 22 | 3,998 | 3,998 | The healthy 73,246-token prompt advances in steps of 3,921, exactly the predicted first-chunk width: ``` [maya] reading the prompt: 3,921 of 73,246 tokens, 3 s so far [maya] reading the prompt: 7,842 of 73,246 tokens, 4 s so far [maya] reading the prompt: 11,763 of 73,246 tokens, 6 s so far ... ``` 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`), `:10912` and `:10916` (`part(0, a)` then `part(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 logs `done: 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: | Frozen prompt | First freeze line | Nearest preceding stop | Aborted prompt | Stop duration | Cancel line | Gap (lines) | |---:|---:|---|---:|---:|---:|---:| | 184,804 | 19,874 | `stopped while reading the prompt of 179963 tokens` | 179,963 | 3,558 ms | 18,805 | 1,069 | | 57,123 | 71,926 | `stopped while reading the prompt of 7726 tokens` | 7,726 | 2,806 ms | 70,671 | 1,255 | | 110,769 | 109,148 | `stopped while reading the prompt of 176938 tokens` | 176,938 | 80,830 ms | 108,601 | 547 | | 19,541 | 125,747 | `stopped while reading the prompt of 18887 tokens` | 18,887 | 3,557 ms | 125,221 | 526 | Excerpts: ``` maya ds4 serve: stopped while reading the prompt of 179963 tokens, after 3558 ms [maya] done: 0 tokens in 4 s (0.0 tok/s) (disconnect, cancel=True) ... [maya] reading the prompt: 4,048 of 184,804 tokens, 10 s so far [maya] reading the prompt: 4,048 of 184,804 tokens, 11 s so far ... (11,000 such lines over 11 attempts) ``` ``` maya ds4 serve: stopped while reading the prompt of 18887 tokens, after 3557 ms [maya] done: 0 tokens in 4 s (0.0 tok/s) (disconnect, cancel=True) ... [maya] reading the prompt: 3,375 of 19,541 tokens, 7 s so far [maya] reading the prompt: 3,375 of 19,541 tokens, 8 s so far ... (1,857 lines, up to 1,859 s) ``` 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: ``` [maya] reading the prompt: 3,921 of 73,246 tokens, 2 s so far maya ds4 serve: stopped while reading the prompt of 73246 tokens, after 3407 ms [maya] done: 0 tokens in 3 s (0.0 tok/s) (disconnect, cancel=True) ... [maya] reading the prompt: 162 tokens, 10 s so far [maya] reading the prompt: 162 tokens, 20 s so far [maya] reading the prompt: 162 of 162 tokens, 23 s so far [maya] thinking: 8 of max 4096 tokens, 7.8 tok/s, 24 s ... maya ds4 serve: prompt 162 tokens = 0 reused + 162 read in 23377 ms (6.9 tok/s), 54 generated in 8021 ms (6.73 tok/s) [maya] reading the prompt: 6,397 tokens, 10 s so far [maya] reading the prompt: 6,397 tokens, 20 s so far [maya] stopped, and the engine did not say the request had ended within 60 s (STRATA_DRAIN_S) - going on; ... [maya] done: 0 tokens in 80 s (0.0 tok/s) (disconnect, cancel=True) [maya] reading the prompt: 6,417 tokens, 10 s so far [maya] reading the prompt: 6,417 tokens, 20 s so far [maya] stopped, and the engine did not say the request had ended within 60 s (STRATA_DRAIN_S) - going on; ... [maya] done: 0 tokens in 80 s (0.0 tok/s) (disconnect, cancel=True) [maya] reading the prompt: 2,579 tokens, 10 s so far [maya] reading the prompt: 2,579 tokens, 20 s so far [maya] reading the prompt: 2,579 tokens, 30 s so far [maya] reading the prompt: 2,579 tokens, 40 s so far [maya] stopping (SIGINT): the engine ends ``` 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 - The process stays alive in each episode. There is no `ds4:` error line, no CUDA error, no `illegal memory access`, no watchdog message, and no engine restart before the manual `SIGINT`. I searched the five freeze segments for `error|CUDA|watchdog|stall|timeout|assert|illegal|fatal|exception` and found **0 matches**. - Client disconnects do not release the engine. They produce `done: 0 tokens ... (disconnect, cancel=True)` and then the next request starts, but the GPU stays pinned. The server keeps `1 of 1 place(s) in use` and reports `reading the prompt, 0 tokens so far` (even when the engine has already reported 3,375 of 19,541). - The queue accumulates. During the 19,541-token wedge the log shows `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**. - Retries do not help. The 184,804-token prompt was retried 11 times and froze at 4,048 every time; the 57,123-token prompt has 7 attempts; the 110,769-token prompt has 5. - A restart fixes it. After `SIGINT` and 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 post-kill message is wrong about the cause: ``` [maya] the engine stopped unexpectedly (exit code -2). The usual cause is running out of RAM ... ``` 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: 1. **Engine stall** (`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.0` means 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. 2. **Request quiet** (`STRATA_REQUEST_QUIET_S`, default 900 s) is implemented for the multi-request path, but the `ds4` single-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 the `ds4` serve 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:** 1. The last completed chunk is chunk 0; chunk 1 never completes. The frozen value is exactly chunk 0's width, in all four prompts. 2. The engine is alive, one GPU is at 100%, the other at 0%, no kernel error is reported, and no watchdog acts. 3. The condition survives client disconnects and repeats on retry; a process restart clears it. 4. The preceding event is a client abort during prefill/stream, logged by the engine as a clean `stopped while reading the prompt` and `cancel=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 `:9450` and `: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 not `arb_seq`; I did not find a reset of `arb_seq` or the hand-off flags in `restore()` (`: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: ```cpp __device__ __forceinline__ void wait_at_least(const unsigned* flag, unsigned seq) { while ((int) (*(volatile const unsigned*) flag - seq) < 0) { #if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 __nanosleep(100); #endif } } ``` It has no timeout, no counter, and no diagnostic. `xfer_get_kernel`, `wait_flags_kernel`, `ar_sum_kernel` and 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_ack` and `hand_flag[2]` are host-mapped, allocated once, and never cleared at run start. Before sending chunk `k`'s hand-off, the sender waits for the next group's acknowledgements of chunk `k − 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 >= 2` is 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 calls `cudaStreamSynchronize()` 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 chunk `halt_k` or 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 does `atomicAdd(cnt, 1u) == gridDim.x - 1`, then resets `*cnt = 0` and sets the flag. This is correct only if two `xfer_put` grids never overlap on the same device. In TP=2 all `xfer_put` calls I found are on the main stream, so this is probably not the trigger here; it is another place where an overlapped grid would leave `cnt` nonzero 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_kernel` for 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 with `DS4_ATTN_MMA=0` would 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 `SIGINT` the engine and let the server restart it. This is the only reliable recovery I have. The prompt (or its retry) then reads normally.
Author
Owner

@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_S sets the time, and 0 turns 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

<!-- gh-comment-id:6456001853 --> @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_S` sets the time, and `0` turns 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
Author
Owner

@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!

<!-- gh-comment-id:6484869464 --> @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!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#218
No description provided.