Skip to content

Wrong results when plugin outputs feed an axis-1 Concatenation that is consumed by another plugin (dynamic shape, M > 1) — TensorRT 10.15 / 10.16 / 11.5 #4949

Open

Description

@nabe2030

Description

When the outputs of two (or more) plugin layers are concatenated along axis 1 and the concatenation is consumed by another plugin layer, the engine returns wrong values as soon as the dynamic leading dimension M is greater than 1. With M = 1 the result is correct.

It looks as if TensorRT places each producer plugin's output directly inside the concatenation buffer and inserts no copy. A plugin writes a dense [M, K] tensor, but a column slice of an [M, 2K] buffer is only contiguous when M = 1, so for M > 1 the rows end up in the wrong place.

What we observed:

  • Pure TensorRT reproducer (below): three trivial Python plugins, no model, no other library. Wrong for M ≥ 2 on TensorRT 10.15.1.29, 10.16.1.11 and 11.5.0.63.
  • The result is correct if the concatenation is marked as a network output instead of feeding a plugin, and also if the consumer is an elementwise layer.
  • We first hit this in a real engine built with TensorRT Edge-LLM 0.12.0 (C++ IPluginV3 plugins: three GEMM plugins for q/k/v → concat → attention plugin). There, the engine inspector (--profiling-detailed) shows that the three producer plugins have the [Concatenation]_output tensor itself as their output tensor, and the consumer plugin reads that same tensor as [-1, 4096]. In the variant of the same network that works, each producer writes a temporary and a __myl_Move kernel copies it into the concat buffer.
  • In that engine the corruption has a clear pattern: row r of the concat holds the first producer's output for row 2r+1, which is what a dense M × 2048 write over the start of an [M, 4096] buffer produces.

We could only test on one device (DGX Spark, GB10), so we do not know whether other GPUs are affected. Nothing in the mechanism looks GPU-specific.

Issue #4854 looks related. There, a fused layer reads an operand that aliases a channel slice of a later concatenation buffer as if it were dense. Here, a plugin writes into such a slice as if it were dense.

Environment

TensorRT Version: 10.15.1.29, 10.16.1.11, 11.5.0.63 (pip wheels, tensorrt-cu13) — all three fail

NVIDIA GPU: DGX Spark (GB10, compute capability 12.1)

NVIDIA Driver Version: 580.178.04

CUDA Version: 13.0 (runtime libraries from the pip wheels)

CUDNN Version: not used

Operating System: DGX OS 7.6.0 (aarch64)

Python Version: 3.12.3

PyTorch Version: 2.14.0+cu130 (used only to implement the Python plugins and to hold the I/O buffers)

Baremetal or Container: baremetal, Python virtual environment

Relevant Files

None needed. The script below is self-contained.

Steps To Reproduce

Graph:

x[M, K] -> plugin copy(x)   -> a
x[M, K] -> plugin double(x) -> b
c   = Concatenation([a, b], axis=1)      # [M, 2K]
out = plugin copy(c)                      # expected: out == [x, 2x]

Script:

from typing import Tuple

import tensorrt as trt
import tensorrt.plugin as trtp
import torch


def _run(inp0, outputs, stream, factor):
    with torch.cuda.stream(torch.cuda.ExternalStream(stream)):
        x = torch.as_tensor(inp0, device="cuda")
        y = torch.as_tensor(outputs[0], device="cuda")
        y.copy_(x * factor)


@trtp.register("repro::copy")
def copy_desc(inp0: trtp.TensorDesc) -> trtp.TensorDesc:
    return inp0.like()


@trtp.impl("repro::copy")
def copy_impl(inp0: trtp.Tensor, outputs: Tuple[trtp.Tensor], stream: int) -> None:
    _run(inp0, outputs, stream, 1.0)


@trtp.register("repro::double")
def double_desc(inp0: trtp.TensorDesc) -> trtp.TensorDesc:
    return inp0.like()


@trtp.impl("repro::double")
def double_impl(inp0: trtp.Tensor, outputs: Tuple[trtp.Tensor], stream: int) -> None:
    _run(inp0, outputs, stream, 2.0)


K = 256
logger = trt.Logger(trt.Logger.WARNING)
builder = trt.Builder(logger)
net = builder.create_network(1 << int(trt.NetworkDefinitionCreationFlag.STRONGLY_TYPED))
x = net.add_input("x", trt.float16, (-1, K))
a = net.add_plugin(trtp.op.repro.copy(x)).get_output(0)
b = net.add_plugin(trtp.op.repro.double(x)).get_output(0)
cat = net.add_concatenation([a, b])
cat.axis = 1
out = net.add_plugin(trtp.op.repro.copy(cat.get_output(0))).get_output(0)
out.name = "out"
net.mark_output(out)

cfg = builder.create_builder_config()
prof = builder.create_optimization_profile()
prof.set_shape("x", (1, K), (64, K), (4096, K))
cfg.add_optimization_profile(prof)
engine = trt.Runtime(logger).deserialize_cuda_engine(builder.build_serialized_network(net, cfg))
ctx = engine.create_execution_context()

for m in (1, 2, 33, 512):
    xin = torch.randn((m, K), device="cuda").half()
    o = torch.full((m, 2 * K), float("nan"), device="cuda", dtype=torch.float16)
    ctx.set_input_shape("x", (m, K))
    ctx.set_tensor_address("x", xin.data_ptr())
    ctx.set_tensor_address("out", o.data_ptr())
    s = torch.cuda.Stream()
    ctx.execute_async_v3(s.cuda_stream)
    s.synchronize()
    ref = torch.cat([xin, 2 * xin], 1)
    err = (o.float() - ref.float()).abs().max().item()
    print(f"TRT {trt.__version__} M={m}: max abs err {err:.3e} {'OK' if err < 1e-2 else 'WRONG'}")

Observed (max abs error; expected 0 for every M):

TensorRT M = 1 M = 2 M = 33 M = 512
10.15.1.29 0 (OK) 7.5 (wrong) 8.9 (wrong) 10.2 (wrong)
10.16.1.11 0 (OK) 5.6 (wrong) 8.4 (wrong) 9.2 (wrong)
11.5.0.63 0 (OK) 8.0 (wrong) 7.9 (wrong) 9.9 (wrong)

The input is random, so the exact error values change from run to run. It also fails with K = 2048, M = 3261.

Workarounds we tried

Inserted between each producer plugin and the concatenation:

Layer Result
IIdentityLayer still wrong (removed by the optimizer)
IShuffleLayer (reshape to the same shape) still wrong (removed)
x * 1 still wrong (removed)
IElementWiseLayer MAX(x, x) correct (kept as a real copy)
Cast to FP32, concatenate in FP32, cast back to FP16 correct

Have you tried the latest release?

Yes. 11.5.0.63 was the newest tensorrt-cu13 wheel on PyPI when we tested, and it fails in the same way.

Can this model run on other frameworks?

Not applicable (the network consists of TensorRT plugins only). The expected output is [x, 2x].

Activity

  1. added
    Module:Plugins
    on Nov 21, 2026
  2. nabe2030 commented on Nov 21, 2026

    @nabe2030
    Author

    Related TensorRT Edge-LLM issue (NVFP4-A16 engines on DGX Spark, with a builder-side workaround): NVIDIA/TensorRT-Edge-LLM#288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module:Plugins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions