[Core][Frontend] Support request-level batching for diffusion pipelines (#4079)
Signed-off-by: jader <yjader@foxmail.com> Co-authored-by: Samit <285365963@qq.com>
This commit is contained in:
1 parent
504698dec8
commit
c45ac74d43
123 files changed
+4160
-2233
No files matched your search
@@ -48,7 +48,7 @@ from vllm_omni.diffusion.registry import get_diffusion_ir_op_priority_func
|
||||
from vllm_omni.diffusion.request import OmniDiffusionRequest
|
||||
from vllm_omni.diffusion.sched.interface import DiffusionSchedulerOutput
|
||||
from vllm_omni.diffusion.worker.diffusion_model_runner import DiffusionModelRunner
|
||||
from vllm_omni.diffusion.worker.utils import BaseRunnerOutput
|
||||
from vllm_omni.diffusion.worker.utils import BaseRunnerOutput, BatchRunnerOutput
|
||||
from vllm_omni.engine.stage_init_utils import set_death_signal
|
||||
from vllm_omni.lora.request import LoRARequest
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
@@ -392,6 +392,28 @@ class DiffusionWorker:
|
||||
profiler.step()
|
||||
return output
|
||||
|
||||
def execute_model_batch(
|
||||
self, scheduler_output: DiffusionSchedulerOutput, od_config: OmniDiffusionConfig
|
||||
) -> BatchRunnerOutput:
|
||||
"""Batch forward: LoRA activate once, delegate to model runner."""
|
||||
assert self.model_runner is not None, "Model runner not initialized"
|
||||
# LoRA: same adapter/scale within batch guaranteed by SamplingParamsKey
|
||||
if self.lora_manager is not None and scheduler_output.scheduled_new_reqs:
|
||||
sp = scheduler_output.scheduled_new_reqs[0].req.sampling_params
|
||||
try:
|
||||
self.lora_manager.set_active_adapter(sp.lora_request, sp.lora_scale)
|
||||
except Exception as exc:
|
||||
if sp.lora_request is not None:
|
||||
raise
|
||||
logger.warning("LoRA activation skipped: %s", exc)
|
||||
profiler = self._get_profiler()
|
||||
ctx = profiler.annotate_context_manager("diffusion_forward_batch") if profiler else nullcontext()
|
||||
with ctx:
|
||||
output = self.model_runner.execute_model_batch(scheduler_output, od_config)
|
||||
if profiler:
|
||||
profiler.step()
|
||||
return output
|
||||
|
||||
def execute_stepwise(self, scheduler_output: DiffusionSchedulerOutput) -> BaseRunnerOutput:
|
||||
"""Execute one diffusion step by delegating to the model runner."""
|
||||
assert self.model_runner is not None, "Model runner not initialized"
|
||||
@@ -887,7 +909,7 @@ class WorkerProc:
|
||||
continue
|
||||
|
||||
else:
|
||||
# Handle generation request
|
||||
# Handle direct generation requests.
|
||||
try:
|
||||
output = self.worker.execute_model(msg, self.od_config)
|
||||
except Exception as e:
|
||||
|
||||
Reference in new issue
Block a user