Skip to content

Hoist sigma_minus_dc out of the per-k loop in SumkDFT_opt#175

Open
k-yoshimi wants to merge 1 commit into
developfrom
perf-sigma-minus-dc-hoist
Open

Hoist sigma_minus_dc out of the per-k loop in SumkDFT_opt#175
k-yoshimi wants to merge 1 commit into
developfrom
perf-sigma-minus-dc-hoist

Conversation

@k-yoshimi

Copy link
Copy Markdown
Contributor

Summary

sigma_minus_dc (Sigma_imp minus double counting) is independent of the k-point and the chemical potential, but lattice_gf() recomputed it (a full copy, plus add_dc()) for every k — and total_density() is called repeatedly during the chemical-potential bisection, amplifying the cost.

  • Add SumkDFT_opt._compute_sigma_minus_dc(iw_or_w, with_dc).
  • lattice_gf() accepts an optional precomputed sigma_minus_dc (backward compatible: it recomputes when not supplied).
  • extract_G_loc() and total_density_matsubara() precompute it once before the k-loop and pass it in.

upfold() only reads gf_to_upfold, so sharing one object across all k is safe.

Verification

End-to-end with the TRIQS-compat (dcorelib) backend: tests/non-mpi passes (20 passed; HPhi-binary tests excluded), including the wannier90 DMFT tests that exercise this path on both numpy 1.26.4 and numpy 2.5.0.

🤖 Generated with Claude Code

sigma_minus_dc (Sigma_imp minus double counting) is independent of the
k-point and the chemical potential, but lattice_gf() recomputed it (a full
copy, and add_dc()) for every k -- and total_density() is called repeatedly
during the chemical-potential bisection, so the cost was amplified.

- Add SumkDFT_opt._compute_sigma_minus_dc(iw_or_w, with_dc).
- lattice_gf() accepts an optional precomputed sigma_minus_dc (backward
  compatible: recomputes when not supplied).
- extract_G_loc() and total_density_matsubara() precompute it once before
  the k-loop and pass it in.

upfold() only reads gf_to_upfold, so sharing one object across all k is
safe. Verified end-to-end with the TRIQS-compat (dcorelib) backend:
tests/non-mpi passes (20 passed, HPhi-binary tests excluded).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant