[Feature] HunyuanImage3 allow guidance_scale<=1 in DiT stage (#2762)
Signed-off-by: KexiongYu <yukexiong1@huawei.com>
This commit is contained in:
1 parent
82f8c93343
commit
50ae1de7da
2 files changed
+4
-5
No files matched your search
@@ -1684,7 +1684,8 @@ class HunYuanAttention(nn.Module):
|
||||
else:
|
||||
attn_output = self.attn(q, k, v)
|
||||
# For o_proj
|
||||
attn_output = attn_output.view(q.shape[0], -1)
|
||||
# image_attn may return a non-contiguous tensor; reshape is safe here.
|
||||
attn_output = attn_output.reshape(q.shape[0], -1)
|
||||
output, _ = self.o_proj(attn_output)
|
||||
output = output.reshape(bsz, q_len, -1)
|
||||
return output, None, past_key_value
|
||||
|
||||
@@ -6,7 +6,6 @@ import os
|
||||
from collections.abc import Iterable
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
from diffusers.schedulers.scheduling_flow_match_euler_discrete import FlowMatchEulerDiscreteScheduler
|
||||
@@ -544,7 +543,7 @@ class HunyuanImage3Pipeline(HunyuanImage3PreTrainedModel, GenerationMixin, Diffu
|
||||
generator = [torch.Generator(self.device).manual_seed(seed) for seed in seeds]
|
||||
|
||||
# 3. apply chat template
|
||||
cfg_factor = {"gen_text": 1, "gen_image": 2}
|
||||
cfg_factor = {"gen_text": 1, "gen_image": 1 + int(guidance_scale > 1.0)}
|
||||
bot_task = kwargs.pop("bot_task", "auto")
|
||||
# If `drop_think` enabled, always drop <think> parts in the context.
|
||||
drop_think = kwargs.get("drop_think", self.generation_config.drop_think)
|
||||
@@ -1009,8 +1008,7 @@ class HunyuanImage3Pipeline(HunyuanImage3PreTrainedModel, GenerationMixin, Diffu
|
||||
if req.sampling_params.guidance_scale_provided:
|
||||
guidance_scale = req.sampling_params.guidance_scale
|
||||
if guidance_scale <= 1.0:
|
||||
logger.warning("HunyuanImage3.0 does not support guidance_scale <= 1.0, will set it to 1.0 + epsilon.")
|
||||
guidance_scale = 1.0 + np.finfo(float).eps
|
||||
logger.info("HunyuanImage3.0 runs without classifier-free guidance when guidance_scale <= 1.0.")
|
||||
image_size = (height, width)
|
||||
model_inputs = self.prepare_model_inputs(
|
||||
prompt=prompt,
|
||||
|
||||
Reference in new issue
Block a user