Skip to content

🐛 [Bug] enabled_precisions={torch.float16} is silently ignored in 2.15, and the engine stays FP32 #5030

Done

Description

@shoumikhin

Bug Description

In 2.15, enabled_precisions={torch.float16} is accepted and then ignored. The engine is built in FP32, with no warning and no error.

  • torch_tensorrt.dynamo.compile no longer has an enabled_precisions parameter, so the argument falls into **kwargs and nothing reads it.
  • torch_tensorrt.compile(..., ir="dynamo") still takes enabled_precisions, but its dynamo branch drops it.

This is the FP16 switch that most tutorials and existing user code use. A user asks for FP16, gets an FP32 engine twice the size, and has no way to notice.

To Reproduce

import torch
import torch_tensorrt

model = torch.nn.Sequential(
    torch.nn.Linear(1024, 4096), torch.nn.SiLU(), torch.nn.Linear(4096, 1024)
).cuda().eval()
x = torch.randn(1, 1024, device="cuda")
ep = torch.export.export(model, (x,))


def engine_bytes(gm):
    return sum(
        len(m.serialized_engine)
        for _, m in gm.named_modules()
        if getattr(m, "serialized_engine", None) is not None
    )


default = torch_tensorrt.dynamo.compile(ep, inputs=[x], min_block_size=1)
fp16 = torch_tensorrt.dynamo.compile(
    ep, inputs=[x], min_block_size=1, enabled_precisions={torch.float16}
)
autocast = torch_tensorrt.dynamo.compile(
    ep, inputs=[x], min_block_size=1,
    enable_autocast=True, autocast_low_precision_type=torch.float16,
)
print("default            ", engine_bytes(default))
print("enabled_precisions ", engine_bytes(fp16))
print("enable_autocast    ", engine_bytes(autocast))

Output:

default             33682780
enabled_precisions  33682780
enable_autocast     16896188

torch_tensorrt.compile(model, ir="dynamo", inputs=[x], min_block_size=1, enabled_precisions={torch.float16}) gives the same FP32 engine.

Expected behavior

A clear error or a warning that enabled_precisions is no longer used, naming the replacement (enable_autocast=True, autocast_low_precision_type=torch.float16, or casting the model to half precision).

dynamo.compile already does this for other removed options: truncate_long_and_double, refit and make_refittable are still recognized in kwargs and raise a DeprecationWarning or a ValueError. Handling enabled_precisions the same way, in both dynamo.compile and the dynamo branch of torch_tensorrt.compile, would fix this.

Environment

  • Torch-TensorRT: 2.15.0 (PyPI)
  • PyTorch: 2.15.0+cu132
  • TensorRT: 11.4.0.106
  • Python: 3.12
  • Seen on Jetson AGX Thor (aarch64) and on x86_64 with an H100. The same code is on main.

Activity

  1. narendasan commented on Nov 13, 2026

    @narendasan
    Collaborator

    @zewenli98 didnt we add a warning that with TRT 11.x enabled precisions does not do anything?

  2. narendasan commented on Nov 13, 2026

    @narendasan
    Collaborator

    @shoumikhin the correct replacement is to use autocast

  3. shoumikhin commented on Nov 13, 2026

    @shoumikhin
    ContributorAuthor

    Thanks, autocast works for us. In the repro above, enable_autocast=True, autocast_low_precision_type=torch.float16 gives the half-size engine.

    I could not find a warning, though. On 2.15.0 from PyPI, both torch_tensorrt.dynamo.compile(..., enabled_precisions={torch.float16}) and torch_tensorrt.compile(..., ir="dynamo", enabled_precisions={torch.float16}) finish with no warning about precision. On main, nothing under py/torch_tensorrt/dynamo mentions enabled_precisions, and the dynamo branch of torch_tensorrt.compile drops it, so there is no warning that could fire.

    Many tutorials and existing scripts still pass it, so a DeprecationWarning that points to autocast, like the one for truncate_long_and_double, would save people from shipping FP32 engines by accident.

  4. zewenli98 commented on Nov 13, 2026

    @zewenli98
    Collaborator

    @shoumikhin Thanks for pointing this out. I traced back to #4195 which directly removed the deprecated APIs without raising any warning/error. I also found that PR silently removed use_explicit_typing. I'll open a PR to fix both.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions