Support DROID policy server for Cosmos3 OpenPI (#4282)

Signed-off-by: yuzhud <yuzhudong@gmail.com>
This commit is contained in:
Yuzhu Dong authored and GitHub committed 2026-06-15 21:22:59 +08:00
1 parent ae937320ff
commit e2e79177db
16 files changed
+1397 -154

No files matched your search

+40
View File
@@ -512,6 +512,20 @@ _DIFFUSION_POST_PROCESS_FUNCS = {
"HiDreamImagePipeline": "get_hidream_image_post_process_func",
}
_DIFFUSION_ACTION_POST_PROCESS_FUNCS = {
# arch: action_post_process_func
# `action_post_process_func` function must be placed in {mod_folder}/{mod_relname}.py,
# where mod_folder and mod_relname are defined and mapped using `_DIFFUSION_MODELS` via the `arch` key.
"Cosmos3OmniDiffusersPipeline": "get_cosmos3_action_post_process_func",
}
_DIFFUSION_IR_OP_PRIORITY_FUNCS = {
# arch: ir_op_priority_func
# `ir_op_priority_func` function must be placed in {mod_folder}/{mod_relname}.py,
# where mod_folder and mod_relname are defined and mapped using `_DIFFUSION_MODELS` via the `arch` key.
"Cosmos3OmniDiffusersPipeline": "get_cosmos3_ir_op_priority_func",
}
_DIFFUSION_PRE_PROCESS_FUNCS = {
# arch: pre_process_func
# `pre_process_func` function must be placed in {mod_folder}/{mod_relname}.py,
@@ -543,6 +557,8 @@ def register_diffusion_model(
class_name: str,
pre_process_func_name: str | None = None,
post_process_func_name: str | None = None,
action_post_process_func_name: str | None = None,
ir_op_priority_func_name: str | None = None,
) -> None:
"""Register a diffusion model pipeline from an out-of-tree plugin.
@@ -561,6 +577,12 @@ def register_diffusion_model(
post_process_func_name: Optional name of the post-process function
located in *module_name*. Pass ``None`` to keep the existing
entry when replacing a built-in model.
action_post_process_func_name: Optional name of the action post-process
function located in *module_name*. Pass ``None`` to keep the
existing entry when replacing a built-in model.
ir_op_priority_func_name: Optional name of the IR op priority merge
function located in *module_name*. Pass ``None`` to keep the
existing entry when replacing a built-in model.
"""
# Register model class in DiffusionModelRegistry
DiffusionModelRegistry.register_model(
@@ -578,6 +600,10 @@ def register_diffusion_model(
_DIFFUSION_PRE_PROCESS_FUNCS[model_arch] = pre_process_func_name
if post_process_func_name is not None:
_DIFFUSION_POST_PROCESS_FUNCS[model_arch] = post_process_func_name
if action_post_process_func_name is not None:
_DIFFUSION_ACTION_POST_PROCESS_FUNCS[model_arch] = action_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
logger.info(
"Registered diffusion model %s -> %s.%s",
@@ -608,6 +634,20 @@ def get_diffusion_post_process_func(od_config: OmniDiffusionConfig):
return _load_process_func(od_config, func_name)
def get_diffusion_action_post_process_func(od_config: OmniDiffusionConfig):
if od_config.model_class_name not in _DIFFUSION_ACTION_POST_PROCESS_FUNCS:
return None
func_name = _DIFFUSION_ACTION_POST_PROCESS_FUNCS[od_config.model_class_name]
return _load_process_func(od_config, func_name)
def get_diffusion_ir_op_priority_func(od_config: OmniDiffusionConfig):
if od_config.model_class_name not in _DIFFUSION_IR_OP_PRIORITY_FUNCS:
return None
func_name = _DIFFUSION_IR_OP_PRIORITY_FUNCS[od_config.model_class_name]
return _load_process_func(od_config, func_name)
def get_diffusion_pre_process_func(od_config: OmniDiffusionConfig):
if od_config.model_class_name not in _DIFFUSION_PRE_PROCESS_FUNCS:
return None # Return None if no pre-processing function is registered (for backward compatibility)