litebird / litebird_sim

Simulation tools for LiteBIRD
GNU General Public License v3.0
18 stars 13 forks source link

Memory optimisation #245

Closed paganol closed 1 year ago

paganol commented 1 year ago

This PR reduces the memory consumption of make_bin_map

ziotom78 commented 1 year ago

I was able to solve the warning (and possibly make the code slightly more robust) by using numpy.linalg.solve instead of the combo that inverts a matrix and uses numpy.dot on it. (Usually solvers avoid creating the inverse matrix to reduce roundoff errors.) This has the benefit of solving the warning produced about numpy.dot.

I also removed a useless memory allocation, but I am not sure if this solves the original memory problem.

paganol commented 1 year ago

Sure, that was the original implementation, and I agree that it's better. I went for inverting ata and then using the dot product for obtaining the covariance for free. With this last change we are not outputting the covariance matrix, ma its inverse.

Regarding the memory, yes, nothing changed.

ziotom78 commented 1 year ago

I believe we can merge this and then release version 0.10.0. @paganol , I'll do it tomorrow in the early morning if there are no objections.