| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | import pytest |
| 4 | |
| 5 | from vllm.platforms import current_platform |
| 6 | |
| 7 | |
| 8 | @pytest.fixture(autouse=True) |
| 9 | def _mock_cpu_backend_block_sizes(monkeypatch): |
| 10 | """Mock the CPU attention backend's kernel block-size declaration. |
| 11 | |
| 12 | Connector unit tests exercise transfer logic, never the attention |
| 13 | kernel, and hard-code block_size=16. On CPU-only machines |
| 14 | `CPUAttentionBackend` declares `MultipleOf(32)` (#54042), so every |
| 15 | worker construction would fail in `select_common_block_size` before |
| 16 | reaching the code under test. |
| 17 | """ |
| 18 | if not current_platform.is_cpu(): |
| 19 | return |
| 20 | from vllm.v1.attention.backend import MultipleOf |
| 21 | from vllm.v1.attention.backends.cpu_attn import CPUAttentionBackend |
| 22 | |
| 23 | monkeypatch.setattr( |
| 24 | CPUAttentionBackend, |
| 25 | "get_supported_kernel_block_sizes", |
| 26 | staticmethod(lambda: [MultipleOf(16)]), |
| 27 | ) |