Skip to content

fix(hybrid): preserve cache reuse and decode under prefill pressure - #583

Closed
logprobz wants to merge 17 commits into
local-inference-lab:dev/jovian-judgementfrom
logprobz:fix/lp15-concurrency-r15
Closed

fix(hybrid): preserve cache reuse and decode under prefill pressure#583
logprobz wants to merge 17 commits into
local-inference-lab:dev/jovian-judgementfrom
logprobz:fix/lp15-concurrency-r15

Conversation

@logprobz

@logprobz logprobz commented Sep 2, 2026

Copy link
Copy Markdown

Purpose

Preserve hybrid prefix-cache reuse and active decode progress when many long prefills compete with decode. This draft consolidates the source behavior validated in the LP15 high-concurrency investigation onto the current dev/jovian-judgement base.

This is intentionally a draft integration PR. It keeps the existing focused PRs open while maintainers decide whether to review the combined behavior or split it by concern.

Root causes

The incident required fixes in two interacting paths:

  1. A fixed mixed-prefill quantum still ran too frequently under active decode. It protected one scheduler step but could repeatedly fragment prefill and collapse job goodput.
  2. Hybrid cache groups did not retain and reconcile the same replay boundary under DFlash, Mamba, EAGLE, and DCP. Aggregate counters hid which group limited the common hit, and repeated scheduler lookups could inflate new diagnostics before admission.

The r15 rebase exposed two more shared-path details. Full-attention cache lookup must use the coordinator DCP width, while replicated or non-full groups use width one. Sparse retention must align its primary mask to prefix_cache_alignment_tokens, not the larger scheduler page.

Changes

Decode and prefill scheduling

  • Add zero-default adaptive mixed-prefill budgeting and bounded rotation.
  • Limit active partial prefills without changing the disabled behavior.
  • Add a zero-default decode-burst controller with an oldest-waiter fairness deadline.
  • Preserve full prefill budget when no decode is eligible.

Hybrid prefix cache

  • Retain DFlash and Mamba replay states reachable after EAGLE drops a block.
  • Align sparse retention and lookup to the common prefix-cache boundary.
  • Reconcile per-group hits with the correct DCP width.
  • Record cacheable tokens, reconciled hits, per-group hits, registrations, and evictions only at admission.
  • Keep metric labels bounded by configured cache groups and emit no request content or identifiers.

DCP correctness

  • Mask ranks with no local sequences before DCP reduction.
  • Gather sparse MLA queries when DCP is active without PCP.
  • Add a CPU regression around the sparse MLA query-gather helper.

Related PRs

This draft does not close or modify those PRs.

r15 baseline

Validation uses the immutable image:

voipmonitor/vllm@sha256:d9ca4c299fdb8e6176d70f36c8f98a687474eef807b7a71fe6fee9f154208fe0

Its source lock names dev/jovian-judgement@9c4dd05487629eccb26d7166459867a3db9b099f, which is also this PR's Git base. The image's exact composition commit is not published to either GitHub fork, so it is used as the installed-source and dependency baseline rather than as an unreproducible Git parent.

Exact draft head and tree:

commit 8dbf46366e1934d80fa6ff84c4abfda1c154ef1a
tree   7a7e08789b4c7211cdd650baf62cd63610165f3a

Validation

Pinned r15 CPU-only container, networking disabled, no GPU devices:

25 passed, 256 deselected, 1 xfailed

The xfail is the optional fine-grained resume checkpoint that this branch does not claim to implement. Added regressions cover decode-burst fairness, partial-prefill bounds, DFlash and Mamba replay boundaries, DCP1 and DCP4 group reconciliation, admission-only metrics, empty DCP ranks, and sparse MLA query gathering.

Changed-file pre-commit 4.3.0 passed Ruff, formatting, mypy, typos, SPDX, forbidden imports, configuration defaults, CUDA API guards, and all applicable repository hooks. git diff --check and the source-only scope check also passed.

A separate source-locked LP15 image completed a matched 20-agent DCP1 screen and reverse-order repeat against the prior LP8 runtime. It delivered 2.304x and 2.388x job goodput, with p99 ITL at 37.3% and 36.8% of baseline. That evidence motivated this port, but it is not an r15 GPU qualification claim.

