Conversation
📊 Coverage Summary
Detailed Coverage ReportsC++ Coverage DetailsPython Coverage DetailsPybind11 Coverage Details |
| single_orbital_entropies.size()); | ||
|
|
||
| const bool is_symm = bra_begin == ket_begin and bra_end == ket_end; | ||
| #ifdef MACIS_ENABLE_MPI |
There was a problem hiding this comment.
This does not seem to emit a proper MPI implementation, so it should error out if world_size > 1.
There was a problem hiding this comment.
This was just a copy/paste from the RDM loops. Shouldn't these then also error out if world_size > 1 ?
There was a problem hiding this comment.
Pull request overview
This PR implements direct computation of single-orbital entropies (s1), two-orbital entropies (s2), and mutual information (MI) in MACIS, addressing issue #139. The implementation adds comprehensive entropy calculation infrastructure with lazy evaluation support and full serialization.
Changes:
- Added new entropy computation infrastructure in external/macis with RDM intermediate accumulation and eigenvalue-based entropy calculation
- Extended WavefunctionContainer and derived classes to support pre-computed entropies at construction with lazy evaluation (MI derivable from s1+s2, s2 derivable from s1+MI)
- Added Python bindings, serialization (JSON/HDF5), and comprehensive test coverage including integration tests with reference values
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| external/macis/include/macis/util/entropies.hpp | New header implementing orbital RDM intermediate accumulation, 4x4 Jacobi eigenvalue solver, and s1/s2/MI builders |
| external/macis/include/macis/util/rdms.hpp | Bug fix: moved val *= sign * 0.5 before conditional to ensure correct opposite-spin 2-RDM contributions |
| external/macis/include/macis/hamiltonian_generator.hpp | Added pure virtual form_entropies method to base generator class |
| external/macis/include/macis/hamiltonian_generator/double_loop.hpp | Implemented form_entropies for double-loop generator with intermediate accumulation |
| external/macis/include/macis/hamiltonian_generator/sorted_double_loop.hpp | Implemented form_entropies for sorted double-loop generator with OpenMP parallelization |
| cpp/include/qdk/chemistry/data/wavefunction.hpp | Added OrbitalEntropies struct and methods for has/get s1/s2/MI with lazy evaluation |
| cpp/include/qdk/chemistry/data/wavefunction_containers/cas.hpp | Added entropy parameter to CasWavefunctionContainer constructors |
| cpp/include/qdk/chemistry/data/wavefunction_containers/sci.hpp | Added entropy parameter to SciWavefunctionContainer constructors |
| cpp/include/qdk/chemistry/algorithms/mc.hpp | Added settings for calculate_single_orbital_entropies, calculate_two_orbital_entropies, and calculate_mutual_information |
| cpp/src/qdk/chemistry/data/wavefunction.cpp | Implemented entropy storage, lazy evaluation, and JSON/HDF5 serialization/deserialization |
| cpp/src/qdk/chemistry/data/wavefunction_containers/cas.cpp | Updated constructors to thread entropies through to base class |
| cpp/src/qdk/chemistry/data/wavefunction_containers/sci.cpp | Updated constructors to thread entropies through to base class and clone method |
| cpp/src/qdk/chemistry/algorithms/microsoft/macis_base.hpp | Updated build_wavefunction to compute and attach entropies based on settings |
| python/src/pybind11/data/wavefunction.cpp | Added parse_entropies helper and updated container constructors to accept entropies dict; exposed has/get methods |
| cpp/tests/test_wavefunction.cpp | Added C++ tests for lazy evaluation of MI from s1+s2 and s2 from s1+MI, plus serialization roundtrip tests |
| python/tests/test_wavefunction.py | Added Python tests for lazy evaluation and serialization roundtrips |
| python/tests/test_mc.py | Added integration tests computing s1/s2/MI for NO doublet and H2O singlet with reference value validation |
| python/tests/reference_tolerances.py | Added entropy_tol = 1e-6 for entropy comparison tolerance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::nullopt, // two_rdm_bbbb | ||
| std::nullopt, // single_orbital_entropies | ||
| std::nullopt, // mutual_information | ||
| {}, // entropies |
There was a problem hiding this comment.
Unnamed brace initializer should be avoided. Now sure if this shows up other places in the PR, but it should be something like OrbitalEntropies{}
| single_orbital_entropies.size()); | ||
|
|
||
| const bool is_symm = bra_begin == ket_begin and bra_end == ket_end; | ||
| #ifdef MACIS_ENABLE_MPI |
This PR implement the direct computation of mutual information and single orbital entropies in MACIS.
Additionally, the wavefunction class is expanded to accept pre-computed s1 entropies and mutual information at construction.
Resolves #139