2024-07-19 04:22:08 +02:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from .conftest import run_equality_correctness_test
|
|
|
|
|
2024-09-11 14:07:34 -07:00
|
|
|
# main model
|
|
|
|
MAIN_MODEL = "JackFram/llama-68m"
|
|
|
|
|
|
|
|
# speculative model
|
|
|
|
SPEC_MODEL = "JackFram/llama-160m"
|
|
|
|
|
2024-07-19 04:22:08 +02:00
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"common_llm_kwargs",
|
|
|
|
[{
|
2024-09-11 14:07:34 -07:00
|
|
|
"model_name": "JackFram/llama-68m",
|
2024-07-19 04:22:08 +02:00
|
|
|
|
|
|
|
# Skip cuda graph recording for fast test.
|
|
|
|
"enforce_eager": True,
|
|
|
|
|
|
|
|
# speculative model
|
|
|
|
"speculative_model": "JackFram/llama-160m",
|
|
|
|
|
|
|
|
# num speculative tokens
|
|
|
|
"num_speculative_tokens": 3,
|
|
|
|
}])
|
|
|
|
@pytest.mark.parametrize("per_test_common_llm_kwargs", [{}])
|
2024-07-24 08:58:31 -07:00
|
|
|
@pytest.mark.parametrize("baseline_llm_kwargs", [{"seed": 1}])
|
|
|
|
@pytest.mark.parametrize("test_llm_kwargs", [{"seed": 5}])
|
2024-07-19 04:22:08 +02:00
|
|
|
@pytest.mark.parametrize("batch_size", [1, 8, 32])
|
|
|
|
@pytest.mark.parametrize("temperature", [0.1, 1.0])
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"output_len",
|
|
|
|
[
|
|
|
|
# Use smaller output len for fast test.
|
2024-07-30 10:40:08 -07:00
|
|
|
20,
|
2024-07-19 04:22:08 +02:00
|
|
|
])
|
2024-09-11 14:07:34 -07:00
|
|
|
def test_seeded_consistency(vllm_runner, common_llm_kwargs,
|
|
|
|
per_test_common_llm_kwargs, baseline_llm_kwargs,
|
|
|
|
test_llm_kwargs, batch_size: int,
|
|
|
|
temperature: float, output_len: int):
|
2024-07-19 04:22:08 +02:00
|
|
|
"""Verify outputs are consistent across multiple runs with same seed
|
|
|
|
"""
|
2024-09-11 14:07:34 -07:00
|
|
|
run_equality_correctness_test(
|
|
|
|
vllm_runner,
|
|
|
|
common_llm_kwargs,
|
|
|
|
per_test_common_llm_kwargs,
|
|
|
|
baseline_llm_kwargs,
|
|
|
|
test_llm_kwargs,
|
|
|
|
batch_size,
|
|
|
|
max_output_len=output_len,
|
|
|
|
temperature=temperature,
|
|
|
|
disable_seed=False,
|
|
|
|
)
|
2024-07-24 08:58:31 -07:00
|
|
|
|
|
|
|
# Ensure this same test does fail if we _don't_ include per-request seeds
|
|
|
|
with pytest.raises(AssertionError):
|
2024-09-11 14:07:34 -07:00
|
|
|
run_equality_correctness_test(
|
|
|
|
vllm_runner,
|
|
|
|
common_llm_kwargs,
|
|
|
|
per_test_common_llm_kwargs,
|
|
|
|
baseline_llm_kwargs,
|
|
|
|
test_llm_kwargs,
|
|
|
|
batch_size,
|
|
|
|
max_output_len=output_len,
|
|
|
|
temperature=temperature,
|
|
|
|
disable_seed=True,
|
|
|
|
)
|