API documentation¶
Module for conversion between ProjectQ and tket primitives.
- class pytket.extensions.projectq.ProjectQBackend[source]¶
Backend for running statevector simulations on the ProjectQ simulator.
- circuit_status(handle)[source]¶
Return a CircuitStatus reporting the status of the circuit execution corresponding to the ResultHandle
- Return type:
- default_compilation_pass(optimisation_level=1)[source]¶
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:
BasePass
- get_operator_expectation_value(state_circuit, operator, valid_check=True)[source]¶
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, pauli, valid_check=True)[source]¶
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, n_shots=None, valid_check=True, **kwargs)[source]¶
See
pytket.backends.Backend.process_circuits()
. Supported kwargs: seed.- Return type:
- rebase_pass()[source]¶
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:
BasePass
- property backend_info: 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]
- class pytket.extensions.projectq.tketBackendEngine[source]¶
A projectq backend designed to translate from projectq commands to tket Circuits
- is_available(cmd)[source]¶
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
) – Command for which to check availability.- Return type:
- Returns:
True if the command can be executed.
- class pytket.extensions.projectq.tketOptimiser[source]¶
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, qureg, circuit, ignore_measures=False)[source]¶
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
- Return type: