Skip to content

build: Make sympy an optional dependency#27200

Merged
tianleiwu merged 2 commits intomicrosoft:mainfrom
ingyukoh:make-sympy-optional
Feb 19, 2026
Merged

build: Make sympy an optional dependency#27200
tianleiwu merged 2 commits intomicrosoft:mainfrom
ingyukoh:make-sympy-optional

Conversation

@ingyukoh
Copy link
Copy Markdown
Contributor

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 #24872

Description

Make sympy an optional dependency to reduce install size for inference-only users.

Changes:

  • Guard sympy import in symbolic_shape_infer.py with helpful ImportError
  • Remove sympy from requirements.txt (no longer auto-installed)
  • Add sympy to extras_require["symbolic"] in setup.py

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

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>
@ingyukoh
Copy link
Copy Markdown
Contributor Author

ingyukoh commented Feb 4, 2026

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

Comment thread onnxruntime/python/tools/symbolic_shape_infer.py Fixed
@tianleiwu
Copy link
Copy Markdown
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
@ingyukoh
Copy link
Copy Markdown
Contributor Author

@tianleiwu — Applied ruff format and fixed RUFF/B904 (raise ... from None) in 16d636b. Could
you approve the workflow runs? Thanks.

@tianleiwu
Copy link
Copy Markdown
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
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@tianleiwu tianleiwu enabled auto-merge (squash) February 19, 2026 07:09
@tianleiwu tianleiwu merged commit c4780e6 into microsoft:main Feb 19, 2026
91 of 92 checks passed
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.

3 participants