Repository navigation
Add a KV hint dispatcher for multi-hint envelopes - #118
Merged
Merged
Conversation
kahalon
force-pushed
the
hint-dispatcher
branch
from
October 23, 2026 16:45
c1afbef to
bd317ad
Compare
Contributor
|
/ok to test bd317ad |
Pure move: kvcr/hint_parser.py becomes kvcr/hints/parser.py and its tests follow. No behaviour change; it makes room for one module per hint type. Signed-off-by: Omri Kahalon <omrik@nvidia.com>
kahalon
force-pushed
the
hint-dispatcher
branch
from
October 23, 2026 21:57
bd317ad to
dda5a25
Compare
Contributor
|
/ok to test dda5a25 |
kahalon
force-pushed
the
hint-dispatcher
branch
from
October 23, 2026 22:23
dda5a25 to
7cbbbff
Compare
mkhazraee
approved these changes
Oct 23, 2026
Collaborator
|
LGTM, just needs the minor rebase after merging 67 which impacts the example and outcome logs discard their correlation fields. |
submit_hint used the first kv.fetch action of an envelope, ignored the others, and raised ValueError when that action was missing or invalid. It now treats the envelope as a batch of independent hints: - parse_hints returns every valid hint in order and a REJECTED result for each hint it cannot use. Only a malformed envelope raises. - Each hint type is a HintType (action type, version, parser, handler factory) in the dispatcher's fixed _HINT_TYPES table. - HintDispatcher, owned by core, routes each hint to its handler on the caller's thread, rejects a hint whose handler raises (handler_error), and closes handlers once the progress loop is quiescent. - kv.fetch is the first handler; the per-request hint store and its rules are unchanged. - Every result is logged at debug level. No metric is added: integrations forward KVCR stats and may reject undeclared names. A fatal progress-thread failure still propagates from submit_hint. Signed-off-by: Omri Kahalon <omrik@nvidia.com>
Note in the README and the design overview that KVCR parses and handles each hint of an envelope independently and records a per-hint outcome. Signed-off-by: Omri Kahalon <omrik@nvidia.com>
kahalon
force-pushed
the
hint-dispatcher
branch
from
October 23, 2026 23:59
7cbbbff to
6a799bf
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
A KV hint envelope can carry several actions; the format is shared by the framework RFCs (TensorRT-LLM #18153, vLLM #59708, SGLang #36224).
submit_hintused only the firstkv.fetchaction, ignored the rest, and raisedValueErrorwhen that action was missing or invalid.This PR adds a hint dispatcher that treats an envelope as a batch of independent hints. Every hint is parsed, routed to the handler for its type, and gets its own result. It is hint-agnostic infrastructure:
kv.fetchis still the only hint type and keeps its behavior. Prefetch into KVCR DRAM,kv.invalidateandkv.evictare meant to plug into the same path.Changes
kvcr.hintspackage, replacingkvcr/hint_parser.py:dispatcher.py:HintDispatcherand the fixed_HINT_TYPEStable. EachHintTypepairs a parser with a handler factory, so a supported type always has both. Handlers run inline on the caller's thread, without the state lock.parser.py:parse_hintsreturns every valid hint in envelope order, plus aREJECTEDresult for each hint it can't use. Only a malformed envelope raises.fetch.py: thekv.fetchparser and handler. Each hint is one call to the existing per-request hint store.results.py:HintStatus(ACCEPTED/REJECTED) andHintResult.core.pyholds one dispatcher.submit_hintdelegates to it, and handlers are closed with the other main-thread resources once the progress loop is quiescent.No new configuration.
Behavior changes
kv.fetchhint, or an envelope with none, no longer raises fromsubmit_hint. Each unusable hint is reportedREJECTEDwith a reason and logged once per (type, reason). A malformed envelope (not a mapping or struct, oractionsnot a list) still raisesValueError.unsupported_action_type) instead of being skipped silently.kv.fetchin an envelope is submitted, not only the first. The store's existing rules apply: a later hint from the same source replaces the hashes, and a different source marks the request failed so it isn't served remotely. Onekv.fetchper envelope remains the supported shape.handler_error). A fatal progress-thread failure still propagates fromsubmit_hint.Validation
ruff check src testsandruff format --check src tests: clean.pytest tests/uniton Linux (theDockerfile.ciimage, real nixl), rebased on34bb119: 649 passed, 0 failed (main: 627 passed). The 22 new tests aretest_hints_parser.py,test_hints_dispatcher.pyandtest_hints_fetch.py.tests/e2e/run_vllm_kvcr.pyon 2x B200 (vLLM nightly, Dynamo1.6.0.dev20261023): passed. Rank 1 reused 2688 of 2713 prompt tokens via a peer transfer from rank 0.main:submit_hintfollowed bydiscard_hint, called as vLLM does: about 1.5 µs more per hinted request (2.8 → 4.3 µs with 1 block hash, 66.7 → 68.6 µs with 1024). Requests without a hint, and polling, lookup, fetch and deliver, are unchanged.mainitself.Commits are split for review: a pure move, the dispatcher, then the docs.