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

Number of bits not preserved in tk_to_qiskit conversion with RangePredicate #410

Open
CalMacCQ opened this issue Oct 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Oct 29, 2024

Whilst looking into #375 I found that the number of bits was not preserved in the tk_to_qiskit conversion. I think this may well be the cause of the KeyError issue.

from pytket import Circuit, OpType
from pytket.circuit.logic_exp import reg_eq
from pytket.extensions.qiskit import tk_to_qiskit


main_circ = Circuit(2, 2, "main_circ")

creg_0 = main_circ.add_c_register("creg_0", 2)

main_circ.add_gate(OpType.CH,[0, 1], condition = reg_eq(creg_0, 3))

main_circ.measure_all()
print(main_circ.n_bits) # gives 5

Image

But if I convert to a qiskit QuantumCircuit...

qc = tk_to_qiskit(main_circ)
print(qc.num_clbits) # gives 4

We only get 4 bits in the converted qiskit circuit. it seems the tk_SCRATCH_BIT[0] bit is lost in the conversion.

@CalMacCQ CalMacCQ added the bug Something isn't working label Oct 29, 2024
@CalMacCQ CalMacCQ changed the title Number of bits not preserved in tk_to_qiskit conversion Number of bits not preserved in tk_to_qiskit conversion with RangePredicate Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant