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

Support QuantumCircuit.if_test in qiskit_to_tk #415

Open
vtomole opened this issue Nov 8, 2024 · 2 comments
Open

Support QuantumCircuit.if_test in qiskit_to_tk #415

vtomole opened this issue Nov 8, 2024 · 2 comments
Assignees
Labels
circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa enhancement New feature or request

Comments

@vtomole
Copy link

vtomole commented Nov 8, 2024

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from pytket.extensions.qiskit import qiskit_to_tk
 
qubits = QuantumRegister(1)
clbits = ClassicalRegister(1)
circuit = QuantumCircuit(qubits, clbits)
(q0,) = qubits
(c0,) = clbits
 
circuit.h(q0)
circuit.measure(q0, c0)
with circuit.if_test((c0, 1)):
    circuit.x(q0)
circuit.measure(q0, c0)
 
tket_circ = qiskit_to_tk(circuit)

Errors with

  348     return optype
    349 except KeyError:
--> 350     raise NotImplementedError(
    351         f"Conversion of qiskit's {instruction.name} instruction is "
    352         + "currently unsupported by qiskit_to_tk. Consider "
    353         + "using QuantumCircuit.decompose() before attempting "
    354         + "conversion."
    355     )

NotImplementedError: Conversion of qiskit's if_else instruction is currently unsupported by qiskit_to_tk. Consider using QuantumCircuit.decompose() before attempting conversion.

on pytket-qiskit ==0.58.0

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Nov 9, 2024

Hi, thanks for making an issue.

This would be useful for sure. We should add this in soon.

@CalMacCQ CalMacCQ added enhancement New feature or request circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa labels Nov 9, 2024
@CalMacCQ CalMacCQ changed the title Support QuantumCircuit.if_test in qikit_to_tk Support QuantumCircuit.if_test in qiskit_to_tk Nov 9, 2024
@CalMacCQ
Copy link
Contributor

CalMacCQ commented Dec 18, 2024

I haven't forgotten about this issue. I think it'd be great to handle this as some IBM devices have IfElseOp as a native operation. Its also the recommended way to do conditional logic in qiskit as far as I understand.

The best way I can think of to handle this is to handle the if and else circuits as classically controlled CircBoxes.

I made an attempt at implementing this conversion in #437 but the PR is still a bit of a mess. I don't think this will be in the 0.62 release (we are planning to release today) but it should be in 0.63 for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants