Expose the precision dtype to the caller so that users can specify the precision for testing
This commit is contained in:
@@ -23,7 +23,14 @@ def time(func):
|
|||||||
|
|
||||||
@pytest.mark.gpu
|
@pytest.mark.gpu
|
||||||
@pytest.mark.parametrize("nqubits", [1, 2, 5, 10])
|
@pytest.mark.parametrize("nqubits", [1, 2, 5, 10])
|
||||||
def test_eval(nqubits: int):
|
def test_eval(nqubits: int, dtype="complex128"):
|
||||||
|
"""Evaluate QASM with cuQuantum.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
nqubits (int): Total number of qubits in the system.
|
||||||
|
dtype (str): The data type for precision, 'complex64' for single,
|
||||||
|
'complex128' for double.
|
||||||
|
"""
|
||||||
import qibotn.cutn
|
import qibotn.cutn
|
||||||
|
|
||||||
# Test qibo
|
# Test qibo
|
||||||
@@ -33,8 +40,7 @@ def test_eval(nqubits: int):
|
|||||||
lambda: qibo_qft(nqubits, swaps=True))
|
lambda: qibo_qft(nqubits, swaps=True))
|
||||||
|
|
||||||
# Test Cuquantum
|
# Test Cuquantum
|
||||||
data_type = "complex128"
|
cutn_time, result_tn = time(lambda: qibotn.cutn.eval(qibo_circ, dtype))
|
||||||
cutn_time, result_tn = time(lambda: qibotn.cutn.eval(qibo_circ, data_type))
|
|
||||||
|
|
||||||
assert 1e-2 * qibo_time < cutn_time < 1e2 * qibo_time
|
assert 1e-2 * qibo_time < cutn_time < 1e2 * qibo_time
|
||||||
assert np.allclose(
|
assert np.allclose(
|
||||||
|
|||||||
Reference in New Issue
Block a user