Repository navigation
[PR] fix: read BMP BITMAPCOREHEADER 16-bit dims by DIB header size (#6179) - #6232
ranxianglei wants to merge 1 commit into
Conversation
bmpDims always used the 32-bit BITMAPINFOHEADER layout, so a CORE header (bfSize==12) fused height+planes into width and read the bit-count field as height — a valid 64×128 CORE BMP billed 765 tokens instead of the true 1105. Select the dimension layout by the DIB size field: 12 → 16-bit dims at offsets 16/18; >=40 → 32-bit signed dims at 18/22 (top-down magnitude preserved, negative width rejected); any other short/unknown layout → undefined fallback to flat cost. Closes #6179
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9117-pr.6232.b5af0d4This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6232.tgz
npm install -g packageInstall instructions are refreshed on each push. |
|
(ai: vllm-qwen/qwen3.8-27b) Superseded by #6187. While working #6179 I opened this PR before noticing @Afloat16 had already submitted #6187 with the same approach. That reader in fact had a subtle offset bug (it still misparsed real spec-valid CORE BMPs), which I corrected in place on their branch ( |
(ai: vllm-qwen/qwen3.8-27b) Status follow-up to my earlier supersede note — re-verified against live upstream just now; nothing has changed since:
Requested owner actions (agents cannot close/merge PRs): ① merge #6187 once its CI is green; ② close this PR #6232 as superseded. No further agent action needed after that. 中文八问
标签: bug + scope/kernel + p3 + superseded(缺陷类;图像 token 估算属上下文管理内核路径;罕见格式的边缘估算错误定 p3;本 PR 已被 #6187 取代)。 |
🔶 需要决策:此 PR 已被取代(superseded by #6187,修复已在 master),请 owner 关闭 #6232;本 CI 通道不强行 rebase。 (ai: vllm-qwen/qwen3.8-27b) 按任务处理本 PR 与 master 的合并冲突(merge state: dirty)时,核查后发现这个 PR 已经不需要合并,因此没有强行 rebase。证据如下: 1. 修复已合入 master。 #6179 的 BMP CORE 头修复已经通过修正后的 #6187 进入 master(commit 2. 本 PR 的代码是错误变体(不只是冗余)。 本 PR(
3. 冲突只能靠丢弃本 PR 内容解决。 test-merge 确认冲突集中在 4. 作者已两次声明 superseded。 本 PR 作者在 5 楼、7 楼已明确 "Superseded by #6187 … recommend closing #6232 in favor of the corrected #6187",并说明 #6187 修正版已完整包含该修复。 结论:本 PR 已无合并价值(修复已在 master,且本 PR 自身代码为错误变体)。按 AGENTS.md「分支已废弃 / PR 已无需合并,回复说明即可,不要硬救」,我不强行 rebase。已打 请 owner 操作(agent 无权关闭 PR):关闭 #6232(superseded by #6187,修复已在 master 中文八问
收工判定:代码工作无需进行——修复已在 master(#6187 / |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
🔶 需要决策:PR 仍被取代(superseded by #6187,修复已在 master);上一轮的 needs-decision 标签被清除导致本通道重触发,已重新打标。请 owner 关闭 #6232。 (ai: vllm-qwen/qwen3.8-27b) 这是同一 PR 的再次触发(上一轮已完整分析并回复)。本轮重新核对了 live 状态,结论不变: Live 复核(本轮实测)
为什么仍不 rebase:冲突只集中在 关于重触发:上一轮打的 请 owner 操作(agent 无权关闭 PR):关闭 #6232(superseded by #6187,修复已在 master 中文八问
收工判定:状态与上一轮一致——修复已在 master,本 PR 冗余且自身代码为错误变体。等 owner 关闭 #6232 结案。 |
(ai: vllm-qwen/qwen3.8-27b) 本次为看门狗强制重启后的再次唤醒(非新任务)。已重新核对 live 状态,无新工作、结论不变:
未做任何代码改动,工作树干净。 说明:本 PR 的 CI 修复工作已完成并收敛——唯一剩余动作是 owner 关闭 #6232(superseded by #6187,修复已在 master 收工判定:无待办,等 owner 关闭 #6232 结案。 |
What
bmpDims(the hand-rolled BMP dimension reader used by image billing) always read the 32-bitBITMAPINFOHEADERlayout at fixed offsets 18/22. ABITMAPCOREHEADERstores 16-bit dimensions, so the reader fused height+planes into width and read the bit-count field as height. A valid 64×128 CORE BMP therefore billed 765 tokens instead of the true 1105 (pixelTileEstimate(64,128)).Root cause
The DIB header starts at offset 14 and its leading size field selects the dimension layout, but
bmpDimsignored it and hardcoded the INFO/V2–V5 32-bit reads. The low-16-bits marker discriminates cleanly: CORE hasbfSize==12, every INFO variant hasbiSize>=40, so reading the 16 bits at offset 14 distinguishes both exactly (all valid sizes carry zero high bits, so it is exact even for the WORD-sized CORE field).Fix
Select the layout by the DIB size field (
src/image-tokens.tsbmpDims):dibSize == 12→ read 16-bit unsigned width@16 / height@18 (CORE).dibSize >= 40→ read 32-bit signed width@18 / height@22, take magnitude of height (top-down scan order preserved), reject negative width via the existingw > 0gate (INFO/V2–V5 — unchanged).undefined(unsupported short/unknown layout falls back to flat cost instead of being misread).Single function change; all consumers (billing, image-note, rescale, restore, egress-shed) inherit it. The rescale/eegress-shed outputs are structurally immune because
doRescalere-validates against Jimp's authoritative decoded dimensions (src/image-rescale.ts:112-118) before acting — Jimp self-corrects, so only the billing estimate (and shed-note metadata) surfaced the bug.Behavior changes (disclosed)
undefined→ flat fallback cost. Real-world impact negligible (valid BMPs are always 12 or ≥40), but the input class that gets a specific (wrong) estimate now gets the flat fallback instead.Regression coverage
New focused test in
tests/issue767-pixel-billing.test.ts: CORE dims (64×128 / 32×16 / 1000×500), INFO backward-compat (bottom-up + top-down magnitude), rejections (negative INFO width, short DIB sizes 8 & 11), plus an end-to-end billing assertion that a 64×128 CORE BMP bills its true tile cost throughpixelsmode. Verified green locally (targeted files + typecheck); full-suite verdict comes from CI on this head.Closes #6179