Repository navigation
[PR] fix(preflight): compare foldable mass to deficit on one calibrated scale (#3645) - #3650
Conversation
…ale (#3645) The raw-range futility gate compared an UNCALIBRATED foldable pool against a CALIBRATED payload deficit. With a matching-origin k-hat > 1 the deficit is inflated x-k while the kernel range.tokens pool is not, so a fold that would bring the window back under the limit was declared futile and skipped, leaving the session bricked behind a non-retryable 502. - preflight.ts: route the foldable pool through applyEstimateCalibration before comparing it to the deficit (pre-walk gate, relaxed probe, mid-walk bail) and in the log/failure text, so both sides share one scale. Identity for k-hat=1 / absent / mismatched-origin keeps the #1841 uncalibrated path byte-identical. - server.ts: hoist the calibrated post-fold size so the fail-fast message quotes the same scale as the fit decision, instead of claiming a sub-window raw number exceeds the window when k-hat > 1. Regression: tests/issue3645-calibrated-futility.test.ts (calibrated case recovers; uncalibrated control unchanged). Fixes #3645
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4299-pr.3650.36383f7This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3650.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 按失败签名(预检 futility gate 的未校准池 vs 校准 deficit 单位错配)检索 open/closed issue 与近期 PR:唯一同主题条目即本 PR 所修的 #3645 本身;相邻的 #3649(tier-recovery candidate search)机制不同(tier 恢复的候选搜索 vs raw-range gate 的单位),不构成重复。 开始独立审核(不照抄 issue 结论):已拉取分支 |
…n log too (#3645) Review follow-up on #3645: the 'preflight compressed N range(s)' info log mixed scales — calibrated pre-fold tokenCount vs the RAW post-fold anchor (session.stats.lastInputTokens), so for k̂>1 sessions the (A → B) pair no longer diffs to the reported saving. Quote foldedCalibratedSize instead; meter-anchor assignment is untouched.
…librated sessions (#3645) Review follow-up on #3645: symptom 2 (fail-fast quoting the raw post-fold size) had no regression test. New e2e case: k̂=2 with heavy summaries so the walk exhausts deterministically (tiers off) with post-fold raw mass sub-window while the calibrated mass stays over — asserts the quoted context figure is on the calibrated (over-window) scale. Mutation-checked: fails on the pre-fix code with the self-contradictory sub-window quote.
(ai: vllm-qwen/qwen3.8-27b) Review 结论:可合(人工合并:https://github.com/ranxianglei/billion-context/pull/3650)——方向、机制、回归面已独立复核,并在 PR 分支补了两个 follow-up commit(见下)。同一结论也已回帖到原 bug 报告线程(#3645)。 结构化八问
Review 发现并已直接修掉(两个 additive commit,已推到 PR 分支)
一处 PR 描述需修正的细枝:PR 称「未校准路径不变」,严格说 fail-fast 引用的数从 验证证据:定向套件本地 8/8 通过;typecheck 干净;远程 CI 在新 head 判定:可合,请人工合并。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.639-master.80cbe28 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Problem
A session with a persisted matching-origin calibration factor k-hat > 1 can hit a non-retryable local 502 even though folding would have brought it back under the window. Two symptoms, one root cause — a unit mismatch between two token scales:
range.tokens) against a calibrated payload deficit (result.payloadEstimate - limit). With k-hat>1 the deficit is inflated x-k while the pool is not, so the gate declared a recoverable round "futile" and skipped every fold -> the over-window payload was never forwarded and tier recovery never got a chance.~550759) "exceeds the model window 872000".Root cause
Once a matching-origin k-hat is set (#1933 F1),
applyEstimateCalibrationscales the host's own estimate (payloadEstimate, the fit check, the pre-foldtokenCount) by k-hat, but the kernel'srange.tokenspool stays on the raw count. The gate's two operands were on different scales.Fix
src/preflight.ts: route the foldable pool throughapplyEstimateCalibrationbefore comparing it to the deficit -- pre-walk gate, relaxed probe, mid-walk bail -- and in the log/failure text, so both sides share one scale. Folding a raw-mass range removes its mass from the text, so its calibrated saving is bounded bymass*k-hat; comparingmass*k-hat * slack < deficitis the unit-unified bound. Identity for k-hat=1 / absent / mismatched-origin keeps the 模型压缩输出是输入的数倍 #1841 uncalibrated path byte-identical.src/server.ts: hoist the calibrated post-fold size so the fail-fast message quotes the same scale as the fit decision.Behavior change (intended)
The uncalibrated path (k-hat=1 / absent / mismatched origin) is unchanged --
applyEstimateCalibrationreturns the raw value there.Config surface
None. No new config field, env var, CLI flag, wire shape, or persistence format.
Tests
New
tests/issue3645-calibrated-futility.test.ts:Existing
issue1841-preflight-futilityandpreflight-round-budgetsuites stay green locally. Full-suite verdict = remote CI.Fixes #3645