-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Outline & Motivation
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
:
def available_accelerators(self) -> set[str]:
"""Returns a set of registered accelerators."""
return set(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! 🚀
Pitch
No response
Additional context
No response