Qiskit / qiskit-addon-obp

Reducing depth of circuits with operator backpropagation
https://qiskit.github.io/qiskit-addon-obp/
Apache License 2.0
21 stars 0 forks source link

OBP on clifford circuit produces a NoneType backpropagated circuit #16

Open ritajitmajumdar1 opened 4 days ago

ritajitmajumdar1 commented 4 days ago

Environment

What is happening and why is it wrong?

If I pass in a Clifford circuit to the OBP method, it can backpropagate over the entire circuit (since the number of terms in the operator does not increase). The truncated/backpropagated effective circuit will only be a trivial circuit with all qubits initialised in |0>. However, passing in such a clifford circuit through the OBP structure produces a NoneType object for the backpropagated circuit instead of a trivial one, thus restricting the following steps of execution.

How can we reproduce the issue?

` from qiskit.quantum_info import random_clifford from qiskit_addon_obp.utils.simplify import OperatorBudget from qiskit.quantum_info import SparsePauliOp from qiskit_addon_obp import backpropagate

cliff = random_clifford(num_qubits=6, seed=10) clifford_circuit = cliff.to_circuit() op_budget = OperatorBudget(max_qwc_groups=8) # exact value doesn't matter here observable = SparsePauliOp("Z"*clifford_circuit.num_qubits) bp_obs, remaining_slices, metadata = backpropagate(observable, slices, operator_budget=op_budget)

bp_circuit = combine_slices(remaining_slices, include_barriers=True) bp_circuit.draw('mpl') `

The draw function itself throws error because bp_circuit is not a QuantumCircuit object, but is NoneType

Traceback

No response

Any suggestions?

For such a scenario, where backpropagation leads to a trivial backpropagated circuit, the output should be a QuantumCircuit object with the same number of qubits. The simples bypass can be if remaining_slices is [], change the NoneType bp_circuit to QuantumCircuit(num_qubits).

caleb-johnson commented 3 days ago

Thanks, @ritajitmajumdar1 . Indeed this breaks the tutorial. I think we can add a conditional block to that cell which does something if the entire circuit was back-propagated.

I'm not certain this is a bug, as backpropagate is expected to return an empty list if all slices were back-propagated, and combine_slices is expected to return None if passed an empty list.

Leaving this open, as I believe we can tidy up the tutorial some here