Skip to content

Commit 685eeab

Browse files
authored
Merge branch 'main' into fix-clip-lora-tests
2 parents 38f9b2b + 2b9572d commit 685eeab

2 files changed

Lines changed: 2 additions & 59 deletions

File tree

src/diffusers/models/transformers/transformer_qwenimage.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from ...configuration_utils import ConfigMixin, register_to_config
2525
from ...loaders import FromOriginalModelMixin, PeftAdapterMixin
26-
from ...utils import apply_lora_scale, deprecate, logging
26+
from ...utils import apply_lora_scale, logging
2727
from ...utils.torch_utils import lru_cache_unless_export, maybe_allow_in_graph
2828
from .._modeling_parallel import ContextParallelInput, ContextParallelOutput
2929
from ..attention import AttentionMixin, FeedForward
@@ -241,38 +241,21 @@ def _get_device_freqs(self, device: torch.device) -> tuple[torch.Tensor, torch.T
241241
def forward(
242242
self,
243243
video_fhw: tuple[int, int, int, list[tuple[int, int, int]]],
244-
txt_seq_lens: list[int] | None = None,
245244
device: torch.device = None,
246245
max_txt_seq_len: int | torch.Tensor | None = None,
247246
) -> tuple[torch.Tensor, torch.Tensor]:
248247
"""
249248
Args:
250249
video_fhw (`tuple[int, int, int]` or `list[tuple[int, int, int]]`):
251250
A list of 3 integers [frame, height, width] representing the shape of the video.
252-
txt_seq_lens (`list[int]`, *optional*, **Deprecated**):
253-
Deprecated parameter. Use `max_txt_seq_len` instead. If provided, the maximum value will be used.
254251
device: (`torch.device`, *optional*):
255252
The device on which to perform the RoPE computation.
256253
max_txt_seq_len (`int` or `torch.Tensor`, *optional*):
257254
The maximum text sequence length for RoPE computation. This should match the encoder hidden states
258255
sequence length. Can be either an int or a scalar tensor (for torch.compile compatibility).
259256
"""
260-
# Handle deprecated txt_seq_lens parameter
261-
if txt_seq_lens is not None:
262-
deprecate(
263-
"txt_seq_lens",
264-
"0.39.0",
265-
"Passing `txt_seq_lens` is deprecated and will be removed in version 0.39.0. "
266-
"Please use `max_txt_seq_len` instead. "
267-
"The new parameter accepts a single int or tensor value representing the maximum text sequence length.",
268-
standard_warn=False,
269-
)
270-
if max_txt_seq_len is None:
271-
# Use max of txt_seq_lens for backward compatibility
272-
max_txt_seq_len = max(txt_seq_lens) if isinstance(txt_seq_lens, list) else txt_seq_lens
273-
274257
if max_txt_seq_len is None:
275-
raise ValueError("Either `max_txt_seq_len` or `txt_seq_lens` (deprecated) must be provided.")
258+
raise ValueError("`max_txt_seq_len` must be provided.")
276259

277260
# Validate batch inference with variable-sized images
278261
if isinstance(video_fhw, list) and len(video_fhw) > 1:
@@ -855,7 +838,6 @@ def forward(
855838
encoder_hidden_states_mask: torch.Tensor = None,
856839
timestep: torch.LongTensor = None,
857840
img_shapes: list[tuple[int, int, int]] | None = None,
858-
txt_seq_lens: list[int] | None = None,
859841
guidance: torch.Tensor = None, # TODO: this should probably be removed
860842
attention_kwargs: dict[str, Any] | None = None,
861843
controlnet_block_samples=None,
@@ -878,9 +860,6 @@ def forward(
878860
Used to indicate denoising step.
879861
img_shapes (`list[tuple[int, int, int]]`, *optional*):
880862
Image shapes for RoPE computation.
881-
txt_seq_lens (`list[int]`, *optional*, **Deprecated**):
882-
Deprecated parameter. Use `encoder_hidden_states_mask` instead. If provided, the maximum value will be
883-
used to compute RoPE sequence length.
884863
guidance (`torch.Tensor`, *optional*):
885864
Guidance tensor for conditional generation.
886865
attention_kwargs (`dict`, *optional*):
@@ -897,16 +876,6 @@ def forward(
897876
If `return_dict` is True, an [`~models.transformer_2d.Transformer2DModelOutput`] is returned, otherwise a
898877
`tuple` where the first element is the sample tensor.
899878
"""
900-
if txt_seq_lens is not None:
901-
deprecate(
902-
"txt_seq_lens",
903-
"0.39.0",
904-
"Passing `txt_seq_lens` is deprecated and will be removed in version 0.39.0. "
905-
"Please use `encoder_hidden_states_mask` instead. "
906-
"The mask-based approach is more flexible and supports variable-length sequences.",
907-
standard_warn=False,
908-
)
909-
910879
hidden_states = self.img_in(hidden_states)
911880

912881
timestep = timestep.to(hidden_states.dtype)

tests/models/transformers/test_models_transformer_qwenimage.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import warnings
1615

1716
import pytest
1817
import torch
@@ -176,31 +175,6 @@ def test_non_contiguous_attention_mask(self, batch_size):
176175

177176
assert output.sample.shape[1] == inputs["hidden_states"].shape[1]
178177

179-
def test_txt_seq_lens_deprecation(self):
180-
init_dict = self.get_init_dict()
181-
inputs = self.get_dummy_inputs()
182-
model = self.model_class(**init_dict).to(torch_device)
183-
184-
txt_seq_lens = [inputs["encoder_hidden_states"].shape[1]]
185-
186-
inputs_with_deprecated = inputs.copy()
187-
inputs_with_deprecated.pop("encoder_hidden_states_mask")
188-
inputs_with_deprecated["txt_seq_lens"] = txt_seq_lens
189-
190-
with warnings.catch_warnings(record=True) as w:
191-
warnings.simplefilter("always")
192-
with torch.no_grad():
193-
output = model(**inputs_with_deprecated)
194-
195-
future_warnings = [x for x in w if issubclass(x.category, FutureWarning)]
196-
assert len(future_warnings) > 0, "Expected FutureWarning to be raised"
197-
198-
warning_message = str(future_warnings[0].message)
199-
assert "txt_seq_lens" in warning_message
200-
assert "deprecated" in warning_message
201-
202-
assert output.sample.shape[1] == inputs["hidden_states"].shape[1]
203-
204178
def test_layered_model_with_mask(self):
205179
init_dict = {
206180
"patch_size": 2,

0 commit comments

Comments
 (0)