[Bugfix]Stop zero-progress preemption cascades for deferred KV frees - #16265
luoxiaolin712 wants to merge 2 commits into
Conversation
… frees Backport vLLM PR #49675 (fix/zero-reclaim-preemption-cascade) as a platform patch. With deferred block freeing enabled (async scheduling + PD KV-consumer), the schedule() allocation retry loop could pick a preemption victim whose blocks are still fenced by an in-flight step: freeing them is deferred, so the retry allocate_slots keeps failing and preempts the running requests one by one, stalling the engine. The patch ports the three PR deltas onto vllm-ascend: - the retry loop selects the victim before removing it and breaks out when _should_defer_request_block_free(victim) is true (retried on a later step instead of cascading); - new Scheduler._should_defer_request_block_free helper; - _free_request_blocks refactored onto the same helper. schedule() is an ~800-line method, so (as in patch_balance_schedule.py) the whole body is copied verbatim from the pinned release tag (.github/vllm-release-tag.commit = v0.27.1) with only the preemption-loop delta, adapted to the pin's bookkeeping. Install is guarded: skip when the installed vLLM already ships the fix, fail loudly when the installed schedule() signature no longer matches the pin. Behavior is unchanged when defer_block_free is disabled. Signed-off-by: lty <linhebiwen@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical bugfix for the vLLM scheduler, specifically addressing a preemption cascade issue encountered when using async scheduling and deferred KV block freeing. By backporting logic from upstream vLLM, the patch ensures that the scheduler avoids preempting requests whose blocks are still in use by pending GPU steps, thereby preventing engine stalls. The implementation includes a new helper method and a carefully guarded patch to the scheduler's main loop to maintain compatibility with the current pinned vLLM release. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. Tip 💡 Consider Linking a Related Issue or RFCYour PR title contains the [BugFix] tag, indicating a bug fix or new feature. Linking a related issue or RFC in the PR description is strongly encouraged — it gives reviewers helpful context and speeds up the review. You can use any of these keywords:
🙏 Thanks for helping us keep the project well-organized! |
There was a problem hiding this comment.
Code Review
This pull request backports vLLM PR #49675 to introduce a defer-aware preemption retry mechanism, preventing zero-reclaim preemption cascades when deferred block freeing is enabled. However, a critical issue was identified where this patch completely overwrites Scheduler.schedule, silently disabling the previously imported patch_balance_schedule.py patch. It is recommended to merge these patches or dynamically chain the schedule method.
Suggested PR Title:
[Ops][BugFix] Backport defer-aware preemption retry from vLLM PR #49675Suggested PR Summary:
### What this PR does / why we need it?
This PR backports vLLM PR #49675 to introduce a defer-aware preemption retry mechanism. This prevents a zero-reclaim preemption cascade and engine stalls when deferred block freeing is enabled (async scheduling + PD KV-consumer). It patches `Scheduler.schedule`, `Scheduler._free_request_blocks`, and adds `Scheduler._should_defer_request_block_free`.
However, there is a critical issue: this patch completely overwrites `Scheduler.schedule`, which is also patched by `patch_balance_schedule.py`. Since this patch is imported after, it silently disables the balance scheduling feature. These patches should be merged or refactored to dynamically chain/wrap the original method.
### Does this PR introduce _any_ user-facing change?
No, this is an internal scheduling optimization and bug fix.
### How was this patch tested?
CI passed with existing tests.| ) | ||
| Scheduler._should_defer_request_block_free = _should_defer_request_block_free | ||
| Scheduler._free_request_blocks = _free_request_blocks | ||
| Scheduler.schedule = _defer_free_aware_schedule |
There was a problem hiding this comment.
Both patch_balance_schedule.py and patch_defer_block_free_schedule.py monkey-patch Scheduler.schedule by completely overwriting Scheduler.schedule with their respective implementations.
Because patch_defer_block_free_schedule is imported after patch_balance_schedule in vllm_ascend/patch/platform/__init__.py, it completely overwrites Scheduler.schedule, silently disabling the balance scheduling feature even if enable_balance_scheduling is set to True.
To resolve this, you should either:
- Merge the two scheduling patches into a single patch file that handles both balance scheduling and deferred block freeing.
- Dynamically chain/wrap the original
schedulemethod or each other's patched methods instead of copying and overwriting the entire 800-line method verbatim twice.
Import patch_defer_block_free_schedule before patch_balance_schedule so it patches the original Scheduler base class. Previously it ran after balance had swapped the module-level Scheduler name to BalanceScheduler, silently overwriting BalanceScheduler.schedule (including the balance-enabled path) with the defer-aware copy. Patching the base first lets BalanceScheduler inherit the fix via super().schedule() on its disabled path. Signed-off-by: lty <linhebiwen@gmail.com>
What this PR does / why we need it?
vllm fix PR
This PR fixes one known zero-progress transition in the running-request
allocation retry. It does not change the deferred-free safety fence, model
output semantics, or FCFS/PRIORITY victim-selection policy.
Does this PR introduce any user-facing change?
NA
How was this patch tested?