Compiling without Querying Quantinuum API

This notebook contains an example of how to investigate circuits compiled for Quantinuum hardware without logging in or submitting to Quantinuum hardware. This may be useful if it is desired to explore circuit compilation in depth before submitting.

Circuit Preparation

A 2-qubit circuit is generated for submission to H-Series.

from pytket.circuit import Circuit

circuit = Circuit(2, name="Bell Test")
circuit.H(0)
circuit.CX(0, 1)
circuit.measure_all()
[H q[0]; CX q[0], q[1]; Measure q[0] --> c[0]; Measure q[1] --> c[1]; ]
from pytket.circuit.display import render_circuit_jupyter

render_circuit_jupyter(circuit)

Set up Backend

Set up a QuantinuumBackend object. The difference is the machine_debug option uses the default pytket-quantinuum options such as pytket’s version of the Quantinuum native gate set rather than querying the Quantinuum API for this information.

from pytket.extensions.quantinuum import QuantinuumBackend
from pytket.extensions.quantinuum.backends.api_wrappers import QuantinuumAPIOffline

machine = "H1-1E"
backend = QuantinuumBackend(
    device_name=machine, machine_debug=True, api_handler=QuantinuumAPIOffline()
)

Native Gate Set

End users can view the hard-coded native gate set for the Quantinuum backend using the following command.

backend._gate_set
{<OpType.Barrier: 8>,
 <OpType.WASM: 14>,
 <OpType.SetBits: 15>,
 <OpType.CopyBits: 16>,
 <OpType.RangePredicate: 17>,
 <OpType.ExplicitPredicate: 18>,
 <OpType.ExplicitModifier: 19>,
 <OpType.MultiBit: 20>,
 <OpType.Rz: 36>,
 <OpType.TK2: 44>,
 <OpType.Measure: 66>,
 <OpType.Reset: 68>,
 <OpType.PhasedX: 71>,
 <OpType.ZZMax: 73>,
 <OpType.ZZPhase: 76>,
 <OpType.ClassicalExpBox: 107>}

Circuit Compilation

Circuits can now be compiled with the get_compiled_circuit function without querying the Quantinuum API.

compiled_circuit = backend.get_compiled_circuit(circuit, optimisation_level=2)
render_circuit_jupyter(compiled_circuit)