Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions diffsynth_engine/models/flux/flux_dit_fbcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def from_state_dict(
dtype: torch.dtype,
in_channel: int = 64,
attn_kwargs: Optional[Dict[str, Any]] = None,
fb_cache_relative_l1_threshold: float = 0.05,
relative_l1_threshold: float = 0.05,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default value 0.05 is a magic number. To improve readability and maintainability, it's better to define this as a named constant at the module or class level.

For example, you could define it at the module level:

DEFAULT_RELATIVE_L1_THRESHOLD = 0.05

class FluxDiTFBCache(FluxDiT):
    # ...

This constant could then be used here and in the __init__ method (line 27) for consistency. While the __init__ method is outside this diff, making this change consistently would be ideal.

):
with no_init_weights():
model = torch.nn.utils.skip_init(
Expand All @@ -197,7 +197,7 @@ def from_state_dict(
dtype=dtype,
in_channel=in_channel,
attn_kwargs=attn_kwargs,
fb_cache_relative_l1_threshold=fb_cache_relative_l1_threshold,
relative_l1_threshold=relative_l1_threshold,
)
model = model.requires_grad_(False) # for loading gguf
model.load_state_dict(state_dict, assign=True)
Expand Down