-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: add multi-step scheduling support for the synchronous engine (#914
- Loading branch information
Showing
4 changed files
with
170 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Test the LLMEngine with multi-step-decoding | ||
import pytest | ||
|
||
from ..models.utils import check_outputs_equal | ||
|
||
MODELS = [ | ||
"JackFram/llama-160m", | ||
] | ||
NUM_SCHEDULER_STEPS = [8] # Multi-step decoding steps | ||
NUM_PROMPTS = [10] | ||
|
||
|
||
@pytest.mark.parametrize("model", MODELS) | ||
@pytest.mark.parametrize("dtype", ["half"]) | ||
@pytest.mark.parametrize("tp_size", [1]) | ||
@pytest.mark.parametrize("max_tokens", [5]) | ||
@pytest.mark.parametrize("enforce_eager", [True]) | ||
@pytest.mark.parametrize("num_scheduler_steps", NUM_SCHEDULER_STEPS) | ||
@pytest.mark.parametrize("num_prompts", NUM_PROMPTS) | ||
def test_multi_step_llm(hf_runner, aphrodite_runner, example_prompts, | ||
model: str, dtype: str, tp_size: int, max_tokens: int, | ||
enforce_eager: int, num_scheduler_steps: int, | ||
num_prompts: int) -> None: | ||
|
||
prompts = example_prompts | ||
if len(prompts) < num_prompts: | ||
prompts = prompts * ((num_prompts // len(prompts)) + 1) | ||
prompts = prompts[:num_prompts] | ||
assert len(prompts) == num_prompts | ||
|
||
with aphrodite_runner(model, | ||
dtype=dtype, | ||
enforce_eager=enforce_eager, | ||
gpu_memory_utilization=0.7, | ||
tensor_parallel_size=tp_size, | ||
use_v2_block_manager=True, | ||
num_scheduler_steps=num_scheduler_steps | ||
) as aphrodite_model: | ||
aphrodite_outputs = aphrodite_model.generate_greedy(prompts, max_tokens) | ||
|
||
with hf_runner(model, dtype=dtype) as hf_model: | ||
hf_outputs = hf_model.generate_greedy(prompts, max_tokens) | ||
check_outputs_equal( | ||
outputs_0_lst=hf_outputs, | ||
outputs_1_lst=aphrodite_outputs, | ||
name_0="hf", | ||
name_1="aphrodite", | ||
) |