Skip to content

Commit 133184e

Browse files
committed
Merge branch 'master' into v3-improvements
2 parents ad1a0f9 + fc657f4 commit 133184e

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

comfy/ldm/hunyuan_video/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class HunyuanVideoParams:
4343
meanflow: bool
4444
use_cond_type_embedding: bool
4545
vision_in_dim: int
46+
meanflow_sum: bool
4647

4748

4849
class SelfAttentionRef(nn.Module):
@@ -317,7 +318,7 @@ def forward_orig(
317318
timesteps_r = transformer_options['sample_sigmas'][w[0] + 1]
318319
timesteps_r = timesteps_r.unsqueeze(0).to(device=timesteps.device, dtype=timesteps.dtype)
319320
vec_r = self.time_r_in(timestep_embedding(timesteps_r, 256, time_factor=1000.0).to(img.dtype))
320-
vec = (vec + vec_r) / 2
321+
vec = (vec + vec_r) if self.params.meanflow_sum else (vec + vec_r) / 2
321322

322323
if ref_latent is not None:
323324
ref_latent_ids = self.img_ids(ref_latent)

comfy/model_detection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ def detect_unet_config(state_dict, key_prefix, metadata=None):
180180
dit_config["use_cond_type_embedding"] = False
181181
if '{}vision_in.proj.0.weight'.format(key_prefix) in state_dict_keys:
182182
dit_config["vision_in_dim"] = state_dict['{}vision_in.proj.0.weight'.format(key_prefix)].shape[0]
183+
dit_config["meanflow_sum"] = True
183184
else:
184185
dit_config["vision_in_dim"] = None
186+
dit_config["meanflow_sum"] = False
185187
return dit_config
186188

187189
if '{}double_blocks.0.img_attn.norm.key_norm.scale'.format(key_prefix) in state_dict_keys and ('{}img_in.weight'.format(key_prefix) in state_dict_keys or f"{key_prefix}distilled_guidance_layer.norms.0.scale" in state_dict_keys): #Flux, Chroma or Chroma Radiance (has no img_in.weight)

comfy/quant_ops.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,10 @@ def quantize(cls, tensor, scale=None, dtype=torch.float8_e4m3fn, stochastic_roun
399399
orig_dtype = tensor.dtype
400400

401401
if isinstance(scale, str) and scale == "recalculate":
402-
scale = torch.amax(tensor.abs()) / torch.finfo(dtype).max
402+
scale = torch.amax(tensor.abs()).to(dtype=torch.float32) / torch.finfo(dtype).max
403+
if tensor.dtype not in [torch.float32, torch.bfloat16]: # Prevent scale from being too small
404+
tensor_info = torch.finfo(tensor.dtype)
405+
scale = (1.0 / torch.clamp((1.0 / scale), min=tensor_info.min, max=tensor_info.max))
403406

404407
if scale is not None:
405408
if not isinstance(scale, torch.Tensor):

comfyui_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file is automatically generated by the build process when version is
22
# updated in pyproject.toml.
3-
__version__ = "0.3.76"
3+
__version__ = "0.4.0"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ComfyUI"
3-
version = "0.3.76"
3+
version = "0.4.0"
44
readme = "README.md"
55
license = { file = "LICENSE" }
66
requires-python = ">=3.9"

0 commit comments

Comments
 (0)