Skip to content

Checkpoint captures deadlock on an unmeasured snapshot cost: host prefix cache never receives anything (unknown_cost skips forever) #534

Backlog

Description

@semireg

Summary

On some boots, flare_checkpoint_captures_total stays at 0 for every role and flare_graph_launches_total{kind="snapshot"} never moves, while flare_checkpoint_skips_total{reason="unknown_cost"} grows by roughly one per request.
Nothing is published to Selene, so the host prefix cache (DRAM/NVMe) never serves a hit, even though the GPU prefix cache looks healthy. The server stays in this state until restart. We believe this is at least one cause of #327 ("Prefill
ram cache fills but is never reused"). It fits the reports there: GPU hit rate stays normal, RAM hit rate is 0%, and controlled repeats pass on some boots.

User impact

  • Slow turns in interleaved or resumed sessions. When a conversation's prefix is evicted from GPU KV (other sessions, concurrency, idle time), the next turn re-prefills the entire context instead of restoring it from the host tier. On our setup that's 4.5 s vs <0.1 s time to first token for a 115K-token conversation, growing with context length. Back-to-back turns of a single session still hit the GPU cache, so the slowdown seems random to users.
  • Context is lost on restart. The disk tier is meant to survive restarts. With no captures, every session re-prefills from scratch after a deploy or crash.
  • Throughput loss under load. Repeated re-prefill takes GPU time from other requests, which hurts most when the server is busiest and eviction is most frequent.
  • Idle reserved memory. The configured DRAM/NVMe tier is allocated but never serves a hit.
  • It depends on the boot. The same build and config can work on one boot and fail for that boot's whole lifetime, which makes the problem hard to notice and report.

Cause

Every optional checkpoint capture requires a fresh measured duration for the 1-token snapshot graph. That duration can only be measured by running a snapshot copy, which those same captures gate on:

  • checkpoints.rs (current main): checkpoint_selection_uncached (~L427), checkpoint_copy_allowed (~L730) and allocate_terminal_capture (~L791) all require self.costs.fresh_duration(GraphKind::Snapshot, 1). Otherwise they skip
    with unknown_cost.
  • cost.rs: Estimate::fresh() requires nanos != 0, so a never-measured graph is never fresh.
  • cost.rs: stale_keys() also filters nanos != 0, so the bounded refresh in policy.rs never targets the unmeasured snapshot key.
  • The only exemption is anchor-role captures (checkpoint_copy_allowed returns Ok(true) for RetentionRole::Anchor). If an anchor capture happens to run early, it measures the snapshot graph and everything works. If not, nothing ever
    measures it.

#285 fixed the same failure for prefill costs. Its description notes that "the fresh snapshot-copy requirement still governs optional captures" and that "initial unmeasured … shapes can still suppress optional checkpoints". #292 reported
unknown_cost skips "before their capture cost has been measured" but didn't isolate the cause.

Reproduction / evidence

DeepSeek-V4.1-Flash FP8, TP3 on SM120. The build is based on main; cost.rs and the three gate sites match current main.

  • Unmodified image, empty prefix-cache store, fresh boot: after churn plus a 30K-token probe, skips{unknown_cost} went 1 → 91. Captures stayed 0 for every role, snapshot launches stayed 0, and no root records were stored. Varying
    the traffic didn't escape it: small probes, a 152K-token prompt, multi-message replays and 6 concurrent requests all failed.
  • Instrumentation on the same boots: the snapshot estimate read nanos=0, observed=None, fresh=false and never changed.
  • Same image, earlier boots the same day: these seeded within minutes. The anchor capture counter rose on each, consistent with anchors being the only path that measures the graph. We couldn't determine why anchors did or didn't arm
    on a given boot. The fix below doesn't depend on that.

Proposed fix

Let a terminal (endpoint) capture probe the snapshot cost at most once per estimate TTL when the estimate is unmeasured or stale, and only when checkpoint_extra_work_fraction > 0. Message and anchor gating is unchanged; those captures
resume as soon as the probe records a measurement.

// cost.rs
pub fn probe_duration(&self, kind: GraphKind, tokens: usize) -> Option<u64> {
    let key = Key { drafts: 0, kind, batch: 1, tokens, prefill: 0, packed: 0 };
    self.entry(key).filter(|estimate| !estimate.fresh(self.now_ns, self.ttl_ns)
        && (estimate.last_attempt_ns == 0
            || self.now_ns.saturating_sub(estimate.last_attempt_ns) >= self.ttl_ns))
        .map(|estimate| estimate.nanos)
}

pub fn record_probe(&mut self, kind: GraphKind, tokens: usize) {
    let key = Key { drafts: 0, kind, batch: 1, tokens, prefill: 0, packed: 0 };
    if let Some(&index) = self.index.get(&key) {
        // Zero denotes no attempt, so a probe at time zero is recorded as one.
        self.entries[index].1.last_attempt_ns = self.now_ns.max(1);
    }
}

// checkpoints.rs, allocate_terminal_capture()
let fresh = self.costs.fresh_duration(GraphKind::Snapshot, 1);
let probe = fresh.is_none();
let Some(cost) = fresh.or_else(|| {
    (self.policy.checkpoint_extra_work_fraction > 0.0)
        .then(|| self.costs.probe_duration(GraphKind::Snapshot, 1))
        .flatten()
}) else {
    self.stats.checkpoint_skip_unknown_cost += 1;
    return Ok(None);
};
// ... unchanged budget check and snapshot quote ...
if snapshot.is_some() {
    if probe {
        self.costs.record_probe(GraphKind::Snapshot, 1);
    }
    // ... unchanged ...
}

Notes:

  • The probe is recorded only after a snapshot row is actually allocated, so a storage-refused probe doesn't use up the TTL window.
  • A checkpoint_extra_work_fraction of 0 still disables all optional copies. zero_fraction_never_reserves_or_charges_extra_copy_work passes.
  • New regression test unmeasured_snapshot_cost_is_probed_by_one_terminal_capture_per_ttl: with the snapshot cost unmeasured, the first terminal capture is allocated, a second within the TTL is skipped as unknown_cost, and another is
    allocated after the TTL.

Validation (same server, patched build, fresh boot, empty store)

  1. First request: snapshot launches, endpoint captures, publications and root_records{tier="dram",reason="first"} all rose from 0. The unpatched image under identical conditions stayed at 0.
  2. Exact replay: a 114,819-token prompt cold-prefilled in 4.5 s; the replay returned cached_tokens 114,819 in under 0.1 s.
  3. After a server restart: the same replay returned cached_tokens 114,819 in 0.1 s from the disk tier. The new boot seeded on its first request.
  4. 20-minute load: 3,396 multi-turn requests with no errors, 92.3% of prompt tokens cached.
    • Anchor captures 0 → 13, message 0 → 6, endpoint 7 → 6,798.
    • Root records 2 → 169.
    • unknown_cost skips rose by only 5 over the run.
  5. 90-minute soak with sparse traffic: captures continued across idle gaps longer than the TTL, with no relapse.

Diagnosing this on your deployment

If flare_checkpoint_captures_total is flat at 0 while flare_checkpoint_skips_total{reason="unknown_cost"} grows with traffic, you're in this state. Client-side prompt changes and cache sizing won't affect it.

A back-to-back repeat of the same prompt won't show it either, because that hits the GPU prefix cache. Push the prefix out of GPU KV with unrelated traffic before replaying, and check the capture counters.

Happy to open a PR.

