driver: accept legacy flat {min,max,optimals} dynamic-dimension JSON#4926
Open
chun-wan wants to merge 1 commit into
Open
driver: accept legacy flat {min,max,optimals} dynamic-dimension JSON#4926chun-wan wants to merge 1 commit into
chun-wan wants to merge 1 commit into
Conversation
The --default-dyn-dim and --dyn-input-dim flags document and accept a flat
JSON object like {min:1,max:1024,optimals:[1024]}. After dynamic_dimension
was refactored to reflect its bounds under a nested `range` field, feeding
that flat object to from_value<dynamic_dimension> no longer populates
`range` -- the dimension silently resolves to size 0, so a named dynamic
axis (dim_param) becomes a static 0 and shape inference later crashes (e.g.
MULTIBROADCAST: input shape {0,128} cannot be broadcasted to {1,128}).
Parse the flat object explicitly in the driver (min/max/optimals) and
construct the dynamic_dimension, while still accepting the nested
{range:{min,max}} form. Restores the documented behaviour for both
--default-dyn-dim and --dyn-input-dim.
Verified: a model with a named dynamic batch axis that previously crashed
under `compile --gpu --default-dyn-dim "{min:1,max:1024,optimals:[1024]}"`
now compiles and evaluates correctly.
CharlieL7
requested changes
Jun 1, 2026
Collaborator
CharlieL7
left a comment
There was a problem hiding this comment.
Change looks ok. Making doc comment more terse.
Comment on lines
+315
to
+320
| // Accept the legacy flat form {min, max, optimals:[...]} (the format | ||
| // documented in the --dyn-input-dim/--default-dyn-dim help and used by | ||
| // existing scripts) as well as the nested {range:{min,max},...} form | ||
| // that dynamic_dimension now reflects to. Parsing flat input through | ||
| // from_value<dynamic_dimension> leaves the `range` field unset, which | ||
| // resolves the dimension to size 0 and crashes shape inference. |
Collaborator
There was a problem hiding this comment.
Suggested change
| // Accept the legacy flat form {min, max, optimals:[...]} (the format | |
| // documented in the --dyn-input-dim/--default-dyn-dim help and used by | |
| // existing scripts) as well as the nested {range:{min,max},...} form | |
| // that dynamic_dimension now reflects to. Parsing flat input through | |
| // from_value<dynamic_dimension> leaves the `range` field unset, which | |
| // resolves the dimension to size 0 and crashes shape inference. | |
| // Accept the legacy JSON form {min, max, optimals:[...]} |
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.
The --default-dyn-dim and --dyn-input-dim flags document and accept a flat JSON object like {min:1,max:1024,optimals:[1024]}. After dynamic_dimension was refactored to reflect its bounds under a nested
rangefield, feeding that flat object to from_value<dynamic_dimension> no longer populatesrange-- the dimension silently resolves to size 0, so a named dynamic axis (dim_param) becomes a static 0 and shape inference later crashes (e.g. MULTIBROADCAST: input shape {0,128} cannot be broadcasted to {1,128}).Parse the flat object explicitly in the driver (min/max/optimals) and construct the dynamic_dimension, while still accepting the nested {range:{min,max}} form. Restores the documented behaviour for both --default-dyn-dim and --dyn-input-dim.
Verified: a model with a named dynamic batch axis that previously crashed under
compile --gpu --default-dyn-dim "{min:1,max:1024,optimals:[1024]}"now compiles and evaluates correctly.Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot Applicable