mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3675] [Engine] a client cancel during a single-stage prompt read does not stop the read (it runs to its DONE) #1519
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1519
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 @ipriyaaanshu on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3675
Problem: a client cancel/disconnect during a prompt read does not stop the read on a single-GPU (single-stage) engine: the prompt is read to the end anyway, and any request queued behind it waits for the full read.
Environment: engine v0.2.0-beta-1-gf0774897 (built from source, Metal), macOS 27.0.1, Apple M4 Pro 48 GB unified memory, single GPU (no layer split), Qwen3.8-Flash-Next GSQ-RCO Q2_0 at 262144 context,
--prefill auto --spec 2, conversation cache on. Read rate on this box ~200-250 tok/s.Reproduce (streaming endpoint, fresh unique prompt so nothing is reused):
Expected: the read stops at the next prompt chunk after the disconnect, and the queued request proceeds. On 0.1.39/CUDA this is what happens (measured in #962: read stopped within ~4 s at the next 8192-token chunk, tiny follow-up 0.6 s).
Actual: the read does not stop. Reproduced live, once, plus the same signature across production logs:
prompt 31410 tokens = 0 reused + 31405 of 31410 read in 157288 ms (199.7 tok/s) ... (cancelled).serve is not the problem: it forwards the disconnect promptly (the #1182 half, confirmed merged — its merge commit says "the engine half (stop between prompt chunks) is open"). serve's own comment still documents the outcome: "true sends STOP once (the request is then read to its DONE)".
Suspected mechanism (unconfirmed static analysis, verifying with STRATA_TRACE next): in
src/prefill/prefill.cppthe onlyshould_stopcheck (line 2654 on this tree) sits inside the per-chunk loop:but on a single-stage device
plan_chunk()returns 0 (if (pipe <= 0.0 || hand_in_ != nullptr || stages < 2) return 0;), soC = m.T— the buffers' whole size. A 49k prompt then reads in one chunk and the check has no boundary to fire on. On the 0.1.39/CUDA box in #962 the auto chunk was 8192, so the same check landed within seconds. If STRATA_TRACE confirms oneprompt chunk 0 of 49197iteration for this read, that is the whole story.Related: #962 (root report, closed in the 3-day sweep with "a new issue that links this one works too" — this is that issue), #471 (log accounting of a cancelled read, fixed in 0.1.36 — the
N of M readformat above is that fix), #1182 (serve half, merged 0.1.40.2), #2821 (interrupting a long response; a different half of interactivity).Reproduction status: reproduced locally (three times in production logs + one live repro above); the single-chunk mechanism is static analysis until the STRATA_TRACE run.
Proposed scope (happy to send the PR): make a cancel land within seconds on single-stage reads too — e.g. bound the effective read granularity for the single-stage path (the layer-split path already reads in planned chunks), keep the checkpoints of the chunks that were read (the
(cancelled)path already banks them — a re-send of the same prompt reuses 25491 tokens in ~300 ms here, which is a nice property worth keeping), and leave the queued-request preemption itself out (that is #2821's scope). Asking here first per CONTRIBUTING since it touches read granularity on the fast path — if bounding the chunk changes auto-scan throughput on some rig, an alternative is consultingshould_stopat the internal batch boundaries inside the chunk.@ipriyaaanshu commented on GitHub (Oct 22, 2026):
Filed the repro, and opened a minimal fix: Niko1221/Strata#3686 (Metal: the prompt read now stops at the next chunk on a client cancel —
g_prompt_stop_reqset from the stdin reader's STOP handler, checked in the prompt-read'son_chunk, cleared per request withstop_req). Numbers in the PR match this issue's repro (tiny-after-cancel: 207 s before → 3-15 s after).@Niko1221 commented on GitHub (Nov 5, 2026):
Thanks for taking the time to report this.
Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.