Improve sparse mapping matrix in the interferometer sparse inversion (autoarray) #40
Replies: 3 comments
|
@HRSAstro you are right, and thank you for spotting it. The dense mapping matrix is still built on the sparse path by the inherited We are fixing it now as the mirror of the sparse data-vector segment-sum (scatter-add of One thing: your post ends at the quoted code block, so if you had a specific replacement in mind it did not make it into the text; if it differs from the above, please add it. Also, where did you hit the memory peak, and at what mask size, mesh size and backend? |
|
Thanks, that matches what I see. The replacement I had in mind is the same scatter-add, so nothing is missing beyond what you describe. For completeness, this is what the end of the post should have said: rows, cols, vals = self._sparse_triplets_slim_from(mapper) # as in _data_vector_mapper_from
# NumPy
image = np.bincount(rows, weights=vals * reconstruction[cols], minlength=n_image_slim)
# JAX
image = jnp.zeros(n_image_slim).at[rows].add(vals * reconstruction[cols])Linear light profiles can keep the dense path, since they only add a few columns. On where we hit the memory peak: the crash we actually saw was in The setup where
With a sparse mapping in its place, the same fit peaked at 0.73 GB. At a 192 × 192 mesh on the same grid, L alone would be 43 GB, so |
|
@HRSAstro thank you for the snippet, which is exactly what we implemented: |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Thanks for making
InversionInterferometerSparse.data_vectorsparse (_data_vector_mapper_from, thebincount/.at[].addsegment-sum, in 2026.10.18.1). One step on the sparse path still builds the dense mapping matrix L (image pixels × mesh pixels): the reconstructed image. For large images this is still the largest array in the fit.Where
AbstractInversionInterferometer.mapped_reconstructed_data_dict(inversion/inversion/interferometer/abstract.py), which the sparse inversion inherits:All reactions