chore: Run pre-commit on all files

This commit is contained in:
Alessandro Candido
2024-02-07 11:21:27 +01:00
parent c3a4a544b5
commit e496f9f156
10 changed files with 92 additions and 72 deletions

View File

@@ -1,11 +1,10 @@
from cuquantum import contract, contract_path, CircuitToEinsum, tensor
from cuquantum import contract, contract_path
# Reference: https://github.com/NVIDIA/cuQuantum/blob/main/python/samples/cutensornet/tn_algorithms/mps_algorithms.ipynb
class MPSContractionHelper:
"""
A helper class to compute various quantities for a given MPS.
"""A helper class to compute various quantities for a given MPS.
Interleaved format is used to construct the input args for `cuquantum.contract`.
A concrete example on how the modes are populated for a 7-site MPS is provided below:
@@ -43,8 +42,8 @@ class MPSContractionHelper:
]
def contract_norm(self, mps_tensors, options=None):
"""
Contract the corresponding tensor network to form the norm of the MPS.
"""Contract the corresponding tensor network to form the norm of the
MPS.
Args:
mps_tensors: A list of rank-3 ndarray-like tensor objects.
@@ -64,8 +63,8 @@ class MPSContractionHelper:
return self._contract(interleaved_inputs, options=options).real
def contract_state_vector(self, mps_tensors, options=None):
"""
Contract the corresponding tensor network to form the state vector representation of the MPS.
"""Contract the corresponding tensor network to form the state vector
representation of the MPS.
Args:
mps_tensors: A list of rank-3 ndarray-like tensor objects.
@@ -86,8 +85,8 @@ class MPSContractionHelper:
def contract_expectation(
self, mps_tensors, operator, qubits, options=None, normalize=False
):
"""
Contract the corresponding tensor network to form the expectation of the MPS.
"""Contract the corresponding tensor network to form the expectation of
the MPS.
Args:
mps_tensors: A list of rank-3 ndarray-like tensor objects.