CQCL / pytket-phir

pytket-phir is a circuit analyzer and translator from pytket to PHIR.
https://cqcl.github.io/pytket-phir/
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Additional Classical Operations #159

Closed daniel-mills-cqc closed 7 months ago

daniel-mills-cqc commented 7 months ago

There is a mismatch between the classical operations pytket-phir can handle and those that the pytket to qasm converters could handle - if the following OpType could be supported then we should have parity:

OpType.RangePredicate,
OpType.MultiBit,
OpType.ExplicitPredicate,
OpType.ExplicitModifier,
OpType.SetBits,
OpType.CopyBits,
OpType.ClassicalExpBox,
OpType.Conditional,

In particular:

from pytket import Circuit
from pytket.unit_id import BitRegister
from pytket.extensions.quantinuum import QuantinuumBackend, QuantinuumAPIOffline

api_offline = QuantinuumAPIOffline()
backend = QuantinuumBackend(device_name="H1-1LE", api_handler = api_offline)

circuit = Circuit()
target_reg = circuit.add_c_register(BitRegister(name=f"target_reg", size=1))
control_reg = circuit.add_c_register(BitRegister(name=f"control_reg", size=1))

circuit.add_c_not(
    arg_in=target_reg[0],
    arg_out=target_reg[0],
    condition=control_reg[0]
)

compiled_circuit = backend.get_compiled_circuit(circuit=circuit)
backend.run_circuit(
    circuit=compiled_circuit,
    n_shots=10
)

raises NotImplementedError.

qartik commented 7 months ago

might close #25

Asa-Kosto-QTM commented 7 months ago

I cannot reproduce a NotImplementedError from phirgen.py. When i run the file (using device_name='H1-1' instead of 'H1-1LE') I see this error: pytket.qasm.qasm.QASMUnsupportedError: Classical gate NOT not supported. The source of this error is line 206 of pytket/qasm/qasm.py, the NOT operation is missing from _classical_gatestr_map. Are you using a specific branch or doing anything else that might be helpful to know to reproduce the error?

cqc-alec commented 7 months ago

If you are using H1-1 then it won't be going via PHIR at all. But it sounds like there may be a second issue here if the QASM conversion is also failing. I'll check that...

cqc-alec commented 7 months ago

But it sounds like there may be a second issue here if the QASM conversion is also failing.

https://github.com/CQCL/tket/issues/1322