Skip to content

Commit

Permalink
Format update using black formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
yangliwei committed Feb 7, 2024
1 parent 8e73b8c commit 853f721
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/qibotn/backends/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from qibo.config import raise_error


class QuTensorNet(NumpyBackend):
class QuTensorNet(NumpyBackend):

def __init__(self, runcard):
super().__init__()
Expand All @@ -16,7 +16,6 @@ def __init__(self, runcard):
self.NCCL_enabled = runcard.get("NCCL_enabled", False)
self.expectation_enabled_value = runcard.get("expectation_enabled", False)


mps_enabled_value = runcard.get("MPS_enabled")
if mps_enabled_value is True:
self.MPS_enabled = True
Expand All @@ -35,7 +34,6 @@ def __init__(self, runcard):
self.quimb = quimb
self.platform = "qutensornet"
self.versions["quimb"] = self.quimb.__version__


def apply_gate(self, gate, state, nqubits): # pragma: no cover
raise_error(NotImplementedError, "QiboTN cannot apply gates directly.")
Expand All @@ -46,13 +44,10 @@ def apply_gate_density_matrix(self, gate, state, nqubits): # pragma: no cover
def assign_measurements(self, measurement_map, circuit_result):
raise_error(NotImplementedError, "Not implemented in QiboTN.")


def set_precision(self, precision):
if precision != self.precision:
super().set_precision(precision)



def execute_circuit(
self, circuit, initial_state=None, nshots=None, return_array=False
): # pragma: no cover
Expand All @@ -77,63 +72,71 @@ def execute_circuit(
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 (
self.MPI_enabled == False
and self.MPS_enabled == True
and self.NCCL_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 (
self.MPI_enabled == True
and self.MPS_enabled == False
and self.NCCL_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 (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == True
and self.expectation_enabled == False
):

raise_error(NotImplementedError, "QiboTN quimb backend cannot support NCCL.")

raise_error(
NotImplementedError, "QiboTN quimb backend cannot support NCCL."
)

elif (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == True
):

raise_error(NotImplementedError, "QiboTN quimb backend cannot support expectation")

raise_error(
NotImplementedError, "QiboTN quimb backend cannot support expectation"
)

elif (
self.MPI_enabled == True
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == True
):
raise_error(NotImplementedError, "QiboTN quimb backend cannot support expectation")
raise_error(
NotImplementedError, "QiboTN quimb backend cannot support expectation"
)

elif (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_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:
raise_error(NotImplementedError, "Compute type not supported.")

Expand Down

0 comments on commit 853f721

Please sign in to comment.