feat: raw Hessian elements as training data (#124)#190
Merged
ericchansen merged 4 commits intomasterfrom Mar 30, 2026
Merged
Conversation
Add support for using raw Hessian matrix elements (not eigenmatrix) as training data, following the existing pattern established by eigenmatrix evaluators. Changes: - New HessianElementEvaluator in q2mm/optimizers/evaluators/hessian_element.py - ReferenceValue.kind now accepts 'hessian_element' - ReferenceData gains add_hessian_element() and add_hessian_from_matrix() - ObjectiveFunction registers and dispatches to the new evaluator - YAML parser supports 'hessian_element' kind and 'hessian' bulk directive - 30 new tests covering evaluator, ReferenceData, YAML round-trip, and ObjectiveFunction integration Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a new training-data pathway for fitting against raw Cartesian Hessian matrix elements (in Hartree/Bohr²), alongside the existing eigenmatrix-based Hessian training workflow. This expands the objective/reference-data system and YAML reference format to support element-wise Hessian targets.
Changes:
- Introduces
HessianElementEvaluatorto compute an MM Hessian and extract(row, col)elements for residual scoring. - Extends
ReferenceData/ObjectiveFunctionto register and evaluatekind: hessian_element, plus a bulk loader from a full Hessian matrix. - Updates YAML reference parsing to accept
kind: hessian_elementand a bulkkind: hessiandirective that expands to manyhessian_elementreferences; adds a dedicated test module.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
q2mm/optimizers/evaluators/hessian_element.py |
New evaluator computing raw MM Hessian and extracting element values for scoring. |
q2mm/optimizers/objective.py |
Adds hessian_element reference kind, builders for single/bulk Hessian elements, and evaluator registration/evaluation. |
q2mm/parsers/reference_yaml.py |
Adds YAML parsing/serialization for hessian_element plus bulk kind: hessian expansion. |
test/test_hessian_element.py |
New tests covering evaluator behavior, builders, YAML parsing/round-trip, and objective integration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add hessian_element to _kind_to_category() mapping (fixes gradient()) - Validate negative row/col in add_hessian_element() - Validate skip_translational in add_hessian_from_matrix() and YAML parser - Use tmp_path in tests instead of CWD - Remove dead patch.object code in test Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change auto-extraction defaults to match Q2MM literature (Norrby & Liljefors 1998): geometries and eigenmatrix ON, frequencies OFF. - from_molecule(): include_eigenmatrix default True - from_molecules(): include_eigenmatrix default True - from_gaussian(): include_frequencies default False, add include_eigenmatrix parameter (default True) Raw hessian_element training remains opt-in only. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… upper bound - Remove unused **kwargs from HessianElementEvaluator.compute() (no other evaluator uses it; consistent interface) - Validate skip_translational < Hessian dimension in YAML parser with ReferenceYAMLError for proper context Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add support for raw Hessian matrix elements as training data, complementing the existing eigenmatrix-based approach. Closes #124.
Changes
q2mm/optimizers/evaluators/hessian_element.pyHessianElementEvaluator-- computes raw MM Hessian, extracts elements at (row, col)q2mm/optimizers/objective.pyhessian_elementkind,add_hessian_element()andadd_hessian_from_matrix()builders, evaluator registrationq2mm/parsers/reference_yaml.pykind: hessian_elementand bulkkind: hessiandirectiveTesting
YAML Usage