-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Optimizations for Pipeline Parallel Serving #11702
Conversation
@@ -179,6 +180,11 @@ def pipeline_parallel(model, pipeline_parallel_stages, torch_dtype=torch.float32 | |||
layer_start = slice_size * local_rank | |||
layer_end = layer_start + min(slice_size, num_layers - layer_start) | |||
|
|||
# if local_rank == 0: |
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.
Remove these lines if they are not necessary
@@ -738,14 +744,73 @@ def clear_batch(self, cur_id): | |||
self.is_finish.pop(cur_id, None) | |||
self.partial_output_dict.pop(cur_id, None) | |||
|
|||
async def finish_stream_output(self, cur_id): |
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.
wait_xxx maybe better
torch.xpu.synchronize(self.device) | ||
self.send_buff.wait() | ||
if output is not None: | ||
self.send_buff = dist.isend(output, dst=self.next_rank) |
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.
https://pytorch.org/docs/stable/distributed.html#torch.distributed.isend
Use async isend
to replace sync send
.
# remain = 0 | ||
# self.is_finish[request_id] = True | ||
|
||
text = cur_text[cached_index] |
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.
text is not a good name
|
||
text = tokenizer.decode(self.token_cache[request_id]) | ||
|
||
if text.endswith("\n"): |
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.
This block is text-related. Maybe we can move it into a function,
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.
LGTM
3. Summary of the change
Optimize
stream_output()
methods in Pipeline Parallel Serving.4. How to test?
1234
). And paste your action link here once it has been successfully finished.https://github.com/intel-analytics/ipex-llm-workflow/actions/runs/10209347945