I have found it useful to instead create a builder function that takes the model’s data as input and returns the model and any shared variables. I then sample/fit the model and save those results to file (I use pm.save_trace() for the trace and just pickle everything else). When I need everything back again, I just use the builder to create a new model and shared variables (with the same data at before), and load in the sampling/fit results from disk (using pm.load_trace() for the trace). I’m not sure if this is a method that the core devs would endorse, but it has worked so far. ![]()
I hope this helped.