pytensor
Optimizing compiler for evaluating mathematical expressions on CPUs and GPUs.
Decision gist · record as of 2026-08-14
Yes, if you need symbolic computation with automatic differentiation and graph optimization. PyTensor is actively maintained, has no known vulnerabilities, installs easily, and is the standard backend for PyMC. Install it if you're doing probabilistic programming, building custom optimized numerical pipelines, or need fine-grained control over computation graphs. Not necessary if you only need eager-mode tensor operations (use NumPy or PyTorch instead).AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with a pure-Python wheel distribution.
- Active maintenance with a release within 2 days and recent commits; supports current Python versions (3.12–3.14).
- Depends on well-established packages: numpy, scipy, numba, setuptools, and filelock.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is a permissive license; you may use, modify, and distribute PyTensor freely in commercial and private projects provided you include the license notice.
last release 2026-08-12 (2 days) · last repo commit 2026-08-14 · 636 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,197,832 downloads/mo, #3,217 on PyPI
Alternatives
Verify before relying
pip install pytensor
import pytensor
from pytensor import tensor as pt
a = pt.dscalar("a")
b = pt.dscalar("b")
c = a + b
f_c = pytensor.function([a, b], c)
print(f_c(1.5, 2.5)) # Output: 4.0- Whether JAX or Numba compilation backends require additional system dependencies or configuration beyond the listed runtime packages.
- Performance characteristics and memory overhead compared to eager-execution frameworks for typical workloads.
What it is and what it does
PyTensor is a symbolic computation library that lets you define mathematical expressions as static graphs, then compile and optimize them before execution. Unlike eager frameworks, you first declare symbolic variables and operations, then convert the graph into a callable function that PyTensor optimizes—removing redundant operations and replacing computations with efficient BLAS routines. It supports automatic differentiation (gradients) and can compile expressions to C, JAX, or Numba for performance.
The library is primarily used as the computational backend for PyMC, a probabilistic programming framework, but works standalone for any numerical computing task involving arrays and mathematical operations. It depends on numpy for array operations, scipy for scientific functions, and numba for JIT compilation; setuptools and filelock are build and locking utilities. The static-graph design allows advanced optimizations that dynamic frameworks cannot perform.
Use it for
- Build probabilistic models and Bayesian inference pipelines using PyMC, which relies on PyTensor for expression evaluation.
- Define and optimize complex mathematical expressions (e.g., neural network layers, physics simulations) before compilation.
- Compute gradients automatically for optimization and machine learning without manually writing backpropagation.
- Compile symbolic expressions to efficient C or GPU code via JAX or Numba for production inference.
- Prototype numerical algorithms with symbolic manipulation and graph visualization before deployment.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need symbolic computation with automatic differentiation and graph optimization.
PyTensor is actively maintained, has no known vulnerabilities, installs easily, and is the standard backend for PyMC. Install it if you're doing probabilistic programming, building custom optimized numerical pipelines, or need fine-grained control over computation graphs. Not necessary if you only need eager-mode tensor operations (use NumPy or PyTorch instead).
Install
pytensor on PyPI
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance with a release within 2 days and recent commits; supports current Python versions (3.12–3.14). Depends on well-established packages: numpy, scipy, numba, setuptools, and filelock.
License in practice
BSD-3-Clause is a permissive license; you may use, modify, and distribute PyTensor freely in commercial and private projects provided you include the license notice.
Quickstart
pip install pytensor
import pytensor
from pytensor import tensor as pt
a = pt.dscalar("a")
b = pt.dscalar("b")
c = a + b
f_c = pytensor.function([a, b], c)
print(f_c(1.5, 2.5)) # Output: 4.0
Verify before relying
- Whether JAX or Numba compilation backends require additional system dependencies or configuration beyond the listed runtime packages.
- Performance characteristics and memory overhead compared to eager-execution frameworks for typical workloads.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release <3.15,>=3.12 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagessetuptoolsscipynumpynumbafilelock |
| Maintenance | Actively maintained 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,197,832 / month, #3,217 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Free Threading :: 1 - UnstableTopic :: Scientific/Engineering :: MathematicsTopic :: Software Development :: Code GeneratorsTopic :: Software Development :: Compilers |
Evidence: pytensor-3.3.0-py2.py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “static computation graph”
- pytensorPyTensor is a Python library for defining, optimizing, and evaluating…
- torchvizGenerates visual diagrams of PyTorch neural network computation…
- torchPyTorch provides GPU-accelerated tensor computation and automatic…
Give your agent the search over MCP, or paste the wish link into any chat.
More Mathematics packages
NetworkX provides data structures and algorithms for creating, analyzing, and manipulating graphs and networks, supporting everything from simple undirected graphs to complex directed and weighted networks.
kiwisolver is a Python binding to a fast C++ implementation of the Cassowary constraint solver, enabling you to solve systems of linear constraints and inequalities.
Install it if you need to solve constraint systems; skip it if you only need simple linear algebra.
SymPy is a Python library for symbolic mathematics, performing algebraic manipulation, calculus, equation solving, and mathematical expression simplification without numerical approximation.
ContourPy calculates contours of 2D quadrilateral grids using C++11 algorithms wrapped in Python, offering serial and multithreaded implementations without requiring Matplotlib as a dependency.
PyTorch provides GPU-accelerated tensor computation and automatic differentiation for building and training deep neural networks in Python.
onnxruntime loads and executes Open Neural Network Exchange (ONNX) models with a focus on inference performance across CPUs and accelerators.
Install it if you have ONNX models to run in production or development.
See also pytensor-distributions · Theano-PyMC · Theano · py-expression-eval · numexpr · audmath · casadi · sparsediffpy · jax