Skip to content

driver: accept legacy flat {min,max,optimals} dynamic-dimension JSON#4926

Open
chun-wan wants to merge 1 commit into
ROCm:developfrom
chun-wan:fix/driver-dyn-dim-flat-json
Open

driver: accept legacy flat {min,max,optimals} dynamic-dimension JSON#4926
chun-wan wants to merge 1 commit into
ROCm:developfrom
chun-wan:fix/driver-dyn-dim-flat-json

Conversation

@chun-wan
Copy link
Copy Markdown

@chun-wan chun-wan commented Jun 1, 2026

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.

Motivation

Technical Details

Changelog Category

Add a CHANGELOG.md entry for any option other than Not Applicable

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

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.
@chun-wan chun-wan requested a review from causten as a code owner June 1, 2026 13:47
Copy link
Copy Markdown
Collaborator

@CharlieL7 CharlieL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks ok. Making doc comment more terse.

Comment thread src/driver/main.cpp
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.
Copy link
Copy Markdown
Collaborator

@CharlieL7 CharlieL7 Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:[...]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants