qibotn.backends package#
- class qibotn.backends.MetaBackend#
Bases:
object
Meta-backend class which takes care of loading the qibotn backends.
- list_available() dict #
Lists all the available qibotn backends.
- static load(platform: str, runcard: dict = None) QibotnBackend #
Loads the backend.
- Parameters:
platform (str) – Name of the backend to load: either cutensornet or qutensornet.
runcard (dict) – Dictionary containing the simulation settings.
- Returns:
The loaded backend.
- Return type:
qibo.backends.abstract.Backend
Submodules#
qibotn.backends.abstract module#
- class qibotn.backends.abstract.QibotnBackend#
Bases:
ABC
- apply_gate(gate, state, nqubits)#
- apply_gate_density_matrix(gate, state, nqubits)#
- assign_measurements(measurement_map, circuit_result)#
- configure_tn_simulation(**config)#
Configure the TN simulation that will be performed.
- set_device(device)#
- set_precision(precision)#
qibotn.backends.cutensornet module#
- class qibotn.backends.cutensornet.CuTensorNet(runcard)#
Bases:
QibotnBackend
,NumpyBackend
Creates CuQuantum backend for QiboTN.
- cuda_type(dtype='complex64')#
Get CUDA Type.
- Parameters:
dtype (str, optional) – Either single (“complex64”) or double (complex128) precision. Defaults to “complex64”.
- Returns:
tuple of cuquantum.cudaDataType and cuquantum.ComputeType
- Return type:
CUDA Type
- execute_circuit(circuit, initial_state=None, nshots=None, return_array=False)#
Executes a quantum circuit using selected TN backend.
- Parameters:
circuit (
qibo.models.circuit.Circuit
) – Circuit to execute.initial_state (
qibo.models.circuit.Circuit
) – Circuit to prepare the initial state. IfNone
the default|00...0>
state is used.
- Returns:
If return_array is False, returns a QuantumState object representing the quantum state. If return_array is True, returns a numpy array representing the quantum state.
- Return type:
QuantumState or numpy.ndarray
qibotn.backends.qmatchatea module#
qibotn.backends.quimb module#
- class qibotn.backends.quimb.QuimbBackend#
Bases:
QibotnBackend
,NumpyBackend
- configure_tn_simulation(ansatz: str = 'MPS', max_bond_dimension: int = 10, n_most_frequent_states: int = 100)#
Configure tensor network simulation.
- Parameters:
ansatz – str, optional The tensor network ansatz to use. Currently, only “MPS” is supported. Default is “MPS”.
max_bond_dimension – int, optional The maximum bond dimension for the MPS ansatz. Default is 10.
Notes
The ansatz determines the tensor network structure used for simulation. Currently, only “MPS” is supported.
The max_bond_dimension parameter controls the maximum allowed bond dimension for the MPS ansatz.
- execute_circuit(circuit, initial_state=None, nshots=None, return_array=False, **prob_kwargs)#
Execute a quantum circuit using the specified tensor network ansatz and initial state.
- Parameters:
circuit – QuantumCircuit The quantum circuit to be executed.
initial_state – array-like, optional The initial state of the quantum system. Only supported for Matrix Product States (MPS) ansatz.
nshots – int, optional The number of shots for sampling the circuit. If None, no sampling is performed, and the full statevector is used.
return_array – bool, optional If True, returns the statevector as a dense array. Default is False.
n_most_frequent_states – int, optional The number of most frequent computational basis states to return. Default is 100.
**prob_kwargs – dict, optional Additional keyword arguments for probability computation (currently unused).
- Returns:
- TensorNetworkResult
An object containing the results of the circuit execution, including: - nqubits: Number of qubits in the circuit. - backend: The backend used for execution. - measures: The measurement frequencies if nshots is specified, otherwise None. - measured_probabilities: A dictionary of computational basis states and their probabilities. - prob_type: The type of probability computation used (currently “default”). - statevector: The final statevector as a dense array if return_array is True, otherwise None.
- Raises:
ValueError – If an initial state is provided but the ansatz is not “MPS”.
Notes
The ansatz determines the tensor network structure used for simulation. Currently, only “MPS” is supported.
If initial_state is provided, it must be compatible with the MPS ansatz.
The nshots parameter enables sampling from the circuit’s output distribution. If not specified, the full statevector is computed.
- setup_backend_specifics(qimb_backend='numpy')#
Setup backend specifics. :param qimb_backend: str
The backend to use for the quimb tensor network simulation.