[Core][KV Events] Echo session_id on GPU BlockStored events - #51381
[Core][KV Events] Echo session_id on GPU BlockStored events#51381xuhuan51 wants to merge 1 commit into
Conversation
Propagate Request.session_id to GPU BlockStored events for new, reused, and partial prefix-cache entries. Keep unlabeled events wire-compatible and document that the session identifies the triggering request rather than block ownership. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: liuguangli <liuguangli35@gmail.com>
|
Documentation preview: https://vllm--51381.org.readthedocs.build/en/51381/ |
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
|
cc @Change72 |
|
This looks great, super aligned. I think we should wait for convergence between KVEvents consumers on the new contract shape and stack/engine responsibilities. Started a doc with a clear contract and some of the alternatives. |
|
LGTM |
Purpose
Related to #48501. This PR adds an optional
session_idfield toBlockStoredand populates it for request-aware GPU prefix-cache events:kv_cache_report_mode="full"The field identifies the request that triggered the store or reuse report. It does not represent exclusive ownership of a block, since one cached block may be shared by multiple sessions.
BlockRemovedremains hash-keyed. Connector-generated CPU, remote, LMCache, and Mooncake events remain unlabeled in this PR.This is a session-only incremental slice. It does not implement
continuation_id, retention, admission policy, scheduling policy, or the complete V1a/V1b proposal from #48501, and it does not close that RFC.Why this is not a duplicate
Duplicate searches were performed on 2026-08-07.
BlockStoredevents.BlockInactiveevent.session_idplusBlockStored/ KV events was found.However, #48501 states that a V1a prototype exists on a fork. This PR remains a Draft pending coordination with the RFC author. If that prototype already covers this exact slice, this PR should be closed or handed off instead of duplicating the work.
Compatibility
session_idis an appended optional field on the map-encoded msgspec event.omit_defaults=True.session_id=None.session_id.Tests
.venv/bin/python -m pytest tests/distributed/test_kv_cache_events.py -q17 passed.venv/bin/python -m pytest tests/v1/core/test_prefix_caching.py -q91 passed.venv/bin/python -m pytest tests/v1/core/prefix_cache/test_partial_prefix_cache_primitives.py -q10 passed.venv/bin/pre-commit run --files examples/features/kv_events/kv_events_subscriber.py tests/distributed/test_kv_cache_events.py tests/v1/core/prefix_cache/test_partial_prefix_cache_primitives.py tests/v1/core/test_prefix_caching.py vllm/distributed/kv_events.py vllm/v1/core/block_pool.pyPassedModel evaluation
Not applicable. This change only augments KV-event metadata. It does not change model execution, generated tokens, numerical results, cache keys, or serving policy.
AI assistance
AI assistance was used while preparing and reviewing this change, designing tests, and drafting the PR description. I reviewed every changed line, understand the event semantics and compatibility guarantees, and ran the reported tests before submission.