Skip to content
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

LLM: Partial Prefilling for Pipeline Parallel Serving #11457

Merged
merged 11 commits into from
Jul 5, 2024

Conversation

xiangyuT
Copy link
Contributor

@xiangyuT xiangyuT commented Jun 28, 2024

Description

Add continuous-batching-like partial prefilling to reduce the memory peak during prefilling.

Below is an example with a batch_size=4, max_prefilled_seqs=2 BatchTask:

  1. Initially:
    image
  2. First partial prefilling:
    image
  3. Second partial prefilling:
    image
  4. Decoding:
    image

4. How to test?

@xiangyuT xiangyuT changed the title [WIP] LLM: Partial Prefilling for Pipeline Parallel Serving LLM: Partial Prefilling for Pipeline Parallel Serving Jul 2, 2024
def prepare_batch(self, cur_batch):
if self.rank == 0:
cur_input_start = cur_batch.prefilled_index
if self.max_prefilled_seqs > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set cur_batch.partial_prefilling = 0, when max_prefilled_seqs==0.

@@ -146,6 +146,8 @@ def pipeline_parallel(model, pipeline_parallel_stages):
model._modules['lm_head'] = DummyLayer()

model.pipeline_parallel_stages = pipeline_parallel_stages
model.layer_start = layer_start
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace gloabal layer_start and layer_end with model.layer-start etc

Copy link
Contributor

@qiyuangong qiyuangong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xiangyuT xiangyuT merged commit 7d8bc83 into intel-analytics:main Jul 5, 2024
1 check passed
RyuKosei pushed a commit to RyuKosei/ipex-llm that referenced this pull request Jul 19, 2024
…s#11457)

LLM: Partial Prefilling for Pipeline Parallel Serving
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants