Skip to content

🐛 [Bug] slice_scatter: ValueError: all elements of broadcast shape must be non-negative #4437

Description

@zewenli98

Bug Description

While compiling AM1.5 Language and Diffusion models, I got the following error:

[2026-07-28 00:22:00,452][torch_tensorrt.dynamo._compiler][WARNING] - Dynamic dimension 's13': Input range [1, 6] vs exported program range [2, 6]. Input.min_shape=1 but the exported program's min is 2 (PyTorch 0/1 specialization -- Dim(min=1) is recorded as min=2). The compiled engine's min will be 2.
[2026-07-28 00:22:00,452][torch_tensorrt.dynamo._compiler][WARNING] - Dynamic dimension 's15': Input range [1, 3358] vs exported program range [2, 3358]. Input.min_shape=1 but the exported program's min is 2 (PyTorch 0/1 specialization -- Dim(min=1) is recorded as min=2). The compiled engine's min will be 2.
Traceback (most recent call last):
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/eval.py", line 245, in <module>
    main()
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/eval.py", line 171, in main
    compiled_vision, compiled_language, compiled_diffusion = compile_trt(model, processor, clip_ids, device=device)
                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/compile_trt.py", line 133, in compile_trt
    compile_diffusion_step_no_cache(
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/diffusion.py", line 305, in compile_diffusion_step_no_cache
    trt_step = torch_tensorrt.dynamo.compile(exported, inputs=trt_input_specs, **trt_settings)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/_compiler.py", line 826, in compile
    trt_gm = compile_module(
             ^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/_compiler.py", line 1416, in compile_module
    trt_module = convert_module(
                 ^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_conversion.py", line 348, in convert_module
    serialized_interpreter_result = interpret_module_to_result(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_conversion.py", line 281, in interpret_module_to_result
    interpreter_result = interpreter.run()
                         ^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py", line 442, in run
    self._construct_trt_network_def()
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py", line 424, in _construct_trt_network_def
    super().run()
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch/fx/interpreter.py", line 197, in run
    self.env[node] = self.run_node(node)
                     ^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py", line 528, in run_node
    trt_node: torch.fx.Node = super().run_node(n)
                              ^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch/fx/interpreter.py", line 294, in run_node
    return getattr(self, n.op)(n.target, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py", line 686, in call_function
    return converter(self.ctx, target, args, kwargs, self._cur_node_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/converter_utils.py", line 723, in convert_with_type_enforcement
    return func(ctx, target, new_args, new_kwargs, name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/aten_ops_converters.py", line 1183, in aten_ops_slice_scatter
    return impl.slice_scatter.slice_scatter(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/torch_tensorrt/dynamo/conversion/impl/slice_scatter.py", line 218, in slice_scatter
    indices_np = np.broadcast_to(indices_np, src_shape).astype(np.int64)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/numpy/lib/_stride_tricks_impl.py", line 443, in broadcast_to
    return _broadcast_to(array, shape, subok=subok, readonly=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/numpy/lib/_stride_tricks_impl.py", line 379, in _broadcast_to
    raise ValueError('all elements of broadcast shape must be non-'
ValueError: all elements of broadcast shape must be non-negative

While executing %slice_scatter : [num_users=1] = call_function[target=torch.ops.aten.slice_scatter.default](args = (%select_5, %copy, 2, 1, 60, 3), kwargs = {})
Original traceback:
File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/diffusion.py", line 51, in forward
    expert_out = self.expert(
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/transformers/models/qwen3_vl/modeling_qwen3_vl.py", line 846, in forward
    position_embeddings = self.rotary_emb(hidden_states, position_ids)
  File "/home/scratch.zewenl_sw/docker_workspace/alpamayo-recipes/recipes/alpamayo1_5_quant/am15_quant/lib/python3.12/site-packages/transformers/models/qwen3_vl/modeling_qwen3_vl.py", line 329, in forward
    freqs = self.apply_interleaved_mrope(freqs, self.mrope_section)
Use tlparse to see full graph. (https://github.com/pytorch/tlparse?tab=readme-ov-file#tlparse-parse-structured-pt2-logs)

To Reproduce

Compile AM1.5 Language and Diffusion models.

Expected behavior

pass w/o error

Environment

Build information about Torch-TensorRT can be found by turning on debug messages

  • Torch-TensorRT Version (e.g. 1.0.0):
  • PyTorch Version (e.g. 1.0):
  • CPU Architecture:
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, libtorch, source):
  • Build command you used (if compiling from source):
  • Are you using local sources or building from archives:
  • Python version:
  • CUDA version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions