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

Conversion of ClExprOp should handle bitwise operations on more than 2 bits #191

Open
cqc-alec opened this issue Dec 17, 2024 · 0 comments

Comments

@cqc-alec
Copy link
Collaborator

The following circuit runs successfully if submitted with QASM, but not if submitted with QIR:

from pytket.circuit import Circuit, ClBitVar, ClExpr, ClOp, WiredClExpr
from pytket.extensions.quantinuum import QuantinuumBackend, Language

c = Circuit(1).H(0)
ancilla_bits = c.add_c_register("a", 7)
syndrome_bits = c.add_c_register("s", 3)

expr = ClExpr(op=ClOp.BitXor, args=[ClBitVar(i) for i in range(4)])
wexpr = WiredClExpr(expr=expr, bit_posn={i: i for i in range(4)}, output_posn=[4])
c.add_clexpr(
    wexpr,
    [
        ancilla_bits[2],
        ancilla_bits[3],
        ancilla_bits[5],
        ancilla_bits[6],
        syndrome_bits[2],
    ],
)

b = QuantinuumBackend("H1-1E")
c1 = b.get_compiled_circuit(c)
h = b.process_circuit(c1, n_shots=10, language=Language.QASM)
r = b.get_result(h)
print(r.get_counts())

With QIR submission, we get an error from the QIR conversion:

  File "/home/alec/r/pytket-quantinuum/env/lib/python3.12/site-packages/pytket/qir/conversion/qirgenerator.py", line 832, in _get_ssa_from_clexpr_arg
    return True, _TK_CLEXPR_OP_TO_PYQIR[expr_op](self.module.builder)(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Builder.xor() takes 2 positional arguments but 4 were given
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant