Conversation
lgeln10
force-pushed
the
perf/kv-admission-benchmarks
branch
from
September 20, 2026 14:57
3e8ec2a to
52ecc14
Compare
lgeln10
force-pushed
the
perf/kv-admission-benchmarks
branch
from
September 20, 2026 15:04
52ecc14 to
cbdcd26
Compare
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
Reduce KV admission over-reservation and add a fixed benchmark suite for validating the change with the same request set across unit tests, scheduler microbenchmarks, and OpenAI-compatible serving benchmarks.
This PR changes scheduler admission by:
num_reserved_decode_blocks, so admission no longer scans the full running queue on every candidate requestnum_reserved_decode_blocksthrough cache stats for tests and benchmark validationThis PR also adds:
What is measured
The benchmark separates the change into three variants so the over-reservation fix and the bookkeeping optimization can be evaluated independently:
legacyexact-scanincrementalThe over-reservation bug is that admission used the remaining output token budget as if all of it required new KV blocks. For requests that already own partially filled or sufficient KV blocks, this double-counts capacity. The fixed formula computes the final block requirement for
prompt_len + max_tokens, subtracts the request's currentblock_tablelength, and reserves only the extra blocks that may still be needed.End-to-end data
Archived serving runs on RTX 4090 D + TinyLlama-1.1B-Chat-v1.0 used the fixed 384-request workload: 256 first-wave requests, 128 second-wave requests, 128 max output tokens, input lengths cycling through 64/128/192/256/320/512/768/1024 tokens,
block_size=256,num_blocks=864, prefix caching disabled, and EOS ignored. Each variant was run 3 times and the table reports medians.legacy7.68s8.87s2704.85 tok/s384/384exact-scan1.54s11.53s2509.70 tok/s384/384incremental1.49s11.47s2507.13 tok/s384/384Key observations:
96blocks in this workload:256blocks reserved bylegacyversus160blocks required by the exact formula.53to91.79.9%(7.68s -> 1.54s).3.4%(1.54s -> 1.49s).80.6%overall (7.68s -> 1.49s).509.73 usto23.29 us, a21.9xspeedup over exact scanning.7.3%in this mixed workload, and wave2 P95 regresses. This PR improves admission accuracy, scheduler CPU overhead, and P50 latency; it does not claim an end-to-end throughput win.The archived results used the same request contents before compacting the JSON manifest in this PR, so the recorded file SHA differs from the committed compact JSON while the workload fields are unchanged.
Additional workload sanity check
Before the fixed TinyLlama manifest, the same idea was checked with a small
head_dim=64random Llama model on RTX 4090 D. That run is less representative for production model speed, but it is useful as an ablation because it includes a normal control workload where the exact formula should not release extra capacity.Each row below is the median of 3 serving runs with 128 first-wave requests and 64 second-wave requests:
aligned3232603 ms671 msmixed2746760 ms551 msboundary064856 ms621 msThis sanity check shows the optimization is not expected to help every workload. When there is no false reservation (
aligned), exact admission does not increase accepted requests. When prompt lengths create false reservations (mixedandboundary), the exact formula releases capacity and admits more second-wave requests.Testing
Passed locally:
PATH=/tmp/infinilm-pr-pytest/bin:$PATH /tmp/infinilm-pr-pytest/bin/python scripts/format.py --check --path \ python/infinilm/llm/scheduler.py \ scripts/kv_admission_manifest.py \ scripts/generate_kv_admission_manifest.py \ scripts/benchmark_scheduler_admission.py \ scripts/benchmark_serving_admission.py \ scripts/summarize_kv_admission_results.py \ test/scripts/test_kv_admission_manifest.py \ test/scripts/test_benchmark_scheduler_admission.py \ test/scripts/test_benchmark_serving_admission.py \ test/scripts/test_fixed_kv_admission_workload.pyPassed on RTX 4090 D server with the PR source uploaded from the local checkout and the existing
_infinilm.socopied into the test tree:Result: