swagnercarena / paltas

Conduct simulation-based inference on strong gravitational lensing systems.
MIT License
13 stars 12 forks source link

Remove lru_cache on LOS methods #42

Closed JelleAalbers closed 1 year ago

JelleAalbers commented 1 year ago

This removes the lru_cache decorators on some line-of-sight methods. I'm trying to fix some out of memory errors while generating a training set on Sherlock, and while I think #41 is the main problem, these could also contribute.

First, these caches don't actually provide a measurable speedup, at least not when generating a small dataset on my laptop.

Second, lru_cache decorators are tricky when used on methods , see e.g. here or here.

Finally, the power_law_dn_dm cache decorator has an an unbound size. When redshifts are varying, this should cause a (probably small) memory leak. (Besides making the cache of any function that takes a redshift argument useless -- at least as regards to reuse of redshift-dependent computations between images)

coveralls commented 1 year ago

Coverage Status

Coverage decreased (-0.008%) to 95.035% when pulling 6f1c419a3e5b8a193da615cdd2d77058f9110c80 on no_lru_cache into 2edd7f418a63273d5b2fcc75819e811bceb1f149 on main.