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

MetaBackend #172

Merged
merged 14 commits into from
May 10, 2024
Merged

MetaBackend #172

merged 14 commits into from
May 10, 2024

Conversation

BrunoLiegiBastonLiegi
Copy link
Contributor

This PR implements a MetaBackend to load each qibojit backend and list the available ones.

Copy link
Member

@alecandido alecandido left a comment

Choose a reason for hiding this comment

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

Minor comments. It looks perfect.

src/qibojit/backends/__init__.py Outdated Show resolved Hide resolved
src/qibojit/backends/__init__.py Outdated Show resolved Hide resolved
Comment on lines 24 to 34
if platform == "numba":
return NumbaBackend()
elif platform == "cupy":
return CupyBackend()
elif platform == "cuquantum":
return CuQuantumBackend()
else:
raise_error(
ValueError,
f"Unsupported platform, please use one among {PLATFORMS}.",
)
Copy link
Member

Choose a reason for hiding this comment

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

In principle, you could even implement this with a dict. Or, even better, an Enum.

Suggested change
if platform == "numba":
return NumbaBackend()
elif platform == "cupy":
return CupyBackend()
elif platform == "cuquantum":
return CuQuantumBackend()
else:
raise_error(
ValueError,
f"Unsupported platform, please use one among {PLATFORMS}.",
)
return Platforms[platform].value()

and above, changing the constant to:

class Platforms(Enum):
    numpy = NumpyBackend
    ...

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (df23518) to head (09448ce).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #172   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines         1085      1112   +27     
=========================================
+ Hits          1085      1112   +27     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi marked this pull request as ready for review April 23, 2024 11:01
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.

Approving so that you can merge if needed.

@stavros11 stavros11 mentioned this pull request May 8, 2024
4 tasks
@BrunoLiegiBastonLiegi BrunoLiegiBastonLiegi merged commit de78b0d into main May 10, 2024
27 checks passed
@scarrazza scarrazza deleted the list_backends branch August 3, 2024 07:33
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.

3 participants