[ModelRunnerV2] Avoid pipeline parallel bubbles (#42187)
Signed-off-by: Nick Hill <nickhill123@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ class AsyncScheduler(Scheduler):
|
||||
super().__init__(*args, **kwargs)
|
||||
# reusable read-only placeholder list for speculative decoding.
|
||||
self._spec_token_placeholders: list[int] = [-1] * self.num_spec_tokens
|
||||
self.pp_size = self.parallel_config.pipeline_parallel_size
|
||||
|
||||
def _update_after_schedule(self, scheduler_output: SchedulerOutput) -> None:
|
||||
super()._update_after_schedule(scheduler_output)
|
||||
@@ -34,6 +35,11 @@ class AsyncScheduler(Scheduler):
|
||||
# We will update the actual spec token ids in the worker process.
|
||||
request.spec_token_ids = self._spec_token_placeholders
|
||||
|
||||
if self.use_v2_model_runner:
|
||||
# Set the next step index in which this request is eligible to be
|
||||
# scheduled for decode (for PP microbatching).
|
||||
request.next_decode_eligible_step = self.current_step + self.pp_size
|
||||
|
||||
def _update_request_with_output(
|
||||
self, request: Request, new_token_ids: list[int]
|
||||
) -> tuple[list[int], bool]:
|
||||
|
||||
@@ -248,6 +248,9 @@ class Scheduler(SchedulerInterface):
|
||||
|
||||
self.use_pp = self.parallel_config.pipeline_parallel_size > 1
|
||||
self.use_v2_model_runner = vllm_config.use_v2_model_runner
|
||||
# Scheduler iteration counter. Drives the V2+PP+async decode-throttle
|
||||
# cadence (`next_decode_eligible_step`).
|
||||
self.current_step = 0
|
||||
self.scheduler_reserve_full_isl = (
|
||||
self.scheduler_config.scheduler_reserve_full_isl
|
||||
)
|
||||
@@ -333,6 +336,7 @@ class Scheduler(SchedulerInterface):
|
||||
return num_new_tokens
|
||||
|
||||
def schedule(self) -> SchedulerOutput:
|
||||
self.current_step += 1
|
||||
# NOTE(woosuk) on the scheduling algorithm:
|
||||
# There's no "decoding phase" nor "prefill phase" in the scheduler.
|
||||
# Each request just has the num_computed_tokens and
|
||||
@@ -388,6 +392,12 @@ class Scheduler(SchedulerInterface):
|
||||
req_index += 1
|
||||
continue
|
||||
|
||||
if self.current_step < request.next_decode_eligible_step:
|
||||
# V2+PP+async: enforce `pp_size` steps between same-req decodes
|
||||
# to match worker-side sampled-tokens broadcast slot ring cadence.
|
||||
req_index += 1
|
||||
continue
|
||||
|
||||
num_new_tokens = (
|
||||
request.num_tokens_with_spec
|
||||
+ request.num_output_placeholders
|
||||
|
||||
Reference in New Issue
Block a user