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 in the XIR interpreter #49

Merged
merged 8 commits into from Jul 27, 2021

Conversation

Mandrenkov
Copy link
Collaborator

Context:
One of the most common measurements applied to PennyLane circuits is expval() - taking the expected value of an observable in the context of a quantum circuit. This PR introduces support for interpreting expval statements in XIR programs using Jet.

Description of the Change:

  • A Scale decorator class is introduced to linearly scale the _data() representation of an existing gate.
  • The Jet-XIR interpreter now processes expval statements using Circuit.take_expected_value().

Benefits:

  • The Jet-XIR interpreter can execute a serialized PennyLane circuit with one or more expected value measurements.

Possible Drawbacks:

  • Parameterized operators are not supported in expval statements. This is partially due to the fact that the interpreter has no means of evaluating prefactors that reference one or more operator parameters. It is also unclear how the parameters of an operator should be specified in expected value statements. For example:

    expval(observable: obs(1, 2))
    

    or

    expval(observable: obs, observable_params: [1, 2])
    
  • User-defined gates are not supported in operator statements. In principle, this should be possible; however, the implementation burden is relatively high and the benefit of supporting such a use case is questionable.

Related GitHub Issues:
None.

@Mandrenkov Mandrenkov added the enhancement ✨ New feature or request label Jul 16, 2021
@Mandrenkov Mandrenkov requested a review from thisac July 16, 2021 21:35
@github-actions
Copy link

github-actions bot commented Jul 16, 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 2298839. ± Comparison against base commit 2298839.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 16, 2021

Test Report (Python) on Ubuntu

    1 files  ±0      1 suites  ±0   10s ⏱️ ±0s
542 tests ±0  542 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

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

♻️ This comment has been updated with latest results.

Copy link

@thisac thisac left a comment

Choose a reason for hiding this comment

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

Great addition. This made me think a bit more about what we should do with parameterized operators and symbolic handling. I'll put some thought into this, since currently it's not really that usable (for example, the way parameterized operators cannot be used here).

python/tests/jet/test_gate.py Show resolved Hide resolved
python/tests/jet/test_gate.py Show resolved Hide resolved
@Mandrenkov
Copy link
Collaborator Author

Thanks for the comments, @thisac! Let me know if you have any other queries.

@Mandrenkov Mandrenkov merged commit 2298839 into main Jul 27, 2021
Mandrenkov added a commit that referenced this pull request Aug 4, 2021
@Mandrenkov Mandrenkov deleted the xir-operator-expval branch August 4, 2021 20:28
Mandrenkov added a commit that referenced this pull request Aug 5, 2021
* Clarify that Jet is also a Python library

* Improve CudaScopedDevice comments

* Add changelog entry and set development release to 0.2.1

* Save changes to README

* Move PR #49 changelog entry to 0.2.1 release

* Add citations to README and Sphinx documentation

* Add changelog entry for citations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants