Repository navigation
[PR] fix: measure completed preflight round before wall admission - #3732
Conversation
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。open+closed 全量检索 "preflight wall admission lastRoundMs round budget" 无命中;关联的 #3573(根因事故)、#3590(引入 wall gate 的前置 PR)、#3586/#3591(同事故的其他修复线)机制与范围均不同——本 PR 是 #3590 机制自身的缺陷修复,不是其中任何一条线的重复。 标签: bug + dsh + scope/kernel + p2 —— #3590 wall gate 的计时点缺陷;触发场景源自 dsh 长会话耐心问题(#3573);属压缩引擎域;能用但有明显超预算行为 → p2。 审核结论(结构化八问)
CI 与合入顺序(需要 owner 注意)
判定代码层面通过:修法最小且打在根因(测量顺序)上,回归测试经变异验证有牙,无意外行为漂移,无配置/版本/kernel 变更。待办只剩流程项:#3590 先行合并后 rebase 本 PR 并等全量 CI 绿。合并由人执行。 |
rahul05ranjan
left a comment
There was a problem hiding this comment.
Traced the round accounting and this fixes two real problems with the wall-budget admission:
-
The estimate was one round behind. Before the move, at the first admission check (round 1)
lastRoundMswas still 0, soestNextMswas 0 and the check degenerated toelapsed > budget— a marathon attempt with a tiny wall budget would always admit a second slow round. With the update hoisted above the check,estNextMsis the duration of the round that just completed, which is the number the decision actually needs. Later rounds weren't stale before (they read the immediately preceding round), so the fix correctly changes only the first-check behavior, and the ×2 headroom inestNextMskeeps the stop from being timing-marginal. -
wallStopAfterRounds = roundmakes the receipt count the rounds that actually completed, matching the log line ("stopping after round ${round}") — the oldround + 1told the client one more round had run than it did, which would skew retry-side sizing.
The upgraded test is a real improvement: the main upstream now counts tokens and rejects >12k payloads, so the test can assert exactly one fitting payload ever reaches it, and the new 400 branch proves non-fitting attempts never leak past preflight. The stopsBefore indexing into the captured stop lines is sound given single-session log capture.
poboll
left a comment
There was a problem hiding this comment.
Approving after independent verification — the diff, the mechanism, and the red/green behaviour all check out.
Root cause confirmed by reading the loop. lastRoundMs was assigned after the admission gate that reads it:
if (round > 0 && !emergencyFold) {
const estNextMs = lastRoundMs > 0 ? lastRoundMs * 2 : 0; // read
if (elapsedMs + estNextMs > budget) { ... }
}
if (lastRoundStart > 0) lastRoundMs = admissionNow - lastRoundStart; // written afterSo on the second round the estimate still reflects the state before the round that just finished — it lags one round behind precisely when the gate needs it. Moving the assignment above the read is the minimal correct fix.
The receipt off-by-one is also right. The loop is for (let round = 0; ...) with the gate at round > 0. When the gate fires at round = N, rounds 0..N-1 have completed — N rounds — and round N never runs because the break precedes processTurn. So round + 1 overcounts by one and round is correct. I traced wallStopAfterRounds to its only consumer, the detail string at src/preflight.ts:2770, so the impact is confined to that receipt text.
Red/green reproduced locally. I ran the strengthened test against the parent commit c3838188 and it fails as the PR claims:
not ok 1 - #3573 slow summary rounds: ...
error: 'attempt 1: the first slow round must prevent admission of a second round'
with the log showing the pre-fix behaviour — stopping after round 2 (a second round admitted) and stopped at the client-patience wall budget after 3 round(s) in the receipt. On the PR head both target tests pass.
Validation run here:
tests/issue3573-preflight-client-patience.test.ts— 2/2- the four adjacent suites named in the description (
preflight-round-budget,preflight-emergency-fold,preflight-client-abort,preflight-fail-fast) — 22/22, matching the stated count - all 26
preflight*suites — 152 pass / 0 fail tsc --noEmit --project tsconfig.json— clean
The scope is honest too: only src/preflight.ts and its regression test change, no config/version/kernel/runtime-install surface, and the body explicitly scopes this away from the image-accumulation WebSocket 1009 issue rather than quietly widening. The stacked branch not being rebased onto current master is stated up front rather than discovered later.
Good fix, and unusually well-evidenced.
393f4d1
into
ranxianglei:2026-10-17_preflight-client-patience
The wall-clock admission gate in #3590 reads
lastRoundMsbefore recording the just-completed round. The second admission therefore uses zero as its estimate and can start another slow round beyond the intended budget. The stop receipt also counts the rejected round as completed.This is an additive fix based on #3590's exact head,
c38381881d8bb43e6dd9cd8f4ef68af229f51d9e, targeting that PR's branch so its original commits and authorship remain intact. Related: #3573.ceil(JSON.stringify(messages).length / 4), not a real model tokenizer.Validation on the exact #3590 base and this fix:
npm run buildpass. Build emitted an existing unrelatedCONFIG_DIR_NAMEpi host stub warning.Commands:
node --import tsx --test tests/issue3573-preflight-client-patience.test.ts;node --import tsx --test --test-concurrency=1 tests/preflight-round-budget.test.ts tests/preflight-emergency-fold.test.ts tests/preflight-client-abort.test.ts tests/preflight-fail-fast.test.ts;node node_modules/typescript/bin/tsc --noEmit --project tsconfig.json;npm run build.Only
src/preflight.tsand its regression test change. Image sizing remains 1600; no configuration, version, kernel, or runtime installation changes. This fixes wall-clock admission in #3590; it is not a complete fix for the image-accumulation WebSocket 1009 issue. Local validation used real proxy HTTP requests and local stub upstreams; real-client/model E2E and the full remote CI suite have not been run. This stacked branch is not claimed to be rebased onto current master.