ADVI reproducibility

Hello, I am trying to make fully reproducible ADVI runs, meaning that the approx.hist path should be exactly the same between runs. The current specification of seed at pm.ADVI seems to work.

with pm.Model() as model:

with model :
    advi = pm.ADVI(random_seed=74)
    approx =, obj_optimizer=pm.adam(learning_rate=0.01), callbacks=[tracker])

However, if I change a compiledir for aesara, suddenly approx.hist is completely different. Did I forget to specify random seed somewhere? Is it even possible to obtain exactly the same inference results on different platforms?

os.environ['AESARA_FLAGS'] = 'base_compiledir=/some_new_path/.aesara'

Thank you

hmm… investigating the issue further, even keeping the same compiledir doesn’t always yield the same result. So even more broad question, how to make ADVI run reproducible?

What PyMC version are you using?

CC @ferrine

pymc version ‘4.0.1’; aesara version ‘2.7.3’

I don’t have a good answer for that right now. Advi was refactored for v4 and this was just out of scope

What was out of scope? If seeding is not possible we should open an issue on GitHub

Yes, we should open an issue