Skip to content

Commit

Permalink
Rename function name to be more descriptive [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankya2 committed Jan 30, 2024
1 parent 34125d1 commit 93331aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/qibotn/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
from qibotn.mps_contraction_helper import MPSContractionHelper


def eval(qibo_circ, datatype):
def dense_vector_tn(qibo_circ, datatype):
myconvertor = QiboCircuitToEinsum(qibo_circ, dtype=datatype)
return contract(*myconvertor.state_vector_operands())


def eval_expectation(qibo_circ, datatype):
def expectation_tn(qibo_circ, datatype):
myconvertor = QiboCircuitToEinsum(qibo_circ, dtype=datatype)
return contract(
*myconvertor.expectation_operands(PauliStringGen(qibo_circ.nqubits))
)


def eval_tn_MPI(qibo_circ, datatype, n_samples=8):
def dense_vector_tn_MPI(qibo_circ, datatype, n_samples=8):
"""Convert qibo circuit to tensornet (TN) format and perform contraction using multi node and multi GPU through MPI.
The conversion is performed by QiboCircuitToEinsum(), after which it goes through 2 steps: pathfinder and execution.
The pathfinder looks at user defined number of samples (n_samples) iteratively to select the least costly contraction path. This is sped up with multi thread.
Expand Down Expand Up @@ -117,7 +117,7 @@ def eval_tn_MPI(qibo_circ, datatype, n_samples=8):
return result, rank


def eval_tn_nccl(qibo_circ, datatype, n_samples=8):
def dense_vector_tn_nccl(qibo_circ, datatype, n_samples=8):
from mpi4py import MPI # this line initializes MPI
import socket
from cuquantum import Network
Expand Down Expand Up @@ -203,7 +203,7 @@ def eval_tn_nccl(qibo_circ, datatype, n_samples=8):
return result, rank


def eval_tn_nccl_expectation(qibo_circ, datatype, n_samples=8):
def expectation_tn_nccl(qibo_circ, datatype, n_samples=8):
from mpi4py import MPI # this line initializes MPI
import socket
from cuquantum import Network
Expand Down Expand Up @@ -290,7 +290,7 @@ def eval_tn_nccl_expectation(qibo_circ, datatype, n_samples=8):
return result, rank


def eval_tn_MPI_expectation(qibo_circ, datatype, n_samples=8):
def expectation_tn_MPI(qibo_circ, datatype, n_samples=8):
from mpi4py import MPI # this line initializes MPI
import socket
from cuquantum import Network
Expand Down Expand Up @@ -369,7 +369,7 @@ def eval_tn_MPI_expectation(qibo_circ, datatype, n_samples=8):
return result, rank


def eval_mps(qibo_circ, gate_algo, datatype):
def dense_vector_mps(qibo_circ, gate_algo, datatype):
myconvertor = QiboCircuitToMPS(qibo_circ, gate_algo, dtype=datatype)
mps_helper = MPSContractionHelper(myconvertor.num_qubits)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_cuquantum_cutensor_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_eval(nqubits: int, dtype="complex128"):

# Test Cuquantum
cutn_time, result_tn = time(
lambda: qibotn.cutn.eval(qibo_circ, dtype).flatten())
lambda: qibotn.eval.dense_vector_tn(qibo_circ, dtype).flatten())

assert 1e-2 * qibo_time < cutn_time < 1e2 * qibo_time
assert np.allclose(
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_mps(nqubits: int, dtype="complex128"):
}}

cutn_time, result_tn = time(
lambda: qibotn.eval.eval_mps(circ_qibo, gate_algo, dtype).flatten())
lambda: qibotn.eval.dense_vector_mps(circ_qibo, gate_algo, dtype).flatten())

print(
f"State vector difference: {abs(result_tn - result_sv_cp).max():0.3e}")
Expand Down

0 comments on commit 93331aa

Please sign in to comment.