API documentation#
Module for conversion between ProjectQ and tket primitives.
- class pytket.extensions.projectq.ProjectQBackend#
Backend for running statevector simulations on the ProjectQ simulator.
- 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.passes.BasePass #
A suggested compilation pass that will will, if possible, produce an equivalent circuit suitable for running on this backend.
At a minimum it will ensure that compatible gates are used and that all two- qubit interactions are compatible with the backend’s qubit architecture. At higher optimisation levels, further optimisations may be applied.
This is a an abstract method which is implemented in the backend itself, and so is tailored to the backend’s requirements.
- Parameters
optimisation_level (int, optional) –
The level of optimisation to perform during compilation.
Level 0 does the minimum required to solves the device constraints, without any optimisation.
Level 1 additionally performs some light optimisations.
Level 2 (the default) adds more computationally intensive optimisations that should give the best results from execution.
- Returns
Compilation pass guaranteeing required predicates.
- Return type
- get_operator_expectation_value(state_circuit: pytket.circuit.Circuit, operator: pytket.utils.QubitPauliOperator, valid_check: bool = True) complex #
Calculates the expectation value of the given circuit with respect to the operator using the built-in ProjectQ functionality
- Parameters
state_circuit (Circuit) – Circuit that generates the desired state \(\left|\psi\right>\).
operator (QubitPauliOperator) – Operator \(H\). Must be Hermitian.
valid_check (bool, optional) – Explicitly check that the circuit satisfies all required predicates to run on the backend. Defaults to True
- Returns
\(\left<\psi | H | \psi \right>\)
- Return type
- get_pauli_expectation_value(state_circuit: pytket.circuit.Circuit, pauli: pytket.pauli.QubitPauliString, valid_check: bool = True) complex #
Calculates the expectation value of the given circuit using the built-in ProjectQ functionality
- Parameters
state_circuit (Circuit) – Circuit that generates the desired state \(\left|\psi\right>\).
pauli (QubitPauliString) – Pauli operator
valid_check (bool, optional) – Explicitly check that the circuit satisfies all required predicates to run on the backend. Defaults to True
- Returns
\(\left<\psi | P | \psi \right>\)
- Return type
- process_circuits(circuits: Sequence[pytket.circuit.Circuit], n_shots: Union[None, int, Sequence[Optional[int]]] = None, valid_check: bool = True, **kwargs: Optional[Union[int, float, str]]) List[pytket.backends.resulthandle.ResultHandle] #
See
pytket.backends.Backend.process_circuits()
. Supported kwargs: seed.
- rebase_pass() pytket.passes.BasePass #
A single compilation pass that when run converts all gates in a Circuit to an OpType supported by the Backend (ignoring architecture constraints).
- Returns
Compilation pass that converts gates to primitives supported by Backend.
- Return type
- 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 required_predicates: List[pytket.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]
- class pytket.extensions.projectq.tketBackendEngine#
A projectq backend designed to translate from projectq commands to tket Circuits
- is_available(cmd: projectq.ops._command.Command) bool #
Ask the next engine whether a command is available, i.e., whether it can be executed by the next engine(s).
- Raises
LastEngineException – If is_last_engine is True but is_available is not implemented.
- Parameters
cmd – Command for which to check availability.
- Returns
True if the command can be executed.
- property circuit: pytket.circuit.Circuit#
- Raises
NotImplementedError – If the Circuit has no gates, assumes user forgot to flush engines.
- Returns
The tket Circuit from the engine.
- class pytket.extensions.projectq.tketOptimiser#
A ProjectQ BasicEngine designed to translate from ProjectQ commands to tket Circuits, optimise them, and then return other ProjectQ commands.
- pytket.extensions.projectq.tk_to_projectq(engine: projectq.cengines._main.MainEngine, qureg: projectq.types._qubit.Qureg, circuit: pytket.circuit.Circuit, ignore_measures: bool = False) None #
Given a ProjectQ Qureg in an Engine, converts a Circuit to a series of ProjectQ Commands on this Qureg.
- Parameters
engine (MainEngine) – A ProjectQ MainEngine
qureg (Qureg) – A ProjectQ Qureg in this MainEngine
circuit (Circuit) – A tket Circuit