Bug
When using MultimodalGuider with cfg=1.0 (required for the distilled LoRA workflow), SamplerCustomAdvanced crashes with:
UnboundLocalError: local variable 'noise_pred_neg' referenced before assignment
File: guiders/multimodal_guider.py, line 269
Triggered by: euler_ancestral_cfg_pp and euler_cfg_pp samplers, which register a sampler_post_cfg_function hook that references noise_pred_neg.
Root Cause
In MultimodalGuider.predict_noise, noise_pred_neg is only assigned inside the if any(params.do_uncond() for params in [...]) block (line ~167). When cfg=1.0, do_uncond() returns False (not math.isclose(cfg_scale, 1.0)), so the block is skipped entirely. However, line 269 unconditionally references noise_pred_neg when iterating sampler_post_cfg_function hooks:
for fn in model_options.get("sampler_post_cfg_function", []):
args = {
...
"uncond_denoised": noise_pred_neg, # ← crashes here when cfg=1.0
...
}
Note that v_noise_pred_neg and a_noise_pred_neg are correctly initialized to 0 before the block, but noise_pred_neg (the packed form) is not.
Reproduction
- Use the LTX-2.3 22B NVFP4 model with distilled LoRA (
ltx-2.3-22b-distilled-lora-384.safetensors)
- Set
GuiderParameters cfg=1.0 for both VIDEO and VIDEO modalities (correct for distilled)
- Use
KSamplerSelect with euler_ancestral_cfg_pp or euler_cfg_pp
- Queue — crashes immediately on first denoising step
Fix
Initialize noise_pred_neg (and noise_pred_perturbed for the same reason) before the conditional blocks:
# Before the if do_uncond() block, add:
noise_pred_neg = noise_pred_pos # fallback when cfg=1.0 (do_uncond skipped)
noise_pred_perturbed = noise_pred_pos # fallback when stg=0.0 (do_perturbed skipped)
This matches the behavior of the already-initialized v_noise_pred_neg = 0 / a_noise_pred_neg = 0 variables and is the correct semantic for distilled inference (no negative guidance correction needed).
Environment
- LTX-2.3 22B NVFP4 (
ltx-2.3-22b-dev-nvfp4.safetensors)
- Distilled LoRA:
ltx-2.3-22b-distilled-lora-384.safetensors
- ComfyUI-LTXVideo (latest main)
- Sampler:
euler_ancestral_cfg_pp
Bug
When using
MultimodalGuiderwithcfg=1.0(required for the distilled LoRA workflow),SamplerCustomAdvancedcrashes with:File:
guiders/multimodal_guider.py, line 269Triggered by:
euler_ancestral_cfg_ppandeuler_cfg_ppsamplers, which register asampler_post_cfg_functionhook that referencesnoise_pred_neg.Root Cause
In
MultimodalGuider.predict_noise,noise_pred_negis only assigned inside theif any(params.do_uncond() for params in [...])block (line ~167). Whencfg=1.0,do_uncond()returnsFalse(not math.isclose(cfg_scale, 1.0)), so the block is skipped entirely. However, line 269 unconditionally referencesnoise_pred_negwhen iteratingsampler_post_cfg_functionhooks:Note that
v_noise_pred_neganda_noise_pred_negare correctly initialized to0before the block, butnoise_pred_neg(the packed form) is not.Reproduction
ltx-2.3-22b-distilled-lora-384.safetensors)GuiderParameterscfg=1.0 for both VIDEO and VIDEO modalities (correct for distilled)KSamplerSelectwitheuler_ancestral_cfg_pporeuler_cfg_ppFix
Initialize
noise_pred_neg(andnoise_pred_perturbedfor the same reason) before the conditional blocks:This matches the behavior of the already-initialized
v_noise_pred_neg = 0/a_noise_pred_neg = 0variables and is the correct semantic for distilled inference (no negative guidance correction needed).Environment
ltx-2.3-22b-dev-nvfp4.safetensors)ltx-2.3-22b-distilled-lora-384.safetensorseuler_ancestral_cfg_pp