jaqalpaq.transpilers.tket package¶
- class jaqalpaq.transpilers.tket.JaqalBackend(backend_name: str, emulator: Optional[jaqalpaq.emulator.backend.AbstractBackend] = None)¶
Bases:
pytket.backends.backend.Backend
A t|ket> backend representation of the Jaqal emulator. Does not support circuits with multiple subcircuits. Except as described below, this conforms in all respects to the t|ket> backend API; see its documentation for details and usage.
- Parameters
backend_name (str) – Label this backend for internal t|ket> reference.
emulator (
jaqalpaq.emulator.AbstractBackend
or None) – Pass a backend instance to use. If omitted, instantiates a newjaqalpaq.emulator.UnitarySerializedEmulator
, which in practice should usually be the desired usage.
- property backend_info: pytket.backends.backendinfo.BackendInfo¶
Retrieve all Backend properties in a BackendInfo object, including device architecture, supported gate set, gate errors and other hardware-specific information.
- Returns
The BackendInfo describing this backend if it exists.
- Return type
Optional[BackendInfo]
- property characterisation: Optional[Dict[str, Any]]¶
Retrieve the characterisation targeted by the backend if it exists.
- Returns
The characterisation that this backend targets if it exists. The characterisation object contains device-specific information such as gate error rates.
- Return type
Optional[dict]
- circuit_status(handle: pytket.backends.resulthandle.ResultHandle) pytket.backends.status.CircuitStatus ¶
Return a CircuitStatus reporting the status of the circuit execution corresponding to the ResultHandle
- default_compilation_pass(optimisation_level: int = 1) pytket._tket.passes.BasePass ¶
A suggested compilation pass that will guarantee the resulting circuit will be suitable to run on this backend with as few preconditions as possible.
- Parameters
optimisation_level (int, optional) – The level of optimisation to perform during compilation. Level 0 just solves the device constraints without optimising. Level 1 additionally performs some light optimisations. Level 2 adds more intensive optimisations that can increase compilation time for large circuits. Defaults to 1.
- Returns
Compilation pass guaranteeing required predicates.
- Return type
BasePass
- process_circuits(circuits: Sequence[pytket._tket.circuit.Circuit], n_shots: Optional[Union[int, Sequence[int]]] = None, valid_check: bool = True, **kwargs: Optional[Union[int, float]]) List[pytket.backends.resulthandle.ResultHandle] ¶
Submit circuits to the backend for running. The results will be stored in the backend’s result cache to be retrieved by the corresponding get_<data> method.
If the postprocess keyword argument is set to True, and the backend supports the feature (see
supports_contextual_optimisation()
), then contextual optimisatioons are applied before running the circuit and retrieved results will have any necessary classical postprocessing applied. This is not enabled by default.Use keyword arguments to specify parameters to be used in submitting circuits See specific Backend derived class for available parameters, from the following list:
seed: RNG seed for simulators
postprocess: if True, apply contextual optimisations
- Parameters
circuits (Sequence[Circuit]) – Circuits to process on the backend.
n_shots (Optional[Union[int, Iterable[int]], optional) – Number of shots to run per circuit. Optionally, this can be a list of shots specifying the number of shots for each circuit separately. None is to be used for state/unitary simulators. Defaults to None.
valid_check (bool, optional) – Explicitly check that all circuits satisfy all required predicates to run on the backend. Defaults to True
- Returns
Handles to results for each input circuit, as an interable in the same order as the circuits.
- Return type
List[ResultHandle]
- property required_predicates: List[pytket._tket.predicates.Predicate]¶
The minimum set of predicates that a circuit must satisfy before it can be successfully run on this backend.
- Returns
Required predicates.
- Return type
List[Predicate]
- jaqalpaq.transpilers.tket.jaqal_circuit_from_tket_circuit(tkc, native_gates=None, names=None, remove_measurements=False)¶
Converts a pytket Circuit object to a
jaqalpaq.core.Circuit
. The circuit will be structured as a sequence of parallel blocks, one for each Cirq Moment in the input. The circuit will be structured into a sequence of unscheduled blocks. All instructions between one barrier statement and the next will be put into an unscheduled block together. If thejaqalpaq.scheduler
is run on the circuit, as many as possible of those gates will be parallelized within each block, while maintaining the order of the blocks. Otherwise, the circuit will be treated as a fully sequential circuit.Measurement commands are supported, but only if applied to every qubit in the circuit in immediate succession. If so, they will be mapped to a measure_all gate. If the circuit does not end with a measurement, then a measure_all gate will be appended to it.
Circuits containing multiple quantum registers will be converted to circuits with a single quantum register, containing all the qubits from each register. The parts of that larger register that correspond to each of the original registers will be mapped with the appropriate names. Circuits containing multiple-index qubits will have each such qubit mapped to a single-qubit register named with the indices separated by underscore characters.
Measurements are supported, but only if applied to every qubit in the circuit in the same moment. If so, they will be mapped to a measure_all gate. If the measure_all gate is not the last gate in the circuit, a prepare_all gate will be inserted after it. Additionally, a prepare_all gate will be inserted before the first moment. If the circuit does not end with a measurement, then a measure_all gate will be appended.
- Parameters
tkc (pytket.circuit.Circuit) – The Circuit to convert.
names (dict or None) – A mapping from pytket OpTypes to functions taking qubits and gate angle parameters and returning a tuple of arguments for
jaqalpaq.core.Circuit.build_gate()
. If omitted, mapspytket.OpType.PhasedX
to the QSCOUTR
gate,pytket.OpType.Rz
to the QSCOUTRz
gate, andpytket.OpType.XXPhase
to the QSCOUTMS
gate. Thepytket.passes.SynthesizeUMD
compilation pass will compile a circuit into this basis.native_gates (dict or None) – The native gate set to target. If None, target the QSCOUT native gates.
remove_measurements (bool) – Ignore any measure statements in the original circuit and append a measure_all gate instead. Defaults to False.
- Returns
The same quantum circuit, converted to JaqalPaq.
- Return type
- Raises
JaqalError – If the circuit includes a gate not included in names.