-
Couldn't load subscription status.
- Fork 6.5k
Fix #12116: preserve boolean dtype for attention masks in ChromaPipeline #12263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DN6
merged 8 commits into
huggingface:main
from
akshay-babbar:fix/chroma-attention-mask
Sep 29, 2025
+3
−4
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7bb6e4a
fix: preserve boolean dtype for attention masks in ChromaPipeline
akshay-babbar 1cf90c4
test: add ChromaPipeline attention mask dtype tests
akshay-babbar 3f9228b
test: add slow ChromaPipeline attention mask tests
akshay-babbar 60d7385
chore: removed comments
akshay-babbar 26c33ef
refactor: removing redundant type conversion
akshay-babbar 7c16aa8
Remove dedicated dtype tests as per feedback
akshay-babbar ff30295
Merge branch 'main' into fix/chroma-attention-mask
DN6 58557d4
Merge branch 'main' into fix/chroma-attention-mask
DN6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from transformers import AutoTokenizer, T5EncoderModel | ||
|
|
||
| from diffusers import AutoencoderKL, ChromaPipeline, ChromaTransformer2DModel, FlowMatchEulerDiscreteScheduler | ||
| from diffusers.utils.testing_utils import slow | ||
|
|
||
| from ...testing_utils import torch_device | ||
| from ..test_pipelines_common import FluxIPAdapterTesterMixin, PipelineTesterMixin, check_qkv_fused_layers_exist | ||
|
|
@@ -158,3 +159,26 @@ def test_chroma_image_output_shape(self): | |
| image = pipe(**inputs).images[0] | ||
| output_height, output_width, _ = image.shape | ||
| assert (output_height, output_width) == (expected_height, expected_width) | ||
|
|
||
|
|
||
| class ChromaPipelineAttentionMaskTests(unittest.TestCase): | ||
|
||
| def setUp(self): | ||
| self.pipe = ChromaPipeline.from_pretrained( | ||
| "lodestones/Chroma1-Base", | ||
| torch_dtype=torch.float16, | ||
| ) | ||
|
|
||
| @slow | ||
| def test_attention_mask_dtype_is_bool_short_prompt(self): | ||
| prompt_embeds, attn_mask = self.pipe._get_t5_prompt_embeds("man") | ||
| self.assertEqual(attn_mask.dtype, torch.bool, f"Expected bool, got {attn_mask.dtype}") | ||
| self.assertGreater(prompt_embeds.shape[0], 0) | ||
| self.assertGreater(prompt_embeds.shape[1], 0) | ||
|
|
||
| @slow | ||
| def test_attention_mask_dtype_is_bool_long_prompt(self): | ||
| long_prompt = "a detailed portrait of a man standing in a garden with flowers and trees" | ||
| prompt_embeds, attn_mask = self.pipe._get_t5_prompt_embeds(long_prompt) | ||
| self.assertEqual(attn_mask.dtype, torch.bool, f"Expected bool, got {attn_mask.dtype}") | ||
| self.assertGreater(prompt_embeds.shape[0], 0) | ||
| self.assertGreater(prompt_embeds.shape[1], 0) | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we need the type conversion here. We can just convert the final mask to bool.