-
Notifications
You must be signed in to change notification settings - Fork 33
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
Reconstruct expectation values of SparsePauliOp operators in notebooks #523
Conversation
Pull Request Test Coverage Report for Build 8638707318Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
It appears that the depth reduction that is reported in the tutorials is a consequence of this definition-change (for lack of a better phrase) and is not otherwise related to the change to |
Yes, it's such a small change, I included it here as I re-ran all the notebooks. Just included a kwarg to the depth calls. The single-Q rotations and extra ECRs were artificially blowing up the depth. Comparing CX depth to ECR depth directly is still dubious to me since one CX compiles to two ECRs, and it's not clear that two ECRGates produces more noise than a single CX gate. |
As discussed offline, some of the commentary about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks great! Very obvious in retrospect that this is how we should be demonstrating use with SparsePauliOp
. I had a local branch that attempted to do this implicitly, but I think explicit is the way to go.
docs/circuit_cutting/tutorials/01_gate_cutting_to_reduce_circuit_width.ipynb
Outdated
Show resolved
Hide resolved
…it_width.ipynb Co-authored-by: Jim Garrison <[email protected]>
* Add sampling overhead table * typos * Fix heading level * Rearrange table * Fix some Sphinx cross references * Fix Sphinx LaTeX expressions * Add link to IBM blog post on LOCC cutting * Tweaks to intro * Lots of progress * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Rephrase LOCC vs dynamic circuits following discussion at #342 (comment) * Removed `PauliList` limitation, lifted by #523 Follow up to #342 (comment) * Rephrase circuit cutting intro #342 (comment) * Remove circuit cutting graph It's actually very similar to the one at the top of the explanation #342 (comment) * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> --------- Co-authored-by: Ibrahim Shehzad <[email protected]>
* Add sampling overhead table * typos * Fix heading level * Rearrange table * Fix some Sphinx cross references * Fix Sphinx LaTeX expressions * Add link to IBM blog post on LOCC cutting * Tweaks to intro * Lots of progress * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Rephrase LOCC vs dynamic circuits following discussion at #342 (comment) * Removed `PauliList` limitation, lifted by #523 Follow up to #342 (comment) * Rephrase circuit cutting intro #342 (comment) * Remove circuit cutting graph It's actually very similar to the one at the top of the explanation #342 (comment) * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> --------- Co-authored-by: Ibrahim Shehzad <[email protected]> (cherry picked from commit 299c849) # Conflicts: # test/cutting/qpd/test_qpd.py
…ckport #342) (#553) * Add sampling overhead table and expand/update cutting explanation (#342) * Add sampling overhead table * typos * Fix heading level * Rearrange table * Fix some Sphinx cross references * Fix Sphinx LaTeX expressions * Add link to IBM blog post on LOCC cutting * Tweaks to intro * Lots of progress * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Rephrase LOCC vs dynamic circuits following discussion at #342 (comment) * Removed `PauliList` limitation, lifted by #523 Follow up to #342 (comment) * Rephrase circuit cutting intro #342 (comment) * Remove circuit cutting graph It's actually very similar to the one at the top of the explanation #342 (comment) * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> * Update docs/circuit_cutting/explanation/index.rst Co-authored-by: Ibrahim Shehzad <[email protected]> --------- Co-authored-by: Ibrahim Shehzad <[email protected]> (cherry picked from commit 299c849) # Conflicts: # test/cutting/qpd/test_qpd.py * Fix conflict --------- Co-authored-by: Jim Garrison <[email protected]>
Fixes #157
Fixes #489
depth
calls to include only non-local gates provides a more meaningful picture of depth-savingsFixes #524
TODO:
Problem:
In our tutorials and how-tos we treat
PauliList
like a list of individual observables. They aren't allowed to have a non-trivial phase (phase other than1.0 + 0j
) and they are all assumed to have weight1.0 + 0j
. This is somewhat of a misuse ofPauliList
, in my opinion. ThePauliList
class more naturally describe a singleN
-qubit operator with terms of complex unit magnitude and some global phase.It would be better if we supported the primary Pauli operator class from Qiskit,
SparsePauliOp
; however, supporting this class alongside or in place ofPauliList
would be extremely disruptive to our codebase, requiring significant modifications to a sizeable portion of the source and our API.#######################################
A few thoughts:
SparsePauliOp
(e.g. the coefficients/phases) would be ignored until the very last step of reconstruction.SparsePauliOp
.cutting
package actually plays very seamlessly with theSparsePauliOp.paulis: PauliList
field.SparsePauliOp
will remove any non-trivial phase from each Pauli term and shift it to the coefficient (i.e. ("-IIXX", 1.0) becomes ("IIXX", -1.0)). This means theSparsePauliOp.paulis
output will always contain Paulis with trivial phases, making it a compatiblePauliList
for CKT.#########################################
Solution:
Rather than tearing up our codebase to support a class which doesn't provide us any additional flexibility in our workflows, I believe it is better to show users how to create an expectation value for their
SparsePauliOp
operator by passing the underlying Pauli terms to CKT and recombining the terms' expvals with their coefficients in a single-line last step of reconstruction.final_expval = np.dot(reconstructed_expvals, observable.coeffs)
In addition to this being a very clean fix which only affects our docs, it allows us to showcase the primary operator class in Qiskit,
SparsePauliOp
, and it allows us to stop treatingPauliList
s like lists of observables in our docs, which is an abuse of the class. I believe this is a rare case of the easy fix being the correct one, and I believe we can close #157 .##########################################
Final thought:
SparsePauliOp
for a circuit with several cuts, will already result in a large batch of circuits. The CKT workflow being set up for one list of Pauli observables at a time seems totally reasonable to me, considering the batch-size/time constraints of Qiskit Runtime. For large cutting workflows involving manySparsePauliOp
s (or even one large one), users can batch/group their Pauli terms however they like (likely across all their observables), they can run their experiments over the course of hours or days, and they can handle their own reconstruction at that level, usingreconstruct_expectation_values
as a tool within a larger reconstruction workflow (error mitigated expvals will also be reconstructed at this time). CKT will remain:circuit/list_of_paulis --> CKT --> list_of_expvals