Skip to content

feat: gate boundary snapshots by model capability - #1507

Merged
inureyes merged 3 commits into
mainfrom
feature/issue-1153-snapshot-capability
Aug 30, 2026
Merged

inureyes merged 3 commits into
mainfrom
feature/issue-1153-snapshot-capability

Conversation

@inureyes

@inureyes inureyes commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Gate prompt-cache history-boundary rendering on the loaded model snapshot-reuse capability so dense-KV deployments do not pay a second template render and tokenizer pass that the scheduler cannot consume.

What changed

  • Published a ModelProvider snapshot-reuse capability flag from batch, legacy, and XLA workers before the provider is marked loaded.
  • Passed the route decision through AppState into chat, Responses, Anthropic, and prompt-inspection preparation paths.
  • Kept request preparation fail-open until the worker reports loaded=true, so startup-queued requests cannot miss the first boundary snapshot for a snapshot-capable model.
  • Kept preserve_thinking cache-on defaulting independent from snapshot reuse, while requiring snapshot capability before producing history_prompt after readiness.
  • Added test-only history-render attempt counting plus focused regression tests for snapshot-capable, dense-KV, prompt-cache-off, fallback, and multimodal cases.

Test plan

  • cargo test --lib server::chat_request::tests::history_render -- --nocapture
  • cargo test --lib server::chat_request::tests::prompt_cache_on -- --nocapture
  • cargo test --lib pre_reserved_single_stream_enqueue_does_not_double_reserve -- --nocapture
  • cargo test --lib scheduler_paths_do_not_create_single_stream_reservations -- --nocapture
  • cargo clippy --lib --tests -- -D warnings

Validation limits

  • Real llama-3.2-1b-instruct and qwen3.5-0.8b-4bit benchmark/counter parity was not run in this Linux worktree because no local models/ checkpoint directory is present; this PR validates the dispatch gate and prefix invariant with unit tests, while hardware/checkpoint parity remains a qualified-machine check.

Closes #1153

Publish the loaded model snapshot-reuse capability from the worker before the provider is marked ready, then pass it through AppState into every chat-template preparation path that can build prompt-cache context.

Dense-KV models now skip the extra history-boundary render entirely while snapshot-reuse families keep the existing boundary invariant. The manual MLXCEL_DISABLE_BOUNDARY_SNAPSHOT kill switch remains a stricter gate on top of the automatic capability check.

Validated with targeted chat_request history-boundary tests, cache-on preserve_thinking tests, and ModelProvider single-stream fixture tests.

Refs #1153
Keep HTTP request preparation fail-open before the worker publishes loaded=true so a request queued during startup cannot miss the first history-boundary snapshot on a snapshot-reuse model.

Once the worker is loaded, the route follows the published snapshot-reuse capability and dense-KV models skip the history-boundary render.

Refs #1153
@inureyes inureyes added type:performance Performance improvements priority:medium Medium priority area:inference Generation, sampling, decoding (incl. speculative, DRY) status:review Under review labels Aug 30, 2026
Record the snapshot capability gate implementation, validation coverage, and remaining real-checkpoint qualification limits while the PR is still open so the report is included in the merge.

Refs #1153
@inureyes inureyes added status:done Completed and removed status:review Under review labels Aug 30, 2026
@inureyes
inureyes merged commit 1a03192 into main Aug 30, 2026
12 checks passed
@inureyes inureyes self-assigned this Aug 31, 2026
@inureyes
inureyes deleted the feature/issue-1153-snapshot-capability branch October 6, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) priority:medium Medium priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(server): gate the history-boundary render on model snapshot-reuse capability

1 participant