Skip to content

KV pool: host tier for the core pool (5/8) - #1501

Merged
ashhart merged 10 commits into
ashhart:mainfrom
BlivionIaG:pr/kv-pool-host-tier
Nov 24, 2026
Merged

ashhart merged 10 commits into
ashhart:mainfrom
BlivionIaG:pr/kv-pool-host-tier

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Shared host K/V tier Core. Approved source is frozen at the unchanged commit below; no code, commit, dependency or draft-state change in this audit.

Checks on this head

  • Head commit: f0a7ee7545976a798f8e848bd854893939cedb0e.
  • Lean checker, same current upstream checker on base/head: head 763, baseline 763, 0 new; current upstream checker, zero findings. Current checker APIs were run externally because the immutable Core predates tools/pr_check.py; no tool/source was added to its tree. Inherited nonzero totals are not called a clean standalone lean-check exit.
  • Tests run, with command and pass/fail/skip counts: No new runtime suite in this audit: unchanged frozen source. Current exact-public-head CI is reported below; the current pinned preflight was executed. No earlier model result is re-labelled.
  • CI: 7 successful current-head checks; no source change or CI rerun requested.
  • Not run, and why: No CUDA execution authorization; the shared device lock and protected queues are untouched. No local Metal/model execution: Xcode licence remains unaccepted and was not bypassed. CPU subsets do not replace test/test-golden, device/model gates, or macOS dev-tools.

Receipt

  • Main against branch: No new exact-head device numbers. Land together with EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 off by default only after its device receipts and the maintainer release freeze. Core remains byte-for-byte/commit-for-commit unchanged.
  • Boxes it reaches: The original PR backend/model scope remains in the exact-head source and historical receipts; this audit exercised only Darwin27.2.0 arm64 CPU host paths. CUDA/Metal model reach is not newly qualified.
  • New switch? Default, accepted values, profile row: no new serving setting/default/profile activation in this review fix/restack. Original settings and accepted forms are in the exact-head docs/environment.md and platform/environment.zig; no experimental setting is newly enabled by this update.
  • Environment, commit/toolchain/machine/GPU/checkpoint: f0a7ee7545976a798f8e848bd854893939cedb0e; Zig0.17.0; Darwin27.2.0 arm64 CPU only. No GPU or checkpoint loaded for these checks; original checkpoint revisions remain source-bound in the recipes/receipts, not retagged.
  • Paths/platforms run versus unrun: host commands above only; No CUDA execution authorization; the shared device lock and protected queues are untouched. No local Metal/model execution: Xcode licence remains unaccepted and was not bypassed. CPU subsets do not replace test/test-golden, device/model gates, or macOS dev-tools.
  • Exactness, --alone --serial/token_sha versus drafts-off: Not measured on this exact head/device; host fake-target/fixture parity is not a model token-hash receipt.
  • Main against branch before asking for a maintainer machine run: Unavailable under the device/toolchain limits above; explicitly disclosed per CONTRIBUTING.md. No machine run or waiver requested.
  • Decode speed before/after: Not measured on this exact head; old-source timings below are historical only.
  • Prompt speed/cold TTFT before/after: Not measured on this exact head; no TTFT/ITL or prefill improvement claimed.
  • Licence of new weights/drafter: n/a — no new weights or drafter distributed by this Core/app/control-vector change.

Remaining maintainer requests

Land together with #1522 off by default only after its device receipts and the maintainer release freeze. Core remains byte-for-byte/commit-for-commit unchanged.

Checklist

  • Title/description, head and stack agree; older results remain source-bound.

  • Every new/restored test has a failing-before runtime receipt across all reached platforms. Host evidence is above; missing device gates are not waived.

  • No newly added overlong/multiline source comments, measurements or review history; inherited findings are reported above.

  • Complete publication trees/outgoing histories reviewed for public noreply identity, tool trailers and privacy; synthetic detector fixtures and mandatory third-party public contacts are not live secrets. No package/binary upload proposed.

  • All inference-path/lane-round gates qualified on this head.

  • Drafted=plain, restored=fresh, concurrent=solo on required devices/settings.

  • Required precision/reference evidence on this exact head complete.

  • Decode/prompt no slower than Main at the required widths, greedy and sampled.

Historical source-bound notes — not current-head qualification

Earlier commands/measurements retain their original commit/binary scope. Any earlier readiness or provenance claim is superseded by the open gates above.

Current maintainer follow-up — Unreleased placement and credit

  • Exact head: f0a7ee7545976a798f8e848bd854893939cedb0e, still on the agreed upstream qualification pin 116a0d4ca41c50cd7c5c632a24bc8411d61a0220. Addresses the latest review: the (#1501) entry is under ## Unreleased, not the released 1.2.3 section, and ends with Thanks to @BlivionIaG. Host-tier issue: KV pool: host-RAM tier #1511.
  • This follow-up changes only CHANGELOG.md. The approved tier implementation, tests and pool hook are byte-identical to b55d2620315fee31b705860e2b7a83703a7d80d0; no API or runtime arithmetic changed.
  • The real non-test host consumer passed on this exact head: five invalid geometries refuse before allocation; dirty canonical-read/unpin refusals, real row flush, eviction, stale-ticket refusal, refill bytes and final pool/frame ownership were checked; the debug allocator finished clean.
  • A non-mutating merge-tree simulation against observed main 18ecc42d6b3be5c18a26af9ff53acbd1e3922c62 succeeded and placed the entry exactly once under Unreleased, with the requested credit. This is integration evidence, not a merge action or an advance of the agreed qualification pin.
  • The inherited copy in EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 is corrected at documentation-only head 5c73011c52a1cbc72622b06aa4c2547e7ae0ff97. Landing remains paired with EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522, off by default, after EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) #1441–EXL3 Flash Next: KV pages from the core pool (4/8) #1444; its device/client gate and already-existing runtime-entry integration conflicts are not claimed cleared by this documentation fix.
  • All seven automatic checks passed for this exact head: No GPU and Zig format. The fresh review readback has no unresolved threads; earlier-head checks remain historical. No manual CI action or qualification waiver was used.

Prior source-pinned checkpoints — preserved, not new-head qualification

Current maintainer follow-up — changelog reference only

  • Exact head: b55d2620315fee31b705860e2b7a83703a7d80d0, still based on the agreed upstream pin 116a0d4ca41c50cd7c5c632a24bc8411d61a0220. Addresses the latest #1501 review by adding (#1501) to the existing CHANGELOG entry; no implementation or API change.
  • kv_tier.zig and kv_tier_test.zig are byte-identical to approved/rebased 5a504efe419dcb3327f766f5c4aea1d6a3b6c298. The real non-test host consumer was run again against this exact head and passed its geometry refusals, dirty-row flush/eviction/refill, stale-ticket and final ownership checks with a clean allocator.
  • Earlier 50/50 and 60/60 test results and seven successful automatic CI checks below remain pinned to 5a504e; they are not re-labelled as new-head CI. All seven automatic CI checks have now also completed successfully for this exact documentation-only head; no manual rerun or dispatch was used.
  • EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 already contains the correctly numbered copy and the approved Core API. Its exact head remains 63bebd6b272c3413da7a745177b8ecee1630be4b; this standalone documentation change does not invalidate its outstanding device-receipt pin. Landing remains paired with EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522, off by default, after EXL3 Flash Next on CUDA: one rank, offloaded experts, sm_120 gate (1/8) #1441–EXL3 Flash Next: KV pages from the core pool (4/8) #1444 as requested. No merge or qualification waiver is claimed.

The following checkpoints and original PR text are preserved as historical, source-pinned evidence.

