Skip to content

feat: opt-in block budget for the paged KV pool - #174

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

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

Conversation

@inureyes

@inureyes inureyes commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

Sub-step b1 of #122 (block-budget admission, eviction, preemption). Part of #122. The paged pool previously grew without bound (acquire_block lazily minted rows on demand). This adds the budget primitive — opt-in, so default behaviour is unchanged — that the admission/eviction logic in b2 will enforce against.

Changes

  • PagedBlockPool gains block_budget: Option<usize> (default None = unbounded). acquire_block refuses to mint a new block once allocated_block_count >= budget; reusing a freed block is always allowed (it adds no memory), so the budget caps the pool tensors' peak row count without blocking recycling. New accessors: allocated_block_count, live_block_count, block_budget, set_block_budget, free_block_budget (mintable headroom; Some(0) = only reuse remains).
  • CachePool pass-throughs: set_paged_block_budget, paged_block_budget, free_paged_block_budget (no-op without a paged pool) so the scheduler can set the budget and gate admission on the headroom.

Scope

This is the budget mechanism only. b2 derives the value from the configured / estimated KV byte budget (now accurate after #52 TIER 1/2: available − weights − activation), gates prefill admission on free_paged_block_budget, and on pressure evicts cold radix prefixes (pins release cleanly via #170) then falls back to the existing preemption. b1 changes no default behaviour — with block_budget = None the pool is byte-identical to before.

Tests

4 new PagedBlockPool tests: the cap refuses new mints (budget exhausted), freed-block reuse is allowed at the cap (no re-mint), None is unbounded (100 blocks), and free_block_budget tracks allocation. 26 paged_detach tests pass.

Validation

Cold cargo clippy --tests (both crates) clean; cargo fmt --check clean; full core regression green.

Sub-step b1 of #122. PagedBlockPool gains an optional global cap on distinct physical blocks (block_budget: Option<usize>; None = unbounded, the historical lazy-grow default). acquire_block refuses to mint a NEW block once the cap is reached — reusing a freed block is always allowed since it adds no memory — so the pool's tensor growth is bounded. Adds allocated_block_count / live_block_count / block_budget / set_block_budget / free_block_budget accessors, and CachePool pass-throughs (set_paged_block_budget / paged_block_budget / free_paged_block_budget) so the scheduler can set the budget and gate admission on the remaining headroom.

This is the foundation for #122's block-budget admission and eviction: the budget itself, opt-in so default behaviour is unchanged. Deriving the value from the configured or estimated KV byte budget and reacting to allocation failures (evict cold prefixes, then preempt) is sub-step b2. Adds 4 tests: the cap refuses new mints, freed-block reuse is allowed at the cap, None is unbounded, and free-budget tracking.
@inureyes inureyes added the type:enhancement New features, capabilities, or significant additions label Jun 7, 2026
@inureyes
inureyes merged commit 0203f14 into main Jun 7, 2026
4 checks passed
@inureyes
inureyes deleted the feat/122-block-budget branch June 7, 2026 11:50
@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
Sub-step b1 of lablup#122. PagedBlockPool gains an optional global cap on distinct physical blocks (block_budget: Option<usize>; None = unbounded, the historical lazy-grow default). acquire_block refuses to mint a NEW block once the cap is reached — reusing a freed block is always allowed since it adds no memory — so the pool's tensor growth is bounded. Adds allocated_block_count / live_block_count / block_budget / set_block_budget / free_block_budget accessors, and CachePool pass-throughs (set_paged_block_budget / paged_block_budget / free_paged_block_budget) so the scheduler can set the budget and gate admission on the remaining headroom.

This is the foundation for lablup#122's block-budget admission and eviction: the budget itself, opt-in so default behaviour is unchanged. Deriving the value from the configured or estimated KV byte budget and reacting to allocation failures (evict cold prefixes, then preempt) is sub-step b2. Adds 4 tests: the cap refuses new mints, freed-block reuse is allowed at the cap, None is unbounded, and free-budget tracking.
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.

1 participant