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

Migrating TensorFlowBackend to Qiboml #1479

Merged
merged 51 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
05c0463
feat: remove tf backend
MatteoRobbiati Oct 8, 2024
2a65005
feat: construct tf backend from qiboml
MatteoRobbiati Oct 8, 2024
c6264e1
tests: adapt tests to tf parsed from qiboml
MatteoRobbiati Oct 8, 2024
603ac3f
chore: updating lock
MatteoRobbiati Oct 8, 2024
31618c1
fix: rm wrong import
MatteoRobbiati Oct 8, 2024
3801382
chore: rm tensorflow from deps
MatteoRobbiati Oct 8, 2024
6fc80d3
fix: conflicts with master
MatteoRobbiati Oct 8, 2024
0ecd2b7
chore: restoring lock
MatteoRobbiati Oct 8, 2024
10d432a
fix: rm tf backend
MatteoRobbiati Oct 8, 2024
8f17625
change backend priorities
MatteoRobbiati Oct 8, 2024
108c4ad
chore: restore tf dependency in tests
MatteoRobbiati Oct 9, 2024
e4cad13
fix: conditions involving tf
MatteoRobbiati Oct 9, 2024
217f729
fix: tests updating the tf related checks
MatteoRobbiati Oct 10, 2024
eea11bd
Merge branch 'master' into tf_migration
MatteoRobbiati Oct 11, 2024
2d4a67c
fix: tf dependency
MatteoRobbiati Oct 11, 2024
ace74a9
pointing to working branch
MatteoRobbiati Oct 14, 2024
986b84a
Merge branch 'master' into tf_migration
MatteoRobbiati Oct 14, 2024
fe84d9e
chore: update lock
MatteoRobbiati Oct 14, 2024
0a76c00
fix: test models circuit parametrized
MatteoRobbiati Oct 15, 2024
82f540f
Merge branch 'master' into tf_migration
MatteoRobbiati Oct 15, 2024
4845926
fix: replacing backend.name with backend.platform in three more qibo …
MatteoRobbiati Oct 15, 2024
3380fa8
fix: name --> platform in utils.py
MatteoRobbiati Oct 15, 2024
e828343
fix: adapt tf tests to qiboml backend
MatteoRobbiati Oct 15, 2024
bc92554
fix: conflicts after merging master
MatteoRobbiati Oct 16, 2024
8049499
use aliases
renatomello Oct 16, 2024
f768db7
pylint
renatomello Oct 16, 2024
32c9224
lint improvements
renatomello Oct 16, 2024
2fdbf85
lint improvements
renatomello Oct 16, 2024
85df75d
rollback modification
renatomello Oct 16, 2024
205e260
update lock
renatomello Oct 16, 2024
e0d6267
chore: update lock after integrating last modifications into qiboml
MatteoRobbiati Oct 16, 2024
5c5fd92
Merge branch 'tf_migration' of github.com:qiboteam/qibo into tf_migra…
MatteoRobbiati Oct 16, 2024
d4a82d5
fix GPU tests
renatomello Oct 17, 2024
8c6e162
update lock (again)
renatomello Oct 17, 2024
403621b
remove alias
renatomello Oct 17, 2024
7a1c17f
update lock
renatomello Oct 17, 2024
d27446c
revert test order
renatomello Oct 17, 2024
596fd35
Update src/qibo/models/error_mitigation.py
renatomello Oct 17, 2024
5bbeeab
merging origin
MatteoRobbiati Oct 21, 2024
5f36868
Using QIBO_NATIVE_BACKENDS as Andrea suggested
MatteoRobbiati Oct 21, 2024
124816f
chore: update lock
MatteoRobbiati Oct 21, 2024
a968723
fix: ('clifford',) as tuple
MatteoRobbiati Oct 21, 2024
a8fda30
feat: removing direct dependence from tensorflow in tests
MatteoRobbiati Oct 23, 2024
1febc17
Merge branch 'master' into tf_migration
renatomello Oct 24, 2024
45b5870
Merge branch 'master' into tf_migration
MatteoRobbiati Oct 25, 2024
521cbe2
feat: removing tf imports from examples and docs
MatteoRobbiati Oct 25, 2024
652cd4d
chore: remove tf from tests deps
MatteoRobbiati Oct 25, 2024
f9e0f5c
chore: updating lock file
MatteoRobbiati Oct 25, 2024
2dc67c4
Merge branch 'master' into tf_migration
renatomello Oct 28, 2024
8a22e69
fix: remove tf from pyproject
MatteoRobbiati Oct 28, 2024
65a20a2
chore: pointing to qiboml main github repo
MatteoRobbiati Oct 28, 2024
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
2,159 changes: 1,135 additions & 1,024 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ scikit-learn = "^1.2.1"
pytest-cov = "^4.0.0"
pylint = "3.1.0"
matplotlib = "^3.7.0"
tensorflow = { version = "^2.16.1", markers = "sys_platform == 'linux'" }
tensorflow = { version = "^2.16.1", markers = "sys_platform == 'linux' or sys_platform == 'darwin'", optional = true }
BrunoLiegiBastonLiegi marked this conversation as resolved.
Show resolved Hide resolved
torch = "^2.1.1,<2.4"
qibojit = { git = "https://github.com/qiboteam/qibojit.git" }
qibotn = { git = "https://github.com/qiboteam/qibotn.git" }
qiboml = { git = "https://github.com/qiboteam/qiboml.git", branch = "tf-back"}
stim = "^1.12.0"
qulacs = { version = "^0.6.4", markers = "(sys_platform == 'darwin' and python_version > '3.9') or sys_platform != 'darwin'" }

Expand Down
50 changes: 28 additions & 22 deletions src/qibo/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
from qibo.backends.npmatrices import NumpyMatrices
from qibo.backends.numpy import NumpyBackend
from qibo.backends.pytorch import PyTorchBackend
from qibo.backends.tensorflow import TensorflowBackend
from qibo.config import log, raise_error

QIBO_NATIVE_BACKENDS = ("numpy", "tensorflow", "pytorch", "qulacs")
QIBO_NATIVE_BACKENDS = ("numpy", "pytorch", "qulacs")


class MissingBackend(ValueError):
Expand All @@ -27,30 +26,36 @@ def load(backend: str, **kwargs) -> Backend:

Args:
backend (str): Name of the backend to load.
kwargs (dict): Additional arguments for the qibo backend.
kwargs (dict): Additional arguments for the ``qibo`` backend.

Returns:
qibo.backends.abstract.Backend: The loaded backend.
:class:`qibo.backends.abstract.Backend`: Loaded backend.
"""

if backend == "numpy":
return NumpyBackend()
elif backend == "tensorflow":
return TensorflowBackend()
elif backend == "pytorch":
possible_backends = ["numpy", "pytorch", "clifford", "qulacs"]
BrunoLiegiBastonLiegi marked this conversation as resolved.
Show resolved Hide resolved

if backend not in possible_backends:
raise_error(
ValueError,
f"Backend {backend} is not available. "
+ f"The native qibo backends are {QIBO_NATIVE_BACKENDS}.",
)

if backend == "pytorch":
return PyTorchBackend()
elif backend == "clifford":

if backend == "clifford":
engine = kwargs.pop("platform", None)
kwargs["engine"] = engine

return CliffordBackend(**kwargs)
elif backend == "qulacs":
from qibo.backends.qulacs import QulacsBackend

if backend == "qulacs":
from qibo.backends.qulacs import QulacsBackend # pylint: disable=C0415

return QulacsBackend()
else:
raise_error(
ValueError,
f"Backend {backend} is not available. The native qibo backends are {QIBO_NATIVE_BACKENDS}.",
)

return NumpyBackend()
BrunoLiegiBastonLiegi marked this conversation as resolved.
Show resolved Hide resolved

def list_available(self) -> dict:
"""Lists all the available native qibo backends."""
Expand All @@ -73,8 +78,8 @@ class GlobalBackend(NumpyBackend):
_default_order = [
{"backend": "qibojit", "platform": "cupy"},
{"backend": "qibojit", "platform": "numba"},
{"backend": "tensorflow"},
{"backend": "numpy"},
{"backend": "qiboml", "platform": "tensorflow"},
{"backend": "pytorch"},
]

Expand Down Expand Up @@ -211,7 +216,7 @@ def list_available_backends(*providers: str) -> dict:
return available_backends


def construct_backend(backend, **kwargs) -> Backend:
def construct_backend(backend, **kwargs) -> Backend: # pylint: disable=R1710
"""Construct a generic native or non-native qibo backend.

Args:
Expand All @@ -231,10 +236,11 @@ def construct_backend(backend, **kwargs) -> Backend:
# pylint: disable=unsupported-membership-test
if provider not in e.msg:
raise e
raise MissingBackend(
raise_error(
MissingBackend,
f"The '{backend}' backends' provider is not available. Check that a Python "
f"package named '{provider}' is installed, and it is exposing valid Qibo "
"backends.",
+ f"package named '{provider}' is installed, and it is exposing valid Qibo "
+ "backends.",
)


Expand Down
286 changes: 0 additions & 286 deletions src/qibo/backends/tensorflow.py

This file was deleted.

Loading