-
Notifications
You must be signed in to change notification settings - Fork 54
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
List available backends #1096
Comments
This is basically what's already implemented here, no? |
My idea would be something like: def available_backends():
...
available_backends()
#
# {
# "numpy": True,
# "numba": True,
# "cupy": False,
# ...
# } At the moment, even the whole list of possible backends (not actually available ones) is not accessible as a variable, but it's contained in the conditions of a series of |
@alecandido I understand. What I was saying is that one could basically repackage that part of the code as a standalone function and it would already do the job (even if not in the most elegant way) |
Yes, that's fine, we could definitely use it. We're missing something like what is partially in qibo/src/qibo/backends/__init__.py Lines 54 to 59 in 42867eb
i.e. a comprehensive list. Moreover, since the mechanism of platforms is more or less uniform (though not fully, with built-in ones being the exception), most likely it should be something like: {
"core": {
"numpy": True,
"tensorflow": True,
},
"qibojit": False,
"qibolab": {
"tii1q_b1": True,
"iqm5q": True,
...,
},
"qibotn": { ... },
} and register some tiny classes that include the platform discovery mechanism for each of them (instead of implementing all of them in Qibo - it is already like this in Qibolab, but it's just a function). The class could be just: class MetaBackend:
def load(platform: str) -> Backend:
...
def list() -> dict[str, bool]:
"""Having dict mapping to bool could be equivalent to have a list
for some backends, e.g. Qibolab, but used by others to check dependencies
and hardware availability, e.g. Qibojit.
"""
... (there is some confusion among the names "backend", "platform", so I chose a different one to disambiguate - but names are all up for discussion) |
Ok, so, just to make sure that I have understood. The |
So, if you want to have a single |
In my mind, this should have been up to the individual backends. |
@alecandido can you check whether this qibojit |
Yes, definitely |
I created an analogous |
Maybe the But it's fine to have something, and to make it work. Then we can refine how it looks like. |
It would be nice if Qibo were able to check if a backend is available, and have a function to survey all the registered backends, and list those available.
Possibly, it could be implemented even trying to load it, and catching the failure. But if each backend had a property
available
it would be even better.(since the backend might know about the required conditions for availability, and we'd avoid catching a generic error)
The text was updated successfully, but these errors were encountered: