-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Multi Step Scheduling #7000
Merged
+1,004
−34
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Empty file.
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,85 @@ | ||
# Test the AsyncLLMEngine with multi-step-decoding | ||
|
||
from typing import List | ||
|
||
import pytest | ||
|
||
from ..utils import RemoteOpenAIServer | ||
|
||
MODELS = [ | ||
"JackFram/llama-160m", | ||
] | ||
NUM_SCHEDULER_STEPS = [8] # Multi-step decoding steps | ||
NUM_PROMPTS = [10] | ||
|
||
DEFAULT_SERVER_ARGS: List[str] = [ | ||
"--disable-log-requests", | ||
"--use-v2-block-manager", | ||
"--worker-use-ray", | ||
"--gpu-memory-utilization", | ||
"0.85", | ||
"--swap-space", | ||
"16", | ||
] | ||
|
||
|
||
async def completions_with_server_args(prompts: List[str], model_name: str, | ||
server_cli_args: List[str]): | ||
|
||
outputs = None | ||
with RemoteOpenAIServer(model_name, server_cli_args) as server: | ||
client = server.get_async_client() | ||
outputs = await client.completions.create(model=model_name, | ||
prompt=prompts, | ||
temperature=0, | ||
stream=False, | ||
max_tokens=5) | ||
assert outputs is not None | ||
|
||
return outputs | ||
|
||
|
||
@pytest.mark.parametrize("model", MODELS) | ||
@pytest.mark.parametrize(("tp_size, pp_size"), [ | ||
(1, 1), | ||
(2, 2), | ||
]) | ||
@pytest.mark.parametrize("eager_mode", [False, True]) | ||
@pytest.mark.parametrize("num_scheduler_steps", NUM_SCHEDULER_STEPS) | ||
@pytest.mark.parametrize("num_prompts", NUM_PROMPTS) | ||
@pytest.mark.asyncio | ||
async def test_multi_step(example_prompts, model: str, tp_size: int, | ||
pp_size: int, eager_mode: int, | ||
num_scheduler_steps: int, num_prompts: int): | ||
|
||
prompts = example_prompts | ||
if len(prompts) < num_prompts: | ||
prompts = prompts * ((num_prompts // len(prompts)) + 1) | ||
prompts = prompts[:num_prompts] | ||
assert len(prompts) == num_prompts | ||
|
||
server_args = DEFAULT_SERVER_ARGS + ["--enforce-eager"] | ||
ms_server_args = DEFAULT_SERVER_ARGS + \ | ||
["--num-scheduler-steps", f"{num_scheduler_steps}"] | ||
|
||
if eager_mode: | ||
ms_server_args.append("--enforce-eager") | ||
|
||
distributed_args = [ | ||
"--tensor-parallel-size", | ||
str(tp_size), | ||
"--pipeline-parallel-size", | ||
str(pp_size), | ||
] | ||
|
||
ref_completions = await completions_with_server_args( | ||
prompts, model, server_args + distributed_args) | ||
test_completions = await completions_with_server_args( | ||
prompts, model, ms_server_args + distributed_args) | ||
|
||
def get_text_generations(completions): | ||
return [x.text for x in completions.choices] | ||
|
||
ref_generations = get_text_generations(ref_completions) | ||
test_generations = get_text_generations(test_completions) | ||
assert ref_generations == test_generations |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SolitaryThinker no need to block on this feedback - but if you have time - I would propose adding an example/offline_inference_multi_step.py example which instantiates an engine instance with multi-step enabled. Similar in structure to example/offline_inference.py.
An example of why this is useful - as part of the logprobs workstream, I am trying to step through the multi-step model runner with the python debugger & examine the output logprobs. I am using your multi_step/test_correctness.py in order to set up a server with multi-step enabled.
However, multi_step/test_correctness.py is an end-to-end client/server test & it is not straightforward (although technically doable) to step through the server code with the debugger because the server is in another process.
I will get around this by writing a short script which sets up an engine instance with multi-step enabled.
However, for someone else who is approaching this code for the first time, it could be helpful to have an example file (or unit test) which just sets up an engine instance with multi-step enabled and invokes inference using LLM.generate(). This could be a good way to facilitate quick debugging & also gives insight into how the server works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the offline_inference_multi_step.py script I wrote for myself to facilitate debugging, if you would like to use it.