o
    TÃi”  ã                   @   sx   d dl mZmZ dZdZdZdZdZdZdZ	dZ
dZd	ZdZd
ZdZdZeeeeee	e
eeeeeiZG dd„ deƒZdS )é    )Úget_scalar_paramÚDeepSpeedConfigObjectah  
Activation Checkpointing should be configured as:
"session_params": {
  "activation_checkpointing": {
    "partitioned_activations": [true|false],
    "number_checkpoints": 100,
    "contiguous_memory_optimization": [true|false],
    "cpu_checkpointing": [true|false],
    "profile": [true|false],
    "synchronize_checkpoint_boundary": [true|false],
    }
}
Úpartition_activationsFÚnumber_checkpointsNÚcontiguous_memory_optimizationÚsynchronize_checkpoint_boundaryÚprofileÚcpu_checkpointingÚactivation_checkpointingc                       s$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )Ú&DeepSpeedActivationCheckpointingConfigc                    sZ   t t| ƒ ¡  d | _d | _d | _d | _d | _d | _t	| 
¡ v r$|t	 }nt}|  |¡ d S ©N)Úsuperr   Ú__init__r   r   r	   r   r   r   Ú	ACT_CHKPTÚkeysÚACT_CHKPT_DEFAULTÚ_initialize)ÚselfÚ
param_dictÚact_chkpt_config_dict©Ú	__class__© úe/home/ubuntu/.local/lib/python3.10/site-packages/deepspeed/runtime/activation_checkpointing/config.pyr   ;   s   
z/DeepSpeedActivationCheckpointingConfig.__init__c                 C   sX   t |ttƒ| _t |ttƒ| _t |ttƒ| _	t |t
tƒ| _t |ttƒ| _t |ttƒ| _d S r   )r   ÚACT_CHKPT_PARTITION_ACTIVATIONSÚ'ACT_CHKPT_PARTITION_ACTIVATIONS_DEFAULTr   Ú(ACT_CHKPT_CONTIGUOUS_MEMORY_OPTIMIZATIONÚ0ACT_CHKPT_CONTIGUOUS_MEMORY_OPTIMIZATION_DEFAULTr   ÚACT_CHKPT_CPU_CHECKPOINTINGÚ#ACT_CHKPT_CPU_CHECKPOINTING_DEFAULTr	   ÚACT_CHKPT_NUMBER_CHECKPOINTSÚ$ACT_CHKPT_NUMBER_CHECKPOINTS_DEFAULTr   ÚACT_CHKPT_PROFILEÚACT_CHKPT_PROFILE_DEFAULTr   Ú)ACT_CHKPT_SYNCHRONIZE_CHECKPOINT_BOUNDARYÚ1ACT_CHKPT_SYNCHRONIZE_CHECKPOINT_BOUNDARY_DEFAULTr   )r   r   r   r   r   r   L   s$   ÿþÿÿ
þz2DeepSpeedActivationCheckpointingConfig._initialize)Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__r   r   r   r   r   9   s    r   )Údeepspeed.runtime.config_utilsr   r   ÚACTIVATION_CHKPT_FORMATr   r   r    r!   r   r   r$   r%   r"   r#   r   r   r   r   r   r   r   r   r   Ú<module>   s.   ú
