build: Make sympy an optional dependency#27200
Merged
tianleiwu merged 2 commits intomicrosoft:mainfrom Feb 19, 2026
Merged
Conversation
Move sympy from required to optional dependencies. Users doing inference-only don't need symbolic math library. - Guard sympy import in symbolic_shape_infer.py with helpful error message - Remove sympy from requirements.txt - Add sympy to extras_require["symbolic"] in setup.py Users can now install with: pip install onnxruntime[symbolic] Reduces default install size by ~29MB (23%). Addresses microsoft#24872 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
Hi maintainers — CI is blocked by ‘workflows awaiting approval’ (28 pending). Could someone please approve running workflows and take a look? This PR makes sympy optional and adds onnxruntime[symbolic] for users who need symbolic shape inference. Addresses #24872 |
Contributor
|
@ingyukoh, please format the files using lintrunner |
- Add `from None` to re-raised ImportError (RUFF/B904) - Apply ruff format to symbolic_shape_infer.py and setup.py
Contributor
Author
|
@tianleiwu — Applied ruff format and fixed RUFF/B904 (raise ... from None) in 16d636b. Could |
Contributor
|
/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline |
|
Azure Pipelines successfully started running 4 pipeline(s). |
tianleiwu
approved these changes
Feb 19, 2026
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.
Move sympy from required to optional dependencies. Users doing inference-only don't need
symbolic math library.
Users can now install with:
pip install onnxruntime[symbolic]Reduces default install size by ~29MB (23%).
Addresses #24872
Description
Make sympy an optional dependency to reduce install size for inference-only users.
Changes:
Motivation and Context
sympy is ~29MB (23% of total package size) but only used for symbolic shape inference.
Most users doing inference-only don't need it.
After this change:
pip install onnxruntime→ no sympy (smaller install)pip install onnxruntime[symbolic]→ includes sympy