Skip to content

Improve prefix retention and cache-aware request routing - #1326

Merged
Gajesh2007 merged 10 commits into
masterfrom
fix/cache-prefix-performance
Oct 8, 2026
Merged

Gajesh2007 merged 10 commits into
masterfrom
fix/cache-prefix-performance

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Improve usable prefix reuse and reduce planning/routing overhead while preserving exact proofs, memory limits and the original first-content clock.

This refresh integrates current master through e3575b993, including #1212-1215, the persistent SSD write cap, compact candidate storage, native retirement and typical MTP acceptance. It preserves the earlier local coordinator-ownership port. Branch history is retained with a signed, non-force merge update.

Current head: cb7c94881015e1a1dd7c8428d1d6c441dc500c0c. GitHub reports MERGEABLE, all ten PR commits Verified, and all runnable automatic checks passing. The current-head automated review completed without new findings. Benchmark approval is intentionally left pending as requested; required human PR approval remains outstanding.

Before

flowchart TD
  A["Request"] --> B["plan_sync<br/>Compile + fixture copies"]
  B --> C["MatchBoundaries<br/>Every matching depth"]
  C --> D["First-content admission<br/>Heuristic token clock"]
  D -->|expired| X["Retryable 429"]
  D -->|admitted| E["prepareWriteJob<br/>Local-repeat priority"]
  E --> F["Whole-chain hashes"]
  F --> G["Fork misses useful prefix"]
  classDef work fill:#164e63,stroke:#67e8f9,color:#fff;
  classDef guard fill:#713f12,stroke:#fde047,color:#fff;
  classDef loss fill:#7f1d1d,stroke:#fca5a5,color:#fff;
  class A,B,C,E,F work;
  class D guard;
  class X,G loss;
Loading

After

flowchart TD
  A["Request"] --> B["LoadedContract<br/>Bounded prepared templates"]
  B --> C["cacheMatchGroups<br/>Complete compatible hints"]
  C --> D["FirstContentDeadlineForIdentity<br/>Original renderer clock"]
  D -->|expired| X["Bounded retry / 429"]
  D -->|admitted| E["Factory + donationWritePolicy<br/>Qualified capture + repeat priority"]
  E --> F["donationHashes<br/>Exact bounded address"]
  F --> G["Verified prefix restore"]
  classDef work fill:#164e63,stroke:#67e8f9,color:#fff;
  classDef guard fill:#713f12,stroke:#fde047,color:#fff;
  classDef result fill:#14532d,stroke:#86efac,color:#fff;
  class A,B,C,F work;
  class D,E,X guard;
  class G result;
Loading

Blue identifies processing, amber admission/qualification and green verified reuse. Both diagrams describe this PR's remaining change against current master; SDK #289's native historical retention is already inherited, not a new dependency delta here.

Implementation

  • LoadedContract keeps prepared templates within the bounded contract cache. Incremental preload captures the resident owner before dispatch and uses get_or_load_bounded; a removed active owner cannot create unaccounted replacement capacity. Production avoids fixture-only copies without changing exact tokens or proofs.
  • cacheMatchGroups preserves deepest compatible representatives, complete hints and holder counts with eight groups/provider and 256 tracked providers. Overflow resumes the original append-all path. Two immutable renderer strings survive compact candidate evaluation; 48-candidate arena chunks stay below the existing 32 KiB allocation boundary.
  • First-content deadline policy lives in the current api/inference, internal/inference/firstcontent, dispatch and attempt owners. Reservation binds the serving renderer's original-ingress cutoff; final unsent authorization rejects identity drift. Caller/account limits, alias behavior, response byte budgets, retries, independent hedge expiry and physical admission remain enforced.
  • Provider construction forwards both MTP acceptance and checkpoint partition settings. Exact Nemotron/Bonsai short artifact/class gates remain narrow; other unqualified families and serving-long repartition remain disabled. Fleet-covered endpoints can use repeat priority, while unique extensions remain novel. The persistent root-wide cap still charges serialized bytes across reopen; durable duplicates do not spend it.
  • donationHashes stops at the offered checkpoint while preserving addresses, endpoint rules and native-media identity. Existing fix(cache): preserve durable SSD reuse and bound shorter restores #1215 restore, eviction, file-coordination and tracked-retirement paths remain intact.

Dependencies And Compatibility

The final pins match current master: MLX-LM 3fd4944c3b3ee5cb45c5cbfac8805876332d3a29, MLX Swift 6923a80f624f5c91fbf456efe4e00e9698a72961, and both MLX sources cb77239be31b1df7f5db895226af55c39fc4f093. The SDK contains #289, #290 and #165; standalone SDK validation must bind to the provider's local Swift pin rather than the older manifest revision.

No API/protocol JSON-shape change, schema migration, configuration change or new release operation. Checked-in version constants remain 0.9.19 from master. No release tag, deployment, merge into master or protected-environment approval is performed by this refresh.

The unmerged #1216 first-sight policy and #1349 copied-holder revocation fix remain separate PRs; neither is silently included or claimed fixed here.

Refactor Pass

Dedicated post-validation subagents reviewed the refreshed implementation. Rust/docs/CI and Swift received explicit no-change assessments. The Go pass removed the single-field cache-group wrapper in favor of map[string][]int, preserving all grouping and overflow behavior. A separate dedicated pass reviewed the seven-file CPU-isolation follow-up after its RED/GREEN and focused validation, with no further changes warranted. Affected focused tests, builds, lint and documentation checks pass after the combined refactor.

Validation

Fresh local validation uses Go 1.26.8, Rust 1.88.0, Swift 6.4/Xcode 27A266a, the exact dependency tuple above and source-built Metal. These are new correctness checks, not transferred historical runtime populations or new performance measurements.

  • Rust: make prompt-sidecar-format prompt-sidecar-check prompt-sidecar-test prompt-sidecar-build with pinned MiMo metadata, 201 passes and three documented optional artifact/benchmark ignores. The active-preload regression fails with the old unbounded loader and passes with the merged ownership path.
  • Go: make coordinator-test, make coordinator-build, go vet ./coordinator/..., Linux/amd64 cross-build and golangci-lint v2.1.6 pass. The complete canonical test run uses fresh PostgreSQL 16.14 and passes 20 runner guards, 40 API shards and all unsharded packages; the Postgres store package executes 203 test/subtest passes without skips. Declared optional/helper tests still skip in that aggregate. Separate focused race gates and four actual sidecar/API healthy-subset/ninth-contract subcases pass without skips.
  • SDK: the corrected exact local-override build passes its 6/3/7/1 required retention gates and 21 acceptance/retirement methods, with zero skips/failures. The full suite passes 3,742 tests with 369 declared skips, zero failures/known issues. Compiled source paths, local override state and unchanged image/Metal digests are verified before and after execution. An earlier passing native-SwiftPM run used the older manifest dependency and is explicitly excluded from this tuple's validation.
  • Provider: final coverage-enabled canonical runner passes on cb7c94881 in 484.293 seconds: 4,902 framework-reported cases, 217 skipped tests, zero failures/known issues. One skipped-suite marker is not another testcase. All ten invocations complete, including both strict fresh CPU gates without skips. Compiled inputs prove the intended local dependency tuple, with no fallback Swift checkout paths; images remain unchanged through execution. Pinned CMake 3.31.12 builds the same source-matched Metal bytes. The earlier uninstrumented make provider and 156 focused methods also pass, but are recorded separately.
  • Tooling: 14 process-routing, 23 provider-workflow, 25 cache-provenance and 12 Metal-staging tests pass. check-release-version.sh confirms unchanged 0.9.19 parity.
  • Documentation: make docs-impact-check BASE=origin/master passes on the final committed 293-file delta; make docs-check passes for 367 tracked docs. Committed diff whitespace and signatures pass. Both published diagrams are visually verified on GitHub.

Current-head CI, system integration, and SDK 27 unsigned release preparation/qualification all pass. The hosted provider transcript confirms both new CPU suites execute and pass in separate processes, with no timeout or interruption. CodeQL, contribution-policy checks and preview checks also pass. The advisory threat-review wrapper is skipped, not a completed security review.

CPU Gate Isolation

The initial refreshed provider job failed three exact F32 assertions in SSDShorterNativeBlockRestoreTests.typedCapacityRestoresNativeState("plan"). The failure reproduced in a coverage-enabled process after the existing GPU native-store tests. Authenticated file and adopted bytes matched the actual donor exactly; a separate no-SSD control reproduced the cold-state drift across sequential CPU threads using the same frozen parameters.

Swift's task-local CPU selection does not change the native default-stream key used by MLX's per-thread compiled-function cache. A prior GPU trace can therefore affect a CPU recomputation after an executor hop. The fix gives SSDShorterNativeBlockRestoreTests and the new SSDNativeCheckpointOracleTests independent, mandatory fresh processes through the existing nonempty/no-skip wrapper. All original cold-state, offset, key/value and suffix bitwise assertions remain. New donor/file/adoption witnesses and same-thread/owned-thread no-SSD controls add coverage; there is no tolerance change, seed-only workaround, compile toggle or serving-policy change.

The ordered mixed-device reproducer remains RED. Repeated fresh CPU invocations are GREEN, including both restore methods/five cases and both oracle methods/ten cases. Process-routing regression tests reject failure, empty execution and both skip formats while proving later gates still run. Fresh cb7c94881 coverage-enabled local validation, hosted provider tests and system integration pass; the earlier failing c24c4ed4c attempt remains available rather than being relabeled as successful.

Historical Evidence

The original all-model qualification report, prefix qualification and live baseline and their evidence remain byte-for-byte unchanged.

Their A5/B7/provider populations, short-model TTFT/TPS gains and experimental 1,024-stripe results apply only to their recorded sources, kernels, artifacts and acceptance modes. They do not qualify this combined tuple or establish a future fleet cache-hit lift. Default-profile output failures, failed/unavailable model runs and zero qualified long-serving blocks remain documented; no gate is broadened to hide them.

The protected E2E Benchmarks run remains waiting for human approval, intentionally deferred by request. No new benchmark result or production performance lift is claimed. Human PR approval and any eventual release, version bump, signing/notarization, registration or deployment are separate authorized operations.

@Gajesh2007 Gajesh2007 added area:coordinator Coordinator (Go) area:provider Provider (Rust, runs on Apple Silicon) area:docs Documentation work specific to a component or feature labels Oct 3, 2026
@vercel

vercel Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 8, 2026 2:09am UTC
d-inference-console-ui-dev Ready Ready Preview Oct 8, 2026 2:09am UTC
d-inference-landing Ready Ready Preview Oct 8, 2026 2:09am UTC
darkbloom-status Ready Ready Preview Oct 8, 2026 2:09am UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 8, 2026 2:09am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T02:14:57.805920Z cb7c948 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head cb7c94881015 against base e3575b993cb5.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Review unavailable or invalid response; completed findings retained

LOW: Changelog describes publishing short repeated prefixes to the SSD cache, outside the T-041 per-donation gate

CHANGELOG.md:8 · T-041

The changelog says an aligned demanded boundary is now captured "below the normal solo stripe, so repeated short prefixes can be published for reuse". It also says repeated checkpoints get the reserved SSD write share on first local appearance. T-041 records the encrypted SSD tier as signed off only for donations whose whole-block prefix exceeds the model's adoption bound plus the 1,024-token benefit floor. T-041's detection_hint says loosening that gate widens the at-rest surface and needs a fresh SEC-035 review. If this code lets sub-threshold prefixes reach SSDPrefixCache.donate, more at-rest artifacts are written and the same-account TTFT oracle extends to short prefixes. Only the changelog was supplied, so the actual gate behaviour is unverified. Fix: confirm that the SSD donation guard still applies to demanded short captures, or document the exception and refresh the T-041/SEC-035 sign-off.

Raised by: anthropic/claude-sonnet-5.5

LOW: New public model-demand statistics disclosure surface is not covered by the threat model

CHANGELOG.md:608 · T-051

CHANGELOG.md line 608 describes publishing per-model hourly request and fulfillment aggregates on the Stats page, with CSV export and 24h, 7d and 30d histories. The listed controls are a one-hour publication delay, suppression of cohorts with fewer than 20 requests or 3 consumer accounts, and exclusion of suppressed hours from every resolution. The base threat model has no entry for public aggregate leakage of consumer activity. T-051 covers only profiler tables and admin exports. Risks to model: a consumer or competitor could use small cohorts, hour-boundary differencing between resolutions, or sybil accounts to infer or influence demand. Public outcome counts for capacity, timeout and error could also reveal fleet weaknesses. Fix: add a threat entry and assumptions for the public stats boundary, and verify the suppression and differencing logic in the code. This unit shows only the changelog text, so the implementation is not verified.

Raised by: anthropic/claude-sonnet-5.5

Scan incomplete: 2 file(s) could not be fully read as text. Binary, Git LFS and submodule changes require manual review.
Affected files: docs/reports/evidence/openrouter-cache-2026-10-03/cache-by-model.png, docs/reports/evidence/openrouter-cache-2026-10-03/throughput-by-input.png

Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging.

Coverage: 36/1105 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned.

Cost this run: $0.0000 reported, $0.0000 reserved with unknown cost; 0 paid request(s), 9 reused batch(es), 0 provider cache-hit tokens.

Saved findings and earlier report · Historical findings are not confirmed resolved.

Bedrock: 2 request(s), 123565 input / 2975 output tokens; 0 request(s) with unknown usage. OpenRouter backup used 0 time(s). Dollar amounts above cover OpenRouter only; AWS billing is reconciled separately.

@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

Please review latest signed head a10e4d6464bb822a551021b58f1135d46b43dd21. The follow-up only corrects measurement provenance and the verification fixture output-path instructions; production source and the fully tested compatible SDK cut are unchanged. Both published Before/After diagrams have been visually checked.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a10e4d6464

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/reference/ssd-kv-cache.md Resolved
@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

Please review the latest head e8ca1dcf9a51d5f6cd98fd201fb9e8f6d0eb6c33. The serving-renderer deadline finding and SSD documentation symbol are fixed and locally validated. In particular, check candidate-specific cutoff qualification, atomic reservation binding/final unsent handoff, expiry classification, and selected/hedged clocks. The full coordinator suite/build/vet and 103 top-level focused race tests pass; the unchanged native SDK/provider cuts retain their recorded qualification.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: e8ca1dcf9a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gajesh2007

Copy link
Copy Markdown
Member Author

Final preparation status for cb7c94881015e1a1dd7c8428d1d6c441dc500c0c:

  • Refreshed against master e3575b993 through signed, non-force updates, preserving the existing coordinator port and merged cache/SDK fixes. All conflicts are resolved; all ten PR commits are GitHub Verified.
  • Dedicated refactor passes completed. The cache-group wrapper was simplified; the other passes explicitly found no justified cleanup.
  • Reproduced the hosted native CPU failure, proved actual donor/SSD/adopted bytes were identical, and isolated the CPU suites from prior GPU compile-cache history. Every original cold-state and suffix bitwise assertion remains. Both mandatory fresh-process gates pass on the new hosted head.
  • All runnable automatic checks pass, including CI, system integration, and unsigned SDK 27 release preparation/qualification. Current-head automated review completed without new findings; follow-up snapshots show no unresolved threads.
  • Final local coverage-enabled provider run passes: 4,902 framework-reported cases, 217 skipped tests, zero failures or known issues. Source-matched SDK validation passes 3,742 tests with 369 declared skips, plus 38 separate non-skipping focused gates. Original historical performance evidence remains unchanged and is not relabeled as a new benchmark.
  • Documentation checks pass and both final published Before/After diagrams were visually verified on GitHub.

The protected benchmark run is intentionally left awaiting approval as requested. Required human PR approval remains outstanding. No release, version bump, deployment, protected-environment approval, or merge into master was performed.

@Gajesh2007
Gajesh2007 merged commit 3441ebb into master Oct 8, 2026
36 of 37 checks passed
davidtai added a commit that referenced this pull request Oct 8, 2026
…ation report

#1326 moved coordinator/registry/cache_match_groups.go to
coordinator/internal/registry/cachetracker/match_groups.go. The report
still linked the old path, so Docs Lint fails on master and on this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gajesh2007 pushed a commit that referenced this pull request Oct 9, 2026
…rce link (#1423)

The report added by #1326 links `../../coordinator/registry/cache_match_groups.go`.
That path has never existed on master: #1326 itself landed the file as
`coordinator/internal/registry/cachetracker/match_groups.go`, so the
frozen-record history lookup cannot verify the link either. Docs Lint
fails on master and on pull requests that do not already carry this line.

Point the link at the file in the commit that landed the report. The
replacement line is byte-identical to the one already carried by open
pull requests 1381, 1395, 1396 and 1418, so they merge without a
conflict on this line. Nothing else in the report changes.

Co-authored-by: jonathan308 <5055076+jonathan308@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

5 active deployments
benchmarks — cb7c9488 Deployed Oct 8, 2026 by Gajesh2007 via E2E Benchmarks #2453
Preview – d-inference — cb7c9488 Deployed Oct 8, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — cb7c9488 Deployed Oct 8, 2026 by vercel[bot]
Preview – d-inference-landing — cb7c9488 Deployed Oct 8, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — cb7c9488 Deployed Oct 8, 2026 by vercel[bot]
Preview – darkbloom-status — cb7c9488 Deployed Oct 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:coordinator Coordinator (Go) area:docs Documentation work specific to a component or feature area:provider Provider (Rust, runs on Apple Silicon)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants