[ModelRunnerV2] Fix scalar Mamba state update with int32 mappings (#50327)

Signed-off-by: Varun Shenoy <varun.vinayak.shenoy@oracle.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
Co-authored-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
Varun Vinayak Shenoy
2026-08-03 22:05:12 +00:00
committed by GitHub
co-authored by Nick Hill
parent f43e1d26e3
commit e578de311c
2 changed files with 58 additions and 16 deletions
@@ -0,0 +1,29 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import pytest
import torch
from vllm.platforms import current_platform
from vllm.v1.worker.gpu.model_states.mamba_hybrid import MambaHybridModelState
@pytest.mark.skipif(not current_platform.is_cuda(), reason="Requires CUDA")
@pytest.mark.parametrize(("num_sampled", "expected_value"), [(0, 1), (3, 3)])
def test_postprocess_state_scalar_with_int32_mapping(
num_sampled: int, expected_value: int
) -> None:
state = object.__new__(MambaHybridModelState)
state.num_accepted_tokens_gpu = torch.full(
(4,), 9, dtype=torch.int32, device="cuda"
)
state._align_mode = False
state._mamba_ctx = None
idx_mapping = torch.tensor([2, -1, 0], dtype=torch.int32, device="cuda")
state.postprocess_state(idx_mapping, num_sampled)
expected = torch.tensor(
[expected_value, 9, expected_value, 9], dtype=torch.int32, device="cuda"
)
torch.testing.assert_close(state.num_accepted_tokens_gpu, expected)