[Config] Add HunyuanImage3 deploy configs (#3172)

Signed-off-by: KexiongYu <yukexiong1@huawei.com>
Signed-off-by: Y. Fisher <yukexiong1@huawei.com>
This commit is contained in:
Y. Fisher authored and GitHub committed 2026-05-11 22:49:19 +08:00
1 parent c9a8556c24
commit a33e2eb588
26 files changed
+672 -742

No files matched your search

@@ -1424,7 +1424,11 @@ class HunyuanImage3Pipeline(
model_inputs.update(ar_kv_kwargs)
outputs = self._generate(**model_inputs, **kwargs)
custom_output = {}
if any(t is not None for t in cot_text_list):
custom_output["ar_generated_text"] = cot_text_list[0] if len(cot_text_list) == 1 else cot_text_list
return DiffusionOutput(
output=outputs[0],
custom_output=custom_output,
stage_durations=self.stage_durations if hasattr(self, "stage_durations") else None,
)
@@ -17,17 +17,43 @@ canonical mapping for both flows.
from __future__ import annotations
from typing import Any
from .system_prompt import get_system_prompt
# HunyuanImage-3.0-Instruct special token ids from tokenizer.json.
# Keep offline AR prompt/stop-token behavior independent of runtime
# tokenizer lookup for these fixed control tokens.
HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS: dict[str, int] = {
"<|endoftext|>": 127957,
"<|startoftext|>": 127958,
"<boi>": 128000,
"<eoi>": 128001,
"<img>": 128006,
"<cfg>": 128010,
"<recaption>": 128018,
"</recaption>": 128019,
"<think>": 128023,
"</think>": 128024,
"<answer>": 128025,
"</answer>": 128026,
"<img_size_1024>": 128037,
"<img_ratio_0>": 128044,
"<img_ratio_32>": 128076,
"<img_ratio_33>": 130103,
"<img_ratio_36>": 130106,
}
# task -> (sys_type, bot_task, trigger_tag)
_TASK_PRESETS: dict[str, tuple[str, str | None, str | None]] = {
"t2t": ("en_unified", None, None),
"i2t": ("en_unified", None, None),
"it2i_think": ("en_unified", "think", "<think>"),
"it2i_recaption": ("en_unified", "recaption", "<recaption>"),
"t2i": ("en_unified", "image", None),
"t2i_vanilla": ("en_vanilla", "image", None),
"t2i_think": ("en_unified", "think", "<think>"),
"t2i_recaption": ("en_unified", "recaption", "<recaption>"),
"t2i_vanilla": ("en_vanilla", "image", None),
}
@@ -36,6 +62,14 @@ def available_tasks() -> list[str]:
return sorted(_TASK_PRESETS)
def resolve_stop_token_ids(
task: str = "it2i_think",
bot_task: str = "think",
tokenizer: Any | None = None,
):
return [HUNYUAN_IMAGE3_SPECIAL_TOKEN_IDS["<answer>"]]
def build_prompt(
user_prompt: str,
task: str = "it2i_think",
@@ -149,4 +183,4 @@ def build_prompt_tokens(
return ids
__all__ = ["build_prompt", "build_prompt_tokens", "available_tasks"]
__all__ = ["build_prompt", "build_prompt_tokens", "resolve_stop_token_ids", _TASK_PRESETS]