feat: oversampled PSF inversion wiring — mapping formalism (phase 2b)#357
Merged
Conversation
Implements phase 2b of the approved design (PyAutoMind feature/autoarray/oversampling_design.md §4, approved in #353): - Mapper.mapping_matrix_over_sampled: sub-resolution mapping matrix (one row per sub-pixel, per-pixel sub-block order, no sub_fraction fold) — built by the existing mapper_util.mapping_matrix_from with identity parent indices and unit fractions. - AbstractInversionImaging._mapping_matrix_for_convolution_from routes all three PSF-convolution sites through the sub-resolution matrix for Mapper objects when psf.convolve_over_sample_size > 1; mapping.py needs no change (the PSF application site is the shared parent, as the design recorded). - Loud InversionException guards on the image-resolution kernel-native formalisms deferred by the design: linear-func objects without an operated override, the data_linear_func_matrix preload, and InversionImagingSparse.psf_weighted_data. - MockPSF models the new convolve_over_sample_size attribute. - Tests: delta-kernel identity (1e-14), end-to-end s=2 vs an independent brute-force fine-raster convolution (1e-12), guard raises. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Oversampled PSF convolution, phase 2b (inversion wiring) of the feature designed in #353: pixelized reconstructions via the mapping formalism now convolve at the fine resolution when the dataset's PSF is oversampled. The mapper contributes a new sub-resolution
mapping_matrix_over_sampled(one row per sub-pixel, nosub_fractionfold), which the phase-2a Convolver convolves on the fine grid and bins back — convolution now happens before the sub-pixel fold, as the physics requires.mapping.pyitself needed no logic change: the PSF application site is the sharedAbstractInversionImaging.operated_mapping_matrix_list, exactly as the approved design recorded.Tracks #356. Builds on #355 (phase 2a).
API Changes
Additive; nothing changes while
convolve_over_sample_size == 1.Mapper.mapping_matrix_over_sampled— sub-resolution mapping matrix, shape[total_sub_pixels, source_pixels]in per-pixel sub-block order (the 2a Convolver input format). Binning its rows by the mean of each sub-block reproducesmapping_matrixexactly (tested).AbstractInversionImagingroutes every PSF-convolution site (operated_mapping_matrix_list,linear_func_operated_mapping_matrix_dict,mapper_operated_mapping_matrix_dict) through a single helper that picks the sub-resolution matrix forMapperobjects when the PSF is oversampled.InversionException) on the formalisms that consumepsf.kernel.nativeat image resolution and are deferred per the design: linear-function objects without an operated override, thedata_linear_func_matrixpreload, andInversionImagingSparse.psf_weighted_data.MockPSFgainsconvolve_over_sample_size = 1to match the real interface.Test Plan
mapping_matrix_over_sampleddelta-kernel identity: mean-binned rows ==mapping_matrixto 1e-14.operated_mapping_matrix_listmatches an independent brute-force fine-raster convolution + bin (plain loops, no shared indexing) to 1e-12.Memory profile (design §4 risk)
Native FFT cube
(ny·s, nx·s, n_src), fp64, for a realistic strong-lens case (fft frame 256² at s=1):s=2 with ~1000 sources is ~2.1 GB (×4 the s=1 cube) plus FFT transients — fine on A100-class GPUs, tight on small (6 GB) cards. Oversampled inversion stays opt-in (nothing defaults on); chunked per-column convolution and/or
use_mixed_precisionare the mitigations if profiling shows pressure in practice.Validation checklist (--auto run)
🤖 Generated with Claude Code