Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maresb opened this issue Jan 5, 2023 · 0 comments · Fixed by #6440
Closed

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

maresb opened this issue Jan 5, 2023 · 0 comments · Fixed by #6440
Labels

Comments

@maresb
Copy link
Contributor

maresb commented Jan 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant