Skip to content

[PR] fix(preflight): preserve calibrated fit after zero folds - #4933

Closed
ReineLan wants to merge 5 commits into
ranxianglei:masterfrom
ReineLan:2026-10-27_zero-fold-calibrated-fit
Closed

ReineLan wants to merge 5 commits into
ranxianglei:masterfrom
ReineLan:2026-10-27_zero-fold-calibrated-fit

Conversation

@ReineLan

Copy link
Copy Markdown
Contributor

(ai: openai/gpt-6)

When no compression block lands, reuse the already scoped payload fit instead of mixing it with a fresh raw core-only estimate. Anonymous unknown baselines still use result.fitsWindow; image reserve remains unscaled by text calibration.

Fixes #4930. Separate from #4853: this changes the final zero-fold server predicate, not the preflight round-boundary baseline-floor policy. Route/model mismatch, invalid calibration, raw-body fallback, prior refusal and summary-quality controls remain intact.

Validation on head 38a9468, synchronized with upstream e4cc685: typecheck, build and 23 cases pass, zero skips, including all 13 new scenarios plus #1492/#847/#4288 adjacent guards. Six new cases fail on baseline source. This branch is independent of the multipart, native-checkpoint and image-budget fixes. No kernel/configuration/version changes. Full CI and production recovery remain unverified.

Qfeng_66 added 2 commits October 27, 2026 01:46
Use the existing scoped payload fit result when no compression block lands. Integrate the home handoff regression fixture covering calibration direction, route and model provenance, unscaled image reserve, anonymous forwarding, cancellation, and refusal guards.
@ranxianglei ranxianglei changed the title fix(preflight): preserve calibrated fit after zero folds [PR] fix(preflight): preserve calibrated fit after zero folds Oct 27, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。 本 PR 修的是「零折叠时服务端最终 fit 判定」(复用入口已算好的 scoped calibrated fit,而不是重新 raw core-only 估算),与在途条目机制均不同:#4853(round-boundary baseline-floor 策略,正文已声明分离)、#4928(多轮收敛 walk)、#4931(codex native checkpoint reconcile)、#4932(折叠后 image 计量)、#4294(payload 已 fit 时停止折叠)。它是 #4930 的唯一修复 PR。

标签: bug / scope/kernel / p2(缺陷类;src 侧压缩决策面——preflight 零折叠 fit 判定;特定条件下双向误判——校准跨窗口边界时拒掉能装的、放进超窗的,属局部功能异常,非整体不可用)。

开始审核:正在拉取分支核对代码(改动点 src/server.ts preflight 零折叠分支一行谓词替换 + 182 行新测试),随后本地定向跑新测试文件(PR head 应全绿、base 应恰好 6 例失败以证明回归钉住),并核查 #1492/#847/#4288 相邻守卫。CI 结论出来后按八问体例给最终审核结论。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 确认:head 38a946830 全套 check runs 已跑完——37 success + 22 skipped(按设计 env-gated 的 e2e lane)+ 0 失败;41 个 cancelled 均为前一轮触发的被取代尝试,逐项核对每项在当前轮都有绿/跳过孪生,无缺失。mergeable_state=blocked 是分支保护在等人工审批,与 CI 无关。

最终判定:代码审核 + CI 全绿,可合入(合并由你执行:https://github.com/ranxianglei/billion-context/pull/4933)。

ranxianglei added a commit that referenced this pull request Nov 13, 2026
…hropic cache partition

The fake billed whole-body bytes/4 — ~2x any real tokenizer for these
bodies because the JSON wire envelope is 2x the core text — which taught
the per-route calibration factor (#1933) a false k~≈1.9 on the pi lane.
After #4933 the zero-fold fit verdict runs on the calibrated scale, so
the post-restart baseline (raw ≈6.4K, calibrated ≈12.3K) sat ~120 tokens
over the lane's 12288 wall and the pi lane got a deterministic 413 while
master (raw-scale verdict) forwarded the same payload fine.

Two fixture bugs fixed in UpstreamRecorder:
1. billing scale: bill the text a tokenizer sees (message/system text
   chars + tool-schema JSON chars, /4) instead of whole-body bytes/4, so
   the learned factor stays ~1.0 as on a consistent real route;
2. the anthropic usage frame reported the FULL bill in input_tokens AND
   the cached prefix in cache_read_input_tokens — but promptInputTotal
   sums the two (anthropic partitions the prompt; the fields are
   disjoint), double-counting the cached prefix. Now input_tokens is the
   uncached remainder. The OpenAI branch already reported prompt_tokens
   inclusively and is unchanged.

Verified: suite green 3x locally; calibration ring settles ~1.006 on the
pi lane.
@ranxianglei

Copy link
Copy Markdown
Owner

Landed via batch PR #6464 (merged) — closing as superseded.

Louie0806 pushed a commit to Louie0806/billion-context that referenced this pull request Nov 13, 2026
…-body gate (ranxianglei#5000/ranxianglei#4543, 2e02110)

ReineLan's ranxianglei#4933 base (2026-10-31) predates the measured-body 413 tier that
dominates inside the unknown-baseline arbitration arm; with est~=measured, an
over-window estimate now dooms locally instead of forwarding. Pin the current
policy and note the superseded arbitration path in the comment.
@ranxianglei ranxianglei reopened this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p2 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[preflight] Zero-fold final fit discards scoped estimate calibration

2 participants