[Bugfix][CPU][DiffusionGemma] Support narrower canvas w/ sync scheduling (#59107)
Signed-off-by: ojeda-e <estefania.b.ojeda@gmail.com>
This commit is contained in:
+6
-2
@@ -2020,11 +2020,15 @@ class VllmConfig:
|
||||
# After the platform hook, which has the last word on async scheduling.
|
||||
if (
|
||||
self.diffusion_config is not None
|
||||
and self.scheduler_config.async_scheduling
|
||||
and self.scheduler_config.scheduler_cls is None
|
||||
):
|
||||
scheduler_name = (
|
||||
"DiffusionAsyncScheduler"
|
||||
if self.scheduler_config.async_scheduling
|
||||
else "DiffusionScheduler"
|
||||
)
|
||||
self.scheduler_config.scheduler_cls = (
|
||||
"vllm.v1.core.sched.diffusion_scheduler.DiffusionAsyncScheduler"
|
||||
f"vllm.v1.core.sched.diffusion_scheduler.{scheduler_name}"
|
||||
)
|
||||
|
||||
self._normalize_piecewise_cudagraph_mode(
|
||||
|
||||
@@ -15,7 +15,6 @@ def validate_diffusion_sampling_params(
|
||||
*,
|
||||
canvas_length: int | None,
|
||||
vocab_size: int,
|
||||
async_scheduling: bool | None,
|
||||
) -> None:
|
||||
"""Validate request options and normalize one-canvas reads at admission."""
|
||||
extra = params.extra_args
|
||||
@@ -105,12 +104,3 @@ def validate_diffusion_sampling_params(
|
||||
bool(params.logprob_token_ids),
|
||||
"diffusion_constrained needs logprob_token_ids: they are the allowed set.",
|
||||
)
|
||||
|
||||
check(
|
||||
bool(async_scheduling)
|
||||
or width is None
|
||||
or canvas_length is None
|
||||
or width == canvas_length,
|
||||
"A diffusion_canvas_length smaller than the served canvas "
|
||||
"requires --async-scheduling.",
|
||||
)
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Async scheduling for diffusion requests.
|
||||
|
||||
These rules live here so Scheduler.schedule() and AsyncScheduler stay
|
||||
unchanged. VllmConfig selects this class for a diffusion model under async
|
||||
scheduling. A sync scheduler creates no output placeholders, which both rules
|
||||
read.
|
||||
"""
|
||||
"""Canvas-width handling and async read deferral for diffusion requests."""
|
||||
|
||||
from vllm.v1.core.sched.async_scheduler import AsyncScheduler
|
||||
from vllm.v1.core.sched.output import SchedulerOutput
|
||||
from vllm.v1.core.sched.scheduler import Scheduler
|
||||
from vllm.v1.outputs import DraftTokenIds
|
||||
from vllm.v1.request import Request
|
||||
|
||||
|
||||
@@ -38,7 +34,22 @@ def _read_in_flight(request: Request, width: int) -> bool:
|
||||
return request.num_output_placeholders >= steps * width
|
||||
|
||||
|
||||
class DiffusionAsyncScheduler(AsyncScheduler):
|
||||
class DiffusionScheduler(Scheduler):
|
||||
def update_draft_token_ids(self, draft_token_ids: DraftTokenIds) -> None:
|
||||
for i, (req_id, token_ids) in enumerate(
|
||||
zip(draft_token_ids.req_ids, draft_token_ids.draft_token_ids)
|
||||
):
|
||||
request = self.requests.get(req_id)
|
||||
if request is None:
|
||||
continue
|
||||
width = diffusion_canvas_width(request, self.num_spec_tokens)
|
||||
# Remove padded positions before the base scheduler validates grammar.
|
||||
if len(token_ids) > width:
|
||||
draft_token_ids.draft_token_ids[i] = token_ids[:width]
|
||||
super().update_draft_token_ids(draft_token_ids)
|
||||
|
||||
|
||||
class DiffusionAsyncScheduler(DiffusionScheduler, AsyncScheduler):
|
||||
def schedule(self, throttle_prefills: bool = False) -> SchedulerOutput:
|
||||
for request in self.running:
|
||||
width = diffusion_canvas_width(request, self.num_spec_tokens)
|
||||
|
||||
@@ -158,7 +158,6 @@ class InputProcessor:
|
||||
else None
|
||||
),
|
||||
vocab_size=self.model_config.get_vocab_size(),
|
||||
async_scheduling=self.vllm_config.scheduler_config.async_scheduling,
|
||||
)
|
||||
|
||||
if self.model_config.return_sampling_mask:
|
||||
|
||||
Reference in New Issue
Block a user