Skip to content

Commit 56a6219

Browse files
committed
Fix NameError in ZImageOmniPipeline when guidance_scale=0
`ZImageOmniPipeline.__call__` only defines `negative_condition_siglip_embeds` inside a `if self.do_classifier_free_guidance:` block: if self.do_classifier_free_guidance: negative_condition_siglip_embeds = [ [se.clone() for se in batch] for batch in condition_siglip_embeds ] but later reads the name unconditionally when reshaping: condition_siglip_embeds = [None if sels == [] else sels + [None] for sels in condition_siglip_embeds] negative_condition_siglip_embeds = [ None if sels == [] else sels + [None] for sels in negative_condition_siglip_embeds ] `do_classifier_free_guidance` is defined as `self._guidance_scale > 0`, so any call with `guidance_scale=0.0` raises `NameError`. This is the exact configuration the pipeline's own `EXAMPLE_DOC_STRING` uses (`guidance_scale=0.0` for the Z-Image-Turbo distilled checkpoint), so running the documented snippet crashes. The downstream consumption at condition_siglip_embeds_model_input = condition_siglip_embeds + negative_condition_siglip_embeds is already guarded by `if apply_cfg:`, so we only need to guard the reshape step to match. Wrap the negative-branch list comprehension in the same CFG check, matching the symmetric treatment of `negative_condition_latents` (which is already only defined when `do_classifier_free_guidance` is true and used only in the CFG branch of the denoise loop).
1 parent f7fd76a commit 56a6219

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/diffusers/pipelines/z_image/pipeline_z_image_omni.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,10 @@ def __call__(
588588
negative_prompt_embeds = [npe for npe in negative_prompt_embeds for _ in range(num_images_per_prompt)]
589589

590590
condition_siglip_embeds = [None if sels == [] else sels + [None] for sels in condition_siglip_embeds]
591-
negative_condition_siglip_embeds = [
592-
None if sels == [] else sels + [None] for sels in negative_condition_siglip_embeds
593-
]
591+
if self.do_classifier_free_guidance:
592+
negative_condition_siglip_embeds = [
593+
None if sels == [] else sels + [None] for sels in negative_condition_siglip_embeds
594+
]
594595

595596
actual_batch_size = batch_size * num_images_per_prompt
596597
image_seq_len = (latents.shape[2] // 2) * (latents.shape[3] // 2)

0 commit comments

Comments
 (0)