[BugFix][0.18.0][KV Pool] Fix KV Pool not putting kv cache for vllm v0.18.0 (#7874)

<!--  Thanks for sending a pull request!

BEFORE SUBMITTING, PLEASE READ
https://docs.vllm.ai/en/latest/contributing/overview.html

-->
### What this PR does / why we need it?
vLLM v0.18 defers KV connector finalization during target-modelforward
when speculative decoding is enable, leading to KV Pool not doing Put
Operation. This change is forgotten when we bumpped up the version for
vllm-ascend. Fix by adding finalize_kv_connector for spec decode.
<!--
- Please clarify what changes you are proposing. The purpose of this
section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster
reviews in your PR.

- Please clarify why the changes are needed. For instance, the use case
and bug description.

- Fixes #
-->

### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such
as API, interface or other behavior changes.
Documentation-only updates are not considered user-facing changes.
-->

### How was this patch tested?
<!--
CI passed with new added/existing test.
If it was tested in a way different from regular unit tests, please
clarify how you tested step by step, ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future.
If tests were not added, please describe why they were not added and/or
why it was difficult to add.
-->

Signed-off-by: Pz1116 <zpbzpb123123@gmail.com>
Co-authored-by: DreamerLeader <2270923832@qq.com>
Co-authored-by: fems14 <1804143737@qq.com>
This commit is contained in:
pz1116
2026-04-02 10:57:09 +08:00
committed by GitHub
parent 4b2f0130bc
commit 1225c613fb

View File

@@ -1577,8 +1577,11 @@ class NPUModelRunner(GPUModelRunner):
# tokens on the CPU, so they are run after bookkeeping.
propose_draft_token_ids(valid_sampled_token_ids)
if has_kv_transfer_group():
get_kv_transfer_group().clear_connector_metadata()
# vLLM v0.18 defers KV connector finalization during target-model
# forward when speculative decoding is enabled. Finalize here after
# draft model runs so KV pool save/put can complete.
if self.speculative_config is not None:
self.finalize_kv_connector()
if self.model_config.enable_return_routed_experts:
capturer = RoutedExpertsCapturer.get_instance()