Skip to content

Fix wrong do_classifier_free_guidance threshold in ZImagePipeline#13183

Merged
yiyixuxu merged 1 commit intohuggingface:mainfrom
kirillsst:fix/z-image-guidance-scale-threshold
Feb 26, 2026
Merged

Fix wrong do_classifier_free_guidance threshold in ZImagePipeline#13183
yiyixuxu merged 1 commit intohuggingface:mainfrom
kirillsst:fix/z-image-guidance-scale-threshold

Conversation

@kirillsst
Copy link
Contributor

Summary

  • Z-Image uses a different CFG formula: pred = pos + guidance_scale * (pos - neg), where guidance_scale = 0 corresponds to no guidance
  • The do_classifier_free_guidance property was checking > 1 (standard diffusers convention), but for this formula it should be > 0
  • This caused guidance_scale values between 0 and 1 (e.g. 0.5) to be silently ignored

Fixes #12905

Z-Image uses CFG formula `pred = pos + scale * (pos - neg)` where
`guidance_scale = 0` means no guidance. The threshold should be `> 0`
instead of `> 1` to match this formula.
Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

thanks!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@yiyixuxu yiyixuxu merged commit 97c2c6e into huggingface:main Feb 26, 2026
10 of 11 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.

Wrong Z_Image guidance scale implementation

4 participants