-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Light Cone Transpiler Pass #12814
Light Cone Transpiler Pass #12814
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 13636110765Warning: 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 |
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.
Looks like a good start! Here's some initial comments 🙂
of qubits. | ||
""" | ||
|
||
def __init__(self, observable: Pauli | None = None): |
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.
This also takes a list of Paulis, right?
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.
For now only one Pauli. We could easily adapt it to a list of Paulis if we think that would make more sense.
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.
I'm asking because in your code the default path for observable=None
seems to use a list of Paulis already 🙂
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.
A list of Pauli terms would, in general, lead to a collection of different circuits as each Pauli term may have its own independent causal structure. A one circuit in, many circuits out, is not currently supported in the transpiler interface. But perhaps should be as it is useful for twirling as well
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.
Oh I meant that in this case the gates would have to commute with each of the Paulis in the list (how the measurements are treated as list of single-Z Paulis in the code right now). That would e.g. allow to decompose a larger observable into smaller (e.g. ZZZ...
into Z0, Z1, ...
) -- this would give a larger light cone since now things might not commute which would in the bigger observable, but it would make the commutation check faster (which I think would use a matrix multiplication check for non-standard gates).
But that's probably not required for the beginning and we could just issue a warning if the commutation check becomes problematic 🙂
|
||
commutes_bool = True | ||
for op in light_cone_ops: | ||
commute_bool = commutator.commute(op[0], op[1], [], node.op, node.qargs, []) |
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.
We should handle the max_num_qubits
arg, which currently defaults to 3. E.g. if a user would give a PauliGate("ZZZZ")
I think the code would just forego the commutation check and return False
for any commutation.
So we should probably set max_num_qubits=max(len(op[1]), len(node.qargs))
and add a warning if that number becomes too big.
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.
Yes. This is actually a very good point. I am working on fixing it right now , but it creates a bug for some reason.
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.
This leads to a bug. I have created a unitest and opened an issue #13828 . Once this issue is solved, the test can be enabled and everything else should work well.
Light cone polishing, warnings and tests
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Modified LightCone inputs and added tests
I created a test that creates the lightcone of a large Pauli string and it is not passing. This is linked to #13828. How should we proceed? Do we wait until the issue is fixed for merging this PR, or should we just throw a warning for now if the Pauli string gets too big? |
You could comment out the test case saying that it requires #13828 to be fixed, but I wouldn't add a custom warning, since that's extra cleanup work once the bug has been fixed. The expected behavior is for this to work 🙂 |
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
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.
Overall this LGTM, I left some comments below 🙂
Applied suggestions Co-authored-by: Julien Gacon <gaconju@gmail.com>
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.
Some tiny comments, then I think this is good to go!
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.
LGTM thanks for all the work @MarcDrudis and @spiccinelli!
Summary
When measuring or sampling a subset of the qubits of our circuit there will be some gates in our circuit that will not affect the outcome of the measurement. One can thus compute the causal light cone of the circuit and measurement, i.e. the set of gates that does affect the measurement. This transpiler pass provides an easy tool to reduce the number of gates in our circuit provided a Pauli observable to be measured or a subset of measurements in the Z basis.
This PR adresses #12792
Details and comments
This code takes inspiration from an implementation done by @aeddins-ibm.
Before finishing the unit-tests for this PR it would be interesting to solve #12790 .