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

Support for expected values of Circuits #46

Merged
merged 23 commits into from
Jul 14, 2021
Merged

Conversation

Mandrenkov
Copy link
Collaborator

@Mandrenkov Mandrenkov commented Jul 13, 2021

Context:
One of the barriers to developing a useful PennyLane plugin based on Jet is supporting efficient expected value computations. This PR does just that by implementing a relevant operation in the Circuit class.

Description of the Change:

  • The Circuit class now has an expected value operation which accepts an arbitrary observable as input.
  • An Adjoint decorator class has been added to replace the adjoint parameter of Gate.tensor().
    • A similar approach may be used in the future to support operator prefactors.
  • The Circuit._append_validator() method decorator is now a regular method called Circuit._validate_wire_ids().
    • The resulting code is simpler and iterator-friendly.
  • Several docstrings have been fixed to comply with Xanadu OSS conventions.

Benefits:

  • It is easy to compute the expected value of an observable with respect to a Circuit instance.
  • There exists an efficient implementation of a core PennyLane device operation (i.e., expval()).

Possible Drawbacks:
None.

Related GitHub Issues:
None.

@github-actions
Copy link

github-actions bot commented Jul 13, 2021

Test Report (C++) on Ubuntu

    1 files  ±0      1 suites  ±0   0s ⏱️ ±0s
521 tests ±0  521 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
870 runs  ±0  870 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit aa4b4bf. ± Comparison against base commit aa4b4bf.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 13, 2021

Test Report (Python) on Ubuntu

    1 files  ±0      1 suites  ±0   6s ⏱️ ±0s
512 tests ±0  512 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit aa4b4bf. ± Comparison against base commit aa4b4bf.

♻️ This comment has been updated with latest results.

@Mandrenkov Mandrenkov marked this pull request as ready for review July 13, 2021 21:13
Copy link
Member

@mlxd mlxd 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 --- just a small query on the use of the Adjoint class, but feel free to ignore.

python/jet/gate.py Show resolved Hide resolved
Copy link
Collaborator Author

@Mandrenkov Mandrenkov left a comment

Choose a reason for hiding this comment

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

Thanks for the review, @mlxd!

@Mandrenkov Mandrenkov merged commit aa4b4bf into main Jul 14, 2021
@Mandrenkov Mandrenkov deleted the circuit-expected-values branch July 14, 2021 20:42
This pull request was closed.
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