Current approved-core rebase checkpoint — pinned upstream 116a0d4

  • Exact head: 5a504efe419dcb3327f766f5c4aea1d6a3b6c298; base 116a0d4ca41c50cd7c5c632a24bc8411d61a0220. This addresses the requested freed field hunk rebase onto the agreed qualification pin; it does not claim coverage of later moving main.
  • The approved two-commit host-tier implementation is retained. The range-diff changes only the pool field's upstream context (ledger now sits beside it); the tier implementation/API and its tests have exactly the same Git blobs as approved head 374d31275faf8cd9113b084b0fa1d560980c3b29.
  • Exact-head standalone host-tier/imported-pool tests: 50/50 passed. The repository's real module-wired test-kv-pool target also passed 5/5 steps, 60/60 tests, including ledger and lane-host admission coverage. An initial direct invocation of a module-wired test lacked its imports; the correct existing build target above passed, and both receipts are retained.
  • A real non-test host consumer passed five invalid constructor geometries before allocation, dirty canonical-read/unpin refusals, actual row flush, eviction, stale-ticket rejection, refill byte checks and final page/frame/promise ownership audit; its debug allocator finished clean. No model or GPU execution is claimed for this unbound core layer.
  • Mandatory format and whitespace checks passed. The unchanged lean checker has 425 inherited baseline/head findings, zero new; raw checker exit 1 remains disclosed. Both outgoing commits retain canonical public author/committer identity with no tool-attribution trailers.
  • Fresh complete ownership inventory: 188 open PRs / 9,395 file rows; 153 actual comparisons across 51 foreign overlapping exact heads, against pinned main, approved old core and this candidate, introduce zero conflict paths. ATC separately reports incomplete coverage (myPullRequestsLimit, pullFilesLimit); it is not global clearance.
  • Standalone host/API gate and all seven automatic current-head CI checks passed: No GPU, Zig format. This generic core receipt is not model-serving proof or a merge action. EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 now incorporates this exact rebased core and still must complete enabled-tier device/client qualification; the pair remains off by default. No approved API, runtime arithmetic, workflow or performance optimization changed, and no manual CI action was taken.

Historical approved body, preserved verbatim

Everything below retains its original source pins and dates; its earlier CI/test statements do not qualify the new head above. The performance-deferral note remains verbatim exactly once.

What this changes

Adds the independent optional host-resident core K/V tier with constructor geometry validation. The approved implementation and tests are preserved through this ancestry-only rebase.

Standalone core host/API gate passed; the full EXL3 integration gate remains pending on #1522. This is the authorized compliance-only rebase/fix pass, not the separate performance/elastic branch.

Checks on this head

  • Head commit: 374d31275faf8cd9113b084b0fa1d560980c3b29; base 8094ec962ef03fb43bb879c2dde6e71869869e82. Parent scope above distinguishes inherited stack files from this slice.
  • Lean checker: the same tools/zig/lean_check.py on base/head and the actual tools/zig/lean_new.py comparator: 425 inherited / 425 inherited, 0 new. Raw checker exits remain 1; delta comparator exits 0.
  • Checks run: zig fmt --check build.zig zig passes on this exact prefix; git diff --check passes. All outgoing authors/committers use the approved public noreply identity; no co-author trailers or newly added private host/user paths were found.
  • Tests run on this head: zig test zig/src/core/kv_tier.zig -lc —49 passed,0 failed,0 skipped. zig run zig/src/core/compliance_tier_runtime.zig -lc —real consumer PASS, dirty/refill/ticket/ownership behavior checked; temporary source removed after archiving. All7 current-head portability/style/release-path/client CI checks passed; exact published SHA read back.
  • CI: fresh checks for this pushed head must be read and classified; earlier-head CI is not counted.
  • Not run: standalone model/device measurement is not applicable to this unbound core layer. The actual backend/device/client gate remains required on EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522.

Receipt

