fix(vllm): preserve decode handoff on cancellation - #12736
Conversation
d005cd5 to
bf1aaf9
Compare
a86e085 to
5b2102d
Compare
5b2102d to
29b0831
Compare
This comment has been minimized.
This comment has been minimized.
8514ca6 to
a9a363d
Compare
a9a363d to
5aaaa4f
Compare
WalkthroughvLLM generation now separates request cancellation from shutdown. Decode requests remain active until stream setup and first-token or transfer completion, then emit cancelled output. Tests cover delayed cancellation and premature EOF, and the README documents the behavior. ChangesvLLM request cancellation flow
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
lib/sidecar/vllm/src/tests.rs (1)
926-951: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the remaining cancellation-mapping arms.
decode_cancellation_maps_premature_eof_to_cancelledcovers theOk(None)arm inengine.rs. Two sibling arms remain untested: theErr(status)arm that maps a gRPC failure after cancellation to a cancelled result, and theErr(error)arm that maps a conversion failure after cancellation. Both arms are new and both silently convert a failure into a success value, so a regression there is easy to miss.The
FakeVllmservice already supports the required hooks. Add afail_before_first_tokenflag that yieldsErr(Status::internal(...))after the prompt response, and a flag that emits an invalid response (for example,num_tokensthat does not matchtoken_ids.len()) to trigger the conversion error path.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/sidecar/vllm/src/tests.rs` around lines 926 - 951, Add tests alongside decode_cancellation_maps_premature_eof_to_cancelled covering both remaining cancellation mappings: configure FakeVllm with a fail_before_first_token hook that returns Err(Status::internal(...)) after the prompt, and with an invalid-response hook such as mismatched num_tokens and token_ids length to trigger conversion failure. For each case, stop generation after starting the stream and assert the terminal result is a successful cancelled output with FinishReason::Cancelled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/sidecar/vllm/README.md`:
- Line 70: Update the cancellation behavior paragraph near the decode stream
description to document both release conditions: the stream is retained until
either the first output token or a terminal response containing finish_info.
Also state that premature stream termination, gRPC failures, and
post-cancellation conversion failures produce a cancelled result.
In `@lib/sidecar/vllm/src/engine.rs`:
- Around line 223-242: Update the request-processing loop around
request_cancelled and stream.message() to create one per-request cancellation
deadline before the loop, then include that deadline in the post-cancellation
select. When it expires, emit the cancelled output and exit the loop, while
preserving the existing shutdown and stream-message handling and ensuring
intermediate messages do not restart the deadline.
---
Nitpick comments:
In `@lib/sidecar/vllm/src/tests.rs`:
- Around line 926-951: Add tests alongside
decode_cancellation_maps_premature_eof_to_cancelled covering both remaining
cancellation mappings: configure FakeVllm with a fail_before_first_token hook
that returns Err(Status::internal(...)) after the prompt, and with an
invalid-response hook such as mismatched num_tokens and token_ids length to
trigger conversion failure. For each case, stop generation after starting the
stream and assert the terminal result is a successful cancelled output with
FinishReason::Cancelled.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 3b175f35-3496-4ef9-a108-770acd167493
📒 Files selected for processing (3)
lib/sidecar/vllm/README.mdlib/sidecar/vllm/src/engine.rslib/sidecar/vllm/src/tests.rs
Signed-off-by: Connor Carpenter <connorc@nvidia.com>
Signed-off-by: Connor Carpenter <connorc@nvidia.com>
Signed-off-by: Connor Carpenter <connorc@nvidia.com>
Signed-off-by: Connor Carpenter <connorc@nvidia.com>
b467d37 to
a67345b
Compare
|
/ok to test a67345b |
|
I would have thought cancellation / lifecycle would be handled by unified backend not specific to each framework sidecar |
|
Right now cancellation happens by dropping the gRPC response stream, which is owned by the sidecar. Also, to preserve the decode handoff, the sidecar needs to read vLLM-specific fields from transfer params, so that logic cannot live in the unified backend. I think this is the right location for this code until the sidecars are more stable and we can define more clear abstractions. |
Overview:
Part 2 of a 4-PR stack. This layer preserves disaggregated NIXL handoff completion when a client cancels a decode request.
Details:
Cancelledterminal while logging the underlying failure.Abortor close the shared pooled channel.The post-cancellation wait intentionally has no arbitrary timeout; safe bounded cleanup requires a protocol-level transfer-completion or cleanup signal.
Stack
Base: #12734
Validation
cargo fmt --all -- --checkcargo test -p dynamo-vllm-sidecar— 17 tests passedcargo clippy -p dynamo-vllm-sidecar --all-targets -- -D warningsWhere should the reviewer start?
lib/sidecar/vllm/src/engine.rsfor the cancellation race and stream-lifetime behavior.lib/sidecar/vllm/src/tests.rsfor first-token deferral and premature-EOF regression coverage.Related Issues
This PR is NOT linked to an issue:
Summary by CodeRabbit
Bug Fixes
Documentation