CQCL / pytket-quantinuum

pytket-quantinuum, extensions for pytket quantum SDK
Apache License 2.0
29 stars 14 forks source link

`QuantinuumBackend` doesn't check `MaxNQubitsPredicate` #365

Closed CalMacCQ closed 9 months ago

CalMacCQ commented 9 months ago

Compiling a circuit for a H-Series device should fail if the circuit has more qubits than are available on the device.

However compiling a 50 qubit circuit for the H1 device doesn't cause an error

from pytket.extensions.quantinuum import QuantinuumBackend
from pytket import Circuit

circ = Circuit(50).H(0)

for i in range(49):
    circ.CX(i, i + 1)

backend = QuantinuumBackend("H1-1", machine_debug=True)

compiled_circ = backend.get_compiled_circuit(circ)

The MaxNQubitsPredicate isn't checked by the backend.

print(backend.required_predicates)

gives

[NoSymbolsPredicate, GateSetPredicate:{ Reset WASM Rz ZZMax ExplicitModifier PhasedX RangePredicate ClassicalExpBox ExplicitPredicate Barrier ZZPhase SetBits CopyBits MultiBit Measure }]
CalMacCQ commented 9 months ago

Seems the Predicate is added if machine_debug=False. The predicates themselves are checked by process_circuit as with most pytket Backends. Maybe we should leave this as is