TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

fix 4326: bound exported dynamic shapes and normalize symbolic slice …

Open micwill755 opened this issue 5 months ago • 1 comments

Description

This change fixes three dynamic-shape issues exposed by the ZoomASR repro. Together, these fixes make Torch-TensorRT respect user-provided input bounds, lower negative symbolic slicing into TensorRT-friendly shape math, and clean up symbolic expressions that otherwise survive into runtime or conversion.

  1. Dynamic shape bounds fix

A previous working branch had a helper called _apply_dynamic_shape_bounds in Torch-TensorRT _compiler.py. That function propagated user-provided torch_tensorrt.Input min/max bounds into the FX shape_env, which explains why the old path used the intended ZoomASR feature length bound of 3000 instead of the broad exported range [9, 16384].

  1. Negative symbolic slice normalization

PyTorch 2.12 can emit slices with negative symbolic bounds, such as x[-n:] or x[:-n]. This change adds a lowering pass that rewrites those bounds to dim_size - n for both slice start and stop, making the graph explicit and TensorRT-friendly.

  1. No-op sym_min cleanup

The issue discussion mentioned removing torch.sym_min(x, INT64_MAX) as a possible needed patch. This change adds that as a separate lowering pass; it removes the no-op sym_min expression before runtime, preventing failures where torch.sym_min receives tensor-like inputs.

Fixes #4326

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

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

micwill755 avatar Jun 12 '26 20:06 micwill755

@micwill755 precommit/prek (https://github.com/j178/prek) should be able to lint your code for you

narendasan avatar Jun 12 '26 21:06 narendasan