Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions tests/v1/kv_offload/test_cpu_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,29 @@

from vllm.platforms import current_platform
from vllm.v1.attention.backends.flash_attn import FlashAttentionBackend
from vllm.v1.attention.backends.flashinfer import FlashInferBackend
from vllm.v1.attention.backends.mla.flashattn_mla import FlashAttnMLABackend
from vllm.v1.kv_offload.mediums import CPULoadStoreSpec, GPULoadStoreSpec
from vllm.v1.kv_offload.worker.cpu_gpu import CpuGpuOffloadingHandler

BACKENDS_TO_TEST = [FlashAttentionBackend]

if current_platform.is_cuda():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the previous logic for all non-ROCm platforms, to avoid changing the logic prior to this PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkLight1337 sounds good, updated - since I am working on checking AMD CI in general, I wonder if we want to use current_platform to gate CUDA specific kernels/features? The context is I found there are many tests with assumption that they will be running on CUDA platforms, thus these test are failing on AMD.

For example, ROCM uses TritonAttentionImpl as default, which doesn't support models with encoder(like openai/whisper)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from vllm.v1.attention.backends.flashinfer import FlashInferBackend

BACKENDS_TO_TEST.append(FlashInferBackend)

from vllm.v1.attention.backends.mla.flashattn_mla import FlashAttnMLABackend

BACKENDS_TO_TEST.append(FlashAttnMLABackend)

if current_platform.is_rocm():
from vllm.v1.attention.backends.rocm_attn import RocmAttentionBackend

BACKENDS_TO_TEST.append(RocmAttentionBackend)

from vllm.v1.attention.backends.mla.triton_mla import TritonMLABackend

BACKENDS_TO_TEST.append(TritonMLABackend)

NUM_GPU_BLOCKS = [64]
NUM_CPU_BLOCKS = [256]
GPU_BLOCK_SIZES = [16]
Expand All @@ -26,6 +44,10 @@
NUM_MAPPINGS = [3]


@pytest.mark.skipif(
len(BACKENDS_TO_TEST) < 2,
reason="Need at least 2 backends to test heterogeneous KV cache layouts",
)
@pytest.mark.parametrize("gpu_to_cpu", [True, False])
@pytest.mark.parametrize("num_mappings", NUM_MAPPINGS)
@pytest.mark.parametrize("head_size", HEAD_SIZES)
Expand Down Expand Up @@ -55,8 +77,7 @@ def test_transfer(
) -> None:
current_platform.seed_everything(seed)

# create per-layer GPU KV caches
attn_backends_list = [FlashAttentionBackend, FlashInferBackend, FlashAttnMLABackend]
attn_backends_list = BACKENDS_TO_TEST

gpu_caches = {}
attn_backends = {}
Expand Down