[Diffusion][HunyuanImage3] Add request paged prefix caching (#7719)

Signed-off-by: zwhzzz0821 <2831474076@qq.com>
This commit is contained in:
Yukim1 authored and GitHub committed 2026-09-23 15:34:56 +00:00
1 parent 9a1a05facd
commit 205aa01c7b
49 files changed
+2889 -127

No files matched your search

+19
View File
@@ -749,6 +749,11 @@ _DIFFUSION_PRE_PROCESS_FUNCS = {
}
_DIFFUSION_PREFIX_CACHE_FUNCS = {
"HunyuanImage3ForCausalMM": "get_hunyuan_image_3_prefix_cache_func",
}
def register_diffusion_model(
model_arch: str,
module_name: str,
@@ -757,6 +762,7 @@ def register_diffusion_model(
post_process_func_name: str | None = None,
ir_op_priority_func_name: str | None = None,
action_post_process_func_name: str | None = None,
prefix_cache_func_name: str | None = None,
) -> None:
"""Register a diffusion model pipeline from an out-of-tree plugin.
@@ -782,6 +788,9 @@ def register_diffusion_model(
for out-of-tree plugins. Action postprocess hooks are no longer
registered separately; move action handling into
``post_process_func_name`` and return a payload/metadata envelope.
prefix_cache_func_name: Optional factory for a CPU cache-input hook,
called after preprocessing only when paged prefix caching is
enabled. It fills existing DiffusionKVRequest cache inputs in place.
"""
if action_post_process_func_name is not None:
logger.warning(
@@ -810,6 +819,8 @@ def register_diffusion_model(
_DIFFUSION_POST_PROCESS_FUNCS[model_arch] = post_process_func_name
if ir_op_priority_func_name is not None:
_DIFFUSION_IR_OP_PRIORITY_FUNCS[model_arch] = ir_op_priority_func_name
if prefix_cache_func_name is not None:
_DIFFUSION_PREFIX_CACHE_FUNCS[model_arch] = prefix_cache_func_name
logger.info(
"Registered diffusion model %s -> %s.%s",
@@ -860,3 +871,11 @@ def get_diffusion_pre_process_func(od_config: OmniDiffusionConfig):
return None # Return None if no pre-processing function is registered (for backward compatibility)
func_name = _DIFFUSION_PRE_PROCESS_FUNCS[od_config.model_class_name]
return _load_process_func(od_config, func_name)
def get_diffusion_prefix_cache_func(od_config: OmniDiffusionConfig):
"""Load optional model preparation for native multimodal KV identities."""
if uses_diffusers_adapter(od_config) or od_config.model_class_name is None:
return None
func_name = _DIFFUSION_PREFIX_CACHE_FUNCS.get(od_config.model_class_name)
return None if func_name is None else _load_process_func(od_config, func_name)