# ONNX Support for PyMC

**URL:** <https://discourse.pymc.io/t/onnx-support-for-pymc/17465>\
**Category:** General\
**Created:** [December 4, 2025, 2:17am UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465 "2025-12-04T02:17:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Parbhu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/brian_parbhu/32/8208_2.png) [@Brian\_Parbhu](https://discourse.pymc.io/u/Brian_Parbhu)\
**Post date:** [December 4, 2025, 2:17am UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/1 "2025-12-04T02:17:28Z")

</div>

Hey all,

Today myself, **[Andreas Fehlner](https://www.linkedin.com/in/andreas-fehlner-60499971/)**, and **[Adam Pocock](https://www.linkedin.com/in/craigacp/)** made a presentation to the ONNX steering committee to propose new working groups around ONNX support for Bayesian Models from various frameworks. The working groups are not approved yet but we would like to gauge community feedback from this type of work and also do people want more ONNX support for Bayesian Models and Inference from frameworks like Stan, PyMC, Pyro, Numpyro, Tensorflow Probability, and many others. Please drop a comment if you like around what you want from ONNX in terms of support for these frameworks and how can ONNX be more useful in deployment of these models.

Thanks again and any feedback is welcome!

-Brian Parbhu

[Probabilistic models and ONNX 12-03-2025.pdf](https://discourse.pymc.io/uploads/short-url/ud49iaEQaSNnplZDlyJVlth4uN0.pdf) (137.7 KB)

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [December 4, 2025, 7:58am UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/2 "2025-12-04T07:58:17Z")

</div>

Nice initiative. From memory onnx is missing some basic linalg ops like solves, cholesky that show up all the time with multivariate distributions plus special math funcions

---

<div class="post-metadata">

**Author:** ![Brian\_Parbhu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/brian_parbhu/32/8208_2.png) [@Brian\_Parbhu](https://discourse.pymc.io/u/Brian_Parbhu)\
**Post date:** [December 4, 2025, 9:50pm UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/3 "2025-12-04T21:50:44Z")

</div>

Understood, we would also make the necessary operators and distributions that would be necessary in order for you to have those representations in ONNX that’s part of the plan.

---

<div class="post-metadata">

**Author:** ![Brian\_Parbhu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/brian_parbhu/32/8208_2.png) [@Brian\_Parbhu](https://discourse.pymc.io/u/Brian_Parbhu)\
**Post date:** [December 5, 2025, 6:30pm UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/4 "2025-12-05T18:30:51Z")

</div>

Also here’s a link about the ONNX framework for those unfamiliar with it.

> **[ONNX | Home](https://onnx.ai/)**

and their GitHub org

> **[Open Neural Network Exchange](https://github.com/onnx)**
>
> ONNX is an open ecosystem for interoperable AI models. It's a community project: we welcome your contributions! - Open Neural Network Exchange

---

<div class="post-metadata">

**Author:** ![Carlos\_Sandoval](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/carlos_sandoval/32/9532_2.png) [@Carlos\_Sandoval](https://discourse.pymc.io/u/Carlos_Sandoval)\
**Post date:** [December 7, 2025, 8:43am UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/5 "2025-12-07T08:43:57Z")

</div>

Hi! Ill link the PR I made as part of a workshop i did earlier this year,

Definitely not the most optimal implementation of an ONNX backend, but hopefully it’s still useful

> <https://github.com/pymc-devs/pytensor/pull/1777>
>
> \## Description
> 
> This PR adds a complete ONNX backend for PyTensor, enabling ex…port of PyTensor computational graphs to ONNX format and execution via ONNX Runtime.
> 
> \*\*Key features:\*\*
> \- \*\*ONNX Linker\*\*: Core infrastructure for converting PyTensor graphs to ONNX models
> \- \*\*High-level export API\*\*: \`export\_onnx()\`, \`compile\_onnx()\`, and \`export\_function\_onnx()\` for easy model export
> \- \*\*Comprehensive dispatcher system\*\*: Type-based dispatch for converting PyTensor Ops to ONNX nodes
> \- \*\*Operation support across multiple categories\*\*:
> - Elementwise operations (Add, Sub, Mul, Div, Exp, Log, trigonometric functions, etc.)
> - Shape operations (Reshape, DimShuffle, Transpose, Join, Split)
> - Subtensor operations (basic slicing, advanced indexing, IncSubtensor)
> - Math operations (Sum, Prod, Max, Min, Mean, Argmax, Argmin)
> - Linear algebra (MatMul, Dot, BatchedDot, matrix operations)
> - Neural network ops (Softmax, LogSoftmax, Sigmoid, Conv2d, MaxPool)
> \- \*\*Property-based testing\*\*: Hypothesis-powered test strategies for robust validation
> 
> \*\*Files added:\*\*
> \- \`pytensor/link/onnx/\` - Core ONNX backend implementation (13 files, ~2k lines)
> \- \`tests/link/onnx/\` - Comprehensive test suite (18 files, ~4k lines, 186 tests)
> 
> \## Related Issue
> 
> \- \[\] Closes #
> \- \[\] Related #
> 
> \## Checklist
> 
> \- \[x\] Checked that \[the pre-commit linting/style checks pass\](https://docs.pymc.io/en/latest/contributing/python\_style.html)
> \- \[x\] Included tests that prove the fix is effective or that the new feature works
> \- \[\] Added necessary documentation (docstrings and/or example notebooks)
> \- \[\] If you are a pro: each commit corresponds to a \[relevant logical change\](https://wiki.openstack.org/wiki/GitCommitMessages#Structural\_split\_of\_changes)
> 
> \## Type of change
> 
> \- \[x\] New feature / enhancement
> \- \[\] Bug fix
> \- \[\] Documentation
> \- \[\] Maintenance
> \- \[\] Other (please specify):

---

<div class="post-metadata">

**Author:** ![Brian\_Parbhu](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/brian_parbhu/32/8208_2.png) [@Brian\_Parbhu](https://discourse.pymc.io/u/Brian_Parbhu)\
**Post date:** [February 7, 2026, 6:15pm UTC](https://discourse.pymc.io/t/onnx-support-for-pymc/17465/6 "2026-02-07T18:15:18Z")

</div>

@Carlos_Sandoval would you be interested in helping us with this?
