Repository navigation
fix(kv-router): decode SGLang BlockStored metadata in positional KV events - #14530
ishandhanani wants to merge 1 commit into
Conversation
…vents SGLang >= 0.5.18 emits BlockStoredWithMetadata (sgl-project/sglang#30827): the vLLM-compatible positional prefix plus a BlockStoredMetadata map at position 7 whenever the stored node carries a cache_salt. The positional decoder read that slot as vLLM's lora_name string, so every such event failed with "invalid type: map, expected a string" and the listener dropped the whole ZMQ batch, including co-batched unsalted events. The router index then silently diverged from the engine. Accept either a string or a map at position 7, map cache_salt to the cache namespace like the named-map path does, and ignore keys the raw event does not model yet (sgl-project/sglang#37482 adds session_id). Document the shape in the wire README. Signed-off-by: Ishan Dhanani <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. WalkthroughThe ZMQ wire deserializer now accepts SGLang ChangesZMQ wire SGLang metadata support
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to KV-router now accepts SGLang metadata-map events while retaining vLLM compatibility and routes non-empty cache salts into cache namespaces. The covered decoding and namespace behavior presents no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, impact, and validation results, but it does not use the required template sections and omits the required Related Issues declaration and the Where should the reviewer start section. Full details: Docstring CoverageExplanation Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (1 skipped: 1 unsupported.)
Comment |
| } | ||
| } | ||
|
|
||
| /// The listener decodes a whole `EventBatch` at once, so one salted SGLang event |
There was a problem hiding this comment.
This batch-level case is redundant with the added positional SGLang metadata decoder test: decode_event_batch is only rmp_serde::from_slice, so the salted event failure is distinguished by test_deserialize_sglang_positional_block_stored_metadata_map and the batch envelope is already exercised by an existing selected decode_event_batch test. Removing this case still leaves the SGLang metadata map contract and the EventBatch decoding boundary protected.
🤖 AI Fix
Remove test_decode_event_batch_with_sglang_metadata_event and rely on the direct SGLang metadata deserialization test plus the existing batch decode coverage.
| } | ||
| } | ||
|
|
||
| /// SGLang's typed `BlockStoredMetadata` map. Since SGLang 0.5.18 a positional |
There was a problem hiding this comment.
This repeats the version and issue history already recorded in the adjacent wire-format README. Retain only the lasting forward-compatibility constraint: this metadata preserves cache_salt and ignores unmodeled keys.
🤖 AI Fix
Condense this doc comment to the metadata's cache_salt and unknown-key compatibility behavior.
| } | ||
| } | ||
|
|
||
| /// SGLang >= 0.5.18 appends its `BlockStoredMetadata` map at position 7 when the |
There was a problem hiding this comment.
The test name, positional fixture, and assertions already document this compatibility case; the version and issue reference add implementation history without a lasting constraint.
🤖 AI Fix
Remove this test doc comment.
| } | ||
| } | ||
|
|
||
| /// Keys the raw event does not model yet (sgl-project/sglang#37482 adds |
There was a problem hiding this comment.
This merely narrates the unknown-key and empty-value fixture that the test name and assertions make explicit.
🤖 AI Fix
Remove this test doc comment.
| } | ||
| } | ||
|
|
||
| /// The vLLM `lora_name` string at position 7 still decodes as before. |
There was a problem hiding this comment.
This restates the test name and its single lora_name assertion.
🤖 AI Fix
Remove this test doc comment.
| } | ||
| } | ||
|
|
||
| /// The listener decodes a whole `EventBatch` at once, so one salted SGLang event |
There was a problem hiding this comment.
The decode_event_batch call and test name establish the batch-level coverage; "used to drop" is bug history rather than a lasting constraint.
🤖 AI Fix
Remove this test doc comment.
Summary
BlockStoredWithMetadata(feat: add cache salt support to KV cache events sgl-project/sglang#30827): the vLLM-compatible positional prefix plus aBlockStoredMetadatamap at position 7 whenever the stored node carries acache_salt. feat(agent sessions): attribute stored KV cache blocks to sessions sgl-project/sglang#37482 addssession_idto the same map.lora_name: Option<String>. Every such event failed withinvalid type: map, expected a string, andapply_live_batchinservices/indexer/listener.rsdropped the whole ZMQ batch. Co-batched unsalted events were lost too, so the router index silently diverged from the engine. No error reached the client.cache_saltto the cache namespace like the named-map path already does, and ignores keys the raw event does not model yet (session_id), so the event and its batch decode.dynamo.sglangworker forwardscache_salt. It becomes live with sglang#37482 plus session-id forwarding (feat(sglang): support session-attributed KV events #14144), or with anycache_saltsupport for SGLang. Backport candidate forrelease/1.5.0, which has the same decoder and pins SGLang 0.5.18.lib/kv-router/src/zmq_wire/README.mdwith the SGLang shape.Validation
cargo test -p dynamo-kv-router --lib zmq_wire: 62 passed, including 4 new tests (metadata map decode, unknown keys plus empty salt,lora_namestring unchanged, whole-batch decode).cargo clippy -p dynamo-kv-router --tests -- -D warningsandcargo fmt --all -- --check: clean.main:invalid type: map, expected a stringfor both thecache_salt-only map and thesession_idmap; the legacy shape decoded.Failed to decode KvEventBatchand the KV index stayed empty (0 cached tokens on every turn) until this change.Summary by CodeRabbit
New Features
Documentation
Tests