[executor_runner] Add --input_shapes to run dynamic-shape models below their upper bound - #22411
Open
msluszniak wants to merge 1 commit into
Open
[executor_runner] Add --input_shapes to run dynamic-shape models below their upper bound#22411msluszniak wants to merge 1 commit into
msluszniak wants to merge 1 commit into
Conversation
…r bound
prepare_input_tensors() sizes every input from the bound recorded in the
method metadata, so a model exported with dynamic shapes can only ever
be executed at its upper bound from this runner. There is no flag to ask
for a smaller shape, and --inputs files are required to match nbytes()
of the bound, so there is no way to sneak one in either.
That matters because the upper bound is exactly the shape at which a
whole class of backend bug is invisible. An op that fails to resize its
output, or a kernel whose launch geometry disagrees with what it was
compiled for, is correct at the bound and wrong everywhere below it.
Without this flag those defects cannot be reproduced from the runner at
all.
Add --input_shapes, taking a comma-separated shape per input with dims
joined by 'x' ("1x98,1x50x256,1x1x98"). Inputs are resized after
prepare_input_tensors() and before execute(). Input files stay
upper-bound sized; the surplus is simply not read, so existing input
files keep working unchanged.
I used this to find and confirm four ET-VK dynamic-shape bugs; each was
correct at the bound and wrong below it.
msluszniak
requested review from
larryliu0820 and
manuelcandales
as code owners
September 1, 2026 14:26
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22411
Note: Links to docs will display an error until the docs builds have been completed.
|
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prepare_input_tensors()sizes every input from the bound recorded in the method metadata, so a model exported with dynamic shapes can only ever be executed at its upper bound fromexecutor_runner. There is no flag to request a smaller shape, and--inputsfiles must matchnbytes()of the bound, so there is no way to supply one indirectly either.That matters more than it might sound. The upper bound is precisely the shape at which a whole class of backend bug is invisible:
Neither can be reproduced from this runner today.
Change
Add
--input_shapes, taking a comma-separated shape per input with dims joined byx:Inputs are resized after
prepare_input_tensors()and beforeexecute(). Input files stay upper-bound sized and the surplus is simply not read, so existing invocations keep working unchanged and no new file plumbing is needed.The resize is factored into one helper called from both input-preparation sites (the
--server_modeloop and the normal path).Why it is worth having
I used this flag to find and confirm four ET-VK dynamic-shape bugs, every one of which is correct at the bound and wrong below it:
squeeze_copy.dimson dim 0 never resizes (#22409)embedding/index_selectpassnullptrresize fns (#22410)The two nworkers bugs produced NaN sentence embeddings for any input under 31 tokens on real published models, and were undetectable at the bound.
Testing
Built for Android arm64 and exercised on a Galaxy S26 Ultra across four models and shapes from the minimum up to the bound. Verified that omitting the flag reproduces exactly the previous behaviour, and that with the flag the outputs match CPU references at shapes well below the bound.