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

Adds ability to return multi-qubit expectation values to all devices #13

Open
wants to merge 6 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@josh146
Copy link
Collaborator

commented May 18, 2019

In PennyLane core, we have added the ability to use qml.expval.Hermitian(A, wires) on an arbitrary number of wires. That is, you can now pass a matrix A of size [2**N, 2**N] which acts on N qubits (i.e., len(wires)==N).

This PR adds support to the PennyLane-Forest plugin for this feature. This includes the following changes:

  • forest.numpy_wavefunction: replaces the expand_one method with the expand method, allowing an N qubit observable to be expanded to act on the entire system. Corresponding tests also added.

  • forest.wavefunction: replaces the expand_one method with the expand method, allowing an N qubit observable to be expanded to act on the entire system. Corresponding tests also added.

  • forest.qvm: modifies the expval method so that, if a multi-qubit observable is requested, the device calculates the wavefunction probablities, and uses this (alongside the eigenvalues of A) to reconstruct the required expectation value. Corresponding test test_multi_mode_hermitian_expectation also added.

  • forest.qpu: inherits the above functionality from forest.qvm.

Note: This feature requires the latest development version of PennyLane.

@josh146 josh146 added the enhancement label May 18, 2019

@josh146 josh146 requested a review from msohaibalam May 18, 2019

josh146 added some commits May 21, 2019

@msohaibalam
Copy link
Contributor

left a comment

Left a few comments. I'm also seeing two failing tests (both locally as well as on Semaphore): TestPyQVMBasic.test_multi_mode_hermitian_expectation and TestQVMBasic.test_multi_mode_hermitian_expectation.

Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py
Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py
Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py Outdated
Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py Outdated
Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py
Show resolved Hide resolved pennylane_forest/numpy_wavefunction.py Outdated
Show resolved Hide resolved pennylane_forest/qvm.py Outdated
Show resolved Hide resolved pennylane_forest/wavefunction.py
Show resolved Hide resolved tests/test_pyqvm.py Outdated
@josh146

This comment has been minimized.

Copy link
Collaborator Author

commented May 29, 2019

Thanks @msohaibalam for your review, I've just pushed a commit with all suggested changes.

The tests are likely going to fail for two reasons:

  1. There have been breaking changes in pyQuil 2.8, I'll make a new PR now to address this

  2. This PR requires PennyLane GitHub master installed for these two tests to pass --- semaphore is simply installing the pip version. We are working on updating the version on pip this week.

@josh146

This comment has been minimized.

Copy link
Collaborator Author

commented May 30, 2019

Note: this is a stop-gap solution, due to user demand for this feature. Once #9 is implemented, it will likely be faster and more efficient than the matrix expansion done here.

@msohaibalam msohaibalam self-requested a review May 30, 2019

@msohaibalam
Copy link
Contributor

left a comment

Approving this PR, with the understanding that it won't be easy to address the failing tests within this PR, but that we can fix these tests very soon in new PR(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.