You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The available_accelerators method currently returns a list, but using a set is a better choice for performance reasons. Since the method is mainly used for membership checks (in operations), sets offer O(1) average-time complexity compared to lists' O(n).
Proposed Change:
Modify available_accelerators to return a set instead of a list:
defavailable_accelerators(self) ->set[str]:
"""Returns a set of registered accelerators."""returnset(self.keys())
Benefits:
Faster membership checks (like accelerator not in self._accelerator_types -- in accelerator_connectior.py) instead of O(n))
Improves efficiency when handling a large number of accelerators
Would love to hear thoughts from the maintainers on this! 🚀
Outline & Motivation
The
available_accelerators
method currently returns alist
, but using aset
is a better choice for performance reasons. Since the method is mainly used for membership checks (in
operations), sets offer O(1) average-time complexity compared to lists' O(n).Proposed Change:
Modify
available_accelerators
to return aset
instead of alist
:Benefits:
accelerator not in self._accelerator_types
-- in accelerator_connectior.py) instead of O(n))Would love to hear thoughts from the maintainers on this! 🚀
Pitch
No response
Additional context
No response
cc @lantiga @justusschock
The text was updated successfully, but these errors were encountered: