Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create qchem refactoring feature branch #2164

Merged
merged 32 commits into from
Mar 21, 2022
Merged

Create qchem refactoring feature branch #2164

merged 32 commits into from
Mar 21, 2022

Conversation

soranjh
Copy link
Contributor

@soranjh soranjh commented Feb 3, 2022

Context:
This PR creates a feature branch for the first phase of refactoring the quantum chemistry functionality in PennyLane. The details are discussed here. In this PR, a differentiable equivalent of qml.qchem is created and can be accessed with qml.qchem.hf.

Description of the Change:

  • The new qchem.hf subpackage is created.
  • Functions for building a differentiable dipole moment observable are added to qchem.hf.dipole.
  • Functions for building spin and particle number observables, with no external dependency, are added to qchem.hf.
  • Modified versions of general-purpose functions needed for building observables are collected in qchem.hf.observable.
  • Modified version of functions for converting openfermion observables to pennylane ones are collected in qchem.hf.convert.
  • The computational efficiency of the whole workflow is improved.

Benefits:

  • The new functionality covers all features available in qml.qchem, is fully differentiable and is independent of external libraries. Adding this functions to qml.qchem.hf makes the future stepts of the quantum chemistry refactoring easier.

Possible Drawbacks:
Some codes will be duplicated for 1-2 release cycles.

Related GitHub Issues:
NA

@soranjh soranjh added WIP 🚧 Work-in-progress do not merge ⚠️ Do not merge the pull request until this label is removed qchem ⚛️ Related to the QChem package labels Feb 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2022

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #2164 (bb932fe) into master (d291425) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2164      +/-   ##
==========================================
+ Coverage   99.39%   99.41%   +0.02%     
==========================================
  Files         229      242      +13     
  Lines       17457    18258     +801     
==========================================
+ Hits        17351    18152     +801     
  Misses        106      106              
Impacted Files Coverage Δ
qchem/pennylane_qchem/qchem/hf/__init__.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/basis_data.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/basis_set.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/convert.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/dipole.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/hamiltonian.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/hartree_fock.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/integrals.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/matrices.py 100.00% <100.00%> (ø)
qchem/pennylane_qchem/qchem/hf/molecule.py 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d291425...bb932fe. Read the comment docs.

soranjh and others added 20 commits February 18, 2022 14:20
* Add multipole moment integrals to hf
* add functions for creating observables

* modify function locations

* change module name to observable

* change operator to observable in function names

* change name of the test file

* fix autograd warning

* fix autograd warning

* run black and modify comments

* use dic to return pauli ops

* modify variable names

* replace return pauli function with dic

* use reduce for obs multiplication

* add code review comments

* add more jordan wigner tests

* add hydrogen test for fermionic operator

* modify format in simplify
* add functions to convert openfermion obs to PL obs
@soranjh soranjh changed the title [WIP] create qchem refactoring feature branch Create qchem refactoring feature branch Mar 15, 2022
@soranjh soranjh removed the WIP 🚧 Work-in-progress label Mar 15, 2022
Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

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

@soranjh I did a quick skim through 🙂 No need to re-tag me for review.

Just wanted to double check: this is the first stage in moving HF to qchem and renaming some functions, but subsequent steps (moving functionality to new locations) is still to be done?

qchem/pennylane_qchem/__init__.py Show resolved Hide resolved
qchem/pennylane_qchem/qchem/hf/__init__.py Show resolved Hide resolved
qchem/pennylane_qchem/qchem/hf/convert.py Show resolved Hide resolved
qchem/pennylane_qchem/qchem/hf/hamiltonian.py Outdated Show resolved Hide resolved
@soranjh
Copy link
Contributor Author

soranjh commented Mar 15, 2022

@soranjh I did a quick skim through slightly_smiling_face No need to re-tag me for review.

Just wanted to double check: this is the first stage in moving HF to qchem and renaming some functions, but subsequent steps (moving functionality to new locations) is still to be done?

Thanks @josh146. Yes, exactly, there will be few more PRs to fully polish qchem to its final format and then bring it inside pennylane. It is a bit easier for me to make those changes with separate PRs to master.

@soranjh soranjh marked this pull request as ready for review March 15, 2022 18:39
Copy link
Contributor

@obliviateandsurrender obliviateandsurrender left a comment

Choose a reason for hiding this comment

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

Overall looks good to me @soranjh! I just left a few minor comments.

qchem/pennylane_qchem/qchem/hf/basis_data.py Show resolved Hide resolved
qchem/pennylane_qchem/qchem/hf/convert.py Show resolved Hide resolved
qchem/pennylane_qchem/qchem/hf/dipole.py Show resolved Hide resolved
qchem/tests/hf/test_dipole.py Show resolved Hide resolved
@soranjh soranjh merged commit 54950fb into master Mar 21, 2022
@soranjh soranjh deleted the qchem_refactor branch March 21, 2022 13:55
@soranjh soranjh removed the do not merge ⚠️ Do not merge the pull request until this label is removed label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qchem ⚛️ Related to the QChem package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants