Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating cuquantum version #1573

Merged
merged 7 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/qibo/backends/npmatrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def __init__(self, dtype):
self.np = np

def _cast(self, x, dtype):
return self.np.array(x, dtype=dtype)
if isinstance(x, list):
return self.np.array(x, dtype=dtype)
return x.astype(dtype)

@cached_property
def H(self):
Expand Down
5 changes: 2 additions & 3 deletions src/qibo/transpiler/unitary_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def u3_decomposition(unitary, backend):
minus = backend.np.angle(su2[1, 0])
phi = plus + minus
lam = plus - minus

return theta, phi, lam
# explicit conversion to float to avoid issue on GPU
return float(theta), float(phi), float(lam)


def calculate_psi(unitary, backend, magic_basis=magic_basis):
Expand All @@ -51,7 +51,6 @@ def calculate_psi(unitary, backend, magic_basis=magic_basis):
Returns:
ndarray: Eigenvectors in the computational basis and eigenvalues of :math:`U^{T} U`.
"""

magic_basis = backend.cast(magic_basis)
unitary = backend.cast(unitary)
# write unitary in magic basis
Expand Down
20 changes: 4 additions & 16 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from qibo import construct_backend, gates, list_available_backends, set_backend
from qibo.backends import MetaBackend

from .conftest import AVAILABLE_BACKENDS

####################### Test `matrix` #######################
GATES = [
("H", (0,), np.array([[1, 1], [1, -1]]) / np.sqrt(2)),
Expand Down Expand Up @@ -116,26 +118,12 @@ def test_list_available_backends():
qulacs = (
False if platform.system() == "Darwin" and sys.version_info[1] == 9 else True
)
try:
import cupy

cupy_available = True
except ModuleNotFoundError:
cupy_available = False
try:
import cuquantum

cuquantum_available = True
except ModuleNotFoundError:
cuquantum_available = False

available_backends = {
"numpy": True,
"qulacs": qulacs,
"qibojit": {
"numba": True,
"cupy": cupy_available,
"cuquantum": cuquantum_available,
platform: any(platform in backend for backend in AVAILABLE_BACKENDS)
for platform in ["numba", "cupy", "cuquantum"]
},
"qibolab": False,
"qibo-cloud-backends": False,
Expand Down
1 change: 0 additions & 1 deletion tests/test_transpiler_unitary_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def test_eigenbasis_entanglement(backend, seed):
def test_v_decomposition(backend, seed):
"""Check that V_A V_B |psi_k> = |phi_k> according to Lemma 1."""
unitary = random_unitary(4, seed=seed, backend=backend)

psi, _ = calculate_psi(unitary, backend=backend)
va, vb = calculate_single_qubit_unitaries(psi, backend=backend)
assert_single_qubits(backend, psi, va, vb)
Expand Down
Loading