Skip to main content
Hugging Face Accelerate is a library that enables the same PyTorch code to run across any distributed configuration, to simplify model training and inference at scale. Accelerate includes a W&B Tracker which we show how to use below. You can also read more about Accelerate Trackers in Hugging Face.

Start logging with Accelerate

To get started with Accelerate and W&B you can follow the pseudocode below:
Explaining more, you need to:
  1. Pass log_with="wandb" when initialising the Accelerator class
  2. Call the init_trackers method and pass it:
  • a project name via project_name
  • any parameters you want to pass to wandb.init() via a nested dict to init_kwargs
  • any other experiment config information you want to log to your wandb run, via config
  1. Use the wandb.Run.log() method to log to Weigths & Biases; the step argument is optional
  2. Call .end_training() when finished training

Access the W&B tracker

To access the W&B tracker, use the Accelerator.get_tracker() method. Pass in the string corresponding to a tracker’s .name attribute, which returns the tracker on the main process.
From there you can interact with wandb’s run object like normal:
Trackers built in Accelerate will automatically execute on the correct process, so if a tracker is only meant to be ran on the main process it will do so automatically.If you want to truly remove Accelerate’s wrapping entirely, you can achieve the same outcome with:

Accelerate articles

Below is an Accelerate article you may enjoy