Compatibility and gaps

  • All new scheduler controls default to zero.
  • No public default, sampling behavior, model output, KV dtype, or backend selection changes when the controls are disabled.
  • The metrics have fixed names and bounded cache-group labels.
  • TP1, TP2, TP8, ROCm, live DSpark, and r15 GPU serving were not tested here.
  • DCP4 high-concurrency promotion remains unclaimed.
  • The full repository suite was not run in the network-disabled image because unrelated tests require model downloads. The complete PR-added regression set passed.

AI assistance

OpenAI Codex assisted with investigation, source reconstruction, tests, and this draft description. The human submitter reviewed the source and accepts the recorded validation and limitations.

logprobz and others added 17 commits September 2, 2026 08:29
…er EAGLE/MTP

The full-attention EAGLE lookup drops one block below what it matched, so
until a request decodes past the block boundary after its prompt, the only
candidate the coordinator can offer a Mamba group is one block below the
replay boundary. Latest-only retention (prefix_cache_retention_interval=0,
the default) kept exactly the boundary state, leaving every retained state
one block above every reachable candidate: the reconciled prefix-cache hit
was always zero on hybrid models running MTP/EAGLE spec decode.

Measured live on GLM-5.3-Flash (MTP k=3, TP=4): 0 hits across 16,897
queries; per-group lookups on an identical resent 8,901-token prompt
returned (6912, 6912, 6912) for the Mamba groups against 4608 for the
eagle-dropped full-attention group, reconciling to 0.

Keep the state one block below each reachable boundary as well when the
group runs under EAGLE. The extra state only materializes where a block
boundary coincides with an aligned prefill chunk end (the running-state
block), which is how the align-mode scheduler chunks prompts.
…group's drop

Two defects found reviewing the first cut, both caught by new tests:

1. The back-off was hard-coded as one Mamba block, but the drop the
   full-attention finder applies is min(alignment_tokens, its block_size)
   followed by a re-floor to the alignment -- which lands exactly one
   ALIGNMENT unit below the boundary either way. When a group's block size
   differs from the alignment (their LCM), one block is the wrong step: the
   retained state sits at an offset Mamba's own finder rejects, so the hit
   stays 0 and the extra block is dead weight. Now computed in tokens via
   reachable_hit_positions(), which is exact for alignment >, == and < the
   block size.

2. Retention keyed off the group's OWN use_eagle bit, which is 'this group
   holds draft layers'. The right predicate is 'some group's lookup shortens
   the candidate offered to me', since the coordinator reconciles all groups
   to one hit length. It worked only via the coordinator's flag-all fallback
   (no annotator exists for glm5_next); the day one lands, the zero-hit bug
   returns silently. The coordinator now sets lookup_drops_eagle_block on
   every manager from bool(self.eagle_group_ids).

Tests: parametrize the MTP test over the three annotation routes (fallback,
full-only, both) and give it real speculative blocks + lookahead; add a
differing-block-size test pinning the alignment-unit back-off. Both fail on
the previous cut (full_only: 'mamba hash 1 should be cached'; backoff:
'reachable state missing; cached=[5]'). 95/95 in test_prefix_caching.py.
Draft prefill can leave a DCP rank with an empty sequence list. Mark every LSE contribution from that rank as negative infinity before the cross-rank reduction instead of indexing the empty tensor.

Assisted-by: OpenAI Codex
Signed-off-by: derek <derek.yates@live.com>
Signed-off-by: derek <derek.yates@live.com>
Assisted-by: OpenAI Codex
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@voipmonitor

Copy link
Copy Markdown

#583 is superseded by focused, independently reviewable pull requests:

The prefix-hit correction in #556 is a general local vLLM automatic-prefix-
cache invariant; it is not specific to LMCache. A hybrid request can reuse only
the token boundary available in every cache group. Under EAGLE/MTP, the
full-attention lookup discards one volatile lookahead alignment unit. Sparse
Mamba/GDN retention previously kept only the state at the unadjusted boundary,
so no recurrent state existed at the lower boundary offered during group
reconciliation. Retaining the predecessor state restores a common local hit.
An external KV connector can restore such a state, but it does not cause the
local retention defect.

The hybrid-cache diagnostic code from #583 is not being published as a
replacement PR. It evaluates every cache group a second time on the admission
path and mixes diagnostic bookkeeping with replay-boundary ownership. That
overhead and coupling require a separate design before the metrics are suitable
for production.

The DFlash-specific replay commits from #583 are also excluded. They were based
on treating DFlash as if it polluted target KV with EAGLE lookahead; #589
provides the narrower capability check required by the actual DFlash contract.

Original authorship is retained in #556, #560, #589, and #596.

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.

4 participants