[Test] Add xformer and flash attn tests (#3961)

Co-authored-by: Simon Mo <simon.mo@hey.com>
This commit is contained in:
SangBin Cho
2024-04-11 12:09:50 +09:00
committed by GitHub
parent caada5e50a
commit e42df7227d
2 changed files with 15 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ Run `pytest tests/basic_correctness/test_basic_correctness.py`.
"""
import pytest
from vllm.attention.selector import VLLM_ATTENTION_BACKEND
MODELS = [
"facebook/opt-125m",
"meta-llama/Llama-2-7b-hf",
@@ -14,6 +16,7 @@ MODELS = [
@pytest.mark.parametrize("dtype", ["half"])
@pytest.mark.parametrize("max_tokens", [5])
@pytest.mark.parametrize("enforce_eager", [False, True])
@pytest.mark.parametrize("attn_backend", ["XFORMERS", "FLASH_ATTN"])
def test_models(
hf_runner,
vllm_runner,
@@ -22,7 +25,10 @@ def test_models(
dtype: str,
max_tokens: int,
enforce_eager: bool,
attn_backend: str,
monkeypatch,
) -> None:
monkeypatch.setenv(VLLM_ATTENTION_BACKEND, attn_backend)
hf_model = hf_runner(model, dtype=dtype)
hf_outputs = hf_model.generate_greedy(example_prompts, max_tokens)
del hf_model