Pymc3 on Apple M1 Studio - numpy error float128

I have seen it reported that this issue has been fixed, but on a new download using miniforge I get this error, with code that worked unchanged from a month ago.

Last login: Sun Apr 10 17:28:02 on ttys001

(base) me@MacStudio ~ % conda list pymc3

packages in environment at /opt/homebrew/Caskroom/miniforge/base:

Name Version Build Channel

pymc3 3.9.3 pyhd8ed1ab_3 conda-forge

(base) bryanpalmer@BryansMacStudio ~ % ipython

Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:24:38)

Type ‘copyright’, ‘credits’ or ‘license’ for more information

IPython 8.2.0 – An enhanced Interactive Python. Type ‘?’ for help.

In [ 1 ]: import numpy as np

In [ 2 ]: np.version

Out[ 2 ]: ‘1.22.3’

In [ 3 ]: import pymc3 as pm

WARNING (theano.configdefaults): install mkl with conda install mkl-service: No module named ‘mkl’


TypeError Traceback (most recent call last)

Input In [3], in <cell line: 1>()

----> 1 import pymc3 as pm

File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pymc3/init.py:41, in

38 __set_compiler_flags()

40 from .blocking import *

—> 41 from .distributions import *

42 from .distributions import transforms

43 from .glm import *

File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pymc3/distributions/init.py:15, in

1 # Copyright 2020 The PyMC Developers

2 #

3 # Licensed under the Apache License, Version 2.0 (the “License”);

(…)

12 # See the License for the specific language governing permissions and

13 # limitations under the License.

—> 15 from . import timeseries

16 from . import transforms

17 from . import shape_utils

File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pymc3/distributions/timeseries.py:23, in

20 import numpy as np

22 from pymc3.util import get_variable_name

—> 23 from .continuous import get_tau_sigma, Normal, Flat

24 from .shape_utils import to_tuple

25 from . import multivariate

File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pymc3/distributions/continuous.py:32, in

30 from .special import log_i0

31 from …math import invlogit, logit, logdiffexp

—> 32 from .dist_math import (

33 alltrue_elemwise, betaln, bound, gammaln, i0e, incomplete_beta, logpow,

34 normal_lccdf, normal_lcdf, SplineWrapper, std_cdf, zvalue,

35 clipped_beta_rvs,

36 )

37 from .distribution import (Continuous, draw_values, generate_samples)

39 all = [‘Uniform’, ‘Flat’, ‘HalfFlat’, ‘Normal’, ‘TruncatedNormal’, ‘Beta’,

40 ‘Kumaraswamy’, ‘Exponential’, ‘Laplace’, ‘StudentT’, ‘Cauchy’,

41 ‘HalfCauchy’, ‘Gamma’, ‘Weibull’, ‘HalfStudentT’, ‘Lognormal’,

42 ‘ChiSquared’, ‘HalfNormal’, ‘Wald’, ‘Pareto’, ‘InverseGamma’,

43 ‘ExGaussian’, ‘VonMises’, ‘SkewNormal’, ‘Triangular’, ‘Gumbel’,

44 ‘Logistic’, ‘LogitNormal’, ‘Interpolated’, ‘Rice’, ‘Moyal’]

File /opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/pymc3/distributions/dist_math.py:44, in

38 _beta_clip_values = {

39 dtype: (np.nextafter(0, 1, dtype=dtype), np.nextafter(1, 0, dtype=dtype))

40 for dtype in [“float16”, “float32”, “float64”]

41 }

42 if platform.system() in [“Linux”, “Darwin”]:

43 _beta_clip_values[“float128”] = (

—> 44 np.nextafter(0, 1, dtype=“float128”),

45 np.nextafter(1, 0, dtype=“float128”)

46 )

50 def bound(logp, *conditions, **kwargs):

51 “”"

52 Bounds a log probability density with several conditions.

53

(…)

67 logp with elements set to -inf where any condition is False

68 “”"

TypeError: data type ‘float128’ not understood

In [ 4 ]:

The only workaround I have found is to install pymc3 using pip (first thing after miniforge), which brings in a slightly older version of numpy, that happens to be compatible with pymc3. It is a pain, but it works. I then don’t allow that version to be updated by conda.

My understanding is that the there are a couple of different issues with M1/Monterey (e.g., this thread). However, you seem to be using an older version of pymc (3.9.3), which is probably causing you to encounter some altogether different issues. As in that thread, I think the suggestion at this point is to transition to v4 with your new hardware. Installation instructions for the v4 beta are on the conda-forge site.

1 Like

Thanks for your quick response. Much appreciated.

1 Like