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