Skip to content

Driver and API updates for using sym shapes - #4946

Merged
kahmed10 merged 26 commits into
developfrom
sym_driver
Jul 28, 2026
Merged

Driver and API updates for using sym shapes#4946
kahmed10 merged 26 commits into
developfrom
sym_driver

Conversation

@shivadbhavsar

@shivadbhavsar shivadbhavsar commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

Update the driver flags and C/Python APIs to properly allow symbolic shape inputs.

Technical Details

Exposes symbolic dynamic dimensions (sym::expr) through the driver, C API, and Python API.

  • Driver: --enable-symbolic flag; dynamic-dim JSON now accepts a "name" key to make a dim symbolic. Fixed a crash in the single-object --dim-param path.
  • C API: new migraphx_sym_expr type (var/literal/parse, arithmetic ops, to_string); dynamic_dimension(sym_expr) + is_symbolic(); onnx_options setters set_use_symbolic_shapes / set_dim_param.
  • Python: migraphx.sym submodule (expr, var/lit/parse, operators); dynamic_dimension(expr) + is_symbolic(); use_symbolic_shapes on parse_onnx/parse_onnx_buffer, plus dim_params on the buffer variant.
  • Tests: test/api/test_symbolic_shape.cpp and test/py/test_symbolic_shape.py.

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.

@shivadbhavsar
shivadbhavsar requested a review from causten as a code owner June 5, 2026 22:23
Copilot AI review requested due to automatic review settings June 5, 2026 22:23
@shivadbhavsar
shivadbhavsar changed the base branch from develop to sym_onnx_parse June 5, 2026 22:23
@shivadbhavsar shivadbhavsar self-assigned this Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends MIGraphX’s symbolic dynamic-shape support end-to-end by exposing sym::expr through the driver, the C/C++ API surface, and Python bindings, and adds API/Python tests to validate symbolic dimension construction and ONNX parsing behavior.

Changes:

  • Add sym::expr / sym_expr (C API + C++ handle) and enable symbolic dynamic dimensions via dynamic_dimension(sym_expr) and is_symbolic().
  • Extend ONNX options and front-ends (driver + Python bindings) to enable symbolic shapes and pass dim_params.
  • Add new C++ and Python tests for symbolic dynamic dimensions and ONNX parsing.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/driver/main.cpp Adds --enable-symbolic and supports "name" in dynamic-dim JSON to create symbolic dims.
src/api/include/migraphx/migraphx.h Introduces C API migraphx_sym_expr_t and related functions; adds symbolic dynamic-dimension APIs.
src/api/include/migraphx/migraphx.hpp Adds C++ sym_expr handle wrapper and dynamic_dimension(sym_expr) / is_symbolic() accessors.
src/api/api.cpp Implements the new C API for sym_expr, symbolic dynamic dimensions, and ONNX option setters.
tools/api/api.cpp Adds helper(s) used by generated bindings for creating symbolic variables and ONNX option setters.
src/api/migraphx.py Exposes the new migraphx_sym_expr handle + operators and ONNX option setters in the generated API.
src/py/migraphx_py.cpp Adds migraphx.sym submodule, symbolic dynamic_dimension ctor, and ONNX parse flags/params in Python.
test/api/test_symbolic_shape.cpp Adds C++ API tests for symbolic dynamic dimensions and ONNX parsing behavior.
test/api/CMakeLists.txt Registers the new C++ API test.
test/py/test_symbolic_shape.py Adds Python tests for symbolic expressions/dimensions and ONNX parsing behavior.
test/py/CMakeLists.txt Registers the new Python test.

Comment thread src/api/api.cpp Outdated
Comment thread src/py/migraphx_py.cpp
Comment thread src/py/migraphx_py.cpp
Comment thread src/api/api.cpp Outdated
Comment thread tools/api/api.cpp Outdated
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.90476% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api/api.cpp 82.69% 9 Missing ⚠️
src/api/include/migraphx/migraphx.hpp 95.00% 1 Missing ⚠️
src/shape.cpp 90.91% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4946      +/-   ##
===========================================
- Coverage    93.27%   93.26%   -0.00%     
===========================================
  Files          623      623              
  Lines        32889    32969      +80     
===========================================
+ Hits         30674    30747      +73     
- Misses        2215     2222       +7     
Files with missing lines Coverage Δ
src/include/migraphx/shape.hpp 90.59% <ø> (ø)
src/onnx/onnx_parser.cpp 88.29% <100.00%> (-0.05%) ⬇️
src/api/include/migraphx/migraphx.hpp 98.96% <95.00%> (-0.14%) ⬇️
src/shape.cpp 93.74% <90.91%> (-0.04%) ⬇️
src/api/api.cpp 81.18% <82.69%> (+0.30%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/api/include/migraphx/migraphx.hpp Outdated
Comment thread src/api/include/migraphx/migraphx.hpp Outdated
Comment thread src/api/include/migraphx/migraphx.hpp Outdated
@shivadbhavsar
shivadbhavsar requested a review from pfultz2 June 11, 2026 00:43
Base automatically changed from sym_onnx_parse to develop June 19, 2026 20:41
Comment thread src/driver/main.cpp Outdated
Comment thread src/onnx/onnx_parser.cpp Outdated
Comment thread src/onnx/onnx_parser.cpp Outdated
Comment thread src/py/migraphx_py.cpp Outdated
Comment thread src/py/migraphx_py.cpp Outdated
Comment thread src/py/migraphx_py.cpp Outdated
Comment thread src/api/api.cpp Outdated
Comment thread src/api/api.cpp Outdated
Comment thread src/py/migraphx_py.cpp Outdated
@shivadbhavsar
shivadbhavsar requested a review from pfultz2 June 26, 2026 21:01
@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jun 27, 2026

Copy link
Copy Markdown
Test Batch New Rate (e81174) Old Rate (49f842)* Diff Status
torchvision-resnet50 64 3,264.54 3,264.99 -0.01%
torchvision-resnet50_fp16 64 7,546.33 7,543.26 0.04%
torchvision-densenet121 32 2,481.91 2,481.97 -0.00%
torchvision-densenet121_fp16 32 5,003.47 4,973.87 0.60%
torchvision-inceptionv3 32 2,057.73 2,056.79 0.05%
torchvision-inceptionv3_fp16 32 4,412.97 4,410.23 0.06%
cadene-inceptionv4 16 820.80 818.54 0.28%
cadene-resnext64x4 16 782.43 783.25 -0.11%
slim-mobilenet 64 8,386.68 8,354.09 0.39%
slim-nasnetalarge 64 228.82 229.45 -0.28%
slim-resnet50v2 64 3,179.65 3,185.97 -0.20%
bert-mrpc-onnx 8 1,170.82 1,166.61 0.36%
bert-mrpc-tf 1 491.41 493.90 -0.50%
pytorch-examples-wlang-gru 1 477.17 475.08 0.44%
pytorch-examples-wlang-lstm 1 474.21 379.26 25.04% 🔆
torchvision-resnet50_1 1 1,031.11 1,034.33 -0.31%
cadene-dpn92_1 1 438.40 443.17 -1.08%
cadene-resnext101_1 1 364.95 365.51 -0.16%
onnx-taau-downsample 1 839.60 849.29 -1.14%
dlrm-criteoterabyte 1 32.40 32.43 -0.09%
dlrm-criteoterabyte_fp16 1 51.80 52.12 -0.62%
agentmodel 1 11,535.69 9,423.56 22.41% 🔆
unet_fp16 2 58.70 58.72 -0.03%
resnet50v1_fp16 1 1,346.42 1,365.56 -1.40%
resnet50v1_int8 1 1,931.25 1,661.41 16.24% 🔆
bert_base_cased_fp16 64 1,097.97 1,098.85 -0.08%
bert_large_uncased_fp16 32 345.67 345.36 0.09%
bert_large_fp16 1 206.30 205.27 0.50%
distilgpt2_fp16 16 2,090.15 2,095.46 -0.25%
yolov5s 1 558.45 559.47 -0.18%
tinyllama 1 45.78 45.76 0.05%
vicuna-fastchat 1 44.08 43.96 0.27%
whisper-tiny-encoder 1 404.63 412.60 -1.93%
whisper-tiny-decoder 1 399.98 410.66 -2.60%
llama2_7b 1 20.58 20.82 -1.14%
qwen1.5-7b 1 23.54 23.50 0.19%
phi3-3.8b 1 26.55 26.68 -0.48%
llama3-8b 1 10.99 21.73 -49.40% 🔴
whisper-large-encoder 1 3.72 10.14 -63.33% 🔴
whisper-large-decoder 1 107.75 107.31 0.41%
mistral-7b 1 23.79 23.75 0.18%
FLUX.1-schnell 1 760.15 804.98 -5.57% 🔴

Regressions detected 🔴

* No develop baseline was found for this PR's branch point; compared against the latest available develop run instead.

@gh-app-migraphx-bot-pr-write

gh-app-migraphx-bot-pr-write Bot commented Jun 27, 2026

Copy link
Copy Markdown
Test Status Result
bert-mrpc-onnx PASSED: MIGraphX meets tolerance
bert-mrpc-tf PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-gru PASSED: MIGraphX meets tolerance
pytorch-examples-wlang-lstm PASSED: MIGraphX meets tolerance
dlrm-criteoterabyte PASSED: MIGraphX meets tolerance
agentmodel PASSED: MIGraphX meets tolerance
unet PASSED: MIGraphX meets tolerance
resnet50v1 PASSED: MIGraphX meets tolerance
bert_base_cased_fp16 PASSED: MIGraphX meets tolerance
bert_large_uncased_fp16 🔴 FAILED: MIGraphX is not within tolerance - check verbose output
bert_large PASSED: MIGraphX meets tolerance
yolov5s PASSED: MIGraphX meets tolerance
tinyllama PASSED: MIGraphX meets tolerance
vicuna-fastchat PASSED: MIGraphX meets tolerance
whisper-tiny-encoder PASSED: MIGraphX meets tolerance
whisper-tiny-decoder PASSED: MIGraphX meets tolerance
distilgpt2_fp16 PASSED: MIGraphX meets tolerance
llama2_7b PASSED: MIGraphX meets tolerance
qwen1.5-7b PASSED: MIGraphX meets tolerance
phi3-3.8b PASSED: MIGraphX meets tolerance
llama3-8b PASSED: MIGraphX meets tolerance
whisper-large-encoder PASSED: MIGraphX meets tolerance
whisper-large-decoder PASSED: MIGraphX meets tolerance
mistral-7b PASSED: MIGraphX meets tolerance
FLUX.1-schnell PASSED: MIGraphX meets tolerance

@kahmed10
kahmed10 self-requested a review July 23, 2026 20:36

@kahmed10 kahmed10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you update docs/driver/read.rst?

@shivadbhavsar
shivadbhavsar requested a review from a team as a code owner July 24, 2026 15:30
@shivadbhavsar
shivadbhavsar requested a review from kahmed10 July 24, 2026 15:30
@kahmed10
kahmed10 merged commit f4c1630 into develop Jul 28, 2026
53 of 55 checks passed
@kahmed10
kahmed10 deleted the sym_driver branch July 28, 2026 16:21
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.

5 participants