[Feat] DiffusionEngine Support async batch infer (#2729)
Signed-off-by: Semmer <semmer@live.cn> Signed-off-by: jader <yjader@foxmail.com> Signed-off-by: asukaqaq-s <1311722138@qq.com> Co-authored-by: asukaqaq-s <1311722138@qq.com> Co-authored-by: jader <yjader@foxmail.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
32 files changed
+1951
-190
No files matched your search
@@ -38,6 +38,34 @@ class DiffusionRequestStatus(enum.IntEnum):
|
||||
return status >= DiffusionRequestStatus.FINISHED_COMPLETED
|
||||
|
||||
|
||||
@dataclass(frozen=True, eq=True)
|
||||
class SamplingParamsKey:
|
||||
"""Batch-compatibility key derived from ``OmniDiffusionSamplingParams``.
|
||||
|
||||
Only requests with the same key can be batched together.
|
||||
Fields not included here are treated as request-local and do not
|
||||
participate in the current homogeneous batching policy.
|
||||
"""
|
||||
|
||||
# Spatial / temporal shape.
|
||||
height: int | None = None
|
||||
width: int | None = None
|
||||
num_frames: int = 1
|
||||
resolution: int | str | None = None
|
||||
fps: int | None = None
|
||||
frame_rate: float | None = None
|
||||
boundary_ratio: float | None = None
|
||||
|
||||
# CFG / guidance.
|
||||
do_classifier_free_guidance: bool = False
|
||||
guidance_scale: float = 0.0
|
||||
guidance_scale_provided: bool = False
|
||||
guidance_scale_2: float | None = None
|
||||
guidance_rescale: float = 0.0
|
||||
true_cfg_scale: float | None = None
|
||||
cfg_normalize: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
class DiffusionRequestState:
|
||||
"""Scheduler-owned state for one queued OmniDiffusionRequest."""
|
||||
@@ -47,6 +75,7 @@ class DiffusionRequestState:
|
||||
# TODO: Align this with OmniDiffusionRequest.request_ids once scheduler batching is supported.
|
||||
sched_req_id: str
|
||||
req: OmniDiffusionRequest
|
||||
sampling_params_key: SamplingParamsKey | None = None
|
||||
status: DiffusionRequestStatus = DiffusionRequestStatus.WAITING
|
||||
error: str | None = None
|
||||
|
||||
@@ -81,7 +110,7 @@ class CachedRequestData:
|
||||
class DiffusionSchedulerOutput:
|
||||
"""Output of a single scheduling cycle."""
|
||||
|
||||
step_id: int
|
||||
step_id: int # global step index
|
||||
scheduled_new_reqs: list[NewRequestData]
|
||||
scheduled_cached_reqs: CachedRequestData
|
||||
finished_req_ids: set[str]
|
||||
|
||||
Reference in new issue
Block a user