mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #2184] cache_salt/extra_key are computed & carried but never delivered to Req — radix-cache tenant isolation is a no-op (regression vs upstream sglang) #1299
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#1299
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wildoranges on GitHub (Sep 2, 2026).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/2184
Reminder
System Info
Reproduction
Request sequence (OpenAI
/v1/completions, same prompt, 5 semantically distinctcache_salt/extra_keycontexts):(P is a fixed ~450-token text; the full JSON of P and all 5 requests is in the attached scripts.)
Expected: different
(cache_salt, extra_key)contexts → distinct radix namespaces → no cross-hits (T2–T5 should recompute prefill after T1's cold start).Actual (scheduler INFO log, per-request
#cached-token):I.e. all 5 semantically unrelated contexts share a single KV-cache namespace — the
cache_salt/extra_keyisolation contract is a complete no-op at runtime.Code-level break (fork @ 3bb39fca) — the feature is computed, carried layer by layer, then dropped when
Reqis constructed:Upstream comparison (regression evidence): sgl-project/sglang main
managers/scheduler.py:2549passesextra_key=recv_req.extra_keyat the same construction site (also :2863; :2464-2467 additionally uses extra_key for the elastic-EP namespace). In the fork, the serving layer, io_struct, theReq.__init__parameter, and the radix-cache namespace implementation (radix_cache.py:357-364 docstring: "Isolate KV cache lines for different LoRA / adapter IDs … cache version, or retrieval augmentation context") are all retained — only the scheduler hand-off is missing.Others
Impact scope (no over-claiming):
Req.__init__) — statically inferred, not GPU-tested this time.Suggested fix:
extra_key=recv_req.extra_keyto theReq(...)call inscheduler.handle_generate_request(fix_extra_key_delivery.patchattached; py_compile verified;TokenizedGenerateReqInput.extra_keyfield already exists, io_struct:724)."".join([cache_salt, extra_key])) and schedule_batch.py:632-638 ((extra_key or "") + lora_id) permits semantic collisions —(salt="a", ek="bc") ≡ (salt="ab", ek="c") ≡ (ek=<lora_id>)— which become exploitable the moment fix #1 lands (reproduced against the fork's real RadixCache inverify_cache_identity.py: CROSS-CONTEXT HIT). Recommend delimiter/hash encoding (length-prefixed or sha256).Please confirm: is this a regression or intentionally disabled? (Upstream passes the same field at the same site; the fork has no visible git history marking a deliberate removal, so we cannot rule intent out ourselves.)
@UniversePeak commented on GitHub (Sep 2, 2026):
I traced the current vendored SGLang path and found a small regression harness that can make this contract durable: reuse the existing radix-cache isolation test for same-key hits and cross-tenant misses, then add a focused request-construction check that requires
handle_generate_requestto passrecv_req.extra_keyintoReq. The latter currently fails onmain, which confirms the delivery gap rather than assuming the radix cache is at fault. Because SGLang is pinned as a submodule here, would you prefer this regression to land in the vendored SGLang test suite first, or should KTransformers carry a parent-level contract test alongside the coordinated submodule fix?@wildoranges commented on GitHub (Sep 2, 2026):
@UniversePeak Thanks for tracing this. My preference is to land the focused regression in the vendored SGLang test suite alongside https://github.com/kvcache-ai/sglang/pull/89, since the delivery gap is in the SGLang submodule.
The PR already includes the RadixCache isolation and scheduler/session propagation tests. The manual collision-test baseline issue was fixed in
github.com/kvcache-ai/sglang@f29d63fd39.A parent-level KTransformers contract test can be added later if an integration-only check is still needed after the submodule is updated.