[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

@@ -1517,14 +1517,9 @@ class HunyuanImage3ForConditionalGeneration(nn.Module, SupportsMultiModal, Suppo
# For comprehension mode, block image generation tokens but allow
# text structure tokens (<think>, <answer>, etc.) so the model can
# follow its natural generation pattern. The yaml stop_token_ids
# for i2t/t2t now includes </think> (128024) so the AR-only output
# terminates after the analysis section, matching HF's
# `bot_task="think"` behavior. Without that stop, the model
# continues into a recaption section even in comprehension mode
# (the stage-transition processor only fires in generation mode,
# but the instruct-tuned model writes recaption on its own from
# internal habit).
# follow its natural generation pattern. Runtime sampling params
# decide stop tokens from the active bot_task, matching the official
# HunyuanImage3 generation path without hard-coded YAML token ids.
self._blocked_token_ids: set[int] = set()
if self._is_comprehension:
self._blocked_token_ids.update(
@@ -0,0 +1,87 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
"""HunyuanImage3 pipeline topology."""
from vllm_omni.config.stage_config import (
PipelineConfig,
StageExecutionType,
StagePipelineConfig,
)
_HUNYUAN_IMAGE3_HF_ARCHS = (
"HunyuanImage3ForConditionalGeneration",
"HunyuanImage3ForCausalMM",
)
_HUNYUAN_IMAGE3_MODEL_ARCH = "HunyuanImage3ForCausalMM"
_HUNYUAN_IMAGE3_INPUT_PROCESSOR = "vllm_omni.model_executor.stage_input_processors.hunyuan_image3"
HUNYUAN_IMAGE3_PIPELINE = PipelineConfig(
model_type="hunyuan_image3",
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
hf_architectures=_HUNYUAN_IMAGE3_HF_ARCHS,
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="AR",
execution_type=StageExecutionType.LLM_AR,
input_sources=(),
final_output=False,
owns_tokenizer=False,
requires_multimodal_data=True,
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
engine_output_type="latent",
),
StagePipelineConfig(
stage_id=1,
model_stage="dit",
execution_type=StageExecutionType.DIFFUSION,
input_sources=(0,),
final_output=True,
final_output_type="image",
requires_multimodal_data=True,
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
custom_process_input_func=f"{_HUNYUAN_IMAGE3_INPUT_PROCESSOR}.ar2diffusion",
),
),
)
HUNYUAN_IMAGE3_AR_PIPELINE = PipelineConfig(
model_type="hunyuan_image3_ar",
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
hf_architectures=(),
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="AR",
execution_type=StageExecutionType.LLM_AR,
input_sources=(),
final_output=True,
final_output_type="text",
owns_tokenizer=False,
requires_multimodal_data=True,
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
engine_output_type="latent",
),
),
)
HUNYUAN_IMAGE3_DIT_PIPELINE = PipelineConfig(
model_type="hunyuan_image3_dit",
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
hf_architectures=(),
stages=(
StagePipelineConfig(
stage_id=0,
model_stage="dit",
execution_type=StageExecutionType.DIFFUSION,
input_sources=(),
final_output=True,
final_output_type="image",
requires_multimodal_data=True,
model_arch=_HUNYUAN_IMAGE3_MODEL_ARCH,
),
),
)
@@ -1,41 +0,0 @@
# Stage config for HunyuanImage-3.0 Image-to-Text (I2T / image understanding).
# Single LLM stage: AR model reads image + text prompt, generates text output.
stage_args:
- stage_id: 0
stage_type: llm
runtime:
process: true
devices: "0,1,2,3"
max_batch_size: 1
requires_multimodal_data: true
engine_args:
model_stage: AR
max_num_seqs: 1
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.95
enforce_eager: true
trust_remote_code: true
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 4
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
is_comprehension: true
final_output: true
final_output_type: text
default_sampling_params:
temperature: 0.0
top_p: 0.95
top_k: 1024
max_tokens: 2048
stop_token_ids: [127957, 128024, 128026] # <|endoftext|>, </think>, </answer>
detokenize: True
runtime:
enabled: true
@@ -1,72 +0,0 @@
# Stage config for HunyuanImage-3.0 Image+Text-to-Image (image editing).
# Stage 0: AR (HunyuanImage3ForConditionalGeneration) — reads (image, text), emits latent tokens
# Stage 1: Diffusion (HunyuanImage3Pipeline / DiT + VAE) — denoise + decode latents → image
stage_args:
# Stage 0: AR Model
- stage_id: 0
stage_type: llm
runtime:
process: true
devices: "0,1,2,3"
max_batch_size: 1
requires_multimodal_data: true # AR needs the original image
engine_args:
model_stage: AR
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.95
enforce_eager: true
trust_remote_code: true
engine_output_type: latent # AR outputs latent for DiT
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 4
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
is_comprehension: false # Generation task, not comprehension
final_output: false # AR is not the final output
default_sampling_params:
temperature: 0.6
top_p: 0.95
top_k: 1024
max_tokens: 4096
stop_token_ids: [127957] # <|endoftext|>
detokenize: true # DiT bridge consumes ar_generated_text; let the AR engine produce it
# Stage 1: Diffusion (DiT + VAE)
# Receives latents from AR stage, performs denoising + VAE decode
- stage_id: 1
stage_type: diffusion
runtime:
process: true
devices: "4,5,6,7"
max_batch_size: 1
requires_multimodal_data: true # May need condition images
engine_args:
model_stage: dit
model_arch: HunyuanImage3ForCausalMM
enforce_eager: true
trust_remote_code: true
distributed_executor_backend: "mp"
parallel_config:
tensor_parallel_size: 4
enable_expert_parallel: true
engine_input_source: [0] # Input from AR stage
custom_process_input_func: vllm_omni.model_executor.stage_input_processors.hunyuan_image3.ar2diffusion
final_output: true
final_output_type: image
default_sampling_params:
num_inference_steps: 50
guidance_scale: 2.5
# Top-level runtime config
runtime:
enabled: true
edges:
- from: 0 # AR → Diffusion
to: 1
@@ -1,89 +0,0 @@
stage_args:
# Stage 0: AR Model
- stage_id: 0
stage_type: llm
runtime:
process: true
devices: "0,1"
max_batch_size: 1
requires_multimodal_data: true # AR needs the original image
engine_args:
model_stage: AR
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.95
enforce_eager: true
trust_remote_code: true
engine_output_type: latent # AR outputs latent for DiT
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 2
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
omni_kv_config:
need_send_cache: true
is_comprehension: false # Generation task, not comprehension
final_output: true
final_output_type: text
default_sampling_params:
temperature: 0.0
top_p: 1
top_k: -1
max_tokens: 8192
stop_token_ids: [128025] # <answer>
detokenize: true # DiT bridge consumes ar_generated_text; let the AR engine produce it
skip_special_tokens: False
output_connectors:
to_stage_1: rdma_connector
# Stage 1: Diffusion (DiT + VAE)
# Receives latents from AR stage, performs denoising + VAE decode
- stage_id: 1
stage_type: diffusion
runtime:
process: true
devices: "2,3"
max_batch_size: 1
requires_multimodal_data: true # May need condition images
engine_args:
model_stage: dit
model_arch: HunyuanImage3ForCausalMM
enforce_eager: true
trust_remote_code: true
distributed_executor_backend: "mp"
omni_kv_config:
need_recv_cache: true # Receive AR KV cache from stage 0
parallel_config:
tensor_parallel_size: 2
enable_expert_parallel: true
engine_input_source: [0] # Input from AR stage
custom_process_input_func: vllm_omni.model_executor.stage_input_processors.hunyuan_image3.ar2diffusion
final_output: true
final_output_type: image
default_sampling_params:
num_inference_steps: 50
guidance_scale: 0
input_connectors:
from_stage_0: rdma_connector
# Top-level runtime config
runtime:
enabled: true
connectors:
rdma_connector:
name: MooncakeTransferEngineConnector
extra:
host: "auto"
zmq_port: 50051
protocol: "rdma"
device_name: ""
memory_pool_size: 4294967296
memory_pool_device: "cpu"
edges:
- from: 0 # AR → Diffusion
to: 1
@@ -1,96 +0,0 @@
# Stage config for running Hunyuan-Image3.0 with AR→DiT KV reuse.
# Stage 0: AR Model (vLLM implementation)
# Stage 1: DiT Model (diffusion)
#
# text-to-image flow: AR (stage 0) → KV transfer → DiT (stage 1)
# image-to-text flow: AR (stage 0) only
#
# Compared to hunyuan_image3_t2i.yaml, this config:
# 1. Enables both stages [0, 1] for text-to-image (AR prefill + DiT denoising)
# 2. Adds omni_kv_config to send/receive KV cache between stages
# The following config has been verified on 8x L40S-48G GPU (4 for AR + 4 for DiT).
stage_args:
- stage_id: 0
stage_type: llm # Use llm stage type for AR stages
runtime:
process: true # Run this stage in a separate process
devices: "0,1,2,3" # AR stage uses GPU 0-3
engine_args:
model_stage: AR
max_num_seqs: 1
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.9
enforce_eager: true # Now we only support eager mode
trust_remote_code: true
engine_output_type: latent
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 4
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
omni_kv_config:
need_send_cache: true
kv_transfer_criteria:
type: prefill_finished # Send KV cache after AR prefill completes
is_comprehension: true
final_output: true
final_output_type: text
default_sampling_params:
temperature: 0.0
top_p: 1.0
top_k: -1
max_tokens: 2048
seed: 42
detokenize: True
repetition_penalty: 1.1
- stage_id: 1
stage_type: diffusion
runtime:
process: true
devices: "4,5,6,7" # DiT stage uses GPU 4-7
max_batch_size: 1
engine_args:
model_stage: diffusion
enforce_eager: true
distributed_executor_backend: "mp"
vae_use_slicing: false
vae_use_tiling: false
cache_backend: null
cache_config: null
enable_cache_dit_summary: false
omni_kv_config:
need_recv_cache: true # Receive AR KV cache from stage 0
parallel_config:
pipeline_parallel_size: 1
data_parallel_size: 1
tensor_parallel_size: 4
enable_expert_parallel: false
sequence_parallel_size: 1
ulysses_degree: 1
ring_degree: 1
cfg_parallel_size: 1
vae_patch_parallel_size: 1
use_hsdp: false
hsdp_shard_size: -1
hsdp_replicate_size: 1
engine_input_source: [0] # Receive input (including KV) from stage 0
final_output: true
final_output_type: image
# Top-level runtime config: windows, edges, and connectors
runtime:
enabled: true
defaults:
window_size: -1 # Trigger downstream only after full upstream completion
max_inflight: 1 # Process serially within each stage
edges:
- from: 0
to: 1
window_size: -1
@@ -1,32 +0,0 @@
# Stage config for running Hunyuan-Image3.0 DiT with FP8 online quantization.
# The following config is for 2x H200 GPU.
# Stage 0: Diffusion (DiT + VAE)
# This stage receives noise and timesteps and performs denoising + VAE decode
stage_args:
- stage_id: 0
stage_type: diffusion
runtime:
devices: "0,1"
max_batch_size: 1
engine_args:
model_stage: dit
enforce_eager: true
trust_remote_code: true
distributed_executor_backend: "mp"
quantization: "fp8"
parallel_config:
tensor_parallel_size: 2
enable_expert_parallel: true
omni_kv_config:
need_recv_cache: true
final_output: true
final_output_type: image
is_comprehension: false
default_sampling_params:
seed: 42
# Runtime edges
runtime:
enabled: true
@@ -1,31 +0,0 @@
# Stage config for running Hunyuan-Image3.0 DiT.
# The following config has been verified on 4x H20 GPU.
# Stage 0: Diffusion (DiT + VAE)
# This stage receives noise and timesteps and performs denoising + VAE decode
stage_args:
- stage_id: 0
stage_type: diffusion
runtime:
devices: "0,1,2,3"
engine_args:
max_num_seqs: 1
model_stage: dit
enforce_eager: true
trust_remote_code: true
distributed_executor_backend: "mp"
parallel_config:
tensor_parallel_size: 4
enable_expert_parallel: true
omni_kv_config:
need_recv_cache: true
final_output: true
final_output_type: image
is_comprehension: false
default_sampling_params:
seed: 42
# Runtime edges
runtime:
enabled: true
@@ -1,41 +0,0 @@
# Stage config for running Hunyuan-Image3.0 on 2 GPUs with FP8.
# Stage 0: AR Model (vLLM implementation)
stage_args:
- stage_id: 0
stage_type: llm
runtime:
process: true
devices: "0,1"
engine_args:
model_stage: AR
max_num_seqs: 1
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.9
enforce_eager: true
trust_remote_code: true
engine_output_type: latent
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 2
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
is_comprehension: true
final_output: true
final_output_type: text
default_sampling_params:
temperature: 0.0
top_p: 1.0
top_k: -1
max_tokens: 2048
seed: 42
detokenize: True
repetition_penalty: 1.1
runtime:
enabled: true
@@ -1,42 +0,0 @@
# Stage config for HunyuanImage-3.0 Text-to-Text (T2T / pure text generation).
# Single LLM stage: AR model reads text prompt only, generates text output.
# Sampling params aligned with official generation_config.json.
stage_args:
- stage_id: 0
stage_type: llm
runtime:
process: true
devices: "0,1,2,3"
max_batch_size: 1
requires_multimodal_data: false
engine_args:
model_stage: AR
max_num_seqs: 1
model_arch: HunyuanImage3ForCausalMM
worker_cls: vllm_omni.worker.gpu_ar_worker.GPUARWorker
scheduler_cls: vllm_omni.core.sched.omni_ar_scheduler.OmniARScheduler
gpu_memory_utilization: 0.95
enforce_eager: true
trust_remote_code: true
enable_prefix_caching: false
max_num_batched_tokens: 32768
tensor_parallel_size: 4
pipeline_parallel_size: 1
hf_overrides:
rope_parameters:
mrope_section: [0, 32, 32]
rope_type: default
is_comprehension: true
final_output: true
final_output_type: text
default_sampling_params:
temperature: 0.0
top_p: 0.95
top_k: 1024
max_tokens: 2048
stop_token_ids: [127957, 128024, 128026] # <|endoftext|>, </think>, </answer>
detokenize: True
runtime:
enabled: true