Skip to content
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

OBP on clifford circuit produces a NoneType backpropagated circuit #16

Open
ritajitmajumdar1 opened this issue Sep 26, 2024 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@ritajitmajumdar1
Copy link

Environment

  • qiskit-addon-obp version: 0.1.0
  • Python version: 3.12.1
  • Operating system: Mac Sonoma 14.3.1 (23D60)

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).

@ritajitmajumdar1 ritajitmajumdar1 added the bug Something isn't working label Sep 26, 2024
@caleb-johnson
Copy link
Collaborator

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

@caleb-johnson caleb-johnson added documentation Improvements or additions to documentation and removed bug Something isn't working labels Sep 26, 2024
@caleb-johnson caleb-johnson self-assigned this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants