Skip to content

feat: surface paged KV block budget in cache stats and metrics - #178

Merged
inureyes merged 1 commit into
mainfrom
feat/122-block-budget-stats
Jun 7, 2026
Merged

inureyes merged 1 commit into
mainfrom
feat/122-block-budget-stats

Conversation

@inureyes

@inureyes inureyes commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

Sub-step c — the final piece of #122 (Phase 5: block-budget admission, eviction, preemption). b1/b2/b3 built the budget mechanism + activation; this surfaces the pool's block-level usage so operators can observe admission headroom and eviction under pressure.

What changed

GET /v1/cache/stats gains seven paged block-pool fields:

field meaning
paged_block_size block size in tokens (0 = no paged pool)
paged_blocks_allocated rows minted into the pool
paged_blocks_live blocks held by live sequences
paged_blocks_free freed blocks retained for reuse
paged_bytes_reserved / paged_bytes_in_use byte footprint
paged_block_budget configured cap (0 = unbounded)

Sourced from the batch observability snapshot (not the prompt-cache store), so they stay meaningful even with the prompt cache disabled — paged decode runs independently. paged_block_budget - paged_blocks_live is the acquirable headroom before eviction / preemption.

/metrics gains mlxcel_cache_pool_paged_block_budget — the one paged datum that wasn't already a gauge. Added through BatchObservability (recorded each scheduler tick from CachePool::paged_block_budget); the allocated / live / free block + byte gauges already existed.

#122 completion

task / acceptance criterion where
Admit / queue on free-block count + preemption b2
LRU/TTL eviction releasing physical blocks a + b2
Recompute-on-preempt pre-existing, wired b2
Surface pool usage in /v1/cache/stats + Prometheus c (this PR)
AC: evict cold prefixes & admit without OOM b2 + b3, tested
AC: metrics report block-level usage gauges + c

Test plan

  • cargo build + cold cargo clippy -D warnings + cargo fmt --all --check — clean
  • cargo test: routes::cache 17 (3 new), batch::observability 6 (budget assertion), batch::scheduler_prompt_cache 21, server::batch 181, prompt_cache::apc_integration 9 — all green
  • New tests: build_stats_response_surfaces_paged_pool_independent_of_store, paged_block_stats_projects_from_observability_snapshot, serialization-key coverage for the seven fields; admit-under-pressure / no-leak via the existing evicting_cold_prefix_restores_paged_block_budget

Closes #122.

Sub-step c — the final piece of #122 (Phase 5 block-budget admission / eviction / preemption). With b1/b2/b3 the paged KV pool now admits, evicts, and preempts against a configurable block budget; this exposes that state to operators so they can observe admission headroom and eviction under pressure.

`GET /v1/cache/stats` gains seven paged block-pool fields (block_size, blocks_allocated/live/free, bytes_reserved/in_use, and block_budget), sourced from the batch observability snapshot rather than the prompt-cache store so they stay meaningful even when the prompt cache is disabled — paged decode runs independently. `paged_block_budget` is the configured cap (0 = unbounded), so `paged_block_budget - paged_blocks_live` is the acquirable headroom before eviction / preemption kicks in.

The block-budget cap was the one paged datum not already a gauge, so a `cache_pool_paged_block_budget` gauge is added through BatchObservability (recorded each scheduler tick from `CachePool::paged_block_budget`) and exposed as `mlxcel_cache_pool_paged_block_budget` on `/metrics`; the allocated/live/free block and byte gauges already existed.

Tests cover the new data path end to end: observability records the budget, `PagedBlockStats::from_observability` projects the snapshot, and `build_stats_response` propagates the paged fields on both the store-present and store-absent branches. The admit-under-pressure / no-leak behaviour is already covered by the b2 eviction test (`evicting_cold_prefix_restores_paged_block_budget`).

This completes every task and acceptance criterion on #122.

Closes #122.
@inureyes inureyes added the type:enhancement New features, capabilities, or significant additions label Jun 7, 2026
@inureyes
inureyes merged commit b98af14 into main Jun 7, 2026
4 checks passed
@inureyes
inureyes deleted the feat/122-block-budget-stats branch June 7, 2026 15:43
@inureyes inureyes self-assigned this Jun 10, 2026
@inureyes inureyes added status:done Completed priority:medium Medium priority labels Jun 10, 2026
@inureyes inureyes added this to the 0.2 milestone Jun 21, 2026
be-free-snowboy pushed a commit to freestylejs/snowbrain-mlxcel that referenced this pull request Oct 27, 2026
…p#178)

Sub-step c — the final piece of lablup#122 (Phase 5 block-budget admission / eviction / preemption). With b1/b2/b3 the paged KV pool now admits, evicts, and preempts against a configurable block budget; this exposes that state to operators so they can observe admission headroom and eviction under pressure.

`GET /v1/cache/stats` gains seven paged block-pool fields (block_size, blocks_allocated/live/free, bytes_reserved/in_use, and block_budget), sourced from the batch observability snapshot rather than the prompt-cache store so they stay meaningful even when the prompt cache is disabled — paged decode runs independently. `paged_block_budget` is the configured cap (0 = unbounded), so `paged_block_budget - paged_blocks_live` is the acquirable headroom before eviction / preemption kicks in.

The block-budget cap was the one paged datum not already a gauge, so a `cache_pool_paged_block_budget` gauge is added through BatchObservability (recorded each scheduler tick from `CachePool::paged_block_budget`) and exposed as `mlxcel_cache_pool_paged_block_budget` on `/metrics`; the allocated/live/free block and byte gauges already existed.

Tests cover the new data path end to end: observability records the budget, `PagedBlockStats::from_observability` projects the snapshot, and `build_stats_response` propagates the paged fields on both the store-present and store-absent branches. The admit-under-pressure / no-leak behaviour is already covered by the b2 eviction test (`evicting_cold_prefix_restores_paged_block_budget`).

This completes every task and acceptance criterion on lablup#122.

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

Labels

priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 5: Block-budget admission, eviction, and preemption

1 participant