Skip to content

fuse qkv/norm/rottary for z image - #868

Merged
lmxyy merged 3 commits into
nunchaku-ai:mainfrom
devgdovg:feat/z_image_fuse_rope
Jan 7, 2026
Merged

fuse qkv/norm/rottary for z image#868
lmxyy merged 3 commits into
nunchaku-ai:mainfrom
devgdovg:feat/z_image_fuse_rope

Conversation

@devgdovg

@devgdovg devgdovg commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

optimize inference speed for Nunchaku Z-Image-Turbo by fuse qkv/norm/rottary in attention module.

Modifications

  • modify attention processor, calling fused_qkv_norm_rottary method.
  • add a pre forward hook for caching packed freqs_cis tensor.

Checklist

  • Code is formatted using Pre-Commit hooks.
  • Relevant unit tests are added in the tests directory following the guidance in Contribution Guide.
  • Documentation and example scripts in examples are updated if necessary.
  • Throughput/latency benchmarks and quality evaluations are included where applicable.
  • For reviewers: If you're only helping merge the main branch and haven't contributed code to this PR, please remove yourself as a co-author when merging.
  • Please feel free to join our Slack, Discord or WeChat to discuss your PR.

@devgdovg

devgdovg commented Jan 6, 2026

Copy link
Copy Markdown
Contributor Author

No need to add new test cases. Just run existing case for z image for verification.

@devgdovg
devgdovg marked this pull request as ready for review January 6, 2026 01:07
@vgabbo

vgabbo commented Jan 6, 2026

Copy link
Copy Markdown

Can I please ask if it influences quality? And what is the time improvement? Thank you so much for your work! @devgdovg

@lmxyy

lmxyy commented Jan 7, 2026

Copy link
Copy Markdown
Collaborator

Can I please ask if it influences quality? And what is the time improvement? Thank you so much for your work! @devgdovg

No. This is mathematically equivalent to the previous SVDQ inference.

@lmxyy lmxyy closed this Jan 7, 2026
@lmxyy lmxyy reopened this Jan 7, 2026

@lmxyy lmxyy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

passing tests. approved

@lmxyy
lmxyy merged commit 03b4206 into nunchaku-ai:main Jan 7, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants