Skip to content

eri_use_atomics added as option to hamiltonian construction & ecp fix - #583

Open
vbarandun wants to merge 1 commit into
microsoft:mainfrom
vbarandun:fix-hamiltonian-eri-use-atomics-and-ecp-fix
Open

eri_use_atomics added as option to hamiltonian construction & ecp fix#583
vbarandun wants to merge 1 commit into
microsoft:mainfrom
vbarandun:fix-hamiltonian-eri-use-atomics-and-ecp-fix

Conversation

@vbarandun

Copy link
Copy Markdown
  1. The AO/MO transformation had no eri_use_atomics option, which caused an OOM kill for large systems when using many OMP threads. scf_solver already exposes an eri_use_atomics setting for exactly this purpose. Now exposed as HamiltonianSettings::eri_use_atomics (default false, matching scf_solver).
  2. Core energy used Structure::calculate_nuclear_repulsion_energy(), which
    sums un-ECP-adjusted atomic numbers. This yields wrong numbers when the basis set carries one. Added detail::calculate_ecp_adjusted_nuclear_repulsion_energy(), mirroring SCFImpl::calc_nuclear_repulsion_energy_(), scf_impl.cpp), computed once from the already-ECP-corrected internal_basis_set->mol.

…ged core energy computation to read from basis set, instead of structure. Will try to add eri_use_atomic to cholesky hamiltonian if theres time in the future.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Exposes the SCF backend’s eri_use_atomics switch in the Hamiltonian construction path to reduce memory pressure in AO→active-MO ERI transformations, and fixes core-energy (nuclear repulsion) computation for ECP basis sets by using ECP-adjusted nuclear charges from the internal converted molecule.

Changes:

  • Add HamiltonianSettings::eri_use_atomics (default false) and forward it into the SCF ERI configuration used by Hamiltonian construction.
  • Compute nuclear repulsion energy from the ECP-adjusted internal molecule (internal_basis_set->mol) instead of Structure::calculate_nuclear_repulsion_energy().
  • Replace all uses of structure->calculate_nuclear_repulsion_energy() in the canonical Hamiltonian constructor with the new ECP-adjusted value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
cpp/src/qdk/chemistry/algorithms/microsoft/hamiltonian.hpp Adds the eri_use_atomics setting to the native Hamiltonian constructor settings.
cpp/src/qdk/chemistry/algorithms/microsoft/hamiltonian.cpp Forwards eri_use_atomics into the ERI backend config and fixes nuclear repulsion energy to use ECP-adjusted nuclear charges.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +206 to +210
// ECP-adjusted nuclear repulsion energy.
// Uses basis set information instead of structure information.
const double nuclear_repulsion_energy =
detail::calculate_ecp_adjusted_nuclear_repulsion_energy(
*internal_basis_set->mol);
Comment on lines +21 to +24
set_default("eri_use_atomics", false,
"Use atomic accumulation (one shared buffer) instead of "
"per-thread private buffers during the AO->active-MO ERI "
"transformation.");
Comment on lines +206 to +210
// ECP-adjusted nuclear repulsion energy.
// Uses basis set information instead of structure information.
const double nuclear_repulsion_energy =
detail::calculate_ecp_adjusted_nuclear_repulsion_energy(
*internal_basis_set->mol);
@wavefunction91

Copy link
Copy Markdown
Collaborator

Hey vbarandun, can you accept the CLA, merge main and run the pre-commit hooks to fix the linting error?

@vbarandun

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="ETH Zurich"

@mmoerchen

Copy link
Copy Markdown
Contributor

Thanks a lot for identifying this issue in this PR, vbarandun. We found that the problem affected more than the code path here, so we implemented the broader fix separately in #659.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working user A request made by a user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants