Accelerate documentation
Experiment Trackers
Experiment Trackers
GeneralTracker
A base Tracker class to be used for all logging integration implementations.
Each function should take in **kwargs that will automatically be passed in from a base dictionary provided to Accelerator.
Should implement name, requires_logging_directory, and tracker properties such that:
name (str): String representation of the tracker class name, such as “TensorBoard” requires_logging_directory (bool): Whether the logger requires a directory to store their logs. tracker (object): Should return internal
tracking mechanism used by a tracker class (such as the run for wandb)
Implementations can also include a main_process_only (bool) attribute to toggle if relevant logging, init, and
other functions should occur on the main process or across all processes (by default will use True)
Should run any finalizing functions within the tracking API. If the API should not have one, just don’t overwrite that method.
log
< source >( values: dictstep: typing.Optional[int] = None**kwargs )
Logs values to the current run. Base log implementations of a tracking API should go in here, along with
special behavior for the `step parameter.
Lazy initialization of the tracker inside Accelerator to avoid initializing PartialState before InitProcessGroupKwargs.
store_init_configuration
< source >( values: dict )
Logs values as hyperparameters for the run. Implementations should use the experiment configuration
functionality of a tracking API.
register_tracker_class
accelerate.tracking.register_tracker_class
< source >( tracker_class: type )
Parameters
- tracker_class (subclass of
GeneralTracker) — The tracker class to register. It must subclassGeneralTrackerand define a non-emptynameclass attribute and arequires_logging_directoryclass attribute. The class is instantiated with theproject_namepassed toAccelerator.init_trackers()as the first positional argument. Whenrequires_logging_directoryisTrue, the logging directory is passed as the second positional argument (matching the built-in tracker convention). Tracker-specific keyword arguments frominit_kwargsare forwarded as**kwargs.
Registers a custom GeneralTracker subclass so it can be referenced by its name in the log_with argument of Accelerator, the same way as the built-in trackers.
The tracker must be registered before instantiating the Accelerator that uses it.
Example:
from accelerate import Accelerator
from accelerate.tracking import GeneralTracker, register_tracker_class
class MyTracker(GeneralTracker):
name = "my_tracker"
requires_logging_directory = False
# ... implement the rest of the `GeneralTracker` interface
register_tracker_class(MyTracker)
accelerator = Accelerator(log_with="my_tracker")TensorBoardTracker
class accelerate.tracking.TensorBoardTracker
< source >( run_name: strlogging_dir: typing.Union[str, os.PathLike]**kwargs )
A Tracker class that supports tensorboard. Should be initialized at the start of your script.
WandBTracker
class accelerate.tracking.WandBTracker
< source >( run_name: str**kwargs )
A Tracker class that supports wandb. Should be initialized at the start of your script.
Trackio
class accelerate.tracking.TrackioTracker
< source >( run_name: str**kwargs )
Parameters
- run_name (
str) — The name of the experiment run. Will be used as theprojectname when instantiating trackio. - **kwargs (additional keyword arguments, optional) —
Additional key word arguments passed along to the
trackio.initmethod. Refer to this init to see all supported key word arguments.
A Tracker class that supports trackio. Should be initialized at the start of your script.
CometMLTracker
class accelerate.tracking.CometMLTracker
< source >( run_name: str**kwargs )
Parameters
- run_name (
str) — The name of the experiment run. - **kwargs (additional keyword arguments, optional) —
Additional key word arguments passed along to the
comet_ml.startmethod: https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/start/
A Tracker class that supports comet_ml. Should be initialized at the start of your script.
API keys must be stored in a Comet config file.
Note:
For comet_ml versions < 3.41.0, additional keyword arguments are passed to comet_ml.Experiment instead: https://www.comet.com/docs/v2/api-and-sdk/python-sdk/reference/Experiment/#comet_ml.Experiment.__init__
AimTracker
class accelerate.tracking.AimTracker
< source >( run_name: strlogging_dir: typing.Union[str, os.PathLike, NoneType] = '.'**kwargs )
A Tracker class that supports aim. Should be initialized at the start of your script.
__init__
< source >( run_name: strlogging_dir: typing.Union[str, os.PathLike, NoneType] = '.'**kwargs )
MLflowTracker
class accelerate.tracking.MLflowTracker
< source >( experiment_name: typing.Optional[str] = Nonelogging_dir: typing.Union[str, os.PathLike, NoneType] = Nonerun_id: typing.Optional[str] = Nonetags: typing.Union[dict[str, typing.Any], str, NoneType] = Nonenested_run: typing.Optional[bool] = Falserun_name: typing.Optional[str] = Nonedescription: typing.Optional[str] = None )
Parameters
- experiment_name (
str, optional) — Name of the experiment. Environment variable MLFLOW_EXPERIMENT_NAME has priority over this argument. - logging_dir (
stroros.PathLike, defaults to".") — Location for mlflow logs to be stored. - run_id (
str, optional) — If specified, get the run with the specified UUID and log parameters and metrics under that run. The run’s end time is unset and its status is set to running, but the run’s other attributes (source_version, source_type, etc.) are not changed. Environment variable MLFLOW_RUN_ID has priority over this argument. - tags (
Dict[str, str], optional) — An optionaldictofstrkeys and values, or astrdump from adict, to set as tags on the run. If a run is being resumed, these tags are set on the resumed run. If a new run is being created, these tags are set on the new run. Environment variable MLFLOW_TAGS has priority over this argument. - nested_run (
bool, optional, defaults toFalse) — Controls whether run is nested in parent run. True creates a nested run. Environment variable MLFLOW_NESTED_RUN has priority over this argument. - run_name (
str, optional) — Name of new run (stored as a mlflow.runName tag). Used only whenrun_idis unspecified. - description (
str, optional) — An optional string that populates the description box of the run. If a run is being resumed, the description is set on the resumed run. If a new run is being created, the description is set on the new run.
A Tracker class that supports mlflow. Should be initialized at the start of your script.
__init__
< source >( experiment_name: typing.Optional[str] = Nonelogging_dir: typing.Union[str, os.PathLike, NoneType] = Nonerun_id: typing.Optional[str] = Nonetags: typing.Union[dict[str, typing.Any], str, NoneType] = Nonenested_run: typing.Optional[bool] = Falserun_name: typing.Optional[str] = Nonedescription: typing.Optional[str] = None )
ClearMLTracker
class accelerate.tracking.ClearMLTracker
< source >( run_name: typing.Optional[str] = None**kwargs )
A Tracker class that supports clearml. Should be initialized at the start of your script.
SwanLabTracker
class accelerate.tracking.SwanLabTracker
< source >( run_name: str**kwargs )
A Tracker class that supports swanlab. Should be initialized at the start of your script.