Repository navigation
Keep DreamLite's GQA-aware attention processor when attention slicing is disabled - #15191
Open
davrens101 wants to merge 2 commits into
Open
davrens101 wants to merge 2 commits into
davrens101 wants to merge 2 commits into
Conversation
Contributor
|
Hi @davrens101, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #15161.
What was wrong
DreamLiteUNetModelrelies onDreamLiteAttnProcessor2_0, which repeats K/V heads up to the query head count for grouped-query attention.UNet2DConditionModel.set_attention_slice(None)walks everyAttentionmodule and callsAttention.set_attention_slice(None), which installs the stockAttnProcessor2_0— sopipeline.disable_attention_slicing()breaks the next forward pass with a shape error even if slicing was never enabled:(
query.view(batch_size, -1, attn.heads, head_dim)withhead_dim = query.shape[-1] // attn.heads == 0.)Sliced attention itself is not usable here either:
SlicedAttnProcessorhas no GQA path, soenable_attention_slicing()silently produced broken inference.Fix
Override
DreamLiteUNetModel.set_attention_slice:None(the path used bydisable_attention_slicing()) restoresDreamLiteAttnProcessor2_0via the existingset_default_attn_processor()override, without touching anything else.ValueErrorexplaining that DreamLite's GQA layout is not supported bySlicedAttnProcessor, instead of failing later inside attention.Output before/after
set_attention_slice(None)on a tiny GQA (num_kv_heads=1) UNet is now bit-identical.Tests
Added
TestDreamLiteAttentionSlicingintests/pipelines/dreamlite/test_pipeline_dreamlite.py: disable keeps the output identical, enable raises.python -m pytest tests/pipelines/dreamlite/test_pipeline_dreamlite.py -k AttentionSlicing→ 2 passedruff check/ruff format --checkon both files → cleanAI assistance was used for this change; I reviewed and ran the tests above.
Coordination status
The issue author has already investigated this report and is awaiting maintainer feedback. Linking the existing report here does not claim issue assignment or maintainer acknowledgment.