Skip to content

fix: return correct tuple size from predict_with_cfg zero-init early-exit#2028

Open
sajeel-haider wants to merge 1 commit into
kijai:mainfrom
sajeel-haider:fix/predict-with-cfg-tuple-unpack
Open

fix: return correct tuple size from predict_with_cfg zero-init early-exit#2028
sajeel-haider wants to merge 1 commit into
kijai:mainfrom
sajeel-haider:fix/predict-with-cfg-tuple-unpack

Conversation

@sajeel-haider

Copy link
Copy Markdown

Summary

  • Fixes the ValueError: not enough values to unpack (expected 3, got 2) crash when both cfg_zero_star and use_zero_init are enabled in WanVideoExperimentalArgs
  • Passes through cache_state/teacache_state unchanged in the zero-init early-exit path — at step 0 there is no cache update, so returning the input state is the correct identity behavior
  • Fixes the same bug in both nodes_sampler.py (3-tuple callers) and skyreels/nodes.py (2-tuple callers where None was returned instead of state)

Changes

nodes_sampler.py (line 1185):

 if use_cfg_zero_star and (idx <= zero_star_steps) and use_zero_init:
-    return z*0, None
+    return z*0, None, cache_state

skyreels/nodes.py (line 460):

 if use_cfg_zero_star and (idx <= zero_star_steps) and use_zero_init:
-    return latent_model_input*0, None
+    return latent_model_input*0, teacache_state

Test plan

  • Verified the fix matches the return signature of all other return paths in both functions
  • Confirmed all callers in nodes_sampler.py unpack 3 values and all callers in skyreels/nodes.py unpack 2 values
  • Test with Wan 2.2 I2V/T2V workflow with cfg_zero_star=True + use_zero_init=True

Fixes #2010

…exit

The `use_cfg_zero_star + use_zero_init` early-exit path in
`predict_with_cfg` returned a 2-tuple while all callers unpack 3 values
(nodes_sampler.py) or expect the cache state (skyreels/nodes.py),
causing `ValueError: not enough values to unpack` on the first sampling
step when both options are enabled.

Pass through `cache_state`/`teacache_state` unchanged — at the zero-init
step there is no cache update, so returning the input state is the
correct identity behavior.

Fixes kijai#2010
@sajeel-haider sajeel-haider force-pushed the fix/predict-with-cfg-tuple-unpack branch from 404e32f to 2335727 Compare June 2, 2026 16:25
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.

predict_with_cfg use_zero_init early-exit returns 2-tuple, callers expect 3-tuple

1 participant