qibotn.backends package#
- class qibotn.backends.MetaBackend#
Bases:
objectMeta-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, **kwargs) 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=None)#
Bases:
QibotnBackend,NumpyBackendCreates CuQuantum backend for QiboTN.
- configure_tn_simulation(runcard)#
Configure the TN simulation that will be performed.
- 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. IfNonethe 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#
- qibotn.backends.quimb.configure_tn_simulation(self, ansatz: str = 'mps', max_bond_dimension: Optional[int] = None, svd_cutoff: Optional[float] = 1e-10, n_most_frequent_states: int = 100)#
Configure tensor network simulation.
- Parameters
ansatz – str, optional The tensor network ansatz to use. Default is None and, in this case, a generic Circuit Quimb class is used. 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.
- qibotn.backends.quimb.execute_circuit(self, circuit: Circuit, initial_state=None, nshots=None, return_array=False)#
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.
- 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.
- qibotn.backends.quimb.exp_value_observable_symbolic(self, circuit, operators_list, sites_list, coeffs_list, nqubits)#
Compute the expectation value of a symbolic Hamiltonian on a quantum circuit using tensor network contraction. This method takes a Qibo circuit, converts it to a Quimb tensor network circuit, and evaluates the expectation value of a Hamiltonian specified by three lists of strings: operators, sites, and coefficients. The expectation value is computed by summing the contributions from each term in the Hamiltonian, where each term’s expectation is calculated applying gates to the tensor network representation of the circuit and contracting it with the respective bra. Each operator string must act on all different qubits, i.e., for each term, the corresponding sites tuple must contain unique qubit indices. Example: operators_list = [‘xyz’, ‘xyz’], sites_list = [(1,2,3), (1,2,3)], coeffs_list = [1, 2]
- Parameters
circuit (qibo.models.Circuit) – The quantum circuit to evaluate, provided as a Qibo circuit object.
operators_list (list of str) – List of operator strings representing the symbolic Hamiltonian terms.
sites_list (list of tuple of int) – Tuples each specifying the qubits (sites) the corresponding operator acts on.
coeffs_list (list of real/complex) – The coefficients for each Hamiltonian term.
- Returns
The real part of the expectation value of the Hamiltonian on the given circuit state.
- Return type
float
- qibotn.backends.quimb.setup_backend_specifics(self, quimb_backend='numpy', contractions_optimizer='auto-hq')#
Setup backend specifics. :param quimb_backend: str
The backend to use for the quimb tensor network simulation.
- Parameters
contractions_optimizer – str, optional The contractions_optimizer to use for the quimb tensor network simulation.