You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The num_unique_paulis field tracked by the metadata when operators are being simplified can falsely report to be 0.
This does not make any sense because it would imply an empty operator has occurred but we know for a fact that the smallest operator size is bound by 1 (when it gets reduced to an identity operator).
This will output 0 even though the obvious correct number of unique Pauli terms should be 1 (as shown by the second print line).
Traceback
No response
Any suggestions?
The reason that this occurs is the following: when none of the gates in a slice of the circuit overlap with the observable being backpropagated, the num_unique_paulis value never gets set to a correct value and, thus, remains to be its initialized value.
Specifically, the following lines have to always execute:
This will correctly initialize the num_unique_paulis with the current length of each observable.
Add a check here whether num_unique_paulis is still zero and, if so, fix it at this point.
Personally, I find the first fix cleaner but it adds an additional loop over the observables (which should not be a problem).
The latter fix would be preferable if any of the other metadata fields also need to be handled specially, but looking at it now, those should all be correct when initialized with 0 (because num_paulis will always get updated correctly here).
But it won't hurt to double check whether this is indeed correct.
@caleb-johnson I will leave it up to you with which solution you will go 👍
The text was updated successfully, but these errors were encountered:
Environment
What is happening and why is it wrong?
The
num_unique_paulis
field tracked by the metadata when operators are being simplified can falsely report to be0
.This does not make any sense because it would imply an empty operator has occurred but we know for a fact that the smallest operator size is bound by 1 (when it gets reduced to an identity operator).
Credit to @BryceFuller for finding this!
How can we reproduce the issue?
This will output
0
even though the obvious correct number of unique Pauli terms should be1
(as shown by the second print line).Traceback
No response
Any suggestions?
The reason that this occurs is the following: when none of the gates in a slice of the circuit overlap with the observable being backpropagated, the
num_unique_paulis
value never gets set to a correct value and, thus, remains to be its initialized value.Specifically, the following lines have to always execute:
qiskit-addon-obp/qiskit_addon_obp/backpropagation.py
Lines 179 to 181 in bdd9509
Resulting in the
0
remaining set from here:qiskit-addon-obp/qiskit_addon_obp/backpropagation.py
Line 150 in bdd9509
We have multiple solutions for how to fix this.
Change the initialization of
num_unique_paulis
to be the following:This will correctly initialize the
num_unique_paulis
with the current length of each observable.Add a check here whether
num_unique_paulis
is still zero and, if so, fix it at this point.Personally, I find the first fix cleaner but it adds an additional loop over the observables (which should not be a problem).
The latter fix would be preferable if any of the other metadata fields also need to be handled specially, but looking at it now, those should all be correct when initialized with
0
(becausenum_paulis
will always get updated correctly here).But it won't hurt to double check whether this is indeed correct.
@caleb-johnson I will leave it up to you with which solution you will go 👍
The text was updated successfully, but these errors were encountered: