Conversation
11 tasks
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
KV admission checks currently scan every allocated cache page to count reclaimable pages. Track the number of physical pages with live references so
BlockManager.get_total_usable_blocks()becomes O(1).Targets
InfiniLM-v0.2.9cat270feb3. One commit:21c1444.Motivation
Each candidate request calls the capacity query during admission. Repeated scans grow with the page pool and the number of candidate requests. Counting referenced physical pages directly removes this scan; shared prefix pages count once regardless of the number of owners. No linked issue.
Type of Change
perf— performance improvement with unchanged cache behavior.Test Results of Involved Models on Supported Platforms
270feb3sourcescripts/format.py --check, Ruff lint/format, andgit diff --check.Tests ran noninteractively; results are recorded as text rather than screenshots.
The named model/service tests were skipped:
examples/test_infer.py,examples/bench.py,test/bench/test_benchmark.py, andinference_server.py+scripts/test_perf.py. The available validation is the CPU cache/scheduler suite and synthetic admission microbenchmark.Benchmark / Performance Impact
CPU-only synthetic admission fixture on the same i5-14600KF / Python 3.12.13 machine. Baseline is the original cache-manager source at
270feb3; after is this commit. No tensor dtype or GPU kernels are involved.max_tokens=128and 64 generated tokens.max_tokens=128.can_accept_request()calls against fixed state. It does not enqueue/execute those candidates.perf_counter_ns; fixture setup is excluded. CPU affinity/frequency were not pinned.These measurements isolate admission checks, not full scheduling or model generation. The running-queue scan and actual eviction scan remain unchanged. The standalone timing harness was run locally and is not included in this PR.
Notes for Reviewers
The invariant is
_num_referenced_blocks == count(block.ref_count > 0). Therefore usable capacity isnum_blocks - _num_referenced_blocks.CI / ChatOps
Local checks passed. Remote CI status is pending. Hardware CI has not been manually triggered; no ChatOps command or reviewer notification has been posted.
Checklist
Title, Branch, and Commits
<type>/xxx-yyyy-zzzz:perf/kv-cache-capacity-index.main— this PR intentionally targetsInfiniLM-v0.2.9c, directly based on its current270feb3head.Scope and Design
General Code Hygiene
C++ Specific
Python Specific
scripts/format.py --path python/infinilm/llm/cache_manager.py test/llm/test_cache_manager.py --check.python/infinilm/auto_config.py.Testing
Build, CI, and Tooling
/retestrequested — pending.Documentation
Security and Safety