EOF Error with PyMC BART on M2 Mac

Seems to be an error with spawning processes for sampling – full error below. Annoyingly, sometimes it samples, but most of the time it fails out, which makes me question exactly why it’s happening.

Following the example.

coal = np.loadtxt(pm.get_data("coal.csv"))
years = int(coal.max() - coal.min())
bins = years // 4
hist, x_edges = np.histogram(coal, bins=bins)
# compute the location of the centers of the discretized data
x_centers = x_edges[:-1] + (x_edges[1] - x_edges[0]) / 2
# xdata needs to be 2D for BART
x_data = x_centers[:, None]
# express data as the rate number of disaster per year
y_data = hist
with pm.Model() as model_coal:
    μ_ = pmb.BART("μ_", X=x_data, Y=np.log(y_data), m=20)
    μ = pm.Deterministic("μ", pm.math.exp(μ_))
    y_pred = pm.Poisson("y_pred", mu=μ, observed=y_data)
    idata_coal = pm.sample(random_seed=94122)

returns the following error:

EOFError                                  Traceback (most recent call last)
/Users/jp/Dropbox/Projects/pymc_example.py in line 13
     61 y_data = hist
     62 with pm.Model() as model_coal:
---> 63     μ_ = pmb.BART("μ_", X=x_data, Y=np.log(y_data), m=20)
     64     μ = pm.Deterministic("μ", pm.math.exp(μ_))
     65     y_pred = pm.Poisson("y_pred", mu=μ, observed=y_data)

File ~/miniconda3/envs/pymc/lib/python3.10/site-packages/pymc_bart/bart.py:139, in BART.__new__(cls, name, X, Y, m, alpha, beta, response, split_prior, split_rules, separate_trees, **kwargs)
    134 if response in ["linear", "mix"]:
    135     warnings.warn(
    136         "Options linear and mix are experimental and still not well tested\n"
    137         + "Use with caution."
    138     )
--> 139 manager = Manager()
    140 cls.all_trees = manager.list()
    142 X, Y = preprocess_xy(X, Y)

File ~/miniconda3/envs/pymc/lib/python3.10/multiprocessing/context.py:57, in BaseContext.Manager(self)
     55 from .managers import SyncManager
     56 m = SyncManager(ctx=self.get_context())
---> 57 m.start()
     58 return m
...
--> 383         raise EOFError
    384     else:
    385         raise OSError("got end of file during message")

Session info is here:

{‘commit_hash’: ‘f11276427’,
‘commit_source’: ‘installation’,
‘default_encoding’: ‘utf-8’,
‘ipython_path’: ‘/Users/jp/miniconda3/envs/pymc/lib/python3.10/site-packages/IPython’,
‘ipython_version’: ‘8.14.0’,
‘os_name’: ‘posix’,
‘platform’: ‘macOS-13.3-arm64-arm-64bit’,
‘sys_executable’: ‘/Users/jp/miniconda3/envs/pymc/bin/python’,
‘sys_platform’: ‘darwin’,
‘sys_version’: ‘3.10.12 (main, Jul 5 2023, 15:02:25) [Clang 14.0.6 ]’}

I think that’s better tracked as an issue on the pymc-bart repo.

will do!