Repository navigation
feat(z-image): run Z-Image attention on SageAttention when enabled - #9660
Merged
lstein merged 6 commits intoOct 16, 2026
Merged
Conversation
With `attention_backend: sage`, Z-Image denoising enters the SageAttention scope; Z-Image Control masks its attention and keeps SDPA. RTX 4090, Z-Image FP8: 10.4 s → 10.0 s at 1024², 33.7 s → 25.9 s at 2048², peak VRAM unchanged; a blind review judged no image worse.
This was referenced Oct 3, 2026
Pfannkuchensack
marked this pull request as ready for review
October 12, 2026 20:44
lstein
enabled auto-merge
October 16, 2026 12:14
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.
Note
Stacked PR 3 of 8: merge after #9659. It targets
main, so until the PRs before it merge, its diff also shows their commits and the merges that carry them forward. This PR's own change is one commit,6c8718945a.Summary
With
attention_backend: sage, Z-Image denoising enters the SageAttention scope from #9657, so its eligible attention calls run on SageAttention. Z-Image Control passes an attention mask and therefore stays on PyTorch SDPA, like everything outside the loop. The defaultautois unchanged. The docs page lists Z-Image under Supported models.Related Issues / Discussions
Stacked on #9657 (SageAttention backend) and #9659, the PR before it.
QA Instructions
Z-Image FP8, model loaded, three arms per seed as described in #9657:
sageattn()'s default K smoothing; the selection feat(attention): add opt-in SageAttention backend for diffusion models #9657 ships is faster per call.To try it: install SageAttention as the docs page from #9657 describes, set
attention_backend: sage, restart and generate with Z-Image. The first generation logsSageAttention ... serves diffusion-model attention on cuda:0 (...)with the GPU and kernel name, and withlog_level: debugevery generation logs how many calls ran on SageAttention and why the others did not. Withattention_backend: autothe output is bit-identical tomain.Checks: ruff clean;
pytest tests/app/invocationspasses with the whole stack applied (2090 passed). No call-site test was added: this change only enters the scope, whose behavior #9657 tests.Review
No material findings for this call site. Z-Image Control gains nothing until its mask is handled (possible follow-up).
Compatibility / Rollout
Merge after #9659. No API or persisted-state change; only
attention_backend: sagebehaves differently.Checklist
What's Newcopy (if doing a release after this PR)