Skip to content

feat: add dynamic shapes kernel specialization strategy for TRT-RTX#4184

Draft
tp5uiuc wants to merge 4 commits intopytorch:mainfrom
tp5uiuc:feat/trtrtx-dynamic-shapes-strategy
Draft

feat: add dynamic shapes kernel specialization strategy for TRT-RTX#4184
tp5uiuc wants to merge 4 commits intopytorch:mainfrom
tp5uiuc:feat/trtrtx-dynamic-shapes-strategy

Conversation

@tp5uiuc
Copy link
Copy Markdown
Contributor

@tp5uiuc tp5uiuc commented Apr 12, 2026

Description

Expose IRuntimeConfig.setDynamicShapesKernelSpecializationStrategy() through the Torch-TensorRT Python API for TensorRT-RTX builds.

Users can now control how shape-specialized kernels are compiled at runtime for dynamic shapes via the new dynamic_shapes_kernel_specialization_strategy compilation setting:

  • "lazy" (default): Compile shape-specialized kernels in the background, use fallback until ready
  • "eager": Compile immediately (blocking)
  • "none": Always use fallback kernels, never specialize

Depends on: #4180 (runtime cache API — provides the IRuntimeConfig infrastructure)

Type of change

  • New feature (non-breaking change which adds functionality)

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

tp5uiuc and others added 3 commits April 10, 2026 13:16
Add runtime cache support for TensorRT-RTX JIT compilation results,
replacing the timing cache which is not used by RTX (no autotuning).

Changes:
- Skip timing cache creation/saving for TensorRT-RTX in _TRTInterpreter
- Add RUNTIME_CACHE_PATH default and runtime_cache_path setting
- Wire up IRuntimeCache in PythonTorchTensorRTModule (setup, load, save)
- Persist runtime cache to disk with filelock for concurrent access safety
- Thread runtime_cache_path through all compile functions
- Add unit tests (12 tests) and E2E model tests (6 tests)
- Update docstrings and RST documentation

Fixes pytorch#3817

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Version provided by upstream torch; no pin needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expose IRuntimeConfig.setDynamicShapesKernelSpecializationStrategy()
through the Torch-TensorRT Python API. Users can now control how
shape-specialized kernels are compiled at runtime for dynamic shapes
on TensorRT-RTX via the new `dynamic_shapes_kernel_specialization_strategy`
compilation setting ("lazy", "eager", or "none").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@meta-cla meta-cla bot added the cla signed label Apr 12, 2026
@github-actions github-actions bot added documentation Improvements or additions to documentation component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: build system Issues re: Build system component: api [Python] Issues re: Python API component: runtime component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Apr 12, 2026
@github-actions github-actions bot requested a review from cehongwang April 12, 2026 20:48
Address review feedback: compile with torchtrt.Input min/opt/max
ranges so dynamic shapes are actually exercised.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed component: api [Python] Issues re: Python API component: build system Issues re: Build system component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: runtime component: tests Issues re: Tests documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant