Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

Summary

Changes image self-attention from restricted (region-isolated) to unrestricted (all image tokens can attend to each other), similar to the FLUX approach.

This fixes the issue where ZImage-Turbo with multiple regional guidance layers would generate two separate/disconnected images instead of compositing them into a single unified image.

The regional text-image attention remains restricted so that each region still responds to its corresponding prompt.

Fixes #8715

Related Issues / Discussions

QA Instructions

  1. Create a new canvas generation with ZImage-Turbo
  2. Add two or more regional guidance layers with different prompts (e.g., "woman in business suit" on the left, "woman in peasant dress" on the right)
  3. Add a global prompt (e.g., "two women")
  4. Generate the image
  5. Expected: A single unified image with both women composited according to their regions
  6. Previous behavior: Two separate, independent images

Merge Plan

No special merge considerations required. This is a targeted fix to the attention mask construction.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration - N/A
  • Documentation added / updated (if applicable) - N/A
  • Updated What's New copy (if doing a release after this PR)

…pting

Changes image self-attention from restricted (region-isolated) to unrestricted
(all image tokens can attend to each other), similar to the FLUX approach.

This fixes the issue where ZImage-Turbo with multiple regional guidance layers
would generate two separate/disconnected images instead of compositing them
into a single unified image.

The regional text-image attention remains restricted so that each region still
responds to its corresponding prompt.

Fixes invoke-ai#8715
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files labels Dec 28, 2025
Copy link
Collaborator

@lstein lstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change works well in my hands. I find that even minimal overlap of the regions ensures better coherence to the main prompt, but I usually get acceptable results even when the regions are not overlapping.

@lstein lstein merged commit d7d0512 into invoke-ai:main Dec 28, 2025
13 checks passed
@Pfannkuchensack Pfannkuchensack deleted the fix/zimage-regional-guidance-unrestricted-attention branch December 28, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: ZImage-Turbo regional guidance not working as expected

2 participants