Improve sparse mapping matrix in the interferometer sparse inversion (autoarray) #40
|
Summary Thanks for making Where
mapped_reconstructed_data = (
inversion_util.mapped_reconstructed_data_via_mapping_matrix_from(
mapping_matrix=linear_obj.mapping_matrix,
reconstruction=reconstruction,
xp=self._xp,
)
) |
Replies: 4 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: |
|
@HRSAstro as promised: the sparse scatter-add for |
@HRSAstro as promised: the sparse scatter-add for
mapped_reconstructed_data_dict(PyAutoLabs/PyAutoArray#641) shipped in autoarray 2026.10.22.1, so it is on PyPI. The current release is 2026.11.13.1.