Format update using black formatter
This commit is contained in:
@@ -35,18 +35,16 @@ def test_eval(nqubits: int, dtype="complex128"):
|
|||||||
import qibotn.eval
|
import qibotn.eval
|
||||||
|
|
||||||
# Test qibo
|
# Test qibo
|
||||||
qibo.set_backend(backend=config.qibo.backend,
|
qibo.set_backend(backend=config.qibo.backend, platform=config.qibo.platform)
|
||||||
platform=config.qibo.platform)
|
qibo_time, (qibo_circ, result_sv) = time(lambda: qibo_qft(nqubits, swaps=True))
|
||||||
qibo_time, (qibo_circ, result_sv) = time(
|
|
||||||
lambda: qibo_qft(nqubits, swaps=True))
|
|
||||||
|
|
||||||
# Test Cuquantum
|
# Test Cuquantum
|
||||||
cutn_time, result_tn = time(
|
cutn_time, result_tn = time(
|
||||||
lambda: qibotn.eval.dense_vector_tn(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 1e-2 * qibo_time < cutn_time < 1e2 * qibo_time
|
||||||
assert np.allclose(
|
assert np.allclose(result_sv, result_tn), "Resulting dense vectors do not match"
|
||||||
result_sv, result_tn), "Resulting dense vectors do not match"
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.gpu
|
@pytest.mark.gpu
|
||||||
@@ -62,25 +60,25 @@ def test_mps(nqubits: int, dtype="complex128"):
|
|||||||
import qibotn.eval
|
import qibotn.eval
|
||||||
|
|
||||||
# Test qibo
|
# Test qibo
|
||||||
qibo.set_backend(backend=config.qibo.backend,
|
qibo.set_backend(backend=config.qibo.backend, platform=config.qibo.platform)
|
||||||
platform=config.qibo.platform)
|
|
||||||
|
|
||||||
qibo_time, (circ_qibo, result_sv) = time(
|
qibo_time, (circ_qibo, result_sv) = time(lambda: qibo_qft(nqubits, swaps=True))
|
||||||
lambda: qibo_qft(nqubits, swaps=True))
|
|
||||||
|
|
||||||
result_sv_cp = cp.asarray(result_sv)
|
result_sv_cp = cp.asarray(result_sv)
|
||||||
|
|
||||||
# Test of MPS
|
# Test of MPS
|
||||||
gate_algo = {'qr_method': False,
|
gate_algo = {
|
||||||
'svd_method': {
|
"qr_method": False,
|
||||||
'partition': 'UV',
|
"svd_method": {
|
||||||
'abs_cutoff': 1e-12,
|
"partition": "UV",
|
||||||
}}
|
"abs_cutoff": 1e-12,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
cutn_time, result_tn = time(
|
cutn_time, result_tn = time(
|
||||||
lambda: qibotn.eval.dense_vector_mps(circ_qibo, gate_algo, dtype).flatten())
|
lambda: qibotn.eval.dense_vector_mps(circ_qibo, gate_algo, dtype).flatten()
|
||||||
|
)
|
||||||
|
|
||||||
print(
|
print(f"State vector difference: {abs(result_tn - result_sv_cp).max():0.3e}")
|
||||||
f"State vector difference: {abs(result_tn - result_sv_cp).max():0.3e}")
|
|
||||||
|
|
||||||
assert cp.allclose(result_tn, result_sv_cp)
|
assert cp.allclose(result_tn, result_sv_cp)
|
||||||
|
|||||||
Reference in New Issue
Block a user