Skip to content

Preserve prefix-cache reuse under resource pressure - #298

Merged
lukealonso merged 3 commits into
mainfrom
martin/prefix-cache-restore-pressure
Nov 15, 2026
Merged

lukealonso merged 3 commits into
mainfrom
martin/prefix-cache-restore-pressure

Conversation

@voipmonitor

@voipmonitor voipmonitor commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Under memory pressure, Helios recomputed long prompts whose prefix was still cached. A Kimi K3.1 workload on a 16-GPU RTX PRO 6000 host (agent sessions with 200k–580k-token contexts plus parallel subagents) showed three causes. All are in shared scheduler and cache policy, not in any model recipe.

Causes and fixes

Cause Fix
A host restore was abandoned on any Capacity error. The restore needs one snapshot row more than a plain admission. When that row's backing was only temporarily held, admission dropped the host hit and recomputed the whole prompt. The request waits while running requests, inbound tickets, checkpoint pins or retirement fences can still release resources, and for as long as wait plus estimated transfer stay under half the estimated prefill saved. On expiry it recomputes once, as before.
Recency came from admission time. A request that ran for minutes finished ranked below everything admitted meanwhile, so its conversation was evicted first, just before the client continued. Successful completion refreshes the published terminal checkpoint and its direct parent, usually the prompt end. Without a terminal it refreshes the retained prefix. Preemption, execution errors and cancellation before inference do not refresh.
Reuse refreshed every ancestor. A long conversation kept the snapshot rows of all its earlier turns ranked as recent. New conversations' captures were then skipped for storage. PrefixCheckpointCache::touch refreshes only the selected checkpoint. Older single-child ancestors can compact under pressure: their row is freed, their pages move to the descendant. Branch points and direct pins stay protected.

The three commits are one change per row, in that order. The third narrows the completion refresh of the second from the whole chain to the terminal and its parent.

Observed on the reported workload

  • A 201,543-token prefix was found in host memory with an estimated transfer of 0.38 s against an estimated prefill of 682 s. Admission rejected it for capacity twice and recomputed for 161 s and 133 s; the third request restored it.
  • Follow-up requests resumed at the previous prompt end about as often as at the terminal (41–51% against 44–52%), which is why completion also refreshes the parent.
  • With only the first two fixes, snapshot rows held about 87% of KV page backing (1,516 of 1,737 pages for about 70 checkpoints). New subagents then lost 46k tokens per turn.

Scope and limits

  • Core formats, graph contracts and sampling are unchanged; no core re-export is needed. The policy applies to the Kimi, DeepSeek, GLM and Qwen cache contracts alike.
  • Capture budgets and role ordering are unchanged. There is no row cap and no proactive thinning.
  • The wait bound depends on the measured prefill rate and is not a latency guarantee.
  • Qualified by CPU scheduler and worker tests only. No GPU execution or serving benchmark was run; the follow-up is recorded in docs/TODO.txt.

Validation

Linux x86_64, Rust 1.95.0, GCC 13.3, protoc 30.2, pinned template fixtures, CUDA devices masked, cap_dac_override and cap_dac_read_search dropped.

Check Result
New regressions without the fixes Fail: a capacity-blocked host hit recomputes; completion order does not set recency; ancestor recency blocks captures under slot and page pressure; the terminal's parent keeps its admission epoch.
Helios library, server,runtime-core, serial 1,408 passed, 0 failed, 26 ignored
Same patch on 3e9a95d3 (18 fewer tests) 1,390 passed, 0 failed, 26 ignored
Lifecycle models (first commit) 9 configurations and 361,262 observed Rust transitions pass; all 8 TLA+ and 14 Rust mutations detected

The 26 ignored tests need CUDA devices, external checkpoints or manual benchmarks. One parallel run failed the unchanged core::cache::tests::store_slice_streams_multi_block_payloads_and_holds_its_guard; it passes alone and in the serial suite, and this PR does not touch payload-cache code.

Reproduce
python3 tests/frontend/prepare_templates.py \
  --output /tmp/hyperflare-prefix-templates \
  --recipe gemma4 --recipe glm53 --recipe mimo_v2 \
  --recipe nemotron_h --recipe qwen38 --recipe step5
export FLARE_TEST_TEMPLATE_DIR=/tmp/hyperflare-prefix-templates
export PROTOC=protoc CC=gcc-13 CXX=g++-13
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/gcc-13
export CARGO_TARGET_DIR=/tmp/hyperflare-prefix-target CARGO_BUILD_JOBS=8
export CUDA_VISIBLE_DEVICES=''
capsh --drop=cap_dac_override,cap_dac_read_search -- -c \
  'cargo test --locked --manifest-path helios/Cargo.toml --features server,runtime-core --lib -- --test-threads=1'

Template preparation needs huggingface_hub; the locked-memory limit must be at least 64 MiB. An unprivileged process can run the Cargo command without capsh. Lifecycle commands are in verification/helios-lifecycle/README.md.

Includes the commits first opened as #299. No measurement files are included.

🤖 Generated with Claude Code

Host restore admission discarded worthwhile cache hits when snapshot backing
was temporarily held by requests or transfers, while checkpoint recency
followed admission order even after a long request completed. Snapshot
aliases and fenced ownership make capacity failures potentially transient.

Defer restores within the existing transfer-versus-prefill cost budget and
wake admissions on expiry or resource release, including inbound completion
with no remaining waiters. Keep pooled lookup state across retries and reset
wait accounting on admission. Refresh retained checkpoint chains after
successful completion or cancellation with inference progress, excluding
preemption and execution errors. Core formats and graph contracts remain
compatible without re-export.

The implemented policy is expected to avoid unnecessary prefills and retain
recently completed conversations. CPU regressions qualify these decisions;
GPU serving and performance remain unqualified and are tracked in docs/TODO.txt.

Validation: tests for restore deferral and completion recency fail on base
7006928. The Helios library suite with server,runtime-core passes 1402
tests with 26 ignored.
The patch applies cleanly to 3e9a95d3, whose library suite passes 1384 tests
with 26 ignored using the same template fixtures. Ignored cases require
CUDA, checkpoint/payload inputs, or manual CPU benchmarking.
Nine bounded lifecycle model configurations and 361262 observed Rust
transitions pass. Mutation checks detect all 8 TLA+ and 14 Rust faults,
and restored-source checks pass. These checks assume truthful executor
completion and drain signals and do not qualify CUDA execution.

Signed-off-by: Martin Vit <martin@voipmonitor.org>
Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
Reusing or completing a long prefix refreshed every ancestor's eviction
rank, protecting unused continuation rows that compete with KV pages and
other conversations' captures. Descendants need ancestor pages, but only
the selected checkpoint's snapshot; compaction can preserve those pages.

Make PrefixCheckpointCache::touch update only the selected checkpoint's
monotonic demand epoch. Reuse, promotion, duplicate publication, and
completion use that rule. Older unpinned single-child rows can be compacted
without changing descendant pages, branch pins, or retirement fences.
Role ordering and capture budgets remain unchanged. Unused prompt and
message rows can age even when a descendant finishes. Core formats and
prepared graphs remain compatible without re-export.

The implemented change is expected to reduce storage skips and retain
more independently used prefixes under snapshot pressure. CPU regressions
qualify recency and ownership behavior; native serving performance remains
unqualified and is tracked in docs/TODO.txt.

Five focused checks fail with PR #298's implementation and pass with this
change. They cover slot and aliased-page pressure, admission, duplicate
publication, promotion, and completion recency. Compaction preserves pages
and fences at 64-, 128-, 256-, and 2048-token page geometries. The Helios
server,runtime-core CPU suite passes 1405 tests with 26 ignored when run
serially. A parallel run had one failure in unchanged payload-collection
code; that test passes in isolation and in the serial suite. Ignored cases
need CUDA, external checkpoint/payload fixtures, or manual CPU benchmarks.

The patch applies to 3e9a95d3 plus PR #298; that base passes 1387 library
tests with 26 ignored using the same serial CPU configuration.

Signed-off-by: Martin Vit <martin@voipmonitor.org>
Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
A long request can finish with a recent terminal snapshot but a prompt
snapshot still ranked by admission time. Follow-ups that branch or rewrite
generated history can then lose the prompt snapshot under pressure. The
terminal's direct parent provides a bounded second resume point; immutable
checkpoint sharing makes its usefulness independent of which request
captured or restored it.

Refresh the published terminal and its actual cached parent with the same
completion epoch. Duplicate publication follows the retained terminal's
parent link, which can differ from the completing request's prefix. Stop
at that parent so earlier ancestors keep aging. Preemption and execution
errors still suppress completion refresh, and completion without a terminal
or cancellation after progress still refreshes only the retained prefix.
Core formats, capture budgets, and resource lifetime rules remain compatible.

The implemented policy is expected to retain useful prompt boundaries after
long responses without protecting entire checkpoint chains. CPU tests
qualify the retention decisions; live serving improvements remain unmeasured.

Three regressions fail on 8999ad1 and pass with this change: interleaved
request completion, duplicate publication, and a restored parent checkpoint.
Tests also preserve grandparent compaction and page order, preemption epochs,
and client-stop fallback behavior. The Helios library suite with
server,runtime-core and pinned templates passes 1408 tests in serial CPU
execution, with 26 ignored CUDA, external-fixture, or manual-benchmark cases.
No GPU execution or service benchmark was performed.

The combined patch applies to 3e9a95d3 plus PR #298 and passes 1390 library
tests with 26 ignored using the same serial CPU configuration.

Signed-off-by: Martin Vit <martin@voipmonitor.org>
Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
@lukealonso
lukealonso merged commit 29192ef into main Nov 15, 2026
6 of 10 checks passed
FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 1, 2026
Why

`PrefixCheckpointCache::eviction_candidate_within_budget` previously ordered
removable checkpoints solely by `(RetentionRank { use_epoch, role,
consumed_tokens }, id)` (NVIDIA#568). Because `RequestScheduler::retire` refreshes
`use_epoch` via `cache.touch` on every normal completion (NVIDIA#298, NVIDIA#416), one-shot
cold prefills with zero prefix reuse finished at the most-recently-used end of
the cache ahead of idle multi-turn sessions waiting between turns. Under KV page
pressure, `evict` discarded actively reused multi-turn checkpoints before dead
one-shot leaves.

What

- `helios/src/cache.rs` (`+123/-22`, `101` net LOC incl. test-only stats
  invariant): Track cross-request reuse state (`reused`,
  `reused_at_evicted_pages`, `reused_at_evicted_nodes`) on `Checkpoint`, plus
  `ready_tail_pages`, `evicted_pages`, and `evicted_checkpoints` on
  `PrefixCheckpointCache` (counting both retired ready leaves in `retire_leaf`
  and compacted ready ancestors in `compact_ancestor`).
- Add `PrefixCheckpointCache::touch_hit` for genuine cross-request prefix reuse
  without promoting creator-completion `touch` refreshes. Duplicate publications
  (`PublishResult::Existing`), fresh admission hits (`accounting.is_none()`),
  and host-store restores with a live fresh-admission waiter call `touch_hit`.
- Inherit reuse protection on a newly published child only when its parent is
  protected and `parent_len * 2 >= tail_tokens` (`>= 33%` reused prefix),
  protecting linear multi-turn continuations while keeping low-reuse scans that
  share a short boilerplate prefix probationary.
- Make demotion sticky: `demote_expired_reused` permanently clears `node.reused`
  when retirements since the last reuse hit turn over either both
  `ready_tail_pages.max(1)` and `ready_checkpoints.max(1)`, or `2x`
  `ready_checkpoints.max(1)` under snapshot-bound or compaction pressure.
- Order `eviction_candidate_within_budget` by `(self.is_protected(node),
  node.retention_rank(), node.id)` while keeping `eviction_candidates()`,
  `reclaimable_if_pinned`, `RetentionRank`, and optional-capture budget filters
  unchanged.
- `helios/src/scheduler.rs` (`+18/-6`, `12` net LOC): Gate GPU-hit `touch_hit`
  on `accounting.is_none()`, record `fresh_admission` on `Ticket`, and call
  `touch_hit` in `finish_inbound` only when
  `ticket.fresh_admission && !ticket.waiters.is_empty()` (otherwise plain
  `touch`).
- `docs/core-design.md`, `docs/scheduling-runtime-design.md`,
  `docs/prefix-cache-offload.md`: Document two-tier protection ordering, child
  inheritance, sticky turnover aging, and host-restore admission gating.
- `helios/src/cache/tests.rs`, `helios/src/cache/lifecycle_tests.rs`,
  `helios/src/scheduler/tests.rs`, `helios/src/scheduler/policy_tests.rs`: Add
  unit and policy tests for scan resistance, inheritance, sticky demotion,
  compaction aging, reused-document regime shifts, and `finish_inbound` gating,
  and include reuse/turnover state in `Fixture::key()`.

Result

Single-boot A/B vs `5d53040e` on 4x NVIDIA RTX PRO 6000 (`DeepSeek-V4.1-Flash`
TP4, `--kv-cache-limit memory --memory-limit 83GiB --prefix-cache-memory 0`,
`2,606,848` KV tokens / `20,366` pages, `n = 2` cold-salted trials/arm, measured
on `a7568c2c` prior to sticky-demotion/compaction-turnover/restore-gating
hardening):

- Scan-thrash (`24 x 8K` agents vs `8 x 214K` scans, `100s`): hit rate
  `33.95% / 8.91%` (mean `19.76%`) -> `51.82% / 25.99%` (mean `37.31%`, `1.89x`),
  saved prefill `2,083.8 / 749.6` -> `3,335.5 / 2,228.1 tok/s` (`+96.4%`).
- Long-context multi-turn (`4 x 127K` 4-turn vs `12 x 8K` noise): hit rate
  `24.61% / 32.58%` (mean `28.62%`) -> `49.38% / 50.04%` (mean `49.71%`,
  `1.74x`), median TTFT `23,886.7 / 22,228.7` -> `2,876.8 / 3,459.5 ms`
  (`-86.3%` from avoiding 127K re-prefill queueing stalls), saved prefill `+75.8%`.

Limits: No effect when KV capacity fits idle sessions without eviction or active
scans exceed total KV capacity. Live GPU A/B ran on `a7568c2c` with
`--prefix-cache-memory 0`; host-restore gating is verified by scheduler unit
tests rather than live offload serving.

Evidence

- Clean-archive Rust release checks & tests (`rustc 1.94.1`, tree
  `597c23c5d577`, `0` warnings across `helios --features runtime-core,server`,
  `flare`, `flare-cli`, `heliopause`):
  - `helios` `--features server --lib cache::`: `49 passed; 0 failed`
  - `helios` `--features runtime-core,server --lib cache::`: `138 passed; 0 failed`
  - `helios` `--features runtime-core,server --lib scheduler::`: `411 passed; 0 failed; 4 ignored` (incl. `6/6` `policy_*` and `3/3` `finish_inbound_*`)
  - `flare --lib`: `238 passed; 0 failed; 4 ignored`
  - `flare-cli`: `239 passed; 0 failed; 3 ignored`
- TLA+ lifecycle & mutation gate (`verification/helios-lifecycle/check.py`
  with Temurin JRE `21.0.13+9` + TLA+ `1.7.4`, `--jobs 4`):
  - `10/10` TLA+ model configs (`0` errors), `8/8` observed Rust trace suites
    (`621,390` transitions total, incl. `222,817` `CacheOwnership.tla` across
    `110,436` BFS states), `12/12` aux checks passed.
  - `check.py --mutations`: `26/26` Rust mutations KILLED (incl. `lost inherited
    fence` and `unbounded endpoint leaf eviction`), `13/13` TLA+ model mutations
    KILLED, and `DispatchRing SlotReuseSafe` observed-edge violation detected.
- Core boundary: `pytest tests/preparation/test_core_boundary.py` (`4 passed`).

Discord: Doone

Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
FujitsuPolycom added a commit to FujitsuPolycom/flare-local-inference that referenced this pull request Dec 2, 2026
Why

`PrefixCheckpointCache::eviction_candidate_within_budget` previously ordered
removable checkpoints solely by `(RetentionRank { use_epoch, role,
consumed_tokens }, id)` (NVIDIA#568). Because `RequestScheduler::retire` refreshes
`use_epoch` via `cache.touch` on every normal completion (NVIDIA#298, NVIDIA#416), one-shot
cold prefills with zero prefix reuse finished at the most-recently-used end of
the cache ahead of idle multi-turn sessions waiting between turns. Under KV page
pressure, `evict` discarded actively reused multi-turn checkpoints before dead
one-shot leaves.

What

- `helios/src/cache.rs` (`+138/-22`, `116` net LOC incl. test-only stats
  invariant): Track cross-request reuse state (`reused`,
  `reused_at_evicted_pages`, `reused_at_evicted_nodes`) on `Checkpoint`, plus
  `ready_tail_pages`, `evicted_pages`, and `evicted_checkpoints` on
  `PrefixCheckpointCache` (counting both retired ready leaves in `retire_leaf`
  and compacted ready ancestors in `compact_ancestor`).
- Add `PrefixCheckpointCache::touch_hit` for genuine cross-request prefix reuse
  without promoting creator-completion `touch` refreshes, and
  `publish_with_retention_with_hit` so duplicate capture publications promote
  while waiterless or preempted-only host-store `Existing` restores refresh
  demand recency only.
- Inherit reuse protection on a newly published child only when its parent is
  protected and `parent_len * 2 >= tail_tokens` (`>= 33%` reused prefix),
  protecting linear multi-turn continuations while keeping low-reuse scans that
  share a short boilerplate prefix probationary.
- Make demotion sticky: `demote_expired_reused` permanently clears `node.reused`
  when retirements since the last reuse hit turn over either both
  `ready_tail_pages.max(1)` and `ready_checkpoints.max(1)`, or `2x`
  `ready_checkpoints.max(1)` under snapshot-bound or compaction pressure.
- Order `eviction_candidate_within_budget` by `(self.is_protected(node),
  node.retention_rank(), node.id)` while keeping `eviction_candidates()`,
  `reclaimable_if_pinned`, `RetentionRank`, and optional-capture budget filters
  unchanged.
- `helios/src/scheduler.rs` (`+32/-13`, `19` net LOC): Gate GPU-hit `touch_hit`
  on `accounting.is_none()`, track per-waiter `(RequestHandle, bool)` freshness
  on `Ticket` so cancelling a fresh waiter recomputes freshness from remaining
  live waiters, and gate both `Created` and `Existing` `finish_inbound` reuse
  promotion on `ticket.waiters.iter().any(|&(_, fresh)| fresh)`.
- `docs/core-design.md`, `docs/scheduling-runtime-design.md`,
  `docs/prefix-cache-offload.md`, `helios/README.md`: Reconcile two-tier
  protection ordering, child inheritance, sticky turnover aging, and
  host-restore admission gating across all cache/offload specifications.
- `helios/src/cache/tests.rs`, `helios/src/cache/lifecycle_tests.rs`,
  `helios/src/scheduler/tests.rs`, `helios/src/scheduler/policy_tests.rs`: Add
  unit and policy tests for scan resistance, inheritance, sticky demotion,
  compaction aging, reused-document regime shifts, per-waiter cancellation, and
  `Existing` restore gating, and include reuse/turnover state in
  `Fixture::key()`.

Result

Single-boot A/B vs `5d53040e` on 4x NVIDIA RTX PRO 6000 (`DeepSeek-V4.1-Flash`
TP4, core `gb202-tp4-202612010626`, `--kv-cache-limit memory --memory-limit
83GiB --prefix-cache-memory 0`, `2,606,848` KV tokens / `20,366` pages, `n = 2`
cold-salted trials/arm, measured on `a7568c2c` prior to sticky-demotion,
compaction-turnover, and restore-gating hardening):

- Scan-thrash (`24 x 8K` agents vs `8 x 214K` scans, `100s`): hit rate
  `33.95% / 8.91%` (mean `19.76%`) -> `51.82% / 25.99%` (mean `37.31%`, `1.89x`),
  saved prefill `2,083.8 / 749.6` -> `3,335.5 / 2,228.1 tok/s` (`+96.4%`).
- Long-context multi-turn (`4 x 127K` 4-turn vs `12 x 8K` noise): hit rate
  `24.61% / 32.58%` (mean `28.62%`) -> `49.38% / 50.04%` (mean `49.71%`,
  `1.74x`), median TTFT `23,886.7 / 22,228.7` -> `2,876.8 / 3,459.5 ms`
  (`-86.3%` from avoiding 127K re-prefill queueing stalls), saved prefill `+75.8%`.

Limits: Default-ON with no opt-out flag; under a sudden workload shift, stale
reused entries survive until full dual turnover or `2x` ready-checkpoint
turnover, evicting newly admitted probationary entries first during the
transition window. No effect when KV capacity fits idle sessions without
eviction or active scans exceed total KV capacity. Live GPU A/B ran on
`a7568c2c` with `--prefix-cache-memory 0`; host-restore gating is verified by
scheduler unit tests rather than live offload serving.

Evidence

- Clean-archive Rust release checks & tests atop `1fbcc3c9` (`rustc 1.94.1`,
  tree `402aa4794d46`, `RUSTFLAGS="-D warnings"` `0` warnings across `helios
  --features runtime-core,server --lib/--tests`, `flare --lib`, `flare-cli
  --bins`, `heliopause --features extension-module --lib`):
  - `helios --features server --lib`: `1,284 passed; 0 failed; 14 ignored` (`8`
    `FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
  - `helios --features runtime-core,server --lib`: `1,796 passed; 0 failed; 46
    ignored` (`8` `FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
  - Targeted: `cache::` `49` (`server`) / `139` (`runtime-core,server`),
    `scheduler::policy_tests::policy_` `6/6`, `scheduler::tests::finish_inbound_`
    `5/5`
  - `flare --lib`: `246 passed; 0 failed; 4 ignored`
  - `flare-cli`: `245 passed; 0 failed; 3 ignored` (`219+9+6+4+7`)
- TLA+ lifecycle & mutation gate (`verification/helios-lifecycle/check.py`,
  Temurin JRE `21.0.13+9`, TLA+ `1.7.4`, `--jobs 4`):
  - `10/10` TLA+ model configs (`0` errors), `8/8` observed Rust trace suites
    (`621,390` transitions total, incl. `222,817` `CacheOwnership.tla`), `12/12`
    aux checks passed.
  - `check.py --mutations`: `26/26` Rust mutations KILLED, `13/13` TLA+ model
    mutations KILLED, and `1/1` `DispatchRing SlotReuseSafe` bad-edge KILLED.
- Python checks: `pytest tests/preparation/test_core_boundary.py
  tests/test_scheduling*.py` (`834 passed; 0 failed`); `ruff==0.12.8` reports
  `0` issues on PR-touched files (no Python files modified).

Discord: Dooner

Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b
lukealonso pushed a commit that referenced this pull request Dec 2, 2026
…#665)

Why

`PrefixCheckpointCache::eviction_candidate_within_budget` previously ordered
removable checkpoints solely by `(RetentionRank { use_epoch, role,
consumed_tokens }, id)` (#568). Because `RequestScheduler::retire` refreshes
`use_epoch` via `cache.touch` on every normal completion (#298, #416), one-shot
cold prefills with zero prefix reuse finished at the most-recently-used end of
the cache ahead of idle multi-turn sessions waiting between turns. Under KV page
pressure, `evict` discarded actively reused multi-turn checkpoints before dead
one-shot leaves.

What

- `helios/src/cache.rs` (`+138/-22`, `116` net LOC incl. test-only stats
  invariant): Track cross-request reuse state (`reused`,
  `reused_at_evicted_pages`, `reused_at_evicted_nodes`) on `Checkpoint`, plus
  `ready_tail_pages`, `evicted_pages`, and `evicted_checkpoints` on
  `PrefixCheckpointCache` (counting both retired ready leaves in `retire_leaf`
  and compacted ready ancestors in `compact_ancestor`).
- Add `PrefixCheckpointCache::touch_hit` for genuine cross-request prefix reuse
  without promoting creator-completion `touch` refreshes, and
  `publish_with_retention_with_hit` so duplicate capture publications promote
  while waiterless or preempted-only host-store `Existing` restores refresh
  demand recency only.
- Inherit reuse protection on a newly published child only when its parent is
  protected and `parent_len * 2 >= tail_tokens` (`>= 33%` reused prefix),
  protecting linear multi-turn continuations while keeping low-reuse scans that
  share a short boilerplate prefix probationary.
- Make demotion sticky: `demote_expired_reused` permanently clears `node.reused`
  when retirements since the last reuse hit turn over either both
  `ready_tail_pages.max(1)` and `ready_checkpoints.max(1)`, or `2x`
  `ready_checkpoints.max(1)` under snapshot-bound or compaction pressure.
- Order `eviction_candidate_within_budget` by `(self.is_protected(node),
  node.retention_rank(), node.id)` while keeping `eviction_candidates()`,
  `reclaimable_if_pinned`, `RetentionRank`, and optional-capture budget filters
  unchanged.
- `helios/src/scheduler.rs` (`+32/-13`, `19` net LOC): Gate GPU-hit `touch_hit`
  on `accounting.is_none()`, track per-waiter `(RequestHandle, bool)` freshness
  on `Ticket` so cancelling a fresh waiter recomputes freshness from remaining
  live waiters, and gate both `Created` and `Existing` `finish_inbound` reuse
  promotion on `ticket.waiters.iter().any(|&(_, fresh)| fresh)`.
- `docs/core-design.md`, `docs/scheduling-runtime-design.md`,
  `docs/prefix-cache-offload.md`, `helios/README.md`: Reconcile two-tier
  protection ordering, child inheritance, sticky turnover aging, and
  host-restore admission gating across all cache/offload specifications.
- `helios/src/cache/tests.rs`, `helios/src/cache/lifecycle_tests.rs`,
  `helios/src/scheduler/tests.rs`, `helios/src/scheduler/policy_tests.rs`: Add
  unit and policy tests for scan resistance, inheritance, sticky demotion,
  compaction aging, reused-document regime shifts, per-waiter cancellation, and
  `Existing` restore gating, and include reuse/turnover state in
  `Fixture::key()`.

Result

Single-boot A/B vs `5d53040e` on 4x NVIDIA RTX PRO 6000 (`DeepSeek-V4.1-Flash`
TP4, core `gb202-tp4-202612010626`, `--kv-cache-limit memory --memory-limit
83GiB --prefix-cache-memory 0`, `2,606,848` KV tokens / `20,366` pages, `n = 2`
cold-salted trials/arm, measured on `a7568c2c` prior to sticky-demotion,
compaction-turnover, and restore-gating hardening):

- Scan-thrash (`24 x 8K` agents vs `8 x 214K` scans, `100s`): hit rate
  `33.95% / 8.91%` (mean `19.76%`) -> `51.82% / 25.99%` (mean `37.31%`, `1.89x`),
  saved prefill `2,083.8 / 749.6` -> `3,335.5 / 2,228.1 tok/s` (`+96.4%`).
- Long-context multi-turn (`4 x 127K` 4-turn vs `12 x 8K` noise): hit rate
  `24.61% / 32.58%` (mean `28.62%`) -> `49.38% / 50.04%` (mean `49.71%`,
  `1.74x`), median TTFT `23,886.7 / 22,228.7` -> `2,876.8 / 3,459.5 ms`
  (`-86.3%` from avoiding 127K re-prefill queueing stalls), saved prefill `+75.8%`.

Limits: Default-ON with no opt-out flag; under a sudden workload shift, stale
reused entries survive until full dual turnover or `2x` ready-checkpoint
turnover, evicting newly admitted probationary entries first during the
transition window. No effect when KV capacity fits idle sessions without
eviction or active scans exceed total KV capacity. Live GPU A/B ran on
`a7568c2c` with `--prefix-cache-memory 0`; host-restore gating is verified by
scheduler unit tests rather than live offload serving.

Evidence

- Clean-archive Rust release checks & tests atop `1fbcc3c9` (`rustc 1.94.1`,
  tree `402aa4794d46`, `RUSTFLAGS="-D warnings"` `0` warnings across `helios
  --features runtime-core,server --lib/--tests`, `flare --lib`, `flare-cli
  --bins`, `heliopause --features extension-module --lib`):
  - `helios --features server --lib`: `1,284 passed; 0 failed; 14 ignored` (`8`
    `FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
  - `helios --features runtime-core,server --lib`: `1,796 passed; 0 failed; 46
    ignored` (`8` `FLARE_TEST_TEMPLATE_DIR`-gated template tests skipped)
  - Targeted: `cache::` `49` (`server`) / `139` (`runtime-core,server`),
    `scheduler::policy_tests::policy_` `6/6`, `scheduler::tests::finish_inbound_`
    `5/5`
  - `flare --lib`: `246 passed; 0 failed; 4 ignored`
  - `flare-cli`: `245 passed; 0 failed; 3 ignored` (`219+9+6+4+7`)
- TLA+ lifecycle & mutation gate (`verification/helios-lifecycle/check.py`,
  Temurin JRE `21.0.13+9`, TLA+ `1.7.4`, `--jobs 4`):
  - `10/10` TLA+ model configs (`0` errors), `8/8` observed Rust trace suites
    (`621,390` transitions total, incl. `222,817` `CacheOwnership.tla`), `12/12`
    aux checks passed.
  - `check.py --mutations`: `26/26` Rust mutations KILLED, `13/13` TLA+ model
    mutations KILLED, and `1/1` `DispatchRing SlotReuseSafe` bad-edge KILLED.
- Python checks: `pytest tests/preparation/test_core_boundary.py
  tests/test_scheduling*.py` (`834 passed; 0 failed`); `ruff==0.12.8` reports
  `0` issues on PR-touched files (no Python files modified).

Discord: Dooner


Design-Signed-Off-By: Antigravity (Gemini 4 Neon); design-review=2e5b

Signed-off-by: FujitsuPolycom <87842395+FujitsuPolycom@users.noreply.github.com>
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.

2 participants