Activity

  1. mark-yong commented on Nov 28, 2026

    @mark-yong
    Contributor

    This cold-boot deadlock looks specific to the SM120 TP3 fork (AzallazA/hyperflare-inference, ba6a4c11) rather than upstream main.

    On pure NVIDIA/hyperflare-inference main (353551e9), PrefillTailMerge and prefill_merge_min_rows (ported into the fork from closed PR #69) do not exist:

    • checkpoint_anchor at helios/src/scheduler/checkpoints.rs:107 falls back to prompt_tokens, so anchor > start holds on a cold boot.
    • prefill_work_through at helios/src/scheduler/policy.rs:338 stops at checkpoint_anchor, resolve_prefill_kind at helios/src/scheduler.rs:868 selects GraphKind::TerminalPrefill at that cut on TerminalPrefill cores, and checkpoint_copy_allowed at helios/src/scheduler/checkpoints.rs:727 returns Ok(true) for RetentionRole::Anchor.
    • The first cold-boot request on pure main arms Anchor and measures Snapshot-1-1.

    The 13 anchor captures vs 6,798 endpoint captures over 3,396 multi-turn requests in the validation run matches PrefillTailMerge merging past Anchor on tools=true (and under On, non-thinking tools=false) requests. That explains why anchors only armed on some boots; on that fork, --scheduler-prefill-tail-merge false avoids the deadlock.

    Pure main still has two transient, self-healing unknown_cost cases after the 30 s TTL (a resumed prompt hitting anchor <= start at checkpoints.rs:416, or concurrent anchor copies batching into batch > 1 while fresh_duration at cost.rs:233 checks batch: 1), though neither causes a permanent captures == 0 cold-boot deadlock. Unless this reproduces on pure main without PrefillTailMerge, this belongs on the fork and can probably be closed here.

  2. added
    area:caching
    area:selene
    bug
    performance
    priority:P2
    triage:investigate
    on Nov 30, 2026
  3. flare-autobot commented on Nov 30, 2026

    @flare-autobot
    Collaborator

    The reported cold-boot deadlock—where host prefix-cache checkpoint captures remain at zero across all retention roles on an empty store and optional captures skip indefinitely with unknown_cost—does not reproduce in NVIDIA/hyperflare-inference on origin/main at commit c146d7be.

    The reported DeepSeek-V4.1-Flash FP8 TP3 build and low anchor-capture ratio (13 anchor captures versus 6,798 endpoint captures across 3,396 multi-turn requests) correspond to the third-party fork AzallazA/hyperflare-inference, which carries prefill tail-merging symbols (PrefillTailMerge and prefill_merge_min_rows) that do not exist in NVIDIA/hyperflare-inference at c146d7be.

    On origin/main at c146d7be, an uncached cold-boot request schedules and executes a conversation anchor capture even before any snapshot-copy timing estimate exists:

    • On an empty prefix-cache store (consumed_tokens == 0), LiveRequest::checkpoint_anchor (helios/src/scheduler/checkpoints.rs:108-115) computes a strictly positive anchor endpoint, falling back to prompt_tokens when no message boundary is eligible.
    • RequestScheduler::checkpoint_selection_uncached (helios/src/scheduler/checkpoints.rs:543-559) pushes that anchor cut (RetentionRole::Anchor) before querying fresh smallest-batch snapshot-copy timing via ActionCosts::fresh_duration(GraphKind::Snapshot, 1) at line 557.
    • RequestScheduler::prefill_work_through (helios/src/scheduler/policy.rs:337-351) bounds prefill at the anchor cut, RequestScheduler::resolve_prefill_kind (helios/src/scheduler.rs:854-884) selects GraphKind::TerminalPrefill on model cores that declare terminal prefill graphs (with deferred-prefill checkpoint edge cases fixed in commit 0c25e88f / PR helios: fix deferred_prefill checkpoints, shared_pages accounting, drop teardown, and >64 MiB wire prepares #613, and catalogs without terminal prefill graphs fixed in commit 1364062c / PR Restore prefix checkpoints on prefill catalogs without terminal prefill #550), and RequestScheduler::checkpoint_copy_allowed (helios/src/scheduler/checkpoints.rs:888-895) permits RetentionRole::Anchor copies unconditionally.
    • If concurrent cold-boot anchor captures batch into a wider snapshot capacity on the first snapshot step, ValueRate::compare (helios/src/scheduler/utility.rs:134-139) ranks unmeasured operations (duration_ns == 0) ahead of measured ones, so the subsequent snapshot phase measures the smallest declared snapshot batch queried by ActionCosts::fresh_duration (helios/src/scheduler/cost.rs:264-269). Once measured, stale-key tracking in ActionCosts::stale_keys (helios/src/scheduler/cost.rs:271-274) and funded timing refresh in RequestScheduler::select_plan (helios/src/scheduler/policy.rs:1238-1274) refresh the estimate after the 30-second timing freshness window (PolicyConfig::estimate_ttl_ns, helios/src/scheduler/policy.rs:38) whenever a snapshot phase runs.
    • Optional Message and Endpoint captures skip with unknown_cost only transiently when a request hits an already-cached anchor (anchor <= start) while the smallest-batch snapshot timing is unmeasured or expired. That behavior matches the freshness contract in docs/scheduling-runtime-design.md (lines 573–575) and clears on the subsequent request with an uncached anchor.

    No upstream code change is proposed. Adding an unconditional terminal-capture probe to work around fork-specific prefill tail-merging behavior would alter the documented freshness contract in docs/scheduling-runtime-design.md (lines 573–575) without a demonstrated defect in NVIDIA/hyperflare-inference.

    Verification and limitations: This assessment is based on static source inspection of origin/main at c146d7be across helios/src/scheduler/checkpoints.rs, helios/src/scheduler/cost.rs, helios/src/scheduler/policy.rs, helios/src/scheduler/utility.rs, helios/src/scheduler.rs, and docs/scheduling-runtime-design.md, together with upstream commits 0c25e88f and 1364062c. Because no code was modified, no Rust crate tests, scheduling simulator runs, formal lifecycle checks, or GPU serving workloads were executed.

    Recommended disposition: Close this issue as specific to a third-party fork. If a permanent zero-capture cold-boot deadlock reproduces on unmodified NVIDIA/hyperflare-inference main at or after c146d7be, please reopen with the exact commit SHA, flare inspect output for the model core, launch configuration, and observed checkpoint capture and skip counters.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cachingarea:selenebugperformancepriority:P2triage:investigate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions