Skip to content

fix the interface for pyscf plugin. - #215

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/pyscf/fix-interface
Mar 16, 2026
Merged

fix the interface for pyscf plugin.#215
hzhangxyz merged 1 commit into
mainfrom
dev/pyscf/fix-interface

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 16, 2026 06:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR targets the PySCF plugin integration by adjusting how the solver extracts energies from QMP checkpoint data and by updating packaging metadata to include PySCF as a dependency.

Changes:

  • Pass the constructed model into _extract_energy() and extend _extract_energy() to optionally recompute energies from the saved (configs, psi) pool.
  • Add pyscf>=2.12.1 to project dependencies and update uv.lock accordingly.
  • Update the lockfile to include additional resolved wheels/metadata.

Reviewed changes

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

File Description
qmp/plugins/pyscf.py Changes energy extraction behavior for the PySCF-facing solver.
pyproject.toml Adds PySCF as a required dependency (while still keeping an optional extra).
uv.lock Updates lock data to reflect dependency changes (incl. PySCF and new torch wheels).

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread qmp/plugins/pyscf.py
Comment on lines +503 to +514
# Try to compute energy from the pool (configs, psi) if model is available
pool = haar_data.get("pool")
if pool is not None and model is not None:
configs, psi = pool
if configs is not None and psi is not None:
# Compute expectation value <psi|H|psi> / <psi|psi>
h_psi = model.apply_within(configs, psi, configs)
energy = ((psi.conj() @ h_psi) / (psi.conj() @ psi)).real
if hasattr(energy, "item"):
return float(energy.item())
return float(energy)

Comment thread qmp/plugins/pyscf.py
Comment on lines +508 to +510
# Compute expectation value <psi|H|psi> / <psi|psi>
h_psi = model.apply_within(configs, psi, configs)
energy = ((psi.conj() @ h_psi) / (psi.conj() @ psi)).real
Comment thread pyproject.toml
Comment on lines 16 to 20
"openfermion>=1.7.1",
"tensorboard>=2.20.0",
"dacite>=1.9.2",
"pyscf>=2.12.1",
]
Comment thread qmp/plugins/pyscf.py
# results is list[(energy_tensor, configs, psi)]; index 0 is ground state.
energy_val = results[0][0]
if hasattr(energy_val, "item"):
return float(energy_val.item())
@hzhangxyz
hzhangxyz merged commit 2e73e27 into main Mar 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants