-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add apply_layout
method to SparsePauliOp
#10947
Add apply_layout
method to SparsePauliOp
#10947
Conversation
One or more of the the following people are requested to review this:
|
0cdaa47
to
96aa556
Compare
Pull Request Test Coverage Report for Build 6424225330
💛 - Coveralls |
can we also make it take a layout object |
This commit adds a new method, `apply_layout`, to the `SparsePauliOp` class. It takes in either a `TranspileLayout` object or a list of indices that represent a layout transformation caused by the transpiler and then returns a new SparsePauliOp object that applies a matching transformation.
can you rebase this PR? Overall it looks good to me. |
96aa556
to
9b0ba86
Compare
I'm not sure there is a simple path for supporting just a |
Done |
releasenotes/notes/sparse-pauli-op-apply-layout-43149125d29ad015.yaml
Outdated
Show resolved
Hide resolved
I'm confused, this current PR accepts a list of integers, which seems like it would contain strictly less information than a Layout object would. So if a list of integers is possible, Layout should be possible too? |
The difference is that a qr = QuantumRegister(3)
qc = QuantumCircuit()
qc.add_bits([qr[i] for i in [2, 0, 1]])
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2) if you had solely a {qr[0]: 0, qr[1]: 1, qr[2]: 2} with solely this mapping you wouldn't know how to transform the operator as this layout object doesn't have any details about the starting position of each qubit. (I used registers here to illustrate you can't rely on ordering of bits, but also if you used bare A list of integers is different because it maps ever index in the list to it's new position, so we have all the information needed to apply the layout. |
Ok @mtreinish I think I see now the problem is with the Layout class. I'm fine with this PR |
releasenotes/notes/sparse-pauli-op-apply-layout-43149125d29ad015.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/sparse-pauli-op-apply-layout-43149125d29ad015.yaml
Outdated
Show resolved
Hide resolved
releasenotes/notes/sparse-pauli-op-apply-layout-43149125d29ad015.yaml
Outdated
Show resolved
Hide resolved
Co-authored-by: Kevin Hartman <kevin@hart.mn>
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
Summary
This commit adds a new method,
apply_layout
, to theSparsePauliOp
class. It takes in either a
TranspileLayout
object or a list ofindices that represent a layout transformation caused by the transpiler
and then returns a new SparsePauliOp object that applies a matching
transformation.
Details and comments
This PR is based on top of #10835 and includes the contents of that PR. To see the content of just this PR you can view:
https://github.com/mtreinish/qiskit-core/compare/imrpove-transpile-layout...mtreinish:qiskit-core:apply-layout-spare-pauli-op?expand=1