accelerate
665444ce - Add register_tracker_class to register custom trackers by name (#4060)

Commit
4 days ago
Add register_tracker_class to register custom trackers by name (#4060) * feat(tracking): register custom tracker classes by name Add register_tracker_class to register a custom GeneralTracker subclass into the LOGGER_TYPE_TO_CLASS registry so it can be selected by string name in Accelerator(log_with=...), the same way as the built-in trackers. Expose a module-level register_tracker_class in accelerate.tracking. Validate that the class subclasses GeneralTracker and defines name and requires_logging_directory, and warn when an existing name is overwritten. Extend filter_trackers so registered custom names resolve through the registry, including when combined with 'all', with the same logging-directory guard as the built-in trackers. Add tests and documentation for registering and using a custom tracker by name. Fixes #2734 * refactor(tracking): drop registered-name resolution alongside "all" Custom trackers registered via register_tracker_class are selected by listing their name explicitly, not when combined with "all". The "all" branch of filter_trackers returns to its original behavior (instances plus available built-ins). Removes the test covering the dropped behavior and its now-unused filter_trackers import. * fix(tracking): avoid RuntimeError in register_tracker_class warning register_tracker_class is documented to run before Accelerator()/PartialState(), so the accelerate logger (a MultiProcessAdapter) raises RuntimeError when the name-collision warning fires (shadowing a built-in or re-registering a name). Use warnings.warn so the warning is emitted regardless of state, matching how tracker warnings are reported elsewhere. The test now exercises the real warning instead of mocking the logger.
Parents
Loading