Skip to content

feat: add TRT 11.0 API compatibility shims#4218

Open
yizhuoz004 wants to merge 1 commit intopytorch:mainfrom
yizhuoz004:feat/trt11-api-compat
Open

feat: add TRT 11.0 API compatibility shims#4218
yizhuoz004 wants to merge 1 commit intopytorch:mainfrom
yizhuoz004:feat/trt11-api-compat

Conversation

@yizhuoz004
Copy link
Copy Markdown
Contributor

Description

TRT 11.0 makes strongly-typed mode always-on and removes several weak-typing APIs. Guard all affected call sites with version/feature macros so the build works against both TRT 10.x and TRT 11.0+:

  • ConversionCtx: use createNetworkV2(0) on TRT 11+ (kEXPLICIT_BATCH removed); gate platformHasFastFp16 / BuilderFlag::kFP16 on ENABLE_FEATURE_WEAK_TYPING
  • layer_norm: gate setComputePrecision on ENABLE_FEATURE_WEAK_TYPING
  • unary (sqrt): gate setOutputType on ENABLE_FEATURE_WEAK_TYPING
  • batch_norm, interpolate, normalize, pooling: getPluginCreator renamed to getCreator (returns IPluginCreatorInterface*) on TRT 11+; dynamic_cast to IPluginCreator* for v1 plugin path
  • register_plugins: getPluginCreatorList renamed to getAllCreators on TRT 11+
  • _TRTInterpreter: catch AttributeError when setting output.dtype (read-only in TRT 11 strongly-typed mode)
  • MODULE.bazel: switch tensorrt dependency to new_local_repository pointing at local TRT 11 installation; comment out TRT 10 http_archive

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented Apr 28, 2026

Hi @yizhuoz004!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions github-actions Bot added component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: converters Issues re: Specific op converters component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 28, 2026
TRT 11.0 makes strongly-typed mode always-on and removes several weak-typing
APIs. Guard all affected call sites with version/feature macros so the build
works against both TRT 10.x and TRT 11.0+:

- ConversionCtx: use createNetworkV2(0) on TRT 11+ (kEXPLICIT_BATCH removed);
  gate platformHasFastFp16 / BuilderFlag::kFP16 on ENABLE_FEATURE_WEAK_TYPING
- layer_norm: gate setComputePrecision on ENABLE_FEATURE_WEAK_TYPING
- unary (sqrt): gate setOutputType on ENABLE_FEATURE_WEAK_TYPING
- batch_norm, interpolate, normalize, pooling: getPluginCreator renamed to
  getCreator (returns IPluginCreatorInterface*) on TRT 11+; dynamic_cast to
  IPluginCreator* for v1 plugin path
- register_plugins: getPluginCreatorList renamed to getAllCreators on TRT 11+
- _TRTInterpreter: catch AttributeError when setting output.dtype (read-only
  in TRT 11 strongly-typed mode)
- MODULE.bazel: switch tensorrt dependency to new_local_repository pointing at
  local TRT 11 installation; comment out TRT 10 http_archive

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yizhuoz004 yizhuoz004 force-pushed the feat/trt11-api-compat branch from dd250e9 to 61bb401 Compare April 28, 2026 17:55
@narendasan
Copy link
Copy Markdown
Collaborator

Do these new apis exist in 10.16 or only 11.0?

@yizhuoz004
Copy link
Copy Markdown
Contributor Author

yizhuoz004 commented Apr 28, 2026

Do these new apis exist in 10.16 or only 11.0?

the new API getCreator only exists on 11.0. rest of the changes are just gating the strongly typed network / deprecated types.

@narendasan
Copy link
Copy Markdown
Collaborator

We should just drop the deprecated types, I think @lanluo-nvidia has done much of this already, but good to know about the new plugin creator

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

Labels

component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants