Repository navigation
[imfreq] select DLR Matsubara nodes on a dyadic fine grid - #24
Open
HugoStrand wants to merge 3 commits into
Open
HugoStrand wants to merge 3 commits into
HugoStrand wants to merge 3 commits into
Conversation
imfreq_ops built the analytic continuation kernel at every Matsubara index up to the cutoff nmax = max(ceil(lambda), 20) before pivoting, so memory and time grew linearly in lambda: 6.8-9.4 GB and 54-104 s at lambda = 1e6. Pivot instead on a dyadic grid (build_if_fine): panels of 2r consecutive indices whose spacing doubles from panel to panel, up to the cutoff, which is always included, mirrored to negative frequencies as pivrgs_sym and flip_to_mirror expect. When 2r >= nmax this is the full grid and the non-symmetrized nodes are unchanged. At lambda = 1e6 construction now takes 18-32 MB and 0.15-0.36 s. On this grid the sum-of-norms pair score in the rank-r pivrgs_sym can pick a mirror pair whose second row is parallel to the first after projection, leaving an ill-conditioned node set (up to 9.5 eps at eps = 1e-10). Score pairs by the squared volume of their residuals instead, and keep the sum for a pair that exceeds the column dimension, where every volume vanishes. Also evaluate 2n+1 and 2n in double in k_if, which overflowed int for |n| >= 2^30, now reachable at lambda ~ 1e9. DLR Matsubara nodes change for symmetrized grids and, where 2r < nmax, for non-symmetrized grids. Benchmarked against dense node selection on lambda in [10, 1e7], eps 1e-6 to 1e-14, both statistics, with and without symmetrization: errors within a few eps of dense everywhere dense is affordable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fineparams computes nmax = max((int)ceil(lambda), 20). For ceil(lambda) > INT_MAX the conversion to int is undefined behavior: on x86-64 it gives INT_MIN, hence nmax = 20, and imfreq_ops throws 'Fine imaginary frequency grid smaller than # DLR imaginary frequency nodes'; on ARM64 it saturates to INT_MAX and the construction succeeds. Add a test of nmax across 2^31 and a DLR interpolation test at lambda = 2.2e9 with test indices over the int range. Both fail on x86-64 before the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fineparams set nmax = max((int)ceil(lambda), 20). For lambda > INT_MAX the conversion is undefined behavior: INT_MIN on x86-64, so nmax = 20 and the dyadic fine grid of imfreq_ops had fewer points than DLR nodes, while ARM64 saturates to INT_MAX. Clamp nmax to INT_MAX explicitly, the ARM64 result. The cutoff nu_max = (2 INT_MAX - 1) pi ~ 1.35e10 still exceeds lambda up to ~1.35e10. Fixes dlr_build.fineparams_nmax_large_lambda and imfreq_ops.interp_lambda_above_int_max (L^inf err 2-3e-11 at lambda = 2.2e9, eps = 1e-10). All 137 cppdlr tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
imfreq_ops built the analytic continuation kernel at every Matsubara index up to the cutoff nmax = max(ceil(lambda), 20) before pivoting, so memory and time grew linearly in lambda: 6.8-9.4 GB and 54-104 s at lambda = 1e6.
Pivot instead on a dyadic grid (build_if_fine): panels of 2r consecutive indices whose spacing doubles from panel to panel, up to the cutoff, which is always included, mirrored to negative frequencies as pivrgs_sym and flip_to_mirror expect. When 2r >= nmax this is the full grid and the non-symmetrized nodes are unchanged. At lambda = 1e6 construction now takes 18-32 MB and 0.15-0.36 s.
On this grid the sum-of-norms pair score in the rank-r pivrgs_sym can pick a mirror pair whose second row is parallel to the first after projection, leaving an ill-conditioned node set (up to 9.5 eps at eps = 1e-10). Score pairs by the squared volume of their residuals instead, and keep the sum for a pair that exceeds the column dimension, where every volume vanishes.
Also evaluate 2n+1 and 2n in double in k_if, which overflowed int for |n| >= 2^30, now reachable at lambda ~ 1e9.
DLR Matsubara nodes change for symmetrized grids and, where 2r < nmax, for non-symmetrized grids. Benchmarked against dense node selection on lambda in [10, 1e7], eps 1e-6 to 1e-14, both statistics, with and without symmetrization: errors within a few eps of dense everywhere dense is affordable.