This is the independent generic core host-tier layer, not a standalone model-serving backend. Its maintainer-approved gate is the pool/Tier host API; the enabled-tier CUDA/model integration gate remains on #1522 and is not waived.

  • Environment: base 8094ec962ef03fb43bb879c2dde6e71869869e82, head 374d31275faf8cd9113b084b0fa1d560980c3b29, Zig0.17.0, macOS arm64 host. GPU/checkpoint/drafter: n/a for this standalone in-memory core layer; EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 must bind those in its device receipt.
  • Paths/platforms: pool/Tier construction, page/frame promises, dirty ownership, canonical rows, eviction, generations and lease release. Native host API exercised here; all7 current-head CI checks passed on Linux, Windows and the macOS developer-tool compile path. No CUDA/Metal/HIP model claim is made by this core receipt.
  • Exactness: 49/49 host tests, zero failed/skipped, plus a real compiled consumer that refuses dirty canonical reads/unpin, flushes and evicts/refills actual row bytes, rejects a stale ticket and finishes with zero leaked promises, pins or allocator blocks. The earlier55-test receipt below stays bound to its earlier source; upstream test inventory changes are not repinned.
  • Decode speed: n/a for the unbound core library; matched enabled/disabled host-tier and default-path model measurements remain required in EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522.
  • Prompt speed: n/a for the unbound core library; EXL3 Flash Next: host-resident K/V on the tier (6/8) #1522 retains cold-prefill, resume and concurrency requirements.
  • Licence: n/a; no weights or drafter are introduced by this pool/Tier layer.

The inference checklist is not a claim that this core-only PR served a model; the full chain's integration requirements remain explicitly pending.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled.
  • New lean findings are zero; inherited raw-checker failures are named, not called clean.
  • Complete required platform/model gates and source-scoped raw receipts attached.

The following deferral is retained verbatim as the project’s scope policy, not as a qualification claim for this pending head.

Performance work is deferred on purpose

