×ばつ1024) + long prompts required accessing pos_freqs[1024:2048] from a 1024-element buffer. Solution Added dynamic buffer expansion that automatically resizes pos_freqs when needed: Only expands when required (memory efficient) Uses register_buffer() for proper tensor management Maintains backward compatibility and performance Changes Added _expand_pos_freqs_if_needed() method Modified forward() to check expansion requirements Added test case for long prompt scenarios Before: pos_freqs[1024:2048] → IndexError After: Auto-expands buffer → Success Fixes #12083 Before submitting This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case). Did you read the contributor guideline? Did you read our philosophy doc (important for complex PRs)? Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case. Issue: #12083 Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings. Note: This is a bug fix with internal implementation changes only. No public API changes require documentation updates. Did you write any new necessary tests? Added: test_long_prompt_no_error() in tests/pipelines/qwenimage/test_qwenimage.py Implementation Details Architecture Analysis Our solution follows established patterns in the diffusers codebase: Buffer Management: Uses register_buffer() like other components (modeling_ctx_clip.py, embeddings.py) Dynamic Computation: Mirrors pattern in get_1d_rotary_pos_embed() which computes frequencies on-demand Memory Alignment: Rounds to 512-token boundaries following PyTorch optimization practices Performance Impact Memory: Minimal - only expands when needed (one-time cost) Speed: Negligible - expansion happens once then cached Quality: Zero impact - identical mathematical operations, just larger buffer Backward Compatibility API: No changes to public interface Behavior: Existing short prompts work exactly as before Performance: Same performance characteristics for existing use cases Who can review? This PR affects: Model implementations: @sayakpaul The fix is focused on the QwenImage transformer implementation and follows established PyTorch patterns for dynamic buffer management.">
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Verify warning was logged about the 512-token training limitation
self.assertTrue("512 tokens" in cap_logger.out)
self.assertTrue("unpredictable behavior" in cap_logger.out)
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.