Format update using black formatter
This commit is contained in:
@@ -5,7 +5,7 @@ from qibo.states import CircuitResult
|
|||||||
from qibo.config import raise_error
|
from qibo.config import raise_error
|
||||||
|
|
||||||
|
|
||||||
class QuTensorNet(NumpyBackend):
|
class QuTensorNet(NumpyBackend):
|
||||||
|
|
||||||
def __init__(self, runcard):
|
def __init__(self, runcard):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -16,7 +16,6 @@ class QuTensorNet(NumpyBackend):
|
|||||||
self.NCCL_enabled = runcard.get("NCCL_enabled", False)
|
self.NCCL_enabled = runcard.get("NCCL_enabled", False)
|
||||||
self.expectation_enabled_value = runcard.get("expectation_enabled", False)
|
self.expectation_enabled_value = runcard.get("expectation_enabled", False)
|
||||||
|
|
||||||
|
|
||||||
mps_enabled_value = runcard.get("MPS_enabled")
|
mps_enabled_value = runcard.get("MPS_enabled")
|
||||||
if mps_enabled_value is True:
|
if mps_enabled_value is True:
|
||||||
self.MPS_enabled = True
|
self.MPS_enabled = True
|
||||||
@@ -35,7 +34,6 @@ class QuTensorNet(NumpyBackend):
|
|||||||
self.quimb = quimb
|
self.quimb = quimb
|
||||||
self.platform = "qutensornet"
|
self.platform = "qutensornet"
|
||||||
self.versions["quimb"] = self.quimb.__version__
|
self.versions["quimb"] = self.quimb.__version__
|
||||||
|
|
||||||
|
|
||||||
def apply_gate(self, gate, state, nqubits): # pragma: no cover
|
def apply_gate(self, gate, state, nqubits): # pragma: no cover
|
||||||
raise_error(NotImplementedError, "QiboTN cannot apply gates directly.")
|
raise_error(NotImplementedError, "QiboTN cannot apply gates directly.")
|
||||||
@@ -46,13 +44,10 @@ class QuTensorNet(NumpyBackend):
|
|||||||
def assign_measurements(self, measurement_map, circuit_result):
|
def assign_measurements(self, measurement_map, circuit_result):
|
||||||
raise_error(NotImplementedError, "Not implemented in QiboTN.")
|
raise_error(NotImplementedError, "Not implemented in QiboTN.")
|
||||||
|
|
||||||
|
|
||||||
def set_precision(self, precision):
|
def set_precision(self, precision):
|
||||||
if precision != self.precision:
|
if precision != self.precision:
|
||||||
super().set_precision(precision)
|
super().set_precision(precision)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute_circuit(
|
def execute_circuit(
|
||||||
self, circuit, initial_state=None, nshots=None, return_array=False
|
self, circuit, initial_state=None, nshots=None, return_array=False
|
||||||
): # pragma: no cover
|
): # pragma: no cover
|
||||||
@@ -77,7 +72,9 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.expectation_enabled == False
|
and self.expectation_enabled == False
|
||||||
):
|
):
|
||||||
|
|
||||||
state = eval.dense_vector_tn_qu(circuit, init_state, is_mps=False, backend="numpy")
|
state = eval.dense_vector_tn_qu(
|
||||||
|
circuit, init_state, is_mps=False, backend="numpy"
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == False
|
self.MPI_enabled == False
|
||||||
@@ -85,9 +82,10 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.NCCL_enabled == False
|
and self.NCCL_enabled == False
|
||||||
and self.expectation_enabled == False
|
and self.expectation_enabled == False
|
||||||
):
|
):
|
||||||
|
|
||||||
|
|
||||||
state = eval.dense_vector_tn_qu(circuit, init_state, is_mps=True, backend="numpy")
|
state = eval.dense_vector_tn_qu(
|
||||||
|
circuit, init_state, is_mps=True, backend="numpy"
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == True
|
self.MPI_enabled == True
|
||||||
@@ -95,19 +93,19 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.NCCL_enabled == False
|
and self.NCCL_enabled == False
|
||||||
and self.expectation_enabled == False
|
and self.expectation_enabled == False
|
||||||
):
|
):
|
||||||
|
|
||||||
raise_error(NotImplementedError, "QiboTN quimb backend cannot support MPI.")
|
raise_error(NotImplementedError, "QiboTN quimb backend cannot support MPI.")
|
||||||
|
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == False
|
self.MPI_enabled == False
|
||||||
and self.MPS_enabled == False
|
and self.MPS_enabled == False
|
||||||
and self.NCCL_enabled == True
|
and self.NCCL_enabled == True
|
||||||
and self.expectation_enabled == False
|
and self.expectation_enabled == False
|
||||||
):
|
):
|
||||||
|
|
||||||
raise_error(NotImplementedError, "QiboTN quimb backend cannot support NCCL.")
|
|
||||||
|
|
||||||
|
raise_error(
|
||||||
|
NotImplementedError, "QiboTN quimb backend cannot support NCCL."
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == False
|
self.MPI_enabled == False
|
||||||
@@ -115,9 +113,10 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.NCCL_enabled == False
|
and self.NCCL_enabled == False
|
||||||
and self.expectation_enabled == True
|
and self.expectation_enabled == True
|
||||||
):
|
):
|
||||||
|
|
||||||
raise_error(NotImplementedError, "QiboTN quimb backend cannot support expectation")
|
|
||||||
|
|
||||||
|
raise_error(
|
||||||
|
NotImplementedError, "QiboTN quimb backend cannot support expectation"
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == True
|
self.MPI_enabled == True
|
||||||
@@ -125,7 +124,9 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.NCCL_enabled == False
|
and self.NCCL_enabled == False
|
||||||
and self.expectation_enabled == True
|
and self.expectation_enabled == True
|
||||||
):
|
):
|
||||||
raise_error(NotImplementedError, "QiboTN quimb backend cannot support expectation")
|
raise_error(
|
||||||
|
NotImplementedError, "QiboTN quimb backend cannot support expectation"
|
||||||
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
self.MPI_enabled == False
|
self.MPI_enabled == False
|
||||||
@@ -133,7 +134,9 @@ class QuTensorNet(NumpyBackend):
|
|||||||
and self.NCCL_enabled == True
|
and self.NCCL_enabled == True
|
||||||
and self.expectation_enabled == True
|
and self.expectation_enabled == True
|
||||||
):
|
):
|
||||||
raise_error(NotImplementedError, "QiboTN quimb backend cannot support expectation")
|
raise_error(
|
||||||
|
NotImplementedError, "QiboTN quimb backend cannot support expectation"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise_error(NotImplementedError, "Compute type not supported.")
|
raise_error(NotImplementedError, "Compute type not supported.")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user