Skip to content

BUG: AmbiguityWarning: Ambiguities exist in dispatched function _unify #6434

@maresb

Description

@maresb

Describe the issue:

If aesara is installed then the following warnings are emitted when sampling any PyMC model:

Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
/home/mares/micromamba/envs/pymcaesara/lib/python3.11/site-packages/multipledispatch/dispatcher.py:27: AmbiguityWarning: 
Ambiguities exist in dispatched function _unify

The following signatures may result in ambiguous behavior:
	[object, ConstrainedVar, Mapping], [ConstrainedVar, object, Mapping]
	[object, ConstrainedVar, Mapping], [ConstrainedVar, Var, Mapping]
	[object, ConstrainedVar, Mapping], [ConstrainedVar, object, Mapping]
	[object, ConstrainedVar, Mapping], [ConstrainedVar, Var, Mapping]


Consider making the following additions:

@dispatch(ConstrainedVar, ConstrainedVar, Mapping)
def _unify(...)

@dispatch(ConstrainedVar, ConstrainedVar, Mapping)
def _unify(...)

@dispatch(ConstrainedVar, ConstrainedVar, Mapping)
def _unify(...)

@dispatch(ConstrainedVar, ConstrainedVar, Mapping)
def _unify(...)
  warn(warning_text(dispatcher.name, ambiguities), AmbiguityWarning)
Multiprocess sampling (4 chains in 4 jobs)

I believe the root of the problem is that PyMC triggers an import of Aesara here. That presumably leads to unification.core._unify being registered by both Aesara and PyTensor. Perhaps there's some clever way to warn the user without actually importing Aesara?

Reproduceable code example:

mamba install pymc aesara

...
with model:
    pm.sample()

Error message:

No response

PyMC version information:

Installed via mamba.

pymc 5.0.0
aesara-base 2.8.9
pytensor 2.8.10
python 3.11.0

OS: Ubuntu 20.04

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions