Repository navigation
feat: opt-in block budget for the paged KV pool - #174
Merged
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sub-step b1 of #122 (block-budget admission, eviction, preemption). Part of #122. The paged pool previously grew without bound (
acquire_blocklazily 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
PagedBlockPoolgainsblock_budget: Option<usize>(defaultNone= unbounded).acquire_blockrefuses to mint a new block onceallocated_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).CachePoolpass-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 onfree_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 — withblock_budget = Nonethe pool is byte-identical to before.Tests
4 new
PagedBlockPooltests: the cap refuses new mints (budget exhausted), freed-block reuse is allowed at the cap (no re-mint),Noneis unbounded (100 blocks), andfree_block_budgettracks allocation. 26paged_detachtests pass.Validation
Cold
cargo clippy --tests(both crates) clean;cargo fmt --checkclean; full core regression green.