Add ROHF GDM#453
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables ROHF (restricted open-shell) support in the SCF GDM/DIIS_GDM convergence path by adding ROHF-specific convergence matrix handling to the SCFAlgorithm base and extending GDM to handle ROHF orbital rotations/gradients.
Changes:
- Allow ROHF runs to use
SCFAlgorithmName::GDMandSCFAlgorithmName::DIIS_GDM(previously blocked). - Centralize ROHF “effective Fock + total density” convergence-matrix caching in
SCFAlgorithmand reuse it from DIIS/convergence checks. - Add ROHF-specific kappa packing, orbital rotation, pseudo-canonical transformations, and gradient computation in GDM.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| cpp/tests/test_scf.cpp | Removes the test that asserted ROHF+GDM is invalid (no replacement added). |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/scf_algorithm.cpp | Enables ROHF+GDM/DIIS_GDM in the factory; adds ROHF convergence-matrix caching in base algorithm. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/gdm.cpp | Implements ROHF-specific rotations, gradients, and pseudo-canonical/Hessian logic for GDM line search + iteration. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/diis.h | Removes DIIS-owned ROHF cache API and updates internal helper signature. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/diis.cpp | Switches DIIS ROHF handling to use SCFAlgorithm’s shared ROHF convergence cache. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf/scf_impl.h | Exposes core Hamiltonian accessor and a J/K build helper for use by GDM ROHF gradient code. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf/scf_impl.cpp | Updates trial-density Fock build to treat ROHF like unrestricted; implements build_jk_matrices. |
| cpp/src/qdk/chemistry/algorithms/microsoft/scf/include/qdk/chemistry/scf/core/scf_algorithm.h | Adds ROHF convergence-matrix hook + cache accessors and stores ROHF caches in base class. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Coverage Summary
Detailed Coverage ReportsC++ Coverage DetailsPython Coverage DetailsPybind11 Coverage Details |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/gdm.cpp:1261
- This calls
ERI::build_JK()from insideGDM::iterate(), butSCFImpl::iterate_()invokes the SCF algorithm only onworld_rank == 0, whileERI::build_JK()performs collective MPI reductions whenworld_size > 1. As a result, ROHF GDM will hang under MPI because the non-root ranks never enter this call. The ROHF GDM path should either coordinate the JK build across all ranks or be rejected when MPI is enabled.
scf_impl.build_jk_matrices(scf_impl.get_density_matrix(), J_ao, K_ao);
cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/scf_helper.h:31
- This documentation says callers may pass arbitrary sub-block starts, but
compute_atba_gemm()hardcodes the leading dimensions frommandnand has no way to accept the parent matrix stride. That is only correct for contiguous/full-width blocks; a true interior row-major sub-block would be read with the wrong stride. Please either restrict the contract to contiguous blocks or add leading-dimension parameters.
📊 Coverage Summary
Detailed Coverage ReportsC++ Coverage DetailsPython Coverage DetailsPybind11 Coverage Details |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
cpp/src/qdk/chemistry/algorithms/microsoft/scf/src/scf_algorithm/scf_helper.h:33
- The
compute_atba_gemmdoc says the input pointers may reference sub-block starts, but the implementation hard-codes leading dimensions (e.g.,lda = nfor RowMajor). That only works when the referenced blocks are stored contiguously with those exact strides; for typical Eigen sub-blocks from a larger matrix, the stride is the parent’s column count and the result would be incorrect. Please either (a) tighten the doc to state the required memory layout/stride constraints, or (b) extend the helper to accept explicit leading dimensions (lda/ldb/ldc) so true sub-block pointers are supported.
No description provided.