Skip to content

Commit

Permalink
Add condition to trigger expectation calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankya2 committed Jan 30, 2024
1 parent 44ac064 commit e112140
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/qibotn/backends/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class CuTensorNet(NumpyBackend): # pragma: no cover
# CI does not test for GPU

def __init__(self, MPI_enabled=False, MPS_enabled=False, NCCL_enabled=False):
def __init__(self, MPI_enabled=False, MPS_enabled=False, NCCL_enabled=False, expectation_enabled=False):
super().__init__()
import cuquantum # pylint: disable=import-error
from cuquantum import cutensornet as cutn # pylint: disable=import-error
Expand All @@ -22,6 +22,7 @@ def __init__(self, MPI_enabled=False, MPS_enabled=False, NCCL_enabled=False):
self.MPI_enabled = MPI_enabled
self.MPS_enabled = MPS_enabled
self.NCCL_enabled = NCCL_enabled
self.expectation_enabled = expectation_enabled
self.handle = self.cutn.create()

def apply_gate(self, gate, state, nqubits): # pragma: no cover
Expand Down Expand Up @@ -76,11 +77,13 @@ def execute_circuit(
MPI_enabled = self.MPI_enabled
MPS_enabled = self.MPS_enabled
NCCL_enabled = self.NCCL_enabled
expectation_enabled = self.expectation_enabled

if (
MPI_enabled == False
and MPS_enabled == False
and NCCL_enabled == False
and expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -92,6 +95,7 @@ def execute_circuit(
MPI_enabled == False
and MPS_enabled == True
and NCCL_enabled == False
and expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -110,6 +114,7 @@ def execute_circuit(
MPI_enabled == True
and MPS_enabled == False
and NCCL_enabled == False
and expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -123,6 +128,7 @@ def execute_circuit(
MPI_enabled == False
and MPS_enabled == False
and NCCL_enabled == True
and expectation_enabled == False
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -136,6 +142,7 @@ def execute_circuit(
MPI_enabled == False
and MPS_enabled == False
and NCCL_enabled == False
and expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -147,6 +154,7 @@ def execute_circuit(
MPI_enabled == True
and MPS_enabled == False
and NCCL_enabled == False
and expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand All @@ -162,6 +170,7 @@ def execute_circuit(
MPI_enabled == False
and MPS_enabled == False
and NCCL_enabled == True
and expectation_enabled == True
):
if initial_state is not None:
raise_error(NotImplementedError,
Expand Down

0 comments on commit e112140

Please sign in to comment.