Fix(disagg): correct prefill chunk progress and cache owner IDs - #4977
Open
RunningLeon wants to merge 1 commit into
Open
RunningLeon wants to merge 1 commit into
RunningLeon wants to merge 1 commit into
Conversation
Advance chunk history on Prefill workers and propagate the internal cache_session_id through chat/completions, migration metadata and shelf tracking. Keep the existing forwarding and cleanup structure unchanged. Add chunk-boundary, owner propagation and invalid-owner regression tests.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical cache-owner correctness and retained-session cleanup issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes DistServe cache-owner propagation and long-prefill chunk progress.
Changes:
- Adds internal
cache_session_idpropagation and validation. - Advances chunk history before Prefill early returns.
- Adds regression coverage for ownership and chunk progression.
Critical findings:
completions.py:338(3 votes): Batched prompts may use the wrong cache owner.proxy.py:715(2 votes): Invalid or missing owners can leak retained Prefill sessions.
File summaries
| File | Description |
|---|---|
tests/test_lmdeploy/serve/openai/test_distserve.py |
Tests cache-owner propagation and validation. |
tests/pytorch/engine/test_inputs_maker.py |
Tests chunk-history progression. |
lmdeploy/serve/proxy/proxy.py |
Validates and tracks internal cache owners. |
lmdeploy/serve/openai/endpoints/completions.py |
Emits cache-owner metadata. |
lmdeploy/serve/openai/chat_completions/serving.py |
Emits cache-owner metadata. |
lmdeploy/pytorch/engine/inputs_maker.py |
Updates chunk history for Prefill workers. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| if with_cache: | ||
| # Cache ownership uses the engine's ID, not the public response ID. | ||
| response['cache_session_id'] = sessions[0].session_id |
Comment on lines
+715
to
+718
| if type(remote_session_id) is not int or remote_session_id < 0: | ||
| return create_error_response(HTTPStatus.BAD_GATEWAY, | ||
| 'Prefill response is missing a valid cache_session_id; ' | ||
| 'upgrade the Prefill server together with the proxy.') |
grimoire
approved these changes
Sep 16, 2026
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fix two correctness issues in PyTorch Prefill/Decode disaggregation (DistServe):
chatcmpl-...ID as an integer cache-owner ID. Completions can also use the wrong owner for cache release.Modification
cache_session_idfrom chat/completions and use it consistently for migration and shelf tracking. Reject missing or invalid owners instead of falling back to the public ID.Validation: 91 CPU tests passed, plus Ruff and commit hooks. On full Qwen3-30B-A3B-Instruct-2507 with two H200 GPUs and real synchronous Mooncake RDMA, 30 PD requests and 4 direct Decode controls passed across both endpoints, streaming modes, chunk boundaries, and concurrency. All 30 migration ACKs matched Prefill session release; P/D scheduler sessions drained to zero and services shut down cleanly.
This verifies functional completion, not numerical equivalence. Cancellation/error-path lifecycle fixes and linear-attention state migration are outside this PR.
BC-breaking (Optional)
Upgrade the proxy and Prefill servers together: the proxy requires
cache_session_id. Public response IDs remain unchanged.Checklist