LTX2 NAG - error SamplerCustomAdvanced Input tensor must be contiguous
Hi there,
first of all, a big thank you for the nvfp4 and nvfp4 mixed format for LTX2.3 ! It works by just replacing the default LTX2.3 diffusion model with yours.
But when I tried the First-Last-Frame workflow written by RuneXX (https://huggingface.co/RuneXX/LTX-2.3-Workflows/tree/main), I got a strange error : "Input tensor must be contiguous" on the node LTX2 Nag. When using "ltx-2.3-22b-dev_transformer_only_fp8_scaled.safetensors", no such error.
Hi, you're welcome 😊
it's most likely the "transformer_only" part of it that create the issue: the workflow expect the version of the model that is splitted in more parts than the native workflow (where the VAE and text projections are embedded in the same file)
you can either:
- rewire the workflow with the Load Checkpoint nodes from the native workflow
- try with transformer_only/ltx-2.3-22b-dev_transformer_only_nvfp4_NON-CALIBRATED.safetensors I just did (quick and dirty). The output will probably be somewhere between awful and white noise, but report back if it runs and I will make proper conversions for the transformer_only models
Hi Hippotes,
thank you for this transformer only version, but unfortunately it fails with the same error.
This new "transformer only" version works well for classical workflow (i2v, t2v)
can you check you have everything up to date and share the full report of the crash?
I just ran the workflow with the nvfp4 model, it looks just as bad as I expected but no error on my end
I often hang on Banodoco and SwarmUI discord server, you can ping me there if you want
Hi Hippotes,
I havec updated all the modules, including comfyui to the latest (stable) version.
Still got the problem.
There are the logs :
Model LTXAV prepared for dynamic VRAM loading. 14629MB Staged. 1660 patches attached.
0%| | 0/8 [00:01<?, ?it/s, Model Initializing ... ]
!!! Exception during processing !!! Input tensor must be contiguous
Traceback (most recent call last):
File "I:\ComfyUI_windows_portable\ComfyUI\execution.py", line 524, in execute
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\execution.py", line 333, in get_output_data
return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\execution.py", line 307, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "I:\ComfyUI_windows_portable\ComfyUI\execution.py", line 295, in process_inputs
result = f(**inputs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy_api\internal__init__.py", line 149, in wrapped_func
return method(locked_class, **inputs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy_api\latest_io.py", line 1764, in EXECUTE_NORMALIZED
to_return = cls.execute(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_custom_sampler.py", line 963, in execute
samples = guider.sample(noise.generate_noise(latent), latent_image, sampler, sigmas, denoise_mask=noise_mask, callback=callback, disable_pbar=disable_pbar, seed=noise.seed)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 1051, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed, latent_shapes=latent_shapes)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 113, in execute
return self.wrappers[self.idx](self, *args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 857, in __call__
out = executor(noise, latent_image, sampler, sigmas, denoise_mask, combined_callback, disable_pbar, seed, latent_shapes=latent_shapes)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 105, in __call__
return new_executor.execute(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 995, in outer_sample
output = self.inner_sample(noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed, latent_shapes=latent_shapes)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 981, in inner_sample
samples = executor.execute(self, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 751, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\utils_contextlib.py", line 124, in decorate_context
return func(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\k_diffusion\sampling.py", line 1265, in sample_euler_ancestral_cfg_pp
denoised = model(x, sigmas[i] * s_in, **extra_args)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 400, in __call__
out = self.inner_model(x, sigma, model_options=model_options, seed=seed)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 954, in __call__
return self.outer_predict_noise(*args, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 961, in outer_predict_noise
).execute(x, timestep, model_options, seed)
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 964, in predict_noise
return sampling_function(self.inner_model, x, timestep, self.conds.get("negative", None), self.conds.get("positive", None), self.cfg, model_options=model_options, seed=seed)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 380, in sampling_function
out = calc_cond_batch(model, conds, x, timestep, model_options)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 205, in calc_cond_batch
return _calc_cond_batch_outer(model, conds, x_in, timestep, model_options)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 213, in _calc_cond_batch_outer
return executor.execute(model, conds, x_in, timestep, model_options)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\samplers.py", line 325, in _calc_cond_batch
output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\model_base.py", line 170, in apply_model
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...<2 lines>...
comfy.patcher_extension.get_all_wrappers(comfy.patcher_extension.WrappersMP.APPLY_MODEL, transformer_options)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
).execute(x, t, c_concat, c_crossattn, control, transformer_options, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\model_base.py", line 209, in _apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1776, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1787, in _call_impl
return forward_call(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\av_model.py", line 1020, in forward
return super().forward(
~~~~~~~~~~~~~~~^
x,
^^
...<6 lines>...
**kwargs,
^^^^^^^^^
)
^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\model.py", line 879, in forward
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...<4 lines>...
),
~~
).execute(x, timestep, context, attention_mask, frame_rate, transformer_options, keyframe_idxs, denoise_mask=denoise_mask, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\model.py", line 932, in _forward
x = self._process_transformer_blocks(
x, context, attention_mask, timestep, pe,
...<2 lines>...
**merged_args,
)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\av_model.py", line 929, in _process_transformer_blocks
vx, ax = block(
~~~~~^
(vx, ax),
^^^^^^^^^
...<16 lines>...
a_prompt_timestep=a_prompt_timestep,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1776, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1787, in call_impl
return forward_call(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\av_model.py", line 282, in forward
vx.add(self._apply_text_cross_attention(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
vx, v_context, self.attn2, self.scale_shift_table,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
getattr(self, 'prompt_scale_shift_table', None),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
v_timestep, v_prompt_timestep, attention_mask, transformer_options,)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\av_model.py", line 246, in _apply_text_cross_attention
return apply_cross_attention_adaln(
x, context, attn, shift_q, scale_q, gate,
prompt_scale_shift_table, prompt_timestep,
attention_mask, transformer_options,
)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\lightricks\model.py", line 529, in apply_cross_attention_adaln
return attn(attn_input, context=encoder_hidden_states, mask=attention_mask, transformer_options=transformer_options) * q_gate
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1776, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1787, in _call_impl
return forward_call(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 436, in wrapped_attention
return ltxv_crossattn_forward_nag(self_module, *args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 391, in ltxv_crossattn_forward_nag
x_positive, x_negative = nag_attention(self, q_pos, context_pos, self.nag_context, attention_precision=self.attn_precision, transformer_options=transformer_options)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 343, in nag_attention
x_negative = _compute_attention(self, query, nag_context, attention_precision, transformer_options)
File "I:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-kjnodes\nodes\ltxv_nodes.py", line 335, in _compute_attention
k = self.k_norm(self.to_k(context)).to(query.dtype)
~~~~~~~~~^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1776, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1787, in call_impl
return forward_call(*args, **kwargs)
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\ops.py", line 906, in forward
input = QuantizedTensor.from_float(input_reshaped, self.layout_type, scale=scale)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\comfy_kitchen\tensor\base.py", line 234, in from_float
qdata, params = get_layout_class(layout_cls).quantize(tensor, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\ComfyUI\comfy\quant_ops.py", line 109, in quantize
qdata, block_scale = ck.quantize_nvfp4(tensor, scale, pad_16x=needs_padding)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\comfy_kitchen_init.py", line 104, in quantize_nvfp4
return torch.ops.comfy_kitchen.quantize_nvfp4(x, per_tensor_scale, epsilon, pad_16x)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch_ops.py", line 1209, in call
return self._op(*args, **kwargs)
~~~~~~~~^^^^^^^^^^^^^^^^^
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch_library\custom_ops.py", line 347, in backend_impl
result = self._backend_fns[device_type](*args, **kwargs)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch_compile.py", line 54, in inner
return disable_fn(*args, **kwargs)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch_dynamo\eval_frame.py", line 1181, in _fn
return fn(*args, **kwargs)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch_library\custom_ops.py", line 382, in wrapped_fn
return fn(*args, **kwargs)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\comfy_kitchen\backends\eager\quantization.py", line 283, in op_quantize_nvfp4
return impl(**kwargs)
File "I:\ComfyUI_windows_portable\python_embeded\Lib\site-packages\comfy_kitchen\backends\cuda_init.py", line 196, in quantize_nvfp4
assert x.is_contiguous(), "Input tensor must be contiguous"
~~~~~~~~~~~~~~~^^
AssertionError: Input tensor must be contiguous
Prompt executed in 41.21 seconds
So I tried it again, and I can't reproduce your error...
@MrReclusive shared the fp4 he uploaded on civitai (https://civitai.com/models/2445970?modelVersionId=2751189), maybe you can give it a try see if it runs?