Overflow issues with PyMC-BART

Hi y’all! Long time lurker, first time poster. I recently read @aloctavodia 's book on Bayesian Analysis with Python and enthusiastically fitted a Gamma BART model last Friday. Today when I came back to the model it won’t even make it one step into sampling and fails with “OverflowError: Python int too large to convert to C long pymc”. From the snooping that I have done so far it seems like it could maybe be an issue with the leapfrog step size? I did not change anything about the model or the data and I did set a random seed so I am pulling my hair out as to what might be going on here. Has anyone seen this error before? It seems super hard to track. Thanks!

Could you post the model code you ran, along with the full error traceback you got?

Unfortunately I can’t post the full model but it is a model with a BART variable that I pass into a pm.Gamma() using its mu and sigma. The point of failure happens at pm.sample() and the key points in the stack trace are:

strace.record(draw.point, draw.stats)
for data, vars in zip(self._stats, sampler_stats):
for key, val in vars.items():
data[key][draw_idx] = val
elif self._stats is not None:
raise ValueError(“Expected sampler_stats”)

OverflowError: Python int too large to convert to C long

The same model with doing only pm.sample_prior_predictive() instead of pm.sample() doesn’t cause any issues and when I inspect the prior samples there are no values that are unusual.

Can you show the full original traceback?

Yup:

In sample(draws, tune, chains, cores, random_seed, progressbar, progressbar_theme, step, var_names, nuts_sampler, initvals, init, jitter_max_retries, n_init, trace, discard_tuned_samples, compute_convergence_checks, keep_warning_stat, return_inferencedata, idata_kwargs, nuts_sampler_kwargs, callback, mp_ctx, blas_cores, model, compile_kwargs, **kwargs) 926 _print_step_hierarchy(step) 927 try: → 928 _mp_sample(**sample_args, **parallel_args) 929 except pickle.PickleError: 930 _log.warning(“Could not pickle model, sampling singlethreaded.”), in _mp_sample(draws, tune, step, chains, cores, rngs, start, progressbar, progressbar_theme, traces, model, callback, blas_cores, mp_ctx, **kwargs) 1405 strace = traces[draw.chain] 1406 if not zarr_recording: 1407 # Zarr recording happens in each process → 1408 strace.record(draw.point, draw.stats) 1409 log_warning_stats(draw.stats) 1411 if callback is not None: in NDArray.record(self, point, sampler_stats) 114 for data, vars in zip(self._stats, sampler_stats): 115 for key, val in vars.items(): → 116 data[key][draw_idx] = val 117 elif self._stats is not None: 118 raise ValueError(“Expected sampler_stats”) OverflowError: Python int too large to convert to C long