Skip to content

Commit 617ef92

Browse files
committed
Allocate checkpoint slots globally within request work budgets
Dividing snapshot capacity by configured concurrency leaves lightly loaded requests with too few checkpoints. Spending that quota on prompt and answer endpoints loses reusable history when a chat template rewrites reasoning. Complete-message boundaries provide reusable prefixes before that rewrite. Replace fixed capture quotas and evenly spaced cuts with a shared snapshot pool and reverse message-boundary priority. Retain the last eligible message as a best-effort anchor, falling back to the prompt end. Budget extra copies and prefill splits against estimated uncached prefill work, with completed decode earning additional terminal allowance. Expose the fraction through CLI and configuration, defaulting to 0.05. Missing or stale costs suppress extras. Zero retains anchor-only behavior. Rank GPU retention by logical-request demand, role, and endpoint. Account for backing-page aliases, revalidate allocation quotes, and permit mandatory work to revoke unused anchor guards. Retain submitted destinations through completion fences and carry demand and work accounting across preemption. Allocate terminal rows after generation drains. Publish message anchors immediately and defer local host copyout before pinning when headroom is insufficient. Preserve core metadata and captured graph compatibility. A request can use spare global capacity while prioritizing recent message boundaries. On SM120, native serving of Qwen3.8-Flash-Next core gb202-tp1-202611052112 with concurrency limit 32 and 49 snapshot rows reused 2660 prompt tokens after reasoning was omitted, versus zero on baseline c74b613. Both returned the requested answers. With reasoning preserved, reuse was 2660 versus 2693. These cold-cost runs captured anchors only and establish neither optional-capture GPU behavior nor a latency improvement. Validation: - Helios release suite: 1368 passed, 26 ignored. The physical CUDA alias test also passed when explicitly enabled. - Scheduler regression captures 15 message checkpoints for one request with configured concurrency 32 and checks its work allowance. - Lifecycle models and Rust conformance checks passed. CheckpointReservation explored 5180 states and checked 24 observed production Rust transitions. Its bounds cover two requests, three rows, and two submission fences. - Qwen and Nemotron native frontend reasoning tests passed. Application tests passed with four ignored; focused Python config/serve tests passed. - Full CLI tests retain two Orbit fixture failures. Full Python CLI tests retain eight failures involving recipe aliases, collective planning, and a missing Kimi checkpoint. All ten reproduce on unchanged baseline. Native optional captures with warm timing estimates, host-copyout pressure, tensor-parallel serving, and Nemotron serving remain unqualified and are tracked in docs/TODO.txt. The TLA+ model covers reservation ownership and ordering, not budget arithmetic or physical CUDA behavior. Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
1 parent c74b613 commit 617ef92

43 files changed

Lines changed: 3160 additions & 520 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/TODO.txt‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,16 @@
6767
in the same run; it is validated on SM120 only. Drive the workload with
6868
scripts/repro_glm_batched_speculation.py.
6969

70-
[ ] Exercise per-message checkpoint restore and prefill graph selection through
71-
Qwen, GLM, DeepSeek, MiMo, Step, and Nemotron services. See
70+
[ ] Qualify measured-work checkpoint selection and history-rewrite reuse through
71+
Qwen, GLM, DeepSeek, MiMo, Step, and Nemotron services with warm timing
72+
catalogs, host copy-out pressure, and tensor-parallel execution. See
7273
core-design.md#exact-endpoint-capture and scheduling-runtime-design.md.
7374

75+
[ ] Correct the 10-byte core payload fixtures in Orbit agent tests
76+
running_groups_are_stopped_and_outlive_their_controller_session and
77+
groups_run_together_on_disjoint_gpus_and_status_lists_them; their transfer
78+
ranges and file-size assertions currently require 13 bytes.
79+
7480
[ ] Validate multi-window image prefill, prefix skipping, and CPU record reuse
7581
through DeepSeek, MiMo, Kimi, and Nemotron services. Extend Step TP4 coverage
7682
to host cache tiers and image-request preemption, cancellation, and shallower

‎docs/api.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,17 @@ without the `flare_` prefix, such as `input_decoded_images_total`.
343343
| `host_bytes_in` | Bytes copied from the host store into GPU pages and rows | `flare_host_cache_bytes_in_total` |
344344
| `learned_drafter` | Boolean: the model has a learned drafter | none |
345345

