API documentation¶
- class pytket.extensions.braket.backends.braket.BraketBackend(local=False, local_device='default', device=None, region='', s3_bucket=None, s3_folder=None, device_type=None, provider=None, aws_session=None, verbatim=False)[source]¶
Interface to Amazon Braket service
- classmethod available_devices(**kwargs)[source]¶
See
pytket.backends.backend.Backend.available_devices()
. Supported kwargs:region (default None). The particular AWS region to search for devices (e.g. us-east-1). Default to the region configured with AWS. See the Braket docs for more details.
aws_session (default None). The credentials of the provided session will be used to create a new session with the specified region. Otherwise, a default new session will be created
- Return type:
- Returns:
A list of BackendInfo objects describing available devices.
- cancel(handle)[source]¶
Cancel a job.
- Parameters:
handle (
ResultHandle
) – handle to job- Raises:
NotImplementedError – If backend does not support job cancellation
- Return type:
- 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=2)[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
) –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.
- Return type:
- Returns:
Compilation pass guaranteeing required predicates.
- get_amplitudes(circuit, states, valid_check=True, **kwargs)[source]¶
Compute the complex coefficients of the final state.
Supported kwargs are as for
process_circuits()
.
- get_operator_expectation_value(state_circuit, operator, n_shots=0, valid_check=True, **kwargs)[source]¶
Compute the (exact or empirical) expectation of the observed eigenvalues.
See
pytket.utils.get_operator_expectation_value()
.If n_shots > 0 the probabilities are calculated empirically by measurements. If n_shots = 0 (if supported) they are calculated exactly by simulation.
Supported kwargs are as for
get_pauli_expectation_value()
.- Return type:
float64
- get_operator_variance(state_circuit, operator, n_shots=0, valid_check=True, **kwargs)[source]¶
Compute the (exact or empirical) variance of the observed eigenvalues.
See
pytket.utils.get_operator_expectation_value()
.If n_shots > 0 the probabilities are calculated empirically by measurements. If n_shots = 0 (if supported) they are calculated exactly by simulation.
Supported kwargs are as for
get_pauli_expectation_value()
.- Return type:
float64
- get_pauli_expectation_value(state_circuit, pauli, n_shots=0, valid_check=True, **kwargs)[source]¶
Compute the (exact or empirical) expectation of the observed eigenvalues.
See
pytket.utils.get_pauli_expectation_value()
.If n_shots > 0 the probabilities are calculated empirically by measurements. If n_shots = 0 (if supported) they are calculated exactly by simulation.
Supported kwargs (not valid for local simulator):
poll_timeout_seconds (int) : Polling timeout for synchronous retrieval of result, in seconds (default: 5 days).
poll_interval_seconds (int) : Polling interval for synchronous retrieval of result, in seconds (default: 1 second).
- Return type:
float64
- Returns:
\(\left<\psi | P | \psi \right>\)
- get_pauli_variance(state_circuit, pauli, n_shots=0, valid_check=True, **kwargs)[source]¶
Compute the (exact or empirical) variance of the observed eigenvalues.
See
pytket.utils.get_pauli_expectation_value()
.If n_shots > 0 the probabilities are calculated empirically by measurements. If n_shots = 0 (if supported) they are calculated exactly by simulation.
Supported kwargs are as for
get_pauli_expectation_value()
.- Return type:
float64
- get_probabilities(circuit, qubits=None, n_shots=0, valid_check=True, **kwargs)[source]¶
Compute the (exact or empirical) probability distribution of outcomes.
If n_shots > 0 the probabilities are calculated empirically by measurements. If n_shots = 0 (if supported) they are calculated exactly by simulation.
Supported kwargs are as for
process_circuits()
.The order is big-endian with respect to the order of qubits in the argument. For example, if qubits=[0,1] then the order of probabilities is [p(0,0), p(0,1), p(1,0), p(1,1)], while if qubits=[1,0] the order is [p(0,0), p(1,0), p(0,1), p(1,1)], where p(i,j) is the probability of qubit 0 being in state i and qubit 1 being in state j.
- get_result(handle, **kwargs)[source]¶
See
pytket.backends.backend.Backend.get_result()
. Supported kwargs: timeout (default none), wait (default 1s).- Return type:
- process_circuits(circuits, n_shots=None, valid_check=True, **kwargs)[source]¶
Supported kwargs: :rtype:
list
[ResultHandle
]postprocess: apply end-of-circuit simplifications and classical postprocessing to improve fidelity of results (bool, default False)
simplify_initial: apply the pytket
pytket.passes.SimplifyInitial()
pass to improve fidelity of results assuming all qubits initialized to zero (bool, default False)
- 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).
- Return type:
- Returns:
Compilation pass that converts gates to primitives supported by Backend.
- 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.
- property required_predicates: list[Predicate]¶
The minimum set of predicates that a circuit must satisfy before it can be successfully run on this backend.
- Returns:
Required predicates.
- property supports_amplitude: bool¶
Whether the backend support calculation of final state amplitudes
- class pytket.extensions.braket.backends.config.BraketConfig(s3_bucket, s3_folder, device_type, provider)[source]¶
Holds config parameters for pytket-braket.
- pytket.extensions.braket.backends.config.set_braket_config(s3_bucket=None, s3_folder=None, device_type=None, provider=None)[source]¶
Set default values for any of s3_bucket, s3_folder, device_type or provider for AWS Braket. Can be overridden in backend construction.
- Return type:
- pytket.extensions.braket.braket_convert.braket_to_tk(bkcirc)[source]¶
Convert a braket circuit to a tket
Circuit
- Parameters:
bkcirc (
Circuit
) – circuit to be converted- Return type:
- Returns:
circuit converted to tket
- pytket.extensions.braket.braket_convert.get_avg_characterisation(characterisation)[source]¶
Convert gate-specific characterisation into readout, one- and two-qubit errors
Used to convert the stored full characterisation into an input noise characterisation for NoiseAwarePlacement
- pytket.extensions.braket.braket_convert.tk_to_braket(tkcirc, mapped_qubits=False, forced_qubits=None, force_ops_on_target_qubits=False)[source]¶
Convert a tket
Circuit
to a braket circuit.- Parameters:
tkcirc (
Circuit
) – circuit to be convertedmapped_qubits (
bool
) – if True, tkcirc must have a single one-dimensional qubit register; the indices of the qubits in that register correspond directly to the qubit identifiers in the braket circuitforced_qubits (
list
[int
] |None
) – optional list of braket qubit identifiers to include in the converted circuit even if they are unusedforce_ops_on_target_qubits (
bool
) – if True, add no-ops to all target qubits
- Return type:
- Returns:
circuit converted to braket; list of braket qubit ids corresponding in order of corresponding positions in tkcirc.qubits; (partial) map from braket qubit ids to corresponding pytket bit indices holding measurement results