From 16a84b29d51165a47152c540babce56392dfdc0e Mon Sep 17 00:00:00 2001 From: Zeng Chuang Date: Wed, 13 May 2026 22:10:35 +0800 Subject: [PATCH] [Bugfix] Add bot_task option of think_recaption for hunyuanimage3 it2i (#3551) Signed-off-by: zengchuang --- examples/offline_inference/hunyuan_image3/end2end.py | 2 +- tests/diffusion/models/hunyuan_image3/test_prompt_utils.py | 4 +++- vllm_omni/diffusion/models/hunyuan_image3/prompt_utils.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/offline_inference/hunyuan_image3/end2end.py b/examples/offline_inference/hunyuan_image3/end2end.py index 8d29b0f58..f4eb8cffc 100644 --- a/examples/offline_inference/hunyuan_image3/end2end.py +++ b/examples/offline_inference/hunyuan_image3/end2end.py @@ -136,7 +136,7 @@ def main(): if task not in _TASK_PRESETS: valid_bot_tasks = { "text2img": ["think", "recaption", "vanilla"], - "img2img": ["think", "recaption"], + "img2img": ["think", "recaption", "think_recaption"], "img2text": ["auto"], "text2text": ["auto"], }[args.modality] diff --git a/tests/diffusion/models/hunyuan_image3/test_prompt_utils.py b/tests/diffusion/models/hunyuan_image3/test_prompt_utils.py index 9972d328d..1130c0f6d 100644 --- a/tests/diffusion/models/hunyuan_image3/test_prompt_utils.py +++ b/tests/diffusion/models/hunyuan_image3/test_prompt_utils.py @@ -78,6 +78,7 @@ def test_available_tasks_covers_all_modalities(): "i2t", "it2i_think", "it2i_recaption", + "it2i_think_recaption", "t2i_think", "t2i_recaption", "t2i_vanilla", @@ -99,6 +100,7 @@ def test_resolve_stop_token_ids_uses_answer_for_generation_tasks(): "i2t", "it2i_think", "it2i_recaption", + "it2i_think_recaption", "t2i_think", "t2i_recaption", ], @@ -125,7 +127,7 @@ def test_build_prompt_string_structure_chat_template(task: str): # documentation, so substring index() catches the wrong occurrence -- use # endswith() which directly captures "trigger is at the tail" (the Part A # fix: trigger goes AFTER `Assistant: `, not before user_prompt). - if task in ("it2i_think", "t2i_think"): + if task in ("it2i_think", "t2i_think", "it2i_think_recaption"): assert s.endswith("Assistant: "), ( f"Trigger must be appended right after `Assistant: ` (Part A fix). Got tail: ...{s[-40:]!r}" ) diff --git a/vllm_omni/diffusion/models/hunyuan_image3/prompt_utils.py b/vllm_omni/diffusion/models/hunyuan_image3/prompt_utils.py index 3cd679b68..5d8e9af6a 100644 --- a/vllm_omni/diffusion/models/hunyuan_image3/prompt_utils.py +++ b/vllm_omni/diffusion/models/hunyuan_image3/prompt_utils.py @@ -51,6 +51,7 @@ _TASK_PRESETS: dict[str, tuple[str, str | None, str | None]] = { "i2t": ("en_unified", None, None), "it2i_think": ("en_unified", "think", ""), "it2i_recaption": ("en_unified", "recaption", ""), + "it2i_think_recaption": ("en_unified", "think_recaption", ""), "t2i": ("en_unified", "image", None), "t2i_vanilla": ("en_vanilla", "image", None), "t2i_think": ("en_unified", "think", ""),