Repository navigation
fix: reject a KV page pool smaller than one max_context request (#169) - #186
Merged
Merged
Conversation
submit() admits requests up to max_context, but with pages < max_context / page_size such a request could never get its pages: FIFO admission blocked everything behind it and the owner loop spun. PagedKV now rejects that configuration at construction. test_paged_admission_follows_pages_not_slots used such a pool (6 pages, max_context 128); it now uses max_context 96, which its requests fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Background
submitchecks onlymax_context. Withpages < max_context / page_size, a request withinmax_contextthat needs more pages than the whole pool could never be admitted (PagedKV.allocreturns None forever). FIFO admission then blocked every request behind it, and the owner loop spun because the batcher never went idle (batching.py:177-179,pd_batching.py:363-365,paged.py:281).Changes
opt_prime/opt_prime/accel/pd/paged.py(PagedKV.__init__): raisesValueError("pages must hold one max_context request")whenpages < max_context // page_size. This coversContinuousBatcher,PDBatcherandTorchPrefillEngine, which all build aPagedKV.opt_prime/tests/test_pd_batching.py::test_paged_pool_smaller_than_one_request_is_rejected:pages=2,max_context=64,page_size=16must raise.test_paged_admission_follows_pages_not_slotsused exactly such a pool (6 pages,max_context=128). It now usesmax_context=96(6 pages). Its requests (at most 38 tokens) and its assertions are unchanged.Verification
Python 3.10, torch 2.10.0+cu128, transformers 5.1.0, CPU plus one A100 (
CUDA_VISIBLE_DEVICES=1) on the RNGD+A100 host. Base: optimus-rm @253be20.DID NOT RAISE ValueError.tests/test_pd_batching.py tests/test_pd_prefix_cache.py tests/test_pd_batching_disagg.pygave 38 passed.opt_prime/:TORCH_DEVICE_BACKEND_AUTOLOAD=0 CUDA_VISIBLE_DEVICES=1 PYTHONPATH=$PWD python3 -m pytest -q tests): 400 passed, 23 skipped before; 401 passed, 23 skipped after.Compatibility and limits
pagesbelowmax_context / page_sizenow fail at startup instead of hanging on the first long request. The fix for those is to lowermax_contextor raisepages. The defaults (slots * max_context / page_size, and4 * max_context / page_sizefor the prefill engine) andexamples/pd/kv_tier_replay.py(384 pages vs 29 needed) are unaffected.Related Issue
Closes #169
🤖 Generated with Claude Code