Skip to content

fix(conversion): preserve static extents in dynamic slices - #5109

Draft
apbose wants to merge 1 commit into
mainfrom
abose/fix-static-slice-output-shapes
Draft

apbose wants to merge 1 commit into
mainfrom
abose/fix-static-slice-output-shapes

Conversation

@apbose

@apbose apbose commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #5037.

Dynamic slice bound arithmetic can hide output dimensions that export already knows are constant. This makes attention reject matching K/V shapes after a sliced table is broadcast into K, and makes narrow(1, x.shape[1] - 12, 12).split([8, 4], 1) fail because TensorRT sees the split axis as dynamic instead of 12.

Pass the slice output's constant dimensions from FakeTensor metadata into the TensorRT slice size vector. Keep the existing runtime size calculations for symbolic dimensions and when export metadata is unavailable. Concrete ShapeProp examples are not used to specialize shapes, and internal converter calls do not inherit the enclosing FX node's output shape.

The regressions cover the attention repro with both zero and nonzero table scales, the fixed-length narrow/split with static and dynamic batch sizes, and an output extent that must continue changing at runtime. They require full compilation and compare actual GPU outputs at several input sizes, including profile endpoints. The existing split assertion and slice clamping remain in place.

Also make the existing _is_bf16() predicate explicitly return bool to resolve a pre-existing mypy no-any-return error in the touched converter file.

Validation:

  • Reproduced the reported attention and split failures on main before the converter change (all four regression variants).
  • 45 passed: the new regression file plus the existing slice and split converter suites, including finite-stop clamping and empty-slice coverage.
  • Both issue repros compile and match eager through the default partitioning path with TF32 disabled for the numerical comparison.
  • All applicable pre-commit checks passed, including mypy, Ruff, Black and isort.

@meta-cla meta-cla Bot added the cla signed label Nov 24, 2026
@github-actions github-actions Bot added component: tests Issues re: Tests 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 Nov 24, 2026
@github-actions
github-actions Bot requested a review from narendasan November 24, 2026 22:35

This branch has not been deployed

No deployments
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: 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 component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic sequence length: attention and split fail to build in 2.15 when the length is a symbol

1 participant