qiboml.backends package#
- class qiboml.backends.MetaBackend[source]#
Bases:
object
Meta-backend class which takes care of loading the qiboml backends.
Submodules#
qiboml.backends.jax module#
- class qiboml.backends.jax.JaxBackend[source]#
Bases:
NumpyBackend
- set_precision(precision)[source]#
Set complex number precision.
- Parameters:
precision (str) – ‘single’ or ‘double’.
- cast(x, dtype=None, copy=False)[source]#
Cast an object as the array type of the current backend.
- Parameters:
x – Object to cast to array.
copy (bool) – If
True
a copy of the object is created in memory.
- sample_shots(probabilities, nshots)[source]#
Sample measurement shots according to a probability distribution.
- zero_density_matrix(nqubits)[source]#
Generate \(|000\cdots0\rangle\langle000\cdots0|\) density matrix as an array.
- plus_density_matrix(nqubits)[source]#
Generate \(|+++\cdots+\rangle\langle+++\cdots+|\) density matrix as an array.
- _abc_impl = <_abc._abc_data object>#
- _append_zeros(state, qubits, results)#
Helper method for collapse.
- _order_probabilities(probs, qubits, nqubits)#
Arrange probabilities according to the given
qubits
ordering.
- _test_regressions(name)#
Correct outcomes for tests that involve random numbers.
The outcomes of such tests depend on the backend.
- aggregate_shots(shots)#
Collect shots to a single array.
- apply_bitflips(noiseless_samples, bitflip_probabilities)#
- apply_channel(channel, state, nqubits)#
Apply a channel to state vector.
- apply_channel_density_matrix(channel, state, nqubits)#
Apply a channel to density matrix.
- apply_gate(gate, state, nqubits)#
Apply a gate to state vector.
- apply_gate_half_density_matrix(gate, state, nqubits)#
Apply a gate to one side of the density matrix.
- assert_allclose(value, target, rtol=1e-07, atol=0.0)#
- assert_circuitclose(circuit, target_circuit, rtol=1e-07, atol=0.0)#
- calculate_eigenvalues(matrix, k: int = 6, hermitian: bool = True)#
Calculate eigenvalues of a matrix.
- calculate_eigenvectors(matrix, k: int = 6, hermitian: bool = True)#
Calculate eigenvectors of a matrix.
- calculate_expectation_density_matrix(hamiltonian, state, normalize)#
Calculate expectation value of a density matrix given the observable matrix.
- calculate_expectation_state(hamiltonian, state, normalize)#
Calculate expectation value of a state vector given the observable matrix.
- calculate_frequencies(samples)#
Calculate measurement frequencies from shots.
- calculate_hamiltonian_matrix_product(matrix1, matrix2)#
Multiply two matrices.
- calculate_hamiltonian_state_product(matrix, state)#
Multiply a matrix to a state vector or density matrix.
- calculate_jacobian_matrix(circuit, parameters=None, initial_state=None, return_complex: bool = True)#
Calculate the Jacobian matrix of
circuit
with respect to varablesparams
.
- calculate_matrix_exp(a, matrix, eigenvectors=None, eigenvalues=None)#
Calculate matrix exponential of a matrix. If the eigenvectors and eigenvalues are given the matrix diagonalization is used for exponentiation.
- calculate_matrix_norm(state, order='nuc')#
Calculate norm of a \(2\)-dimensional array.
Default is the
nuclear
norm. Iforder="nuc"
, it returns the nuclear norm ofstate
, assumingstate
is Hermitian (also known as trace norm). For specifications on the other possible values of the parameterorder
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- calculate_matrix_power(matrix, power: Union[float, int], precision_singularity: float = 1e-14)#
Calculate the (fractional)
power
\(\alpha\) ofmatrix
\(A\), i.e. \(A^{\alpha}\).Note
For the
pytorch
backend, this method relies on a copy of the original tensor. This may break the gradient flow. For the GPU backends (i.e.cupy
andcuquantum
), this method falls back to CPU wheneverpower
is not an integer.
- calculate_overlap(state1, state2)#
Calculate overlap of two state vectors.
- calculate_overlap_density_matrix(state1, state2)#
Calculate overlap of two density matrices.
- calculate_probabilities(state, qubits, nqubits)#
Calculate probabilities given a state vector.
- calculate_probabilities_density_matrix(state, qubits, nqubits)#
Calculate probabilities given a density matrix.
- calculate_singular_value_decomposition(matrix)#
Calculate the Singular Value Decomposition of
matrix
.
- calculate_symbolic(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a state vector.
- calculate_symbolic_density_matrix(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a density matrix.
- calculate_vector_norm(state, order=2)#
Calculate norm of an \(1\)-dimensional array.
For specifications on possible values of the parameter
order
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- collapse_density_matrix(state, qubits, shot, nqubits, normalize=True)#
Collapse density matrix according to measurement shot.
- collapse_state(state, qubits, shot, nqubits, normalize=True)#
Collapse state vector according to measurement shot.
- compile(func)#
Compile the given method.
Available only for the tensorflow backend.
- property connectivity#
Return the available qubit pairs of the backend. If
SimulationBackend
, return None.
- depolarizing_error_density_matrix(gate, state, nqubits)#
- execute_circuit(circuit, initial_state=None, nshots=1000)#
Execute a
qibo.models.circuit.Circuit
.
- execute_circuit_repeated(circuit, nshots, initial_state=None)#
Execute the circuit nshots times to retrieve probabilities, frequencies and samples. Note that this method is called only if a unitary channel is present in the circuit (i.e. noisy simulation) and density_matrix=False, or if some collapsing measurement is performed.
- execute_circuits(circuits, initial_states=None, nshots=1000, processes=None)#
Execute multiple
qibo.models.circuit.Circuit
in parallel.
- execute_distributed_circuit(circuit, initial_state=None, nshots=None)#
Execute a
qibo.models.circuit.Circuit
using multiple GPUs.
- identity_density_matrix(nqubits, normalize: bool = True)#
Generate density matrix
\[\rho = \frac{1}{2^\text{nqubits}} \, \sum_{k=0}^{2^\text{nqubits} - 1} \, |k \rangle \langle k|\]if
normalize=True
. Ifnormalize=False
, returns the unnormalized Identity matrix, which is equivalent tonumpy.eye()
.
- is_sparse(x)#
Determine if a given array is a sparse tensor.
- matrix(gate)#
Convert a gate to its matrix representation in the computational basis.
- matrix_fused(fgate)#
Fuse matrices of multiple gates.
- matrix_parametrized(gate)#
Convert a parametrized gate to its matrix representation in the computational basis.
- property natives#
Return the native gates of the backend. If
SimulationBackend
, return None.
- property qubits#
Return the qubit names of the backend. If
SimulationBackend
, return None.
- reset_error_density_matrix(gate, state, nqubits)#
Apply reset error to density matrix.
- sample_frequencies(probabilities, nshots)#
Sample measurement frequencies according to a probability distribution.
- samples_to_binary(samples, nqubits)#
Convert samples from decimal representation to binary.
- samples_to_decimal(samples, nqubits)#
Convert samples from binary representation to decimal.
- set_device(device)#
Set simulation device.
- Parameters:
device (str) – Device such as ‘/CPU:0’, ‘/GPU:0’, etc.
- set_threads(nthreads)#
Set number of threads for CPU simulation.
- Parameters:
nthreads (int) – Number of threads.
- thermal_error_density_matrix(gate, state, nqubits)#
Apply thermal relaxation error to density matrix.
qiboml.backends.pytorch module#
PyTorch backend.
- class qiboml.backends.pytorch.TorchMatrices(dtype)[source]#
Bases:
NumpyMatrices
Matrix representation of every gate as a torch Tensor.
- Parameters:
dtype (torch.dtype) – Data type of the matrices.
- Align(delay, n=2)#
- property CCZ#
- property CNOT#
- CRX(theta)#
- CRY(theta)#
- CRZ(theta)#
- property CSX#
- property CSXDG#
- CU1(theta)#
- CU2(phi, lam)#
- CU3(theta, phi, lam)#
- property CY#
- property CZ#
- CallbackGate()#
- DEUTSCH(theta)#
- property ECR#
- property FSWAP#
- FusedGate()#
- GIVENS(theta)#
- GPI(phi)#
- GPI2(phi)#
- GeneralizedRBS(qubits_in, qubits_out, theta, phi)#
- GeneralizedfSim(u, phi)#
- property H#
- I(n=2)#
- M()#
- MS(phi0, phi1, theta)#
- PRX(theta, phi)#
- PartialTrace()#
- PauliNoiseChannel()#
- RBS(theta)#
- RX(theta)#
- RXX(theta)#
- RXXYY(theta)#
- RY(theta)#
- RYY(theta)#
- RZ(theta)#
- RZX(theta)#
- RZZ(theta)#
- ResetChannel()#
- property S#
- property SDG#
- property SWAP#
- property SX#
- property SXDG#
- property SYC#
- property SiSWAP#
- property SiSWAPDG#
- property T#
- property TDG#
- property TOFFOLI#
- ThermalRelaxationChannel()#
- U1(theta)#
- U1q(theta, phi)#
- U2(phi, lam)#
- U3(theta, phi, lam)#
- UnitaryChannel()#
- property X#
- property Y#
- property Z#
- fSim(theta, phi)#
- property iSWAP#
- class qiboml.backends.pytorch.PyTorchBackend[source]#
Bases:
NumpyBackend
- set_device(device)[source]#
Set simulation device.
- Parameters:
device (str) – Device such as ‘/CPU:0’, ‘/GPU:0’, etc.
- cast(x, dtype=None, copy: bool = False)[source]#
Casts input as a Torch tensor of the specified dtype.
This method supports casting of single tensors or lists of tensors as for the
qibo.backends.PyTorchBackend
.- Parameters:
x (Union[torch.Tensor, list[torch.Tensor], np.ndarray, list[np.ndarray], int, float, complex]) – Input to be casted.
dtype (Union[str, torch.dtype, np.dtype, type]) – Target data type. If
None
, the default dtype of the backend is used. Defaults toNone
.copy (bool, optional) – If
True
, the input tensor is copied before casting. Defaults toFalse
.
- matrix_parametrized(gate)[source]#
Convert a parametrized gate to its matrix representation in the computational basis.
- _order_probabilities(probs, qubits, nqubits)[source]#
Arrange probabilities according to the given
qubits
ordering.
- calculate_probabilities(state, qubits, nqubits)[source]#
Calculate probabilities given a state vector.
- sample_shots(probabilities, nshots)[source]#
Sample measurement shots according to a probability distribution.
- calculate_eigenvalues(matrix, k: int = 6, hermitian: bool = True)[source]#
Calculate eigenvalues of a matrix.
- calculate_eigenvectors(matrix, k: int = 6, hermitian: int = True)[source]#
Calculate eigenvectors of a matrix.
- calculate_matrix_exp(a, matrix, eigenvectors=None, eigenvalues=None)[source]#
Calculate matrix exponential of a matrix. If the eigenvectors and eigenvalues are given the matrix diagonalization is used for exponentiation.
- calculate_matrix_power(matrix, power: Union[float, int], precision_singularity: float = 1e-14)[source]#
Calculate the (fractional)
power
\(\alpha\) ofmatrix
\(A\), i.e. \(A^{\alpha}\).Note
For the
pytorch
backend, this method relies on a copy of the original tensor. This may break the gradient flow. For the GPU backends (i.e.cupy
andcuquantum
), this method falls back to CPU wheneverpower
is not an integer.
- calculate_jacobian_matrix(circuit, parameters=None, initial_state=None, return_complex: bool = True)[source]#
Calculate the Jacobian matrix of
circuit
with respect to varablesparams
.
- _test_regressions(name)[source]#
Correct outcomes for tests that involve random numbers.
The outcomes of such tests depend on the backend.
- _abc_impl = <_abc._abc_data object>#
- _append_zeros(state, qubits, results)#
Helper method for collapse.
- aggregate_shots(shots)#
Collect shots to a single array.
- apply_bitflips(noiseless_samples, bitflip_probabilities)#
- apply_channel(channel, state, nqubits)#
Apply a channel to state vector.
- apply_channel_density_matrix(channel, state, nqubits)#
Apply a channel to density matrix.
- apply_gate(gate, state, nqubits)#
Apply a gate to state vector.
- apply_gate_density_matrix(gate, state, nqubits)#
Apply a gate to density matrix.
- apply_gate_half_density_matrix(gate, state, nqubits)#
Apply a gate to one side of the density matrix.
- assert_allclose(value, target, rtol=1e-07, atol=0.0)#
- assert_circuitclose(circuit, target_circuit, rtol=1e-07, atol=0.0)#
- calculate_expectation_density_matrix(hamiltonian, state, normalize)#
Calculate expectation value of a density matrix given the observable matrix.
- calculate_expectation_state(hamiltonian, state, normalize)#
Calculate expectation value of a state vector given the observable matrix.
- calculate_frequencies(samples)#
Calculate measurement frequencies from shots.
- calculate_hamiltonian_matrix_product(matrix1, matrix2)#
Multiply two matrices.
- calculate_hamiltonian_state_product(matrix, state)#
Multiply a matrix to a state vector or density matrix.
- calculate_matrix_norm(state, order='nuc')#
Calculate norm of a \(2\)-dimensional array.
Default is the
nuclear
norm. Iforder="nuc"
, it returns the nuclear norm ofstate
, assumingstate
is Hermitian (also known as trace norm). For specifications on the other possible values of the parameterorder
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- calculate_overlap(state1, state2)#
Calculate overlap of two state vectors.
- calculate_overlap_density_matrix(state1, state2)#
Calculate overlap of two density matrices.
- calculate_probabilities_density_matrix(state, qubits, nqubits)#
Calculate probabilities given a density matrix.
- calculate_singular_value_decomposition(matrix)#
Calculate the Singular Value Decomposition of
matrix
.
- calculate_symbolic(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a state vector.
- calculate_symbolic_density_matrix(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a density matrix.
- calculate_vector_norm(state, order=2)#
Calculate norm of an \(1\)-dimensional array.
For specifications on possible values of the parameter
order
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- collapse_density_matrix(state, qubits, shot, nqubits, normalize=True)#
Collapse density matrix according to measurement shot.
- collapse_state(state, qubits, shot, nqubits, normalize=True)#
Collapse state vector according to measurement shot.
- compile(func)#
Compile the given method.
Available only for the tensorflow backend.
- property connectivity#
Return the available qubit pairs of the backend. If
SimulationBackend
, return None.
- depolarizing_error_density_matrix(gate, state, nqubits)#
- execute_circuit(circuit, initial_state=None, nshots=1000)#
Execute a
qibo.models.circuit.Circuit
.
- execute_circuit_repeated(circuit, nshots, initial_state=None)#
Execute the circuit nshots times to retrieve probabilities, frequencies and samples. Note that this method is called only if a unitary channel is present in the circuit (i.e. noisy simulation) and density_matrix=False, or if some collapsing measurement is performed.
- execute_circuits(circuits, initial_states=None, nshots=1000, processes=None)#
Execute multiple
qibo.models.circuit.Circuit
in parallel.
- execute_distributed_circuit(circuit, initial_state=None, nshots=None)#
Execute a
qibo.models.circuit.Circuit
using multiple GPUs.
- identity_density_matrix(nqubits, normalize: bool = True)#
Generate density matrix
\[\rho = \frac{1}{2^\text{nqubits}} \, \sum_{k=0}^{2^\text{nqubits} - 1} \, |k \rangle \langle k|\]if
normalize=True
. Ifnormalize=False
, returns the unnormalized Identity matrix, which is equivalent tonumpy.eye()
.
- matrix(gate)#
Convert a gate to its matrix representation in the computational basis.
- matrix_fused(fgate)#
Fuse matrices of multiple gates.
- property natives#
Return the native gates of the backend. If
SimulationBackend
, return None.
- plus_density_matrix(nqubits)#
Generate \(|+++\cdots+\rangle\langle+++\cdots+|\) density matrix as an array.
- plus_state(nqubits)#
Generate \(|+++\cdots+\rangle\) state vector as an array.
- property qubits#
Return the qubit names of the backend. If
SimulationBackend
, return None.
- reset_error_density_matrix(gate, state, nqubits)#
Apply reset error to density matrix.
- sample_frequencies(probabilities, nshots)#
Sample measurement frequencies according to a probability distribution.
- samples_to_binary(samples, nqubits)#
Convert samples from decimal representation to binary.
- samples_to_decimal(samples, nqubits)#
Convert samples from binary representation to decimal.
- set_precision(precision)#
Set complex number precision.
- Parameters:
precision (str) – ‘single’ or ‘double’.
- set_threads(nthreads)#
Set number of threads for CPU simulation.
- Parameters:
nthreads (int) – Number of threads.
- thermal_error_density_matrix(gate, state, nqubits)#
Apply thermal relaxation error to density matrix.
- update_frequencies(frequencies, probabilities, nsamples)#
- zero_density_matrix(nqubits)#
Generate \(|000\cdots0\rangle\langle000\cdots0|\) density matrix as an array.
- zero_state(nqubits)#
Generate \(|000 \cdots 0 \rangle\) state vector as an array.
qiboml.backends.tensorflow module#
- class qiboml.backends.tensorflow.TensorflowMatrices(dtype)[source]#
Bases:
NumpyMatrices
- Align(delay, n=2)#
- property CCZ#
- property CNOT#
- CRX(theta)#
- CRY(theta)#
- CRZ(theta)#
- property CSX#
- property CSXDG#
- CU1(theta)#
- CU2(phi, lam)#
- CU3(theta, phi, lam)#
- property CY#
- property CZ#
- CallbackGate()#
- DEUTSCH(theta)#
- property ECR#
- property FSWAP#
- FusedGate()#
- GIVENS(theta)#
- GPI(phi)#
- GPI2(phi)#
- GeneralizedRBS(qubits_in, qubits_out, theta, phi)#
- GeneralizedfSim(u, phi)#
- property H#
- I(n=2)#
- M()#
- MS(phi0, phi1, theta)#
- PRX(theta, phi)#
- PartialTrace()#
- PauliNoiseChannel()#
- RBS(theta)#
- RX(theta)#
- RXX(theta)#
- RXXYY(theta)#
- RY(theta)#
- RYY(theta)#
- RZ(theta)#
- RZX(theta)#
- RZZ(theta)#
- ResetChannel()#
- property S#
- property SDG#
- property SWAP#
- property SX#
- property SXDG#
- property SYC#
- property SiSWAP#
- property SiSWAPDG#
- property T#
- property TDG#
- property TOFFOLI#
- ThermalRelaxationChannel()#
- U1(theta)#
- U1q(theta, phi)#
- U2(phi, lam)#
- U3(theta, phi, lam)#
- UnitaryChannel()#
- property X#
- property Y#
- property Z#
- fSim(theta, phi)#
- property iSWAP#
- class qiboml.backends.tensorflow.TensorflowBackend[source]#
Bases:
NumpyBackend
- set_device(device)[source]#
Set simulation device.
- Parameters:
device (str) – Device such as ‘/CPU:0’, ‘/GPU:0’, etc.
- set_threads(nthreads)[source]#
Set number of threads for CPU simulation.
- Parameters:
nthreads (int) – Number of threads.
- cast(x, dtype=None, copy=False)[source]#
Cast an object as the array type of the current backend.
- Parameters:
x – Object to cast to array.
copy (bool) – If
True
a copy of the object is created in memory.
- zero_density_matrix(nqubits)[source]#
Generate \(|000\cdots0\rangle\langle000\cdots0|\) density matrix as an array.
- matrix_parametrized(gate)[source]#
Convert a parametrized gate to its matrix representation in the computational basis.
- execute_circuit(circuit, initial_state=None, nshots=1000)[source]#
Execute a
qibo.models.circuit.Circuit
.
- execute_circuit_repeated(circuit, nshots, initial_state=None)[source]#
Execute the circuit nshots times to retrieve probabilities, frequencies and samples. Note that this method is called only if a unitary channel is present in the circuit (i.e. noisy simulation) and density_matrix=False, or if some collapsing measurement is performed.
- sample_shots(probabilities, nshots)[source]#
Sample measurement shots according to a probability distribution.
- calculate_vector_norm(state, order=2)[source]#
Calculate norm of an \(1\)-dimensional array.
For specifications on possible values of the parameter
order
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- calculate_matrix_norm(state, order='nuc')[source]#
Calculate norm of a \(2\)-dimensional array.
Default is the
nuclear
norm. Iforder="nuc"
, it returns the nuclear norm ofstate
, assumingstate
is Hermitian (also known as trace norm). For specifications on the other possible values of the parameterorder
for thetensorflow
backend, please refer to tensorflow.norm. For all other backends, please refer to numpy.linalg.norm.
- calculate_eigenvalues(matrix, k: int = 6, hermitian: bool = True)[source]#
Calculate eigenvalues of a matrix.
- calculate_eigenvectors(matrix, k: int = 6, hermitian: bool = True)[source]#
Calculate eigenvectors of a matrix.
- calculate_matrix_exp(a, matrix, eigenvectors=None, eigenvalues=None)[source]#
Calculate matrix exponential of a matrix. If the eigenvectors and eigenvalues are given the matrix diagonalization is used for exponentiation.
- calculate_matrix_power(matrix, power: Union[float, int], precision_singularity: float = 1e-14)[source]#
Calculate the (fractional)
power
\(\alpha\) ofmatrix
\(A\), i.e. \(A^{\alpha}\).Note
For the
pytorch
backend, this method relies on a copy of the original tensor. This may break the gradient flow. For the GPU backends (i.e.cupy
andcuquantum
), this method falls back to CPU wheneverpower
is not an integer.
- calculate_singular_value_decomposition(matrix)[source]#
Calculate the Singular Value Decomposition of
matrix
.
- calculate_jacobian_matrix(circuit, parameters=None, initial_state=None, return_complex: bool = True)[source]#
Calculate the Jacobian matrix of
circuit
with respect to varablesparams
.
- _abc_impl = <_abc._abc_data object>#
- _append_zeros(state, qubits, results)#
Helper method for collapse.
- _order_probabilities(probs, qubits, nqubits)#
Arrange probabilities according to the given
qubits
ordering.
- aggregate_shots(shots)#
Collect shots to a single array.
- apply_bitflips(noiseless_samples, bitflip_probabilities)#
- apply_channel(channel, state, nqubits)#
Apply a channel to state vector.
- apply_channel_density_matrix(channel, state, nqubits)#
Apply a channel to density matrix.
- apply_gate(gate, state, nqubits)#
Apply a gate to state vector.
- apply_gate_density_matrix(gate, state, nqubits)#
Apply a gate to density matrix.
- apply_gate_half_density_matrix(gate, state, nqubits)#
Apply a gate to one side of the density matrix.
- assert_allclose(value, target, rtol=1e-07, atol=0.0)#
- assert_circuitclose(circuit, target_circuit, rtol=1e-07, atol=0.0)#
- calculate_expectation_density_matrix(hamiltonian, state, normalize)#
Calculate expectation value of a density matrix given the observable matrix.
- calculate_expectation_state(hamiltonian, state, normalize)#
Calculate expectation value of a state vector given the observable matrix.
- calculate_overlap(state1, state2)#
Calculate overlap of two state vectors.
- calculate_overlap_density_matrix(state1, state2)#
Calculate overlap of two density matrices.
- calculate_probabilities(state, qubits, nqubits)#
Calculate probabilities given a state vector.
- calculate_probabilities_density_matrix(state, qubits, nqubits)#
Calculate probabilities given a density matrix.
- calculate_symbolic(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a state vector.
- calculate_symbolic_density_matrix(state, nqubits, decimals=5, cutoff=1e-10, max_terms=20)#
Dirac representation of a density matrix.
- collapse_density_matrix(state, qubits, shot, nqubits, normalize=True)#
Collapse density matrix according to measurement shot.
- collapse_state(state, qubits, shot, nqubits, normalize=True)#
Collapse state vector according to measurement shot.
- property connectivity#
Return the available qubit pairs of the backend. If
SimulationBackend
, return None.
- depolarizing_error_density_matrix(gate, state, nqubits)#
- execute_circuits(circuits, initial_states=None, nshots=1000, processes=None)#
Execute multiple
qibo.models.circuit.Circuit
in parallel.
- execute_distributed_circuit(circuit, initial_state=None, nshots=None)#
Execute a
qibo.models.circuit.Circuit
using multiple GPUs.
- identity_density_matrix(nqubits, normalize: bool = True)#
Generate density matrix
\[\rho = \frac{1}{2^\text{nqubits}} \, \sum_{k=0}^{2^\text{nqubits} - 1} \, |k \rangle \langle k|\]if
normalize=True
. Ifnormalize=False
, returns the unnormalized Identity matrix, which is equivalent tonumpy.eye()
.
- property natives#
Return the native gates of the backend. If
SimulationBackend
, return None.
- plus_density_matrix(nqubits)#
Generate \(|+++\cdots+\rangle\langle+++\cdots+|\) density matrix as an array.
- plus_state(nqubits)#
Generate \(|+++\cdots+\rangle\) state vector as an array.
- property qubits#
Return the qubit names of the backend. If
SimulationBackend
, return None.
- reset_error_density_matrix(gate, state, nqubits)#
Apply reset error to density matrix.
- sample_frequencies(probabilities, nshots)#
Sample measurement frequencies according to a probability distribution.
- samples_to_decimal(samples, nqubits)#
Convert samples from binary representation to decimal.
- set_precision(precision)#
Set complex number precision.
- Parameters:
precision (str) – ‘single’ or ‘double’.
- set_seed(seed)#
Set the seed of the random number generator.
- thermal_error_density_matrix(gate, state, nqubits)#
Apply thermal relaxation error to density matrix.