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

Handle register conditions/multiple bits for IfElseOp in qiskit_to_tk #452

Open
CalMacCQ opened this issue Jan 23, 2025 · 2 comments
Open
Assignees
Labels
circuit_conversion Issues and pull requests related to coverting qiskit circuits to pytket and vice versa enhancement New feature or request good first issue Good for newcomers

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Jan 23, 2025

After #437 we can now convert circuits containing IfElseOp instructions to equivalent pytket circuits with qiskit_to_tk

Currently the conversion is limited to conditions on single bits and gives a NotImplemtedError when we try to convert an If-else conditioned on a register.

It shouldn't be much work to remove the restriction to a single bits and convert a wider range of operations

Example (taken from the tests)

from qiskit import QuantumCircuit
from qiskit import QuantumRegister, ClassicalRegister

qreg = QuantumRegister(2, "q")
creg = ClassicalRegister(2, "c")
circuit = QuantumCircuit(creg, qreg)
(q0, q1) = qreg
(c0, c1) = creg

circuit.h(q0)
circuit.h(q1)
circuit.measure(q0, c0)
circuit.measure(q1, c1)
# Condition is on a register not a bit
with circuit.if_test((creg, 2)):
    circuit.x(q0)
    circuit.x(q1)
circuit.measure(q0, c0)
circuit.measure(q1, c1)
@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 Jan 23, 2025
@CalMacCQ CalMacCQ added the good first issue Good for newcomers label Jan 23, 2025
@cqc-alec
Copy link
Collaborator

This is kinda blocking #438 since it's needed to make round-trip tests work once we use if_test instead of c_if in tk_to_qiskit().

@CalMacCQ
Copy link
Contributor Author

Good spot, probably worth prioritising then

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 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants