Repository navigation
feat(mocker): publish native KV events from SGLang gRPC servers - #14744
Conversation
9add2a6 to
02a912d
Compare
Signed-off-by: jthomson04 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
02a912d to
f4e87cf
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: ai-dynamo/dynamo/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 10 remain after this review. WalkthroughThe SGLang mocker can publish ZMQ KV cache events when prefix caching is enabled in supported server modes. The server includes publisher metadata in discovery. Tests cover publisher bind failure and sidecar event relay for SGLang and vLLM. ChangesKV event publishing
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change adds KV event publication and discovery for supported SGLang modes while preserving serving when publisher setup fails. No merge-blocking issue is identified; merge after normal checks pass. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 6 files. (2 skipped: 2 unsupported.)
Comment |
jthomson04
left a comment
There was a problem hiding this comment.
Review notes on f4e87cf03d (static review; nothing was built or run):
- Validation-order regression: with
normalized()moved after thedp_sizeguard, AISattention_dp > 1configs now fail late with a misleading error. - KV publishing on by default: every SGLang mock server now binds an unauthenticated ZMQ PUB socket on 0.0.0.0 that streams prompt token IDs, and pays the token-ID encoding cost on the scheduler hot path even with no subscriber.
- Smaller items:
expectpanics in a fallible constructor, IPv6 wildcard mismatch, explicit ports silently ignored, test coverage drift, and duplication with the vLLM server.
Signed-off-by: jthomson04 <[email protected]>
✅ Dynamo PR CI passed — run 36926942220 (attempt 2) on
|
dmitry-tokarev-nv
left a comment
There was a problem hiding this comment.
Approve at 4012dd74437efe25b41dc94415efa37216f28885. I found no P0, P1, or P2 defect. One P3 is open.
[P3] The README does not say that the mock encodes KV events differently from SGLang. lib/mocker/servers/sglang/README.md:46. SGLang 0.5.19's own decoder rejects the mock's events, but Dynamo's router decodes both encodings. Please add one sentence about this to the KV events section.
Event encoding, measured with the SGLang 0.5.19 image and this head.
I sent live mock events to SGLang's own KVEventBatch decoder. As a control, the same decoder accepts an event that SGLang encodes.
| Source | Encoded BlockStored event |
SGLang typed decode |
|---|---|---|
| SGLang 0.5.19 | ['BlockStored', [1, 2], None, [0, ..., 7], 4, None, None] |
OK |
| Mock at this head | {'type': 'BlockStored', 'block_hashes': [...], 'parent_block_hash': None, 'token_ids': [600, ..., 607], 'block_size': 4, 'group_idx': 0} |
ValidationError Expected `array`, got `object` - at `$[1][0]` |
The frames (topic, sequence, payload), the batch envelope ([ts, events, dp_rank]), and the descriptor keys match. The mock omits only the optional load-publisher keys. The mock sink uses named fields on purpose (see the test comment in lib/mocker/src/services/zmq_events.rs). Thus I do not ask for a new encoding. The new end-to-end test covers Dynamo's map decoder, not the positional path that real SGLang uses.
What I measured at this head, with base and merge controls.
All runs are on a GPU box with Rust 1.96.1 and cargo test --locked --all-targets for dynamo-sglang-mocker, dynamo-vllm-mocker, dynamo-trtllm-mocker, and dynamo-sidecar-testkit.
| Tree | Passed | Failed |
|---|---|---|
Merge base 006e5f340e |
88 | 0 |
| This head | 92 | 0 |
This head merged into main e54dbaba29 |
92 | 0 |
This head merged into main 0a6f58b95d |
92 | 0 |
The 4 extra tests are the new SGLang tests. The counts match the Pre Merge job.
- Event path:
sidecar_relays_stored_and_evicted_blockspassed 20 of 20 runs. A probe printed the relayed events. The stored event carries the router's own hashes of both prompt blocks, so the token IDs arrive. A later removed event names the same two block hashes. The sidecar replaces0.0.0.0with the--grpc-endpointhost. - Gates, with the server binary: decode mode and
"enable_prefix_caching":falsebind no publisher and leave the explicit port free. Prefill mode publishes. The server binds explicit event and replay ports. - Bind failure: the server logs
ZMQ PUB bind to tcp://0.0.0.0:37605 failed: Zmq error: Address already in useand serves without KV events. - Automatic ports: two servers on one host got ports 37605 and 41331, each held by its own process. A collision needs an explicit port that another server already holds. That server then logs the error above and runs without events.
- Arguments: 11 cases give the same result through the base and head binaries, except
"block_size":4294967296. Head now rejects it at startup in aggregated and decode mode. A secondnormalized()call does not change deserialized arguments (5 cases). Thus the removed call inmain.rshas no effect. - Mutations: I broke the decode gate, the prefix-caching gate, the advertised port, host, block size, and descriptor, and I moved or removed
normalized(). Each of the 9 mutants fails at least one test. A wrong advertised port fails only the end-to-end test, after a 10 s timeout. Normalization after the checks givessingle-rank create_engine does not support attention DP; use create_grouped_scheduler, as the PR body says. Cargo.lock: both sides list the same 1052 packages. The 3 new entries are workspace crates. The--lockedbuilds pass on every tree above.
Deferred by the author and documented in the README, so I did not reopen them: publishing on by default, the unauthenticated IPv4 0.0.0.0 bind, token-ID work without subscribers, and IPv4-only events. These match the merged vLLM mock server.
Summary
The SGLang mock gRPC server does not advertise or publish KV events, so requests through its sidecar cannot update Dynamo's KV router. Connect the existing ZMQ sink to
LiveEngineConfigand advertise the bound endpoint throughGetServerInfo.kv_events. The real SGLang sidecar then relays stored and removed blocks through the shared event path.Publish when prefix caching is enabled and the wire role is not decode. Bind an automatic port by default, honor explicit event and replay ports, and retain regular-mocker error-and-continue behavior on publisher bind failure. Construction remains synchronous and uses the active Tokio runtime. Normalize engine arguments before the server's role and single-rank checks. Share the existing vLLM store/eviction test helper with SGLang, retain default prefix caching in the existing SGLang tests, and document discovery, IPv4 binding, token payloads, and disabled-publisher behavior.
This PR uses the published dependency pins from main: Rust
aisimulate-core=0.13.0-dev.202609300000000061and Pythonaisimulate==0.13.0.dev202609300000000061. No dependency overrides or compatibility patches are required. The parent vLLM change (#14737) and AISimulate compatibility update (#14541) are merged.Related Issues
Validation
Local validation for
4012dd74437efe25b41dc94415efa37216f28885, with builds and execution outside the sandbox:cargo test --locked -p dynamo-sglang-mocker -p dynamo-vllm-mocker -p dynamo-sidecar-testkit --no-fail-fast: 42 passed (33 mock-server tests and 9 testkit tests). Includes default-prefix-caching generation, cancellation and handoff, both sidecar store/eviction tests, publication gates, and bind failure.single-rank create_engine does not support attention DP; use create_grouped_scheduler, then passed after normalization moved before the server checks. It now receivesMocker dp_size must be 1for Rust-built arguments with canonicalattention_dp=2; no model download or performance database was needed.--locked. Reused the unchanged frontend bindings and sidecar binaries from the prior validation.cargo fmt --all -- --check, pre-commit checks for the four changed files, andgit diff --check: passed.The HTTP smoke used one worker per case, a local tokenizer,
speedup_ratio=1000, direct ZMQ events, and isolated etcd/NATS state in memory. These are CPU-only local results, not full repository CI, GPU validation, or a performance comparison.Summary by CodeRabbit