[Perf] Support request-level batching for Wan2.2 pipelines (#5676)
Signed-off-by: nagisa-kun <1434936049@qq.com> Signed-off-by: nagisa <1434936049@qq.com>
This commit is contained in:
1 parent
d1e230c95b
commit
2a315e1a2d
18 files changed
+1871
-374
No files matched your search
@@ -22,7 +22,21 @@ if TYPE_CHECKING:
|
||||
# on sampling params, so it must be resolved separately from the bulk lookup.
|
||||
_REQUEST_BATCH_SAMPLING_PARAMS_KEY_FIELD_NAMES = frozenset(
|
||||
field.name for field in fields(RequestBatchSamplingParamsKey)
|
||||
) - {"lora_int_id"}
|
||||
) - {"condition_key", "flow_shift", "lora_int_id", "sample_solver"}
|
||||
|
||||
|
||||
def _normalize_explicit_sample_solver(value: object | None) -> str | None:
|
||||
"""Normalize an explicitly provided solver without selecting a default."""
|
||||
if value is None:
|
||||
return None
|
||||
return str(value).strip().lower()
|
||||
|
||||
|
||||
def _normalize_explicit_flow_shift(value: object | None) -> float | None:
|
||||
"""Normalize an explicitly provided flow shift without selecting a default."""
|
||||
if value is None:
|
||||
return None
|
||||
return float(value)
|
||||
|
||||
|
||||
def build_request_batch_sampling_params_key(request: OmniDiffusionRequest) -> RequestBatchSamplingParamsKey:
|
||||
@@ -31,6 +45,13 @@ def build_request_batch_sampling_params_key(request: OmniDiffusionRequest) -> Re
|
||||
# LoRA identity is optional on sampling params (and on test stubs).
|
||||
lora_request = getattr(sampling, "lora_request", None)
|
||||
key_kwargs = {name: getattr(sampling, name) for name in _REQUEST_BATCH_SAMPLING_PARAMS_KEY_FIELD_NAMES}
|
||||
extra_args = sampling.extra_args or {}
|
||||
# Match pipeline resolution for explicit overrides, but preserve None:
|
||||
# pipeline/engine defaults are configuration-dependent and must not be
|
||||
# inferred while building the request-batch key.
|
||||
key_kwargs["sample_solver"] = _normalize_explicit_sample_solver(extra_args.get("sample_solver"))
|
||||
key_kwargs["flow_shift"] = _normalize_explicit_flow_shift(extra_args.get("flow_shift"))
|
||||
key_kwargs["condition_key"] = getattr(request, "batch_compatibility_key", None)
|
||||
key_kwargs["lora_int_id"] = lora_request.lora_int_id if lora_request is not None else None
|
||||
return RequestBatchSamplingParamsKey(**key_kwargs)
|
||||
|
||||
|
||||
Reference in new issue
Block a user