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/qwen_image/qwen_image_dit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def __init__(
super().__init__()
self.theta = theta
self.axes_dim = axes_dim
pos_index = torch.arange(1024)
neg_index = torch.arange(1024).flip(0) * -1 - 1
pos_index = torch.arange(10000)
neg_index = torch.arange(10000).flip(0) * -1 - 1
Comment on lines +51 to +52
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 value 10000 is used as a magic number in two places. To improve readability and maintainability, it would be better to define it as a named constant at the module or class level. This makes the purpose of the number clear and simplifies future modifications.

For example:

# At module level
MAX_ROPE_INDEX = 10000

# In __init__
pos_index = torch.arange(MAX_ROPE_INDEX)
neg_index = torch.arange(MAX_ROPE_INDEX).flip(0) * -1 - 1

self.pos_freqs = torch.cat(
[
self.rope_params(pos_index, self.axes_dim[0], self.theta),
Expand Down