This chain lands the architecture first: a working, bit-exact base on upstream main (TP=2 equals TP=1, drafted equals plain, prompt rows equal decode rows, NVFP4 bytes unchanged). The performance optimizations of the origin draft (#1113) are not all ported here. We ported only the ones that are exact and cheap; the rest follow in separate PRs once this base is merged, each with its own byte-equality receipt, so nothing in this chain has to be rewritten.

Known gaps against #1113 on the same hardware (numbers in the tables below): deep prefill is slower than #1113's non-exact version, drafted decode and the expert-line count at 2 streams are below it, and the two-stream prose case with drafts on is slower than plain. Candidates for the follow-ups: tile tuning, overlapping the partial all-reduce with attention, trimming the deep-prefill chunk buffers, a cheaper draft probe.

Historical receipt sections — original head 45623b9; not qualification of 374d312

These preserved sections predate this ref update. Any use of “current head” inside them refers to the original head named above, and any integrated-descendant receipt retains its separately stated source. None is relabelled onto the updated candidate.

Receipt

  • Environment: host-only change; no GPU, checkpoint or model involved. Current-head checks below used macOS and Zig 0.17.0. Historical head 433e866f9b94b15097d1719a18c381ea4e1fba69, over pinned main d4b48fc497, passed 12/12 scoped steps and 53/53 tests, including the native CUDA cross-check; its fmt and lean checks passed, with 425 inherited lean findings and zero new. All seven expected GitHub checks succeeded on that earlier head, including Windows and macOS devtools (run); those are not current-head CI receipts.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: n/a, nothing serves tokens through the tier in this PR; the unit tests check host pages, frame residency and generations against the pool.
  • Decode speed before and after, from tools/bench_openai.py: n/a, the tier is off by default and nothing calls it in this PR.
  • Prompt speed before and after: n/a, the change cannot reach prompt processing.
  • Tests run: exact current head 45623b99749103ecc181de35a20b5c29eb711adb passed test-kv-pool: 5/5 build steps and 55/55 tests. An independent non-test API executable also rejected all five invalid geometries with no allocation capacity, then exercised actual reserve, pin, eviction, stale-ticket rejection and refill. The native CUDA cross-check above belongs to the earlier head and was not repeated for this entry.
  • Not run, and why: no GPU run, because the PR touches no device code; Metal M1 to M5, HIP, XPU and the Windows runtime were not run.
  • Kernel contract: this PR adds no kernels.

Constructor review follow-up — 2026-11-04

Addressed the constructor request in 45623b99749103ecc181de35a20b5c29eb711adb:

  • Tier.init refuses zero page bytes, a host length not divisible by page bytes, zero frames and zero logical pages before allocator access.
  • Negative boundaries include both sides of a page boundary with an allocator that refuses its first allocation; the one-byte/one-page/one-frame tier remains valid.
  • Exact-head zig build test-kv-pool --summary all: 5/5 build steps; 55/55 tests passed.
  • Separate real API smoke: all five invalid geometries returned BadTierGeometry with no allocation available; the smallest valid tier was leased, pinned, unpinned and fully released.
  • zig fmt --check passed on both changed Zig files.

These are core-library receipts, not a CUDA/model qualification claim. The host-tier backend remains paired with #1522 and off by default; older device receipts retain their original source identities.

@ashhart

ashhart commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. This is the tier we hoped for: generic, beside the pool rather than a second pager, with the pool still the only owner of page ids. The random loop, the lockstep digest and the mutants make a good test suite.

It doesn't need slices 1 to 4. The last commit cherry-picks cleanly onto main by itself, and there zig fmt, the lean check (no new findings) and test-kv-pool pass. As we suggested on #1444, please give it its own issue, and rebase this PR onto main with only that commit.

Before it leaves draft:

  1. A failed fill leaves its misses mapped. fill unpins on error (zig/src/core/kv_tier.zig:156), but each miss's mapping (:141-142) stays. The family got an error, so it copied nothing. The next pin of that page is then a hit over rows that were never copied in, and kv_tier_test.zig:110 asserts exactly that. Please unmap the frames a failed call mapped, moving their generation on. Add a test that fails today: a failed fill, then the same pages pinned through the rig, with each frame checked against host_page.
  2. markDirty (:212) needs only a frame, so a dirty frame can be unpinned. victim skips it (:332), and a lease inside its promise can then get FrameMemory, which the frame promise is meant to rule out. Please require a pin by the lease. Have finish apply the dirty rule to every page it pinned, not only to its own table (:257).

No family uses the tier yet, so we'd land it together with its first user, off by default: slice 6, as #1419 lists it. Device cells can then check tokens against the device-only pool under eviction, and speed.

@ashhart

ashhart commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. The latest push looks like it covers both points: a failed fill now
unmaps its misses and moves their generation on, with a test that re-pins through the
rig and checks the host rows, and markDirty now needs a pin by the lease, with finish
checking every page it pinned. The branch also looks like it is down to the single
commit on main. Thank you.

One small thing: failedFillReads takes a fault but only runs with none. A mutant
that skips the undo and goes red would match the rest of the suite.

As before, we'd land this together with its first user, slice 6, off by default. Could
you link the issue for the tier here once it's open?

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart. Both points are in the latest push (cdd541bd8, rebased onto current main, still the single commit): failedFillReads now also runs with a keep_failed_miss fault that skips the undo of a failed batch's misses, and the test expects it to read stale frames and go red. The tier issue is #1511, also linked in the description. Checks are green.

Understood on landing it together with slice 6 (#1522), off by default.

@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. Every earlier ask is answered in the one commit. The pool change is only an optional freed hook (null by default) at the three free-stack pushes, so no other model changes and no family opens a tier yet. It lands together with its first user, #1522, off by default as agreed. Two small asks first: (1) Tier.init should refuse page_bytes of 0, a host length that isn't a multiple of page_bytes, and zero frame or page counts, before it allocates; (2) trim the body to this change, since its TP, device and speed receipts come from the larger chain on other heads.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks for the rebase @BlivionIaG; the body reads as this change alone now, so that ask is done. One small thing left from our last review: Tier.init (kv_tier.zig:57-58) still divides host.len by page_bytes without checking it. Please refuse a page_bytes of 0, a host length that isn't a multiple of page_bytes, and zero frames or pages before anything is allocated, with a test for each. After that this is ready, and it lands together with #1522.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Update on the disk-backed Linux host run: it finished with a build summary of 21,073 passed, 137 skipped, 2 failed. Both failures are the same cli_config_test case in two host targets: the fixture file was group-writable under this machine’s default umask, and the config security check rejected it. The retired-page test was not listed as failing. This is not a full-suite pass. I have started the requested suite again with umask 022 and an explicitly preserved exit status; the earlier focused ReleaseSafe result remains 95/95.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Update: the isolated ab843abb87389e0d6bac258b1c2e08ae60734d4b checkout with the one-line id != none guard passed zig build -j8 -Dfixed-cpu test-host on Linux x86-64 with Zig 0.17.0 and umask 022; the captured process exit status is 0. The log contains skipped optional tokenizer/checkpoint tests and diagnostic hash-difference output, so this is the host build gate’s exit result, not a claim that every optional fixture ran or that all diagnostic hashes agree. The focused ReleaseSafe retired-page regression separately passed 95/95. Full logs and exit status retained. I did not push to your branch; Windows and landing-train integration remain for their owners.

@AIFlowML

Copy link
Copy Markdown
Contributor

I reproduced the train failure on macOS arm64, in a clean trial merge of ab843abb into 9ba855b3. With Zig 0.17.0 on M5 Max, zig build test-kv-pool -Doptimize=ReleaseSafe -Dcpu=apple_m1 -j5 --summary all gave 123 passes and one abort: the retired pinned-frame test indexed dirty[4294967295]. Applying the same id != none guard the author tested on Linux gave 124/124. The original trial merge was textually clean.

One integration detail for the paired landing: git merge-base --is-ancestor ab843abb a8126820 returns 1. The public #1522 head does not contain this exact #1501 head, so carry the guard into the combined tree and rerun the retired-frame check there. My run covers the CPU pool test only.

Igor Lessio - AIFLOW LABS

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Pushed the sentinel guard as 70dc497298147850164c4cad75543352f3a2bdc0 on top of ab843abb87389e0d6bac258b1c2e08ae60734d4b. The Linux Zig 0.17.0 run of this exact source passed zig build -j8 -Dfixed-cpu test-host with umask 022 (exit 0), and the focused ReleaseSafe test passed 95/95, including the retired pinned-frame regression. Optional fixtures skipped by the host suite and the diagnostic output are described in my earlier receipt. The paired #1522 integration still needs to carry this fix; I have not claimed Windows or integrated-tree coverage.

@AIFlowML

Copy link
Copy Markdown
Contributor

The published 70dc4972 sentinel fix trial-merges cleanly into d21617008. On M5 Max with Zig 0.17.0, the current pool and safety suites passed all 188 checks with no local source edits.

zig build test-kv-pool test-kv-safety-host -Dcpu=apple_m1 \
  -Doptimize=ReleaseSafe -j2 --summary all

That confirms the revised parent on current main. The published #1522 child still needs to carry 70dc4972 in its restack.

Igor Lessio - AIFLOW LABS

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thanks @AIFlowML. The retired-marker guard (id != none and ... before indexing dirty) is on 70dc4972 with its regression test (kv_pool_freed_test.zig), which aborted at kv_tier.zig:308 before. While merging main the host loader suite also showed that test-load-prefetch-host fails on this branch but not on main: checkpoint_read_ahead.packInner used toOwnedSlice, whose allocation is not counted when the backing allocator shrinks in place, so the test's fail-index run took a different path from its baseline. It now allocates the span slice exactly (gpa.dupe), so the count no longer depends on remap.

Head 09a3445335 (contains main at 6e44558d72): test-gradient-serving test-kv-pool test-kv-safety-host test-load-prefetch-host 202 of 202 tests; fmt clean; lean 0 new; pr_check 0 errors. CI on this head was still running when I posted.

@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. One question before a model family uses this tier: does a reader keep its pin until its device work has finished? If so, evicting a clean retired page after its last unpin is safe. If a reader can unpin earlier, eviction also needs to skip pages whose readers have not settled. A short comment stating the rule would settle it.

Two small diagnostic fixes would also help. audit treats a retired page still waiting for its readers as broken; that state comes from retirement support merged after your original work, so we can fix that part. digest also leaves out dirty state, so two ranks can match even when one of them cannot evict a page.

  • Synthena

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Yes: a reader keeps its pin until its device work ends, and a pinned frame is never a victim (only unpinned, clean frames are: pin and victim in kv_tier.zig now state exactly that). So evicting a clean retired page after its last unpin is safe, and no extra check on unsettled readers is needed.

The digest now hashes the dirty flags (h.update(sliceAsBytes(t.dirty))), so two ranks with different unflushed writes no longer match. zig/src/core/kv_tier_digest_test.zig shows the ranks agreeing while both have flushed, differing as soon as one holds an unflushed page it cannot evict, and agreeing again after both sync. It fails on the old digest (zig build test-kv-pool: 125/126 tests passed (1 failed) with the digest line removed) and passes now. audit we leave to you, as you offered.

The branch is also merged onto current main (04f1a1c125; the only conflict was CHANGELOG.md, resolved by keeping your list and adding the #1501 bullet). test-kv-pool and test-kv-safety-host pass, lean is 165 vs 165 with none new, and tools/pr_check.py --base ea37382cb1 --pr 1501 reports 0 errors and 0 warnings. CI is queued on the new head.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. That settles both:

  • Pins: the rule is now stated where it applies. A reader holds its pin until its device work ends, and victim only takes unpinned frames with no unflushed rows, so evicting a clean retired page after its last unpin is safe.
  • Digest: it hashes the dirty flags now. The new test shows two ranks agreeing while both have flushed, differing while either holds an unflushed page, and agreeing again after both sync.

The audit fix for retired pages still waiting on readers is ours, as we offered. Nothing more is needed from you: this goes into our landing queue now.

  • Synthena

BlivionIaG and others added 10 commits November 24, 2026 15:14
A Tier beside the Pool for families whose pages are cached on the device from a host store. The pool stays the only
owner of page ids and of what is promised; the tier adds a second currency (device frames a stream may pin at once),
the page-to-frame mapping, an LRU order, pins for the frames a call reads, a dirty flag so a frame is dropped only
once its rows reached the host store, and a generation per frame so a table written before a frame was recycled is
told from a current one. A stream can also be lent frames for its life, mapped to no page, for a family that manages
them itself. The pool tells the tier when a page loses its last holder. It moves no bytes and uses no device API: the
family copies what a miss names, and a snapshot reads canonical rows from the host store.

Tests: reservation conservation in both currencies, eviction order, pin rules, lent frames, generation safety,
canonical rows, a randomised serving loop that audits the mapping and checks every row read against the last write,
two ranks in lockstep (and a step or a lent count taken by one rank caught by the digest), and mutants (no generation,
no pin rule, dirty frames unpinned) that the checks fail on.

A failed batch unmaps the misses it mapped (their generation moves on), a page is marked dirty only under a pin
of the marking lease, a stream cannot end while it holds the last pin of a dirty page, and a family can lend a run of
consecutive frames (lendRun).
Avoid indexing tier state with the pool sentinel left by a retired page.
ArrayList.toOwnedSlice remaps in place when it can, so the pack reader's allocation count varied with allocator state and checkAllAllocationFailures reported NondeterministicMemoryUsage. Duplicate the slice so the count is fixed.
- a rank holding an unflushed page it cannot evict no longer matches one that flushed, so the open check sees it
@ashhart
ashhart force-pushed the pr/kv-pool-host-tier branch from 04f1a1c to 85c4167 Compare November 24, 2026 15:14
@ashhart
ashhart merged commit bd181ec into ashhart:main Nov 24, 2026
12 checks passed
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @BlivionIaG. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants