Repository navigation
fix: avoid double KV release on disaggregated prefill grammar errors - #30937
ShangmingCai merged 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the disaggregation prefill queue handling to prevent overwriting an existing FINISH_ABORT status on requests. It also adds a comprehensive unit test suite to verify prefill queue cleanup under grammar failures and deferred aborts. The reviewer feedback highlights a critical issue where external aborts (req.to_finish) are silently discarded because they are not promoted to req.finished_reason on the prefill server. Suggestions are provided to promote req.to_finish to req.finished_reason in both the success and failure paths, and to update the new unit tests accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if not isinstance(req.finished_reason, FINISH_ABORT): | ||
| req.finished_reason = FINISH_LENGTH(length=0) |
There was a problem hiding this comment.
If a request is aborted externally, req.to_finish is set to FINISH_ABORT. Since update_finish_state is not called on the prefill server, to_finish is never promoted to finished_reason. Overwriting finished_reason with FINISH_LENGTH here will silently discard the external abort, causing the request to be treated as successful and potentially wasting downstream decode resources. We should promote req.to_finish to req.finished_reason if it is set.
if req.to_finish is not None:
req.finished_reason = req.to_finish
elif not isinstance(req.finished_reason, FINISH_ABORT):
req.finished_reason = FINISH_LENGTH(length=0)| if not isinstance(req.finished_reason, FINISH_ABORT): | ||
| prepare_abort( | ||
| req, error_message, status_code=HTTPStatus.INTERNAL_SERVER_ERROR | ||
| ) |
There was a problem hiding this comment.
Similarly, if the transfer fails but the request was already aborted externally, we should promote req.to_finish to req.finished_reason to preserve the original external abort reason instead of overwriting it with a transfer failure abort.
if req.to_finish is not None:
req.finished_reason = req.to_finish
elif not isinstance(req.finished_reason, FINISH_ABORT):
prepare_abort(
req, error_message, status_code=HTTPStatus.INTERNAL_SERVER_ERROR
)| ) | ||
|
|
||
| self.assertEqual(done, [req]) | ||
| self.assertIsInstance(req.finished_reason, FINISH_LENGTH) |
There was a problem hiding this comment.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/rerun-test test/registered/unit/disaggregation/test_prefill_queue_cleanup.py |
|
/rerun-group disaggregation |
|
1 similar comment
|
|
/rerun-test test/registered/unit/disaggregation/test_prefill_queue_cleanup.py |
|
/rerun-group disaggregation |
|
Results for 🚀 |
|
Results for 🚀 🚀 🚀 🚀 🚀 🚀 🚀 |
|
/rerun-test test/registered/unit/disaggregation/test_prefill_queue_cleanup.py |
|
Results for 🚀 |
|
/rerun-group disaggregation |
|
/rerun-test test/registered/unit/disaggregation/test_prefill_queue_cleanup.py |
|
Results for 🚀 |
|
Results for 🚀 🚀 🚀 🚀 🚀 🚀 🚀 |
…gl-project#30937) Co-authored-by: Shangming Cai <csmthu@gmail.com>
Motivation
When grammar validation fails after a disaggregated prefill KV transfer has started, the request remains in the inflight queue until the transfer reaches a terminal state. Releasing its KV cache immediately can release the same allocation again during terminal cleanup. Terminal handling can also replace the original grammar error with a transfer result.
Modifications
Accuracy Tests
Not applicable. This change only affects cleanup after grammar validation rejects a token.
Speed Tests and Profiling
Not applicable. The normal inference path is unchanged.
Checklist
Review and Merge Process
CI States
Latest PR Test (Base): ❌ Run #29323853939
Latest PR Test (Extra): ❌ Run #29323853715