Skip to content

Use physical engine token capacity for footprint measurements - #5218

Merged
joelteply merged 2 commits into
canaryfrom
codex/engine-context-geometry
Oct 20, 2026
Merged

joelteply merged 2 commits into
canaryfrom
codex/engine-context-geometry

Conversation

@joelteply

@joelteply joelteply commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

A unified KV cache can give each sequence the full context limit while sharing one physical token allocation. Multiplying sequence count by that limit understates measured bytes per token. The discrete-GPU EngineContext sampling path now uses the engine's allocated_tokens receipt for the denominator and prediction, preserving sequence count and window separately. Fixed-cost reconstruction converts the measured excess back to physical bytes per lane using the same allocation.

Depends on CambrianTech/llama.cpp#67 and pins producer29eaf83aa. A shared parser rejects present malformed geometry even when memory_breakdown is absent. Older engines without the field retain the managed divided-cache interpretation; no unified-cache flag is enabled. Process-anonymous sampling retains its existing divided-cache contract.

Sampling moves into serving_daemon/footprint.rs, reducing monolith excess by281 lines. Existing fixtures cover unified versus legacy reconstruction, invalid geometry, old persisted JSON without allocation, and malformed geometry without a breakdown. Invalid reconstruction propagates unavailable footprint rather than invented zero cost.

Validation at3f0be60b8 on Windows: dev-fast footprint12/12 passed0.02s, parser2/2 passed0.00s, hygiene39/39 passed5.09s. Receipts geometry-review-footprint.log, geometry-review-parser.log, geometry-review-hygiene.log in team-proof-20260921. Independent review approves producer contract and corrected consumer source; exact-head CI remains pending. Full-debug native PDB linking previously failed; dev-fast passed without another cache purge.

Not deployed. Codex owns post-deployment verification of actual /props allocation against persisted measurement, fixed-cost reconstruction and consumer probe before closing this work. No turn-speed or learning improvement is claimed.

@joelteply
joelteply force-pushed the codex/engine-context-geometry branch from 5b8e591 to 05c612a Compare October 20, 2026 08:39
@joelteply

Copy link
Copy Markdown
Contributor Author

Independent review found and blocked two defects in05c612 despite green CI. Corrected in3f0be60b8:

  • Fixed-cost reconstruction uses excess per physical token * allocated tokens / lanes, with u128 intermediate and checked narrowing. Invalid geometry propagates unavailable footprint; historical records lacking allocated_tokens preserve divided-cache semantics.
  • Shared geometry parsing rejects malformed present receipts before missing memory_breakdown can choose the legacy path.
  • Existing fixtures cover unified versus legacy reconstruction, zero lanes, malformed geometry without breakdown, and real old JSON with the new field absent.

Independent helper delta source review APPROVE, contingent on execution/exact CI. Windows dev-fast footprint12/12 PASS0.02s, parser2/2 PASS0.00s, hygiene39/39 PASS5.09s. Receipts geometry-review-{footprint,parser,hygiene}.log and geometry-review-delta-verdict.txt in the handoff directory. Fresh committed-head CI pending; no deployment or speed/learning claim. Physical receipt consumption is currently the discrete-GPU EngineContext sampling branch; process-anonymous sampling retains its existing divided-cache contract.

@joelteply
joelteply marked this pull request as ready for review October 20, 2026 10:19
@joelteply
joelteply merged commit 50072d3 into canary Oct 20, 2026
8 of 9 checks passed
@joelteply
joelteply deleted the codex/engine-context-geometry branch October 20, 2026 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant