Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ body:
label: "PyMC version information:"
description: >
PyMC/PyMC3 Version:
Aesara/Theano Version:
PyTensor/Aesara Version:
Python Version:
Operating system:
How did you install PyMC/PyMC3: (conda/pip)
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- |
pymc/tests/test_util.py
pymc/tests/distributions/test_logprob.py
pymc/tests/test_aesaraf.py
pymc/tests/test_pytensorf.py
pymc/tests/test_math.py
pymc/tests/backends/test_base.py
pymc/tests/backends/test_ndarray.py
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
defaults:
run:
shell: cmd
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -317,7 +317,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=native'
defaults:
run:
shell: bash -l {0}
Expand Down Expand Up @@ -387,7 +387,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
TEST_SUBSET: ${{ matrix.test-subset }}
AESARA_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
PYTENSOR_FLAGS: floatX=${{ matrix.floatx }},gcc__cxxflags='-march=core2'
defaults:
run:
shell: cmd
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ repos:
entry: >
(?x)(arviz-devs.github.io|
python.arviz.org|
aesara.readthedocs.io|
pytensor.readthedocs.io|
pymc-experimental.readthedocs.io|
docs.pymc.io|
www.pymc.io|
Expand Down
6 changes: 3 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ It is easier to start with functionality that is not present in PyMC but
rather deferred to outside libraries. If seeking to understand any
of the topics below refer to that specific library

### Aesara
### PyTensor
* Gradient computation
* Random number generation
* Low level tensor operation definition
Expand Down Expand Up @@ -62,7 +62,7 @@ In no particular order they are

* `ContextMeta`: The context manager that enables the `with pm.Model() as model` syntax
* {class}`~pymc.Factor`: Defines the methods for the various logprobs for models
* `ValueGrad` which handles the value and gradient and is the main connection point to Aesara
* `ValueGrad` which handles the value and gradient and is the main connection point to PyTensor
* `Deterministic` and `Potential`: Definitions for two pieces of functionality useful in some model definitions

## distributions/
Expand All @@ -74,7 +74,7 @@ Important modules to note are
a random variable distribution from a likelihood distribution.

* `logprob.py`: This contains the log probability logic for the distributions themselves.
The log probability calculation is deferred to Aesara
The log probability calculation is deferred to PyTensor
Copy link
Member

Choose a reason for hiding this comment

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

I think this is at least partially incorrect as "non-basic" distributions have their PPLs in pymc (logprob module)


* `dist_math.py`: Various convenience operators for distributions.
This includes mathematical operators such as `logpower` or `all_true`methods.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Features
- **Variational inference**: `ADVI <http://www.jmlr.org/papers/v18/16-107.html>`__
for fast approximate posterior estimation as well as mini-batch ADVI
for large data sets.
- Relies on `Aesara <https://aesara.readthedocs.io/en/latest/>`__ which provides:
- Relies on `PyTensor <https://pytensor.readthedocs.io/en/latest/>`__ which provides:
* Computation optimization and dynamic C or JAX compilation
* NumPy broadcasting and advanced indexing
* Linear algebra operators
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import time
import timeit

import aesara
import aesara.tensor as at
import arviz as az
import numpy as np
import pandas as pd
import pytensor
import pytensor.tensor as at

import pymc as pm

Expand All @@ -27,7 +27,7 @@ def glm_hierarchical_model(random_seed=123):
"""Sample glm hierarchical model to use in benchmarks"""
np.random.seed(random_seed)
data = pd.read_csv(pm.get_data("radon.csv"))
data["log_radon"] = data["log_radon"].astype(aesara.config.floatX)
data["log_radon"] = data["log_radon"].astype(pytensor.config.floatX)
county_idx = data.county_code.values

n_counties = len(data.county.unique())
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ channels:
- defaults
dependencies:
# Base dependencies
- aesara=2.8.8
- arviz>=0.13.0
- blas
- cachetools>=4.2.1
Expand All @@ -15,6 +14,7 @@ dependencies:
- numpy>=1.15.0
- pandas>=0.24.0
- pip
- pytensor=2.8.10
- python-graphviz
- networkx
- scipy>=1.4.1
Expand Down
3 changes: 2 additions & 1 deletion conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ channels:
- defaults
dependencies:
# Base dependencies
- aesara=2.8.8
- arviz>=0.13.0
- blas
- cachetools>=4.2.1
Expand All @@ -17,6 +16,8 @@ dependencies:
- mkl-service
- numpy>=1.15.0
- pandas>=0.24.0
- pip
- pytensor=2.8.10
- python-graphviz
- networkx
- scipy>=1.4.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/windows-environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ channels:
- defaults
dependencies:
# Base dependencies (see install guide for Windows)
- aesara=2.8.8
- arviz>=0.13.0
- blas
- cachetools>=4.2.1
Expand All @@ -15,6 +14,7 @@ dependencies:
- numpy>=1.15.0
- pandas>=0.24.0
- pip
- pytensor=2.8.10
- python-graphviz
- networkx
- scipy>=1.4.1
Expand Down
2 changes: 1 addition & 1 deletion conda-envs/windows-environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ channels:
- defaults
dependencies:
# Base dependencies (see install guide for Windows)
- aesara=2.8.8
- arviz>=0.13.0
- blas
- cachetools>=4.2.1
Expand All @@ -18,6 +17,7 @@ dependencies:
- numpy>=1.15.0
- pandas>=0.24.0
- pip
- pytensor=2.8.10
- python-graphviz
- networkx
- scipy>=1.4.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
..
_href from docs/source/index.rst

===============
PyMC and Aesara
===============
=================
PyMC and PyTensor
=================

What is Aesara
==============
What is PyTensor
================

Aesara is a package that allows us to define functions involving array
PyTensor is a package that allows us to define functions involving array
operations and linear algebra. When we define a PyMC model, we implicitly
build up an Aesara function from the space of our parameters to
build up an PyTensor function from the space of our parameters to
their posterior probability density up to a constant factor. We then use
symbolic manipulations of this function to also get access to its gradient.

For a thorough introduction to Aesara see the
:doc:`aesara docs <aesara:index>`,
For a thorough introduction to PyTensor see the
:doc:`pytensor docs <pytensor:index>`,
but for the most part you don't need detailed knowledge about it as long
as you are not trying to define new distributions or other extensions
of PyMC. But let's look at a simple example to get a rough
Expand All @@ -33,8 +33,8 @@ arbitrarily chosen) function
First, we need to define symbolic variables for our inputs (this
is similar to eg SymPy's `Symbol`)::

import aesara
import aesara.tensor as at
import pytensor
import pytensor.tensor as at
# We don't specify the dtype of our input variables, so it
# defaults to using float64 without any special config.
a = at.scalar('a')
Expand All @@ -56,16 +56,16 @@ do to compute the output::
of the exponential of `inner`. Somewhat surprisingly, it
would also have worked if we used `np.exp`. This is because numpy
gives objects it operates on a chance to define the results of
operations themselves. Aesara variables do this for a large number
of operations. We usually still prefer the Aesara
operations themselves. PyTensor variables do this for a large number
of operations. We usually still prefer the PyTensor
functions instead of the numpy versions, as that makes it clear that
we are working with symbolic input instead of plain arrays.

Now we can tell Aesara to build a function that does this computation.
With a typical configuration, Aesara generates C code, compiles it,
Now we can tell PyTensor to build a function that does this computation.
With a typical configuration, PyTensor generates C code, compiles it,
and creates a python function which wraps the C function::

func = aesara.function([a, x, y], [out])
func = pytensor.function([a, x, y], [out])

We can call this function with actual arrays as many times as we want::

Expand All @@ -75,15 +75,15 @@ We can call this function with actual arrays as many times as we want::

out = func(a_val, x_vals, y_vals)

For the most part the symbolic Aesara variables can be operated on
like NumPy arrays. Most NumPy functions are available in `aesara.tensor`
For the most part the symbolic PyTensor variables can be operated on
like NumPy arrays. Most NumPy functions are available in `pytensor.tensor`
(which is typically imported as `at`). A lot of linear algebra operations
can be found in `at.nlinalg` and `at.slinalg` (the NumPy and SciPy
operations respectively). Some support for sparse matrices is available
in `aesara.sparse`. For a detailed overview of available operations,
see :mod:`the aesara api docs <aesara.tensor>`.
in `pytensor.sparse`. For a detailed overview of available operations,
see :mod:`the pytensor api docs <pytensor.tensor>`.

A notable exception where Aesara variables do *not* behave like
A notable exception where PyTensor variables do *not* behave like
NumPy arrays are operations involving conditional execution.

Code like this won't work as expected::
Expand Down Expand Up @@ -123,16 +123,16 @@ Changing elements of an array is possible using `at.set_subtensor`::
a = at.vector('a')
b = at.set_subtensor(a[:10], 1)

# is roughly equivalent to this (although aesara avoids
# is roughly equivalent to this (although pytensor avoids
# the copy if `a` isn't used anymore)
a = np.random.randn(10)
b = a.copy()
b[:10] = 1

How PyMC uses Aesara
How PyMC uses PyTensor
====================

Now that we have a basic understanding of Aesara we can look at what
Now that we have a basic understanding of PyTensor we can look at what
happens if we define a PyMC model. Let's look at a simple example::

true_mu = 0.1
Expand All @@ -159,7 +159,7 @@ where with the normal likelihood :math:`N(x|μ,σ^2)`

To build that function we need to keep track of two things: The parameter
space (the *free variables*) and the logp function. For each free variable
we generate an Aesara variable. And for each variable (observed or otherwise)
we generate an PyTensor variable. And for each variable (observed or otherwise)
we add a term to the global logp. In the background something similar to
this is happening::

Expand All @@ -177,7 +177,7 @@ So calling `pm.Normal()` modifies the model: It changes the logp function
of the model. If the `observed` keyword isn't set it also creates a new
free variable. In contrast, `pm.Normal.dist()` doesn't care about the model,
it just creates an object that represents the normal distribution. Calling
`logp` on this object creates an Aesara variable for the logp probability
`logp` on this object creates an PyTensor variable for the logp probability
or log probability density of the distribution, but again without changing
the model in any way.

Expand Down Expand Up @@ -209,8 +209,8 @@ is roughly equivalent to this::
model.add_logp_term(pm.Normal.dist(mu, sigma).logp(data))

The return values of the variable constructors are subclasses
of Aesara variables, so when we define a variable we can use any
Aesara operation on them::
of PyTensor variables, so when we define a variable we can use any
PyTensor operation on them::

design_matrix = np.array([[...]])
with pm.Model() as model:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ API
api/ode
api/tuning
api/math
api/aesaraf
api/pytensorf
api/shape_utils
api/misc

Expand Down
4 changes: 2 additions & 2 deletions docs/source/api/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Math
====

This submodule contains various mathematical functions. Most of them are imported directly
from aesara.tensor (see there for more details). Doing any kind of math with PyMC random
variables, or defining custom likelihoods or priors requires you to use these Aesara
from pytensor.tensor (see there for more details). Doing any kind of math with PyMC random
variables, or defining custom likelihoods or priors requires you to use these PyTensor
expressions rather than NumPy or Python code.

.. currentmodule:: pymc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Aesara utils
PyTensor utils
************

.. currentmodule:: pymc
Expand Down
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
}
# fmt: on
numpydoc_xref_aliases = {
"TensorVariable": ":class:`~aesara.tensor.TensorVariable`",
"RandomVariable": ":class:`~aesara.tensor.random.RandomVariable`",
"TensorVariable": ":class:`~pytensor.tensor.TensorVariable`",
"RandomVariable": ":class:`~pytensor.tensor.random.RandomVariable`",
"ndarray": ":class:`~numpy.ndarray`",
"Covariance": ":mod:`Covariance <pymc.gp.cov>`",
"Mean": ":mod:`Mean <pymc.gp.mean>`",
Expand All @@ -74,7 +74,7 @@
"Point": ":class:`~pymc.Point`",
"Model": ":class:`~pymc.Model`",
"SMC_kernel": ":ref:`SMC Kernel <smc_kernels>`",
"Aesara_Op": ":class:`Aesara Op <aesara.graph.op.Op>`",
"PyTensor_Op": ":class:`PyTensor Op <pytensor.graph.op.Op>`",
"tensor_like": ":term:`tensor_like`",
"numpy_Generator": ":class:`~numpy.random.Generator`",
"Distribution": ":ref:`Distribution <api_distributions>`",
Expand Down Expand Up @@ -187,7 +187,7 @@
# intersphinx configuration to ease linking arviz docs
intersphinx_mapping = {
"arviz": ("https://python.arviz.org/en/latest/", None),
"aesara": ("https://aesara.readthedocs.io/en/latest/", None),
"pytensor": ("https://pytensor.readthedocs.io/en/latest/", None),
"home": ("https://www.pymc.io", None),
"pmx": ("https://www.pymc.io/projects/experimental/en/latest", None),
"numpy": ("https://numpy.org/doc/stable/", None),
Expand Down
Loading