Skip to content

Commit

Permalink
Take out repeat codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankya2 committed Feb 9, 2024
1 parent ed686ee commit 38764f7
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/qibotn/backends/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,96 +110,70 @@ def execute_circuit(

import qibotn.eval as eval

if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

if (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state = eval.dense_vector_tn(circuit, self.dtype)

elif (
self.MPI_enabled == False
and self.MPS_enabled == True
and self.NCCL_enabled == False
and self.expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state = eval.dense_vector_mps(circuit, self.gate_algo, self.dtype)

elif (
self.MPI_enabled == True
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state, rank = eval.dense_vector_tn_MPI(circuit, self.dtype, 32)
if rank > 0:
state = np.array(0)

elif (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == True
and self.expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state, rank = eval.dense_vector_tn_nccl(circuit, self.dtype, 32)
if rank > 0:
state = np.array(0)

elif (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state = eval.expectation_pauli_tn(
circuit, self.dtype, self.pauli_string_pattern
)

elif (
self.MPI_enabled == True
and self.MPS_enabled == False
and self.NCCL_enabled == False
and self.expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state, rank = eval.expectation_pauli_tn_MPI(
circuit, self.dtype, self.pauli_string_pattern, 32
)

if rank > 0:
state = np.array(0)

elif (
self.MPI_enabled == False
and self.MPS_enabled == False
and self.NCCL_enabled == True
and self.expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError, "QiboTN cannot support initial state.")

state, rank = eval.expectation_pauli_tn_nccl(
circuit, self.dtype, self.pauli_string_pattern, 32
)

if rank > 0:
state = np.array(0)
else:
Expand Down

0 comments on commit 38764f7

Please sign in to comment.