Stateful Classes

Below are variations of a singleton class in the sense that all instances share the same state, which is initialized on the first instantiation.

These classes are immutable and store information about certain configurations or states.

class accelerate.state.AcceleratorState

< >

( mixed_precision: str = None cpu: bool = False dynamo_backend = None deepspeed_plugin = None fsdp_plugin = None megatron_lm_plugin = None _from_accelerator: bool = False **kwargs )

Singleton class that has information about the current training environment.

Available attributes:

local_main_process_first

< >

( )

Lets the local main process go inside a with block.

The other processes will enter the with block after the main process exits.

main_process_first

< >

( )

Lets the main process go first inside a with block.

The other processes will enter the with block after the main process exits.

class accelerate.state.GradientState

< >

( )

Singleton class that has information related to gradient synchronization for gradient accumulation

Available attributes: