Repository navigation
feat: add cache salt support to KV cache events - #30827
ishandhanani merged 4 commits into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
jthomson04
left a comment
There was a problem hiding this comment.
Reviewed the full diff. Overall well-scoped: the collision fix is real, the wire-compat strategy (separate struct, same tag, trailing element tolerated by array-like decoders) is sound and tested, and the call-site sweep is nearly complete. Two findings that don't anchor to changed lines:
1. Isolation regression in the experimental C++ radix tree. python/sglang/srt/mem_cache/radix_cache_cpp.py (~lines 188/222/230) still builds RadixKey(token_ids, req.extra_key) with no cache_salt. Before this PR the salt reached that backend embedded in extra_key (via _compute_extra_key), so salted requests were isolated there; now the salt is a separate field that backend silently drops. With SGLANG_EXPERIMENTAL_CPP_RADIX_TREE=1, two requests with different salts and identical tokens share cache entries. Suggest propagating cache_salt at those three sites, or rejecting salted requests when that backend is active.
2. L3 storage tiers are not salt-namespaced (pre-existing; worth documenting). Internal hashes (get_native_hash) cover token ids only, and hicache storage / LMCache / FlexKV key remote blocks off those unsalted chains, so a salted request that misses the device/host tree can still prefetch blocks written under a different salt. Not a regression (extra_key has the same gap), but since this PR formalizes the salt-isolation contract, the limitation deserves a sentence in the PR body or a docstring — especially if cache_salt is meant to close prefix-probing timing side channels.
Also: the red checks are all pr-gate/*-finish jobs failing within seconds — the run gate never opened, so the new unit tests have no CI signal yet.
Inline comments below for the per-file items.
🤖 Generated with Claude Code
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
bcaca2d to
369a759
Compare
|
/tag-and-rerun-ci |
9e7c958 to
8ce7347
Compare
|
/rerun-group disaggregation radix_cache hicache |
0122f20 to
12e354f
Compare
|
/rerun-failed-ci |
3 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Signed-off-by: jthomson04 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
RadixKey now reads req.cache_salt in cache_finished_req (sgl-project#30827, after this branch's base). The SimpleNamespace stand-in did not carry the field, so the test passes on this branch and raises AttributeError once rebased or merged onto current main. Found by cherry-picking the series onto main and running the suite there.

Motivation
External KV-aware routers need request cache namespaces to remain distinct from SGLang's caller-defined
extra_key. Concatenating the two values can collide, and the existing KV-event hashes and payloads do not expose a typed cache namespace.Modifications
cache_saltcontract toEngine.generate,Engine.async_generate, request normalization, tokenization, scheduling, sessions, and the supported Python radix-cache variants.cache_saltseparate fromextra_keyand index salted radix keys with the structured pair(extra_key, cache_salt)while preserving existing unsalted key behavior.SHA256(b"sglang-cache-salt-v1\\0" + cache_salt.encode()); internal cache hashes and unsalted event hashes remain unchanged.{ "cache_salt": "..." }metadata to saltedBlockStoredevents while preserving the legacy unsalted positional wire layout.Cache-salt-plus-LoRA routing semantics are outside this PR.
Accuracy Tests
Not applicable; this does not modify model computation or generated outputs.
Speed Tests and Profiling
Not run. Unsalted radix keys and KV-event hashes retain their existing paths. Namespace hashing is limited to salted requests with KV events enabled.
Validation
python3 -m compileall -q python/sglang/srt ...for all changed source and test modulesKVEventBatchconsumersChecklist
CI States
Latest PR Test (Base): ✅ Run #31618650333
Latest PR Test (Extra): ❌ Run #31618650207