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

Group quantum chemistry templates #1822

Conversation

obliviateandsurrender
Copy link
Contributor

@obliviateandsurrender obliviateandsurrender commented Oct 28, 2021

Context:
Group the templates related to quantum chemistry under a common header.

Description of the Change:

  1. Shifts the templates ParticleConservingU1, ParticleConservingU2, GateFabric (from Layer templates section) and AllSinglesDoubles, UCCSD, k-UpCCGSD (from Other subroutines section) to Quantum Chemistry templates section.
  2. Renames SingleExcitationUnitary and DoubleExcitationUnitary to FermionicSingleExcitation and FermionicDoubleExcitation, respectively, since the term 'Unitary' seemed somewhat redundant.
  3. Incremented the width of the customgalleryitem (defined by GALLERY_TEMPLATE variable) to solve the issue regarding the name of some templates overflowing to an additional line, hence breaking the grid design.

Benefits:
Sends a clear message that Pennylane supports a dedicated collection of templates for quantum chemistry.

Possible Drawbacks:
None.

Related GitHub Issues:
None.


dev = qml.device('default.qubit', wires=5)

@qml.qnode(dev)
def circuit(weight, wires1=None, wires2=None):
DoubleExcitationUnitary(weight, wires1=wires1, wires2=wires2)
FermionicDoubleExcitation(weight, wires1=wires1, wires2=wires2)
Copy link
Member

Choose a reason for hiding this comment

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

quick comment @obliviateandsurrender: as of the upcoming PL release, we now support qml.TemplateName directly, so will be rewriting all tutorials and examples. So here you could simply have

Suggested change
FermionicDoubleExcitation(weight, wires1=wires1, wires2=wires2)
qml.FermionicDoubleExcitation(weight, wires1=wires1, wires2=wires2)

and remove the import above (and similarly, qml.templates.TemplateName can be replaced with qml.TemplateName where it appears)

Copy link
Contributor Author

@obliviateandsurrender obliviateandsurrender Oct 28, 2021

Choose a reason for hiding this comment

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

Hey, thanks for the update! I have incorporated this for the templates (and their unit tests) that are being modified in this PR. I hope that should be fine.

@codecov
Copy link

codecov bot commented Oct 28, 2021

Codecov Report

Merging #1822 (819664d) into master (bbcfb9a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1822   +/-   ##
=======================================
  Coverage   98.92%   98.92%           
=======================================
  Files         209      209           
  Lines       15744    15744           
=======================================
  Hits        15575    15575           
  Misses        169      169           
Impacted Files Coverage Δ
pennylane/templates/subroutines/__init__.py 100.00% <100.00%> (ø)
...mplates/subroutines/fermionic_double_excitation.py 100.00% <100.00%> (ø)
...mplates/subroutines/fermionic_single_excitation.py 100.00% <100.00%> (ø)
pennylane/templates/subroutines/kupccgsd.py 100.00% <100.00%> (ø)
pennylane/templates/subroutines/uccsd.py 100.00% <100.00%> (ø)

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 bbcfb9a...819664d. Read the comment docs.

Copy link
Contributor

@ixfoduap ixfoduap left a comment

Choose a reason for hiding this comment

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

Looks amazing! Thank you for doing this @obliviateandsurrender

I'd just like to re-order the templates, otherwise good to go from my side

Quantum Chemistry templates
---------------------------

Quantum chemistry templates define various heuristic ansätze used in variational algorithms
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Quantum chemistry templates define various heuristic ansätze used in variational algorithms
Quantum chemistry templates define various quantum circuits used in variational algorithms

Quantum chemistry templates define various heuristic ansätze used in variational algorithms
like VQE to perform quantum chemistry simulations.

.. customgalleryitem::
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's order them based on importance. I would suggest:
AllSinglesDoubles
GateFabric
UCCSD
k-UpGCCSD
PC1
PC2

Copy link
Contributor

Choose a reason for hiding this comment

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

Would FermionicSingleExcitation and FermionicDoubleExcitation also belong here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was considering the same. @ixfoduap, what do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think these are better left as subroutines since they are not really templates you would use to build a circuit

Comment on lines 858 to 860
* Templates `SingleExcitationUnitary` and `DoubleExcitationUnitary` have been renamed
to `FermionicSingleExcitation` and `FermionicDoubleExcitation`, respectively.
[(#1822)](https://github.com/PennyLaneAI/pennylane/pull/1822)
Copy link
Contributor

Choose a reason for hiding this comment

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

This item might fit into Breaking changes more. It breaks code that used to use templates before the renaming.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually thought I wrote it under the Breaking changes. I have shifted it there now.

Copy link
Contributor

@antalszava antalszava left a comment

Choose a reason for hiding this comment

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

Looks good to me! 💯

@obliviateandsurrender obliviateandsurrender merged commit ccf5f3d into PennyLaneAI:master Oct 29, 2021
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.

None yet

4 participants