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

adding profile file for backends #457

Merged
merged 19 commits into from
Sep 7, 2021
Merged

adding profile file for backends #457

merged 19 commits into from
Sep 7, 2021

Conversation

scarrazza
Copy link
Member

As discussed, this PR implements the backend loading mechanism using a default configuration file located in qibo/backends/profiles.yml or by using the QIBO_PROFILE environment variable.

At some point in the future, we should consider the possibility to store the backend class definition directly in the external module.

@scarrazza scarrazza requested a review from stavros11 September 4, 2021 13:03
@codecov
Copy link

codecov bot commented Sep 4, 2021

Codecov Report

Merging #457 (80c87a0) into master (e6246f7) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #457   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           85        85           
  Lines        11851     11867   +16     
=========================================
+ Hits         11851     11867   +16     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/qibo/backends/hardware.py 100.00% <ø> (ø)
src/qibo/core/distcircuit.py 100.00% <ø> (ø)
src/qibo/tests/test_core_circuit.py 100.00% <ø> (ø)
src/qibo/backends/__init__.py 100.00% <100.00%> (ø)
src/qibo/backends/abstract.py 100.00% <100.00%> (ø)
src/qibo/backends/jit.py 100.00% <100.00%> (ø)
src/qibo/backends/tensorflow.py 100.00% <100.00%> (ø)
src/qibo/models/circuit.py 100.00% <100.00%> (ø)
src/qibo/optimizers.py 100.00% <100.00%> (ø)
src/qibo/tests/conftest.py 100.00% <100.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6246f7...80c87a0. Read the comment docs.

Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for implementing this, I believe it is a great first step to simplify the process of adding new backends, especially from external collaborators. I think now it is possible to add a backend without requiring to touch the qibo internals at all, which is great, however one should still inherit Qibo's abstract backend and define the corresponding methods.

With that in mind, I believe that as next step we should better document and perhaps somehow simplify this process, for example by making clear which methods are required and optional (eg. the multi-GPU methods could be optional). We should also improve the hardware abstractions, as currently the abstract backend is geared during simulation.

src/qibo/backends/__init__.py Outdated Show resolved Hide resolved
src/qibo/backends/__init__.py Outdated Show resolved Hide resolved
@@ -11,9 +11,9 @@
_ACCELERATORS = None
if ("qibotf" in _available_backends or "qibojit" in _available_backends):
_ACCELERATORS = "2/GPU:0,1/GPU:0+1/GPU:1,2/GPU:0+1/GPU:1+1/GPU:2"
if "icarusq" in _available_backends: # pragma: no cover
if "qiboicarusq" in _available_backends: # pragma: no cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make this backend name agnostic by using the .is_hardware property (which perhaps we need to add to AbstractBackend). Alternatively something that could work and skip the tests for all hardware backends would be to change the _available_backends definition to:

_available_backends = set(qibo.K.available_backends.keys()) - set(qibo.K.hardware_backends.keys())

In a similar manner, we could possibly extend this PR to completely remove hard-coded backend names by adding the relevant properties in the abstract backend. For example another case which currently requires hard-coded backend names around the code is the multi-GPU (see the if "qibotf" in _available_backends: above). We could make this name agnostic using a .supports_multigpu property in the backends. The multi-GPU case may be slightly more complicated than .is_hardware so we should probably to this in a different PR, but let me know what you think.

@scarrazza
Copy link
Member Author

Thanks for the review. Indeed, this PR should be the basis for a more general cleanup and simplification.

@stavros11
Copy link
Member

Thanks for the review. Indeed, this PR should be the basis for a more general cleanup and simplification.

Thank you for the updates, looks good. Just don't forget to change the base branch to master before merging as multigpu is already merged.

@scarrazza scarrazza changed the base branch from multigpu to master September 6, 2021 12:52
@scarrazza scarrazza merged commit 9af4e77 into master Sep 7, 2021
@scarrazza scarrazza deleted the bkdprofile branch September 18, 2021 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants