-
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
SparsePauliOp.apply_layout should do nothing if given None #11026
Comments
From my understanding, the only change will be in the apply_layout function by adding the case for a null layout (in which case the function should do nothing). If this is good for a first issue I would like to help with this one :) |
It is a good first issue, at least in my mind. |
Great! Then I would like to work on it :) |
I've assigned this issue to you @SoranaAurelia |
@mtreinish I think it's solved is it? |
What behaviour would we expect here if |
Maybe we should treat it the same way we treat the case in which the layout is specified and the num_qubits is larger then the num qubits from the layout provided? That is, expanding the operator to the requested number of qubits. Raising an error might also solve the problem, but I think it can be in some cases contradictory to the intention of this feature request: the same code that works for a transpiled circuit for a certain backend might pass while the one transpiled for a simulator will raise due to this. Thanks for catching this! |
I would also expand the operator. |
Personally I'm not a fan of implicitly assuming that the given qubits are the "low" indexed ones - that's the kind of thing a layout is supposed to tell you - but looking at the code, it seems like we've already made that assumption, so it's most consistent to extend it to this case as well. Thanks both. |
What should we add?
Simulators give
None
for the layout when a circuit goes through the transpiler. Currently this raises inSparsePauliOp.apply_layout
. Rather, it would be nice ifNone
is a null op inapply_layout
so that I can run the same code for a sim and a real backend.The text was updated successfully, but these errors were encountered: