Skip to content

fix: use truncated pseudo-inverse for Broyden mixing - #7968

Merged
mohanchen merged 3 commits into
deepmodeling:developfrom
Stardust0831:fix/broyden-pseudoinverse
Sep 15, 2026
Merged

mohanchen merged 3 commits into
deepmodeling:developfrom
Stardust0831:fix/broyden-pseudoinverse

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

This issue was discovered through intermittent failures in daily GPU testing: the same H2 case usually passed, but occasionally terminated with Error when DSYSV without any input changes. Repeated runs reproduced the failure, and inspection of the Broyden history identified nearly linearly dependent residual differences as the cause.

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have linked verification records and summarized their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

Linked Issue

No separate issue is needed: the daily GPU failure records the error and identifies the existing reproducer, tests/12_NAO_Gamma_GPU/006_NO_H2_SZ_S2_GPU.

Unit Tests and/or Case Tests for my changes

Verification reuses existing regression cases:

  • The H2 GPU reproducer passed all repeated checks after the fix, including energy, force and stress comparisons. The Broyden source at 94b0b23cc also passed the 124-case GPU suite.
  • The updated CPU case 13_NO_Taylor_TDDFT passed repeated checks with both the original and updated Broyden solvers. Tighter SCF calculations confirm a common converged energy; all comparison tolerances are unchanged.
  • Full CI for the updated Taylor input and reference is pending.

What's changed?

Broyden mixing forms a small Gram matrix from inner products of recent residual differences and solves G gamma = c to obtain the mixing coefficients. As SCF proceeds, some history directions can become almost linear combinations of others. The Gram matrix then develops very small eigenvalues, making the direct solve sensitive to roundoff: small floating-point differences between otherwise identical GPU runs can be amplified into large coefficient changes, or make the factorization report a singular matrix.

The coefficient solve now uses DSYEV to diagonalize the symmetric Gram matrix and construct a truncated pseudo-inverse. Only eigenvalues strictly greater than 1e-12 * lambda_max contribute to the coefficients. This removes numerically unresolved history combinations from the solve while preserving the existing history buffer, coefficient mapping and Kerker screening.

CP2K's Broyden charge mixer provides a reference for this relative spectral cutoff:

rskip = 1.e-12_dp
CALL get_pseudo_inverse_svd(beta, amat, rskip)

Its SVD helper discards singular values at or below rskip * max(singular_values). The present change applies the cutoff directly to ABACUS's Gram matrix through symmetric eigendecomposition; CP2K's additional history normalization, weighting and diagonal regularization are not ported.

For 13_NO_Taylor_TDDFT, tighten scf_thr from 1e-6 to 1e-10 and refresh the total and per-atom energy references using results converged at 1e-12. The original SCF threshold leaves the energy sensitive to the mixing path beyond the test's 1e-7 eV tolerance. Energy, force and stress comparison tolerances remain unchanged.

Governance Notes

  • INPUT/docs changes: only the Taylor test's scf_thr setting changes. Parameter definitions, defaults and interfaces are unchanged, so parameter documentation updates are unnecessary.
  • Core module impact: only the Broyden coefficient solve in source/source_base/module_mixing/broyden_mixing.cpp changes. For history dimension m, the small-matrix solve remains O(m^3), with O(m^2) eigenvector transforms and O(m) additional temporary storage. No density-grid arrays or additional MPI inner products are introduced.
  • Exceptions requested: none.

@Stardust0831

Copy link
Copy Markdown
Collaborator Author

/abacus-ci gpu

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

GPU validation: success

GPU cases: 124 passed, 0 failed, 0 infrastructure.

Open the Actions run | Download raw test files

Candidate: 94b0b23cce87fc51eeb32a9243cb30a3b2713677

@QuantumMisaka QuantumMisaka added Performance Issues related to fail running ABACUS github_actions Pull requests that update GitHub Actions code labels Sep 14, 2026
@QuantumMisaka

Copy link
Copy Markdown
Collaborator

@WHUweiqingzhou May you have a look for the enhancement of broyden mixing ? Thanks !

@AsTonyshment AsTonyshment left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Sep 15, 2026
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT Diago Issues related to diagonalizaiton methods labels Sep 15, 2026
@mohanchen
mohanchen merged commit 3d200fd into deepmodeling:develop Sep 15, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Diago Issues related to diagonalizaiton methods github_actions Pull requests that update GitHub Actions code Performance Issues related to fail running ABACUS Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When performing Abacus calculations with the GPU version, an error "error with DSYSV" occurs during the rttddft calculatin

4 participants