346+
GPU checkpoint retention exports `flare_checkpoint_captures_total{role}` with
347+
`anchor`, `message`, and `endpoint` roles, and
348+
`flare_checkpoint_skips_total{reason}` with `unknown_cost`, `work_budget`, and
349+
`storage` reasons. Skip counters count selection or capture rejections, not failed
350+
requests. `flare_checkpoint_extra_work_nanoseconds_total` sums charged predicted
351+
extra prefill and copy work; it is not a GPU timing measurement.
352+
`flare_checkpoint_anchor_reservations` reports unused anchor guards, excluding
353+
armed destinations and in-flight copies.
354+
`flare_host_cache_copyout_headroom_deferrals_total` counts local copy-out offers
355+
deferred by the GPU headroom check before acquiring checkpoint pins.
356+
346357
Host retention also exports `flare_host_cache_held_total{tier}` and
347358
`flare_host_cache_dropped_total{tier,reason}`, with `dram` and `nvme` tiers and
348359
`end_of_chain`, `oversize`, `io_error` drop reasons. The gauge
@@ -562,8 +573,10 @@ request preservation of all thinking blocks
562573
marks the end of that block as a candidate prefix-checkpoint boundary, for the
563574
first four such blocks in a request; `cache_control` elsewhere is ignored. The
564575
markers do not change the rendered prompt, and the scheduler chooses among
565-
candidate boundaries within its checkpoint budget as it does for message
566-
boundaries.
576+
candidate boundaries under its work allowance and global storage availability.
577+
Hints remain advisory; they do not reserve a snapshot or override the
578+
conversation-anchor priority described in
579+
[exact endpoint capture](core-design.md#exact-endpoint-capture).
567580

568581
## Stateless Responses
569582

‎docs/cli-design.md‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,18 @@ zero disables that term. Terminal age starts when termination is observed and
689689
includes queued-work drainage. These are scheduling preferences, not deadlines.
690690
The controls use the core's captured snapshot graphs and require no re-export.
691691

692+
`--scheduler-checkpoint-extra-work-fraction FRACTION` bounds optional checkpoint
693+
work relative to productive request work. The default is `0.05`; values must be
694+
finite and in `[0,1]`. It overrides
695+
`[server] scheduler_checkpoint_extra_work_fraction`. The scheduler always considers
696+
the last eligible message endpoint as a best-effort conversation anchor, even
697+
when timing estimates are unavailable or the fraction is zero. Earlier messages
698+
and a distinct prompt end consume the fraction of estimated uncached prefill
699+
work; a distinct terminal endpoint earns its allowance from completed productive
700+
decode. Extra work includes snapshot copies and additional prefill caused by
701+
splitting chunks. Snapshot storage remains globally shared and reclaimable for
702+
mandatory execution. This option requires no core re-export.
703+
692704
`flare run CORE` loads an exported file and reads host defaults from
693705
`~/.config/flare/config.toml` using its Rust configuration reader. `--config PATH`
694706
selects another file. Explicit flags override configuration values. `CORE` accepts a
@@ -1241,7 +1253,8 @@ Ignition and native Flare read this file; `--config PATH` selects another file.
12411253
An absent default file supplies no overrides; an explicitly selected missing
12421254
file or an invalid runtime setting is an error. Help does not read the file.
12431255

1244-
Native `flare run` applies `[server] host`, `port`, `api_key`, and `thinking_token_budget`,
1256+
Native `flare run` applies `[server] host`, `port`, `api_key`, `thinking_token_budget`,
1257+
and `scheduler_checkpoint_extra_work_fraction`,
12451258
`[memory] reserve`, `[defaults] max_concurrency`, `[models.<name>] max_concurrency`, all `[prefix_cache]`
12461259
settings, and `[paths] prefix_cache`. Prepared-model acquisition and cache commands
12471260
use `[paths] core_cache`. Flags override these defaults, including explicit
@@ -1271,6 +1284,7 @@ host = "127.0.0.1"
12711284
port = 8000
12721285
api_key = "" # Empty: no authentication.
12731286
# thinking_token_budget = 1536 # Optional default reasoning-token cap.
1287+
# scheduler_checkpoint_extra_work_fraction = 0.05 # Fraction of productive work for extra captures.
12741288

12751289
[defaults]
12761290
model = "qwen3.8-flash"
@@ -1345,8 +1359,10 @@ value in preference to that recorded reserve.
13451359
The GPU prefix cache is derived. It holds model states at instruction,
13461360
prompt, and answer boundaries so that later requests repeating a prefix skip
13471361
recomputing it. Immutable snapshot capacity is bounded by borrowable KV backing
1348-
and the prepared virtual extent. The per-request capture budget is capped at
1349-
eight. Snapshot slots share physical backing with KV pages and
1362+
and the prepared virtual extent. Checkpoint work uses the request-local work
1363+
allowance described in [native serving flags](#32-native-serving-flags), without
1364+
a capture-count cap or a per-request snapshot share. Snapshot slots share physical
1365+
backing with KV pages and
13501366
acquire it only when retaining a checkpoint. Unpinned checkpoints are evicted
13511367
to admit requests. If active requests or transfers own all suitable backing,
13521368
the engine skips optional checkpoint retention. There is no dedicated snapshot
@@ -1416,7 +1432,7 @@ every rank and have no configuration-file key. See
14161432
| Tensor-parallel size | Count of `--gpus`, or the smallest recipe-supported size whose estimate fits the first GPUs with enough free memory |
14171433
| Context limit | The smaller of the prepared context ceiling and loaded KV capacity after per-request draft-page storage; admission also checks available shared capacity |
14181434
| KV pages | Remaining supply after the runtime memory limit or core reserve, engine headroom, weights, graphs, scratch, and execution rows; bounded by `--kv-cache-limit` and prepared virtual extents. Retained snapshot rows borrow page backing; the load display reports total KV capacity |
1419-
| Prefix cache | Immutable snapshot capacity bounded by borrowable KV backing and the prepared virtual extent, acquired on demand and evicted under pressure; per-request capture budget capped at eight |
1435+
| Prefix cache | Immutable snapshot capacity bounded by borrowable KV backing and the prepared virtual extent, acquired on demand and evicted under pressure; extra captures bounded by predicted work and global storage availability |
14201436
| Live state | One null row plus the recipe's execution rows per active request slot; GLM verification commits into one live row |
14211437
| Decode graph capacities | 1 through `--max-concurrency`, rounded to the recipe's captured set |
14221438
| Image feature arena | Prepared image concurrency times per-request feature capacity and embedding width; slots remain owned through request retirement |

‎docs/core-design.md‎

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,26 +1429,38 @@ them into the prepared token stream without splitting atomic image spans. Cache
14291429
reuse depends on the actual prepared prefix identity; context-dependent changes
14301430
to earlier tokens cannot reuse a checkpoint for different tokens.
14311431

1432-
At admission, the scheduler budgets newly captured cache snapshots from the
1433-
loaded snapshot capacity divided by configured maximum concurrency, rounded
1434-
down and capped at eight. A nonempty pool permits at least one capture per
1435-
request; an empty pool permits none. The budget reserves a terminal capture and,
1436-
when generation can continue beyond the prompt and the budget permits, a prompt
1437-
capture. A single output token shares the prompt and terminal endpoint.
1438-
1439-
The remaining budget selects message checkpoints within the uncached prompt
1440-
suffix. If all eligible boundaries fit, retain them all. Otherwise, place token
1441-
targets at equal intervals between the reused prefix and the prompt end, choose
1442-
the nearest eligible message boundary to each target, and deduplicate the
1443-
results. Equal-distance ties choose the earlier boundary. Only selected boundaries
1444-
interrupt prefill; unselected messages can share a full captured prefill chunk.
1445-
The budget limits new captures, not existing reusable checkpoints or mandatory
1446-
state transfers between conditioned-input windows.
1447-
1448-
Endpoints are not rounded to token groups or KV pages. The scheduler obtains a
1449-
snapshot destination when it reaches a selected endpoint, using normal cache eviction.
1450-
If all snapshot slots are pinned, inference continues without publishing that
1451-
checkpoint. The number of messages does not enlarge the prepared snapshot pool.
1432+
The scheduler chooses the last eligible complete-message boundary as the request's
1433+
conversation anchor. If no message boundary is eligible, the prompt end is the
1434+
anchor. Anchor retention is best effort and independent of duration estimates.
1435+
Earlier complete-message boundaries compete in reverse message order; a distinct
1436+
prompt end follows them. There is no capture-count limit or allocation of a fixed
1437+
snapshot share to each request.
1438+
1439+
Extra captures use a request-local work allowance. Its prefill component is
1440+
`scheduler_checkpoint_extra_work_fraction` times the estimated uncached prefill
1441+
work, with a default fraction of 0.05. An extra endpoint charges the additional
1442+
predicted prefill time caused by splitting its enclosing interval, plus its
1443+
snapshot-copy time. Unknown or stale costs exclude extras without excluding the
1444+
anchor. Productive completed decode earns the same fraction of measured decode
1445+
time for a distinct terminal endpoint. A coincident prompt and terminal endpoint
1446+
uses one capture. Mandatory conditioned-input state transfers do not consume this
1447+
allowance. Preemption preserves the logical request's earned and spent allowance.
1448+
1449+
Snapshot rows come from the global allocator, which accounts for their physical
1450+
KV-page aliases. Selection checks a conservative feasible set of rows for the
1451+
chosen future cuts without reserving those rows or evicting for them. Each
1452+
immediate allocation minimizes the additional page backing within that set.
1453+
Before arming an earlier extra, the scheduler attempts to guard
1454+
a row for the later anchor. An unused guard may be revoked for mandatory request
1455+
pages or state transfers. Prefill destinations are armed before their producing
1456+
submission. A distinct terminal destination is obtained after generation drains,
1457+
before the terminal snapshot submission. Cancellation retains an armed or copying
1458+
destination through its last GPU-use fence. Snapshot copy and publication
1459+
preserve that ownership. Initial selection excludes extras without feasible
1460+
storage. If a selected extra loses storage or its copy estimate expires, prefill
1461+
can retain the selected cut while omitting the copy. Executed splits remain
1462+
charged; unsubmitted copies release their work reservations. Inference continues.
1463+
Endpoint cuts remain exact token boundaries, independent of KV-page geometry.
14521464

14531465
At each required prefill endpoint, the scheduler drains submitted work, snapshots
14541466
the exact live state, and publishes only after the copy fence completes. The
@@ -1509,17 +1521,24 @@ request publishes additional shared ancestors.
15091521
Track logical references separately from outstanding GPU use. A page or slot
15101522
becomes reusable only after both have ended.
15111523

1512-
Under snapshot-only pressure, thin checkpoint chains before evicting their
1513-
endpoints. A removable checkpoint has exactly one child and no direct request
1514-
pin. Prefer interior checkpoints over chain roots, and remove the checkpoint
1515-
whose surviving parent and child delimit the shortest token interval. Break
1516-
equal-distance ties by least recent access. This retains sparse history coverage
1517-
while preserving conversation endpoints during long prefills, including endpoints
1518-
of idle conversations. If no chain can be thinned, evict the least recently
1519-
used unpinned leaf, regardless of its age. Endpoint retention is a preference,
1520-
not a reservation that can prevent progress when only endpoints remain.
1521-
Under KV-page pressure, select the least recently used eligible
1522-
leaf or removable ancestor and recheck physical backing after each retirement.
1524+
GPU retention orders eligible checkpoints by logical-request demand epoch, then
1525+
role, then consumed-token count, then checkpoint identity. Prompt and terminal
1526+
endpoints have the lowest role, earlier message checkpoints follow, and the
1527+
conversation anchor has the highest role. Demand recency takes precedence over
1528+
role, so an idle conversation's anchor can be reclaimed before a recently used
1529+
endpoint. One successfully admitted logical request receives one demand epoch;
1530+
all its captures inherit that epoch. Cache reuse touches the matched checkpoint
1531+
and its ancestors. Duplicate publication retains the maximum role and epoch.
1532+
Preemption carries the epoch into readmission.
1533+
1534+
The global allocator compares victims for both snapshot rows and physical page
1535+
backing. A removable checkpoint is an unpinned leaf or an ancestor with exactly
1536+
one child and no direct request pin. Fenced retirement and alias ownership still
1537+
control when its resources can be reused. Optional capture cannot displace an
1538+
equal or higher retention rank. Mandatory execution resources can reclaim any
1539+
eligible rank and revoke unused anchor guards. Host, disk, and remote-store
1540+
retention keep their independent eviction policies. Local copy-out checks GPU
1541+
headroom before pinning a checkpoint chain for transfer.
15231542

15241543
Removing an ancestor transfers its storage without invalidating descendants:
15251544
transfer its ordered page segment and last-use fence to that child, bypass the

‎docs/prefix-cache-offload.md‎

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,19 @@ pub trait HostStore {
188188
```
189189

190190
The worker calls `store` for each offered checkpoint, without waiting for GPU
191-
pressure. The scheduler defers a message checkpoint whose own planned prompt
192-
checkpoint is its direct child less than one physical page later, and terminal
193-
checkpoints, until a request resumes at that exact checkpoint. A preempted
194-
terminal counts as resumed. If its prompt capture cannot obtain a snapshot, the
195-
message is offered while the request still pins it; cancellation or error before
196-
that capture offers it at retirement. Deferral does not change GPU captures,
197-
prefill cuts, or retention; deferred points can be lost to GPU
198-
eviction before reuse, and are not announced to the pool until offered.
191+
pressure. Completed message and prompt checkpoints are offered after publication.
192+
Terminal checkpoints are offered when a request resumes at that exact checkpoint;
193+
a preempted terminal counts as resumed. A terminal checkpoint can be evicted
194+
before reuse and is not announced to the pool until offered.
199195
Compaction also offers a deferred branch point as its heir and refreshes
200196
descendant offers with their new parent.
201197
`Queued` holds one GPU pin until `Stored` or `Deferred`; `Present`
202198
requires a committed local copy. `Retry` accepts no copy. The worker retains only
203199
checkpoint IDs for retries after store progress and discards IDs that have left
204200
the GPU cache. `Deferred` releases the copy pin and schedules the same retry when
205201
a queued publication cannot obtain host capacity. A failed transfer releases its
206-
pin without retrying. GPU eviction uses the GPU cache's LRU, leaf and compaction
207-
rules. `fetch` copies a looked-up chain into the ticket's page IDs and state slot.
202+
pin without retrying. GPU eviction uses demand/role retention ranking with leaf removal or
203+
ancestor compaction. `fetch` copies a looked-up chain into the ticket's page IDs and state slot.
208204
Submissions never wait; `poll` drains completions and failures.
209205
A `PublishedCheckpoint` names the GPU checkpoint, its key, its nearest offered
210206
ancestor's key, its bucket digest, every page of
@@ -259,12 +255,14 @@ is absent from the host index is stored as a root record holding its complete
259255
page chain, so a skipped or evicted ancestor never makes its descendants
260256
unrestorable.
261257

262-
Eviction follows `PrefixCheckpointCache::evict`: remove the least recently
263-
used unpinned leaf; when every leaf is pinned, compact the least recently used
264-
unpinned single-child ancestor by dropping its row and keeping its pages. A
265-
compacted node stays in the tree as page-only, no longer matches lookups, and
266-
continues to supply chain pages. A node is evictable only when its store's
267-
policy allows it: the memory store standalone evicts any unpinned node, the
258+
GPU eviction ranks eligible checkpoints by logical-request demand epoch,
259+
retention role, consumed-token count, and identity, as specified in
260+
[checkpoint lifetime](core-design.md#branching-and-lifetime). Host-store eviction
261+
independently removes the least recently used unpinned leaf; when every leaf is
262+
pinned, it compacts the least recently used unpinned single-child ancestor by
263+
dropping its row and keeping its pages. A compacted host node stays in the tree
264+
as page-only, no longer matches lookups, and continues to supply chain pages.
265+
A node is evictable only when its store's policy allows it: the memory store standalone evicts any unpinned node, the
268266
disk store evicts any unpinned node, and the composite restricts the memory
269267
store to durable nodes.
270268

@@ -1033,11 +1031,12 @@ same completion events the store produces.
10331031
not; snapshot aliases go through the same `projected_fits` arithmetic that
10341032
admission uses, and the next request's pages come from `admission_pages`,
10351033
which admission also uses. A pin is never revoked once a copy has started.
1036-
- **Evictions.** Every `PrefixCheckpointCache::evict` call goes through
1037-
`RequestScheduler::evict`, which queues the key of each
1038-
retired checkpoint, and for a compaction the offered descendant that took
1039-
its pages. The
1040-
worker passes them to `HostStore::evicted` before the next `store`. The
1034+
- **Evictions.** Mandatory resource reclamation uses `RequestScheduler::evict`;
1035+
optional snapshot allocation applies its selected victims individually.
1036+
Both paths call `RequestScheduler::record_evictions`, which queues each retired
1037+
checkpoint's key and, for compaction, the offered descendant that took its
1038+
pages. The worker passes these notices to `HostStore::evicted` before the next
1039+
`store`. The
10411040
notice is sent when the checkpoint is logically retired, not at its fence;
10421041
the pin of an export in flight keeps a leaf from being evicted and
10431042
compaction never moves pages. The queue is bounded like the publication

0 commit comments

Comments
 (0)