fix: correct Z-Image guidance scale threshold from > 1 to > 0#13094
Open
Mr-Neutr0n wants to merge 1 commit intohuggingface:mainfrom
Open
fix: correct Z-Image guidance scale threshold from > 1 to > 0#13094Mr-Neutr0n wants to merge 1 commit intohuggingface:mainfrom
Mr-Neutr0n wants to merge 1 commit intohuggingface:mainfrom
Conversation
Z-Image uses a non-standard CFG formula: pred = pos + scale * (pos - neg) Unlike the standard formula: pred = neg + scale * (pos - neg) With Z-Image's formula, any guidance_scale > 0 applies CFG effect. The previous > 1 check was incorrect and caused CFG to be ignored when 0 < guidance_scale < 1. Also updated docstring to document the correct Z-Image CFG formula. Fixes huggingface#12905
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.
Summary
Fix incorrect
do_classifier_free_guidancethreshold check in Z-Image pipeline.Problem
Z-Image uses a non-standard CFG formula:
Unlike the standard formula:
With Z-Image's formula:
guidance_scale = 0:pred = pos(conditional, no CFG)guidance_scale = 0.5:pred = 1.5*pos - 0.5*neg(partial CFG)guidance_scale = 1:pred = 2*pos - neg(standard CFG)Any
guidance_scale > 0applies a CFG effect. The previous> 1check was incorrect and caused CFG to be completely ignored when0 < guidance_scale < 1.Changes
do_classifier_free_guidanceproperty from> 1to> 0Fixes #12905