CQCL / pytket-qiskit

pytket-qiskit, extensions for pytket quantum SDK
Apache License 2.0
16 stars 13 forks source link

Support `QuantumCircuit.if_test` in `qiskit_to_tk` #415

Open vtomole opened 1 week ago

vtomole commented 1 week ago
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 commented 1 week ago

Hi, thanks for making an issue.

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