SamplerCustomAdvanced crashes with RuntimeError: The size of tensor a (N) must match the size of tensor b (M) at non-singleton dimension 2 when sampling LTXAV (audio+video) workflows that use LTXVConcatAVLatent to combine video and audio latents.
Still reproduces on master as of 2806163f (2026-05-03).
Repro
- Build (or load) any LTXAV workflow that:
- Combines video and audio latents via
LTXVConcatAVLatent, and
- Feeds the combined latent into
SamplerCustomAdvanced whose noise input comes from a generator that produces a non-nested noise tensor (e.g. plain RandomNoise reading the upstream video latent).
- Queue the prompt.
Example workflow that triggers it: any popular LTX-2.3 I2V/T2V workflow built around LTXVConcatAVLatent + SamplerCustomAdvanced.
Stack trace (abbreviated)
File "comfy_extras/nodes_custom_sampler.py", line 963, in execute
samples = guider.sample(noise.generate_noise(latent), latent_image, sampler, sigmas, ...)
File "comfy/samplers.py", line 1052, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, ...)
...
File "comfy/samplers.py", line 744, in sample
noise = model_wrap.inner_model.model_sampling.noise_scaling(sigmas[0], noise, latent_image, ...)
File "comfy/model_sampling.py", line 96, in noise_scaling
return sigma * noise + (1.0 - sigma) * latent_image
RuntimeError: The size of tensor a (6820) must match the size of tensor b (905216) at non-singleton dimension 2
Reason
In CFGGuider.sample() at comfy/samplers.py:1008-1010:
if latent_image.is_nested:
latent_image, latent_shapes = comfy.utils.pack_latents(latent_image.unbind())
noise, _ = comfy.utils.pack_latents(noise.unbind())
When latent_image is a NestedTensor but noise is a plain tensor, noise.unbind() splits along dim 0 (channels) producing far more tensors than expected. After pack_latents flattens and concatenates, noise and latent_image end up with mismatched dim-2 sizes, and noise_scaling crashes on the broadcast.
The denoise_mask block immediately below already handles this asymmetry defensively (checks is_nested, truncates extras, pads missing components with torch.ones). The noise branch should do the same with torch.zeros_like.
Possible solution?
PR #13318 (open since 2026-04-07) implements this. Just bumping for visibility — the fix is small, safe, and mirrors a pattern already used a few lines below.
Presumably why this hasn't been widely reported
- LTXAV is semi-recent and I'm guessing most LTX workflows are video-only, so they never construct a nested latent?
- Among LTXAV workflows, only those whose noise generator returns a non-nested tensor for a nested latent hit this. Workflows that source noise from the same nested latent should be unaffected.
Related
SamplerCustomAdvancedcrashes withRuntimeError: The size of tensor a (N) must match the size of tensor b (M) at non-singleton dimension 2when sampling LTXAV (audio+video) workflows that useLTXVConcatAVLatentto combine video and audio latents.Still reproduces on master as of
2806163f(2026-05-03).Repro
LTXVConcatAVLatent, andSamplerCustomAdvancedwhosenoiseinput comes from a generator that produces a non-nested noise tensor (e.g. plainRandomNoisereading the upstream video latent).Example workflow that triggers it: any popular LTX-2.3 I2V/T2V workflow built around
LTXVConcatAVLatent+SamplerCustomAdvanced.Stack trace (abbreviated)
Reason
In
CFGGuider.sample()atcomfy/samplers.py:1008-1010:When
latent_imageis aNestedTensorbutnoiseis a plain tensor,noise.unbind()splits along dim 0 (channels) producing far more tensors than expected. Afterpack_latentsflattens and concatenates,noiseandlatent_imageend up with mismatched dim-2 sizes, andnoise_scalingcrashes on the broadcast.The
denoise_maskblock immediately below already handles this asymmetry defensively (checksis_nested, truncates extras, pads missing components withtorch.ones). The noise branch should do the same withtorch.zeros_like.Possible solution?
PR #13318 (open since 2026-04-07) implements this. Just bumping for visibility — the fix is small, safe, and mirrors a pattern already used a few lines below.
Presumably why this hasn't been widely reported
Related
comfy/samplers.py(CFGGuider.sample)