Add KV cache operation observability - #410
Open
shipiyouniao wants to merge 4 commits into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a read-only observability surface for kvcached KV cache pools, including per-manager operation counters and integration-facing snapshot helpers so external collectors can retrieve stable, structured state without relying on engine internals.
Changes:
- Introduces
kvcached.observabilitydataclasses + registry helpers for pool/runtime snapshots and operation counter snapshots. - Adds monotonic operation counters + error metadata to
KVCacheManager, and exposes snapshot/snapshot_dict helpers. - Wires vLLM/SGLang integration interfaces to register pools, clear registration on shutdown, and expose snapshot forwarding; labels SGLang pool types (mha/mla/mamba).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_observability.py | Adds unit tests covering operation counters, snapshot serialization, weakref registry behavior, and integration forwarding. |
| kvcached/observability.py | Implements snapshot dataclasses, capability discovery, and a weakref-based registry for live pools. |
| kvcached/kv_cache_manager.py | Adds operation counter tracking, error recording, and snapshot helper methods on the manager. |
| kvcached/integration/vllm/interfaces.py | Registers vLLM managers in the pool registry and exposes runtime/pool snapshot helpers. |
| kvcached/integration/sglang/interfaces.py | Registers SGLang managers in the pool registry and exposes runtime/pool snapshot helpers. |
| kvcached/integration/sglang/patches.py | Passes stable pool_name labels when creating managers so collectors can distinguish pool types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+205
to
+210
| block_size_bytes = _int_attr(manager, "block_mem_size") or 0 | ||
| bytes_per_block = block_size_bytes * num_layers * num_kv_buffers | ||
| available_blocks = int(manager.available_size()) | ||
| allocated_blocks = int(manager._get_num_alloced_blocks()) | ||
| reserved_blocks = len(getattr(manager, "reserved_blocks", [])) | ||
|
|
Comment on lines
+276
to
+280
| def _record_operation_error(self, code: str, counter_name: str) -> None: | ||
| self._increment_operation_counter("operation_errors_total") | ||
| self._increment_operation_counter(counter_name) | ||
| self._last_error_code = code | ||
| self._last_error_timestamp_ns = time.time_ns() |
shipiyouniao
force-pushed
the
feature/operational-observability
branch
from
July 27, 2026 05:38
d9c1dbe to
4295979
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
Dependency
Depends on #385, which introduces the read-only snapshot foundation. This PR intentionally remains separate from #400; it contains no DeepSeek-V4 pool implementation changes.
Validation
python -m pytest tests/test_observability.py -q(8 passed)The full Linux pre-commit and Python 3.9-3.13 MyPy matrix is left to CI because the local Windows host does not provide the repository scripts' POSIX
flock, Unix sockets, and signal APIs.