healpix_analyse.LocalizedAlm_optimized_v13_fixed ================================================ .. py:module:: healpix_analyse.LocalizedAlm_optimized_v13_fixed .. autoapi-nested-parse:: LocalizedAlm_optimized_v13_fixed.py CRITICAL FIX from v12: - PLM is now kept as REAL (float32) instead of being converted to complex - Output dtype matches the original (float32 instead of float64) - Uses element-wise multiply + sum instead of matmul (matches original gradient flow) These changes ensure proper gradient flow through the real * complex multiplication, which is essential for correct optimization dynamics in synthesis. Strategy: Precompute all Legendre polynomials on CPU using numpy (which is fast for sequential operations), store in CPU memory, and transfer to GPU on-demand during anafast_localized. Classes ------- .. autoapisummary:: healpix_analyse.LocalizedAlm_optimized_v13_fixed.LocalizedAlm Functions --------- .. autoapisummary:: healpix_analyse.LocalizedAlm_optimized_v13_fixed.get_or_compute_coefficients healpix_analyse.LocalizedAlm_optimized_v13_fixed.precompute_all_plm_numpy healpix_analyse.LocalizedAlm_optimized_v13_fixed.test_localized_anafast Module Contents --------------- .. py:function:: get_or_compute_coefficients(lmax, device, dtype=None) Dummy for compatibility. .. py:function:: precompute_all_plm_numpy(co_th_np, lmax, nside, limit_range=10000000000.0) Precompute all P_lm on CPU using numpy. Returns list of numpy arrays (one per m value). This is MUCH faster than computing on GPU with Python loops. .. py:class:: LocalizedAlm(level, patch_idx_ring, backend, lmax=None, lmax_compute=None) Bases: :py:obj:`foscat.alm.alm` Localized spherical harmonic analysis with CPU-precomputed PLM. PLM is precomputed on CPU (fast numpy), stored in CPU RAM, and transferred to GPU on-demand. .. py:attribute:: level .. py:attribute:: nside .. py:attribute:: patch_idx_ring .. py:attribute:: device .. py:attribute:: dtype .. py:attribute:: lmax_full .. py:attribute:: lmax_compute .. py:attribute:: active_shift_ph .. py:attribute:: plm_list_cpu :value: [] .. py:method:: comp_tf_localized(u_patch) Compute FFT on active rings. .. py:method:: anafast_localized(u_patch, map2_patch=None, bandpowers_binning=None) Compute pseudo-Cl using CPU-precomputed PLM. Transfers PLM to GPU on-demand, uses it, then deletes. IMPORTANT: PLM is kept as REAL (float32), matching the original LocalizedAlm.py behavior. This ensures proper gradient flow through the real * complex multiplication. .. py:function:: test_localized_anafast()