-
Notifications
You must be signed in to change notification settings - Fork 843
[Bugfix][VoxCPM2]: Fix vectorized_gather OOB under concurrent prefill+decode batches #2903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hsliuustc0106
merged 5 commits into
vllm-project:main
from
Sy0307:fix/voxcpm2-batch-crash-and-perf
Apr 19, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
30f528f
[Bugfix] VoxCPM2: remove stale-state eviction in preprocess
Sy0307 f6580b4
[Bugfix][VoxCPM2] Address review feedback: constant + comment + tests
Sy0307 5222cb9
[Bugfix][VoxCPM2][CI] Skip state-eviction test when librosa missing
Sy0307 2eb0f19
[Bugfix][VoxCPM2][Test] Add e2e prefill+decode mixed-batch regression
Sy0307 dac2f59
[Bugfix][VoxCPM2][Test] Trim over-commented test files
Sy0307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
121 changes: 121 additions & 0 deletions
121
tests/model_executor/models/voxcpm2/test_talker_state_eviction.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """Regression tests for VoxCPM2 talker per-request state lifecycle.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
|
|
||
| torch = pytest.importorskip("torch") | ||
| pytest.importorskip("librosa") | ||
|
|
||
| from vllm_omni.model_executor.models.voxcpm2.voxcpm2_talker import ( # noqa: E402 | ||
| VoxCPM2TalkerForConditionalGeneration, | ||
| _RequestState, | ||
| ) | ||
|
|
||
|
|
||
| def _make_bare_talker() -> VoxCPM2TalkerForConditionalGeneration: | ||
| talker = VoxCPM2TalkerForConditionalGeneration.__new__(VoxCPM2TalkerForConditionalGeneration) | ||
| talker._active_states = {} | ||
| talker._current_request_id = None | ||
| talker._pending_requests = [] | ||
| talker._results_queue = [] | ||
| talker._audio_queue = [] | ||
| talker._deferred_cleanup_ids = set() | ||
| talker._max_batch_size = 4 | ||
| talker._active_state_warn_threshold = 512 | ||
| talker._active_state_warned = False | ||
| return talker | ||
|
|
||
|
|
||
| def _seed_cached_decode(talker, req_id: str) -> _RequestState: | ||
| state = _RequestState(request_id=req_id) | ||
| state.prefill_completed = True | ||
| state.decode_step_count = 5 | ||
| talker._active_states[req_id] = state | ||
| return state | ||
|
|
||
|
|
||
| class TestStateEvictionContract: | ||
| def test_pending_requests_is_not_used_for_eviction(self) -> None: | ||
| talker = _make_bare_talker() | ||
|
|
||
| cached_ids = [f"req-{i}" for i in range(4)] | ||
| for rid in cached_ids: | ||
| _seed_cached_decode(talker, rid) | ||
|
|
||
| walked_so_far = ["req-new", cached_ids[0], cached_ids[1]] | ||
| talker._pending_requests = [(rid, False, None, 0) for rid in walked_so_far] | ||
|
|
||
| for rid in cached_ids: | ||
| assert rid in talker._active_states | ||
| assert talker._active_states[rid].prefill_completed is True | ||
|
|
||
| def test_on_requests_finished_defers_cleanup(self) -> None: | ||
| talker = _make_bare_talker() | ||
| _seed_cached_decode(talker, "req-A") | ||
| _seed_cached_decode(talker, "req-B") | ||
|
|
||
| talker.on_requests_finished({"req-A"}) | ||
|
|
||
| assert "req-A" in talker._active_states | ||
| assert "req-A" in talker._deferred_cleanup_ids | ||
|
|
||
| def test_flush_deferred_cleanup_removes_only_finished(self) -> None: | ||
| talker = _make_bare_talker() | ||
| _seed_cached_decode(talker, "req-A") | ||
| _seed_cached_decode(talker, "req-B") | ||
| talker.on_requests_finished(["req-A"]) | ||
|
|
||
| talker._flush_deferred_cleanup() | ||
|
|
||
| assert "req-A" not in talker._active_states | ||
| assert "req-B" in talker._active_states | ||
| assert talker._deferred_cleanup_ids == set() | ||
|
|
||
| def test_current_request_id_cleared_when_matching(self) -> None: | ||
| talker = _make_bare_talker() | ||
| _seed_cached_decode(talker, "req-A") | ||
| talker._current_request_id = "req-A" | ||
|
|
||
| talker.on_requests_finished({"req-A"}) | ||
| talker._flush_deferred_cleanup() | ||
|
|
||
| assert talker._current_request_id is None | ||
|
|
||
| def test_current_request_id_preserved_when_not_finished(self) -> None: | ||
| talker = _make_bare_talker() | ||
| _seed_cached_decode(talker, "req-A") | ||
| _seed_cached_decode(talker, "req-B") | ||
| talker._current_request_id = "req-B" | ||
|
|
||
| talker.on_requests_finished({"req-A"}) | ||
| talker._flush_deferred_cleanup() | ||
|
|
||
| assert talker._current_request_id == "req-B" | ||
|
|
||
|
|
||
| class TestLeakWarnGuard: | ||
| def test_warn_fires_once_over_threshold(self, monkeypatch) -> None: | ||
| from vllm_omni.model_executor.models.voxcpm2 import voxcpm2_talker as tk | ||
|
|
||
| calls: list[str] = [] | ||
|
|
||
| def _capture(msg, *args, **kwargs): | ||
| calls.append(msg % args if args else msg) | ||
|
|
||
| monkeypatch.setattr(tk.logger, "warning", _capture) | ||
|
|
||
| talker = _make_bare_talker() | ||
| talker._active_state_warn_threshold = 3 | ||
|
|
||
| for i in range(4): | ||
| talker._active_states[f"seed-{i}"] = _RequestState(request_id=f"seed-{i}") | ||
|
|
||
| talker._get_or_create_state("new-1") | ||
| talker._get_or_create_state("new-2") | ||
|
|
||
| leak_warnings = [m for m in calls if "cleanup path leak" in m] | ||
| assert len(leak_warnings) == 1 | ||
| assert talker._active_state_warned is True |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.