Speed up blurring_mask_2d_from for large PSF kernels
#45
Replies: 4 comments
|
Hi @GeorgeVassilakis, welcome, and thank you! It's great to hear PyAutoLens is being used for HWO-SLAPS, and please say hi to Richard and Qiuhan. This is a nice catch. A box structuring element is separable, so the two 1-D dilations are exact, and I reproduced your result on our side: byte-identical masks and the same ~794 MiB at 101 × 101 that you saw. Please go ahead and open the PR. For context, I timed it on typical modelling setups. The blurring mask is built once or twice per Please open the PR when you're ready. We'll add a couple of extra tests on top, comparing against the full 2-D dilation for even-sized kernels (scipy shifts the origin for even structures) and rectangular ones (ky ≠ kx), so nothing else is needed from you. Once CI is green we'll merge it and it will go out in the next release. |
|
@GeorgeVassilakis quick update: to save you the round trip, we've gone ahead and made the change on our side, with you credited as co-author on the commit. It's the same two-pass dilation, plus tests against the full 2-D dilation for even and rectangular kernels. I'll link the PR here; if you have a moment to check it against your HWO PSFs, that would be great. Thanks again for tracking it down. |
|
@GeorgeVassilakis here it is: PyAutoLabs/PyAutoArray#697 (you're co-author on the commit). It will go out in the next release once it's merged. |
|
@GeorgeVassilakis PyAutoLabs/PyAutoArray#697 is merged and goes out in this week's release, after which |
Uh oh!
There was an error while loading. Please reload this page.
Hi James!
I'm George, a PhD student at Cambridge. I've been using PyAutoLens for my HWO-SLAPS project on subhalo detectability with the Habitable Worlds Observatory (paper here). I worked with your former collaborators Richard Massey and Qiuhan He on this :)
The project uses really large PSF kernels (up to 999 x 999), and building the convolver got extremely slow and memory hungry as the kernel grew, to the point of OOM-killing jobs on our cluster. I traced it to the
binary_dilationinblurring_mask_2d_from, which uses a densenp.ones((ky, kx))structure (scipy's offsets table for it grows as(ky * kx)**2, which is where the memory goes). Since the structure is a box, the dilation is separable, so a(ky, 1)dilation followed by a(1, kx)dilation gives the exact same mask for a fraction of the cost:The masks are byte-identical, the full
test_autoarraysuite passes, and I added a test that checks against the dense dilation.For the paper I just patched autoarray locally, but I figured it'd be better to get this upstream so anyone else using big PSFs doesn't hit the same wall. I have a PR ready to go if you're happy with the approach. Thanks for all the work on PyAuto, and let me know what you think!
All reactions