Accelerate documentation

Megatron-LM 유틸리티

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v1.15.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Megatron-LM 유틸리티

MegatronLMPlugin

class accelerate.utils.MegatronLMPlugin

< >

( tp_degree: int = Nonepp_degree: int = Noneuse_custom_fsdp: bool = Noneoverlap_cpu_optimizer_d2h_h2d: bool = Noneno_load_optim: bool = Noneeod_mask_loss: bool = Noneno_save_optim: bool = Noneoptimizer_cpu_offload: bool = Noneuse_precision_aware_optimizer: bool = Nonedecoder_last_pipeline_num_layers: int = Nonerecompute_granularity: str = Nonerecompute_method: str = Nonerecompute_num_layers: int = Noneattention_backend: bool = Noneexpert_model_parallel_size: int = Nonecontext_parallel_size: int = Noneattention_dropout: float = Nonehidden_dropout: float = Noneattention_softmax_in_fp32: bool = Noneexpert_tensor_parallel_size: int = Nonecalculate_per_token_loss: bool = Noneuse_rotary_position_embeddings: bool = Nonenum_micro_batches: int = Nonegradient_clipping: float = Nonesequence_parallelism: bool = Nonerecompute_activations: bool = Noneuse_distributed_optimizer: bool = Nonepipeline_model_parallel_split_rank: int = Nonenum_layers_per_virtual_pipeline_stage: int = Noneis_train_batch_min: str = Truetrain_iters: int = Nonetrain_samples: int = Noneweight_decay_incr_style: str = 'constant'start_weight_decay: float = Noneend_weight_decay: float = Nonelr_decay_style: str = 'linear'lr_decay_iters: int = Nonelr_decay_samples: int = Nonelr_warmup_iters: int = Nonelr_warmup_samples: int = Nonelr_warmup_fraction: float = Nonemin_lr: float = 0consumed_samples: list = Noneno_wd_decay_cond: typing.Callable | None = Nonescale_lr_cond: typing.Callable | None = Nonelr_mult: float = 1.0megatron_dataset_flag: bool = Falseseq_length: int = Noneencoder_seq_length: int = Nonedecoder_seq_length: int = Nonetensorboard_dir: str = Noneset_all_logging_options: bool = Falseeval_iters: int = 100eval_interval: int = 1000return_logits: bool = Falsecustom_train_step_class: typing.Any | None = Nonecustom_train_step_kwargs: dict[str, typing.Any] | None = Nonecustom_model_provider_function: typing.Callable | None = Nonecustom_prepare_model_function: typing.Callable | None = Nonecustom_megatron_datasets_provider_function: typing.Callable | None = Nonecustom_get_batch_function: typing.Callable | None = Nonecustom_loss_function: typing.Callable | None = Noneother_megatron_args: dict[str, typing.Any] | None = None )

매개변수

  • tp_degree (int, 기본값 None) — Tensor parallelism degree.
  • pp_degree (int, 기본값 None) — 파이프라인 병렬도입니다.
  • num_micro_batches (int, 기본값 None) — 마이크로 배치의 수.
  • gradient_clipping (float, 기본값 None) — 전역 L2 노름에 기반한 그라디언트 클리핑 값(0이면 비활성화).
  • sequence_parallelism (bool, 기본값 None) — 시퀀스 병렬화를 활성화합니다.
  • recompute_activations (bool, 기본값 None) — 선택적 활성화 재계산을 활성화합니다.
  • use_distributed_optimizer (bool, 기본값 None) — 분산 옵티마이저를 활성화합니다.
  • pipeline_model_parallel_split_rank (int, 기본값 None) — 인코더와 디코더를 분리할 랭크.
  • num_layers_per_virtual_pipeline_stage (int, 기본값 None) — 가상 파이프라인 단계별 레이어 수.
  • is_train_batch_min (str, 기본값 True) — train 및 eval dataloader가 모두 지정된 경우, 이 값이 micro_batch_size를 결정합니다.
  • train_iters (int, 기본값 None) — 모든 학습 실행에 걸쳐 학습할 샘플의 총 개수. MegatronLMDummyScheduler를 사용할 때는 train-iters 또는 train-samples 중 하나를 제공해야 합니다.
  • train_samples (int, 기본값 None) — 모든 학습 실행에 걸쳐 학습할 샘플의 총 개수. MegatronLMDummyScheduler를 사용할 때는 train-iters 또는 train-samples 중 하나를 제공해야 합니다.
  • weight_decay_incr_style (str, 기본값 'constant') — Weight decay 증가 함수. choices=[“constant”, “linear”, “cosine”].
  • start_weight_decay (float, 기본값 None) — L2 정규화를 위한 초기 weight decay 계수.
  • end_weight_decay (float, 기본값 None) — L2 정규화를 위한 실행 종료 시 weight decay 계수입니다.
  • lr_decay_style (str, 기본값 'linear') — 학습률 감쇠 함수. choices=[‘constant’, ‘linear’, ‘cosine’].
  • lr_decay_iters (int, 기본값 None) — 학습률 감쇠를 위한 반복 횟수입니다. None인 경우 기본값은 train_iters입니다.
  • lr_decay_samples (int, 기본값 None) — 학습률 감쇠에 사용할 샘플 수. None인 경우 기본값은 train_samples입니다.
  • lr_warmup_iters (int, 기본값 None) — 학습률을 선형으로 워밍업할 반복 횟수입니다.
  • lr_warmup_samples (int, 기본값 None) — 학습률을 선형으로 워밍업할 샘플 수입니다.
  • lr_warmup_fraction (float, 기본값 None) — 학습률을 선형으로 warmup할 lr-warmup-(iters/samples)의 비율.
  • min_lr (float, 기본값 0) — 학습률의 최소값입니다. 스케줄러는 이 임계값보다 작은 값을 이 값으로 잘라냅니다.
  • consumed_samples (List, 기본값 None) — accelerator.prepare 호출에 전달된 dataloader 순서와 동일한 순서로 소비된 샘플 수입니다.
  • no_wd_decay_cond (Optional, 기본값 None) — weight decay를 비활성화할 조건.
  • scale_lr_cond (Optional, 기본값 None) — 학습률을 스케일링할 조건.
  • lr_mult (float, 기본값 1.0) — 학습률 배율입니다.
  • megatron_dataset_flag (bool, 기본값 False) — 데이터셋의 형식이 Megatron-LM Indexed/Cached/MemoryMapped 형식을 따르는지 여부.
  • seq_length (int, 기본값 None) — 처리할 최대 시퀀스 길이입니다.
  • encoder_seq_length (int, 기본값 None) — 인코더에서 처리할 최대 시퀀스 길이입니다.
  • decoder_seq_length (int, 기본값 None) — 디코더에서 처리할 최대 시퀀스 길이입니다.
  • tensorboard_dir (str, 기본값 None) — tensorboard 로그를 저장할 경로입니다.
  • set_all_logging_options (bool, 기본값 False) — 모든 로깅 옵션을 설정할지 여부.
  • eval_iters (int, 기본값 100) — 평가용 검증/테스트를 실행할 반복 횟수입니다.
  • eval_interval (int, 기본값 1000) — 검증 세트에서 평가를 실행하는 간격입니다.
  • return_logits (bool, 기본값 False) — 모델에서 logits를 반환할지 여부.
  • custom_train_step_class (Optional, 기본값 None) — 사용자 정의 학습 단계 클래스입니다.
  • custom_train_step_kwargs (Optional, 기본값 None) — 사용자 정의 train step kwargs입니다.
  • custom_model_provider_function (Optional, 기본값 None) — 사용자 정의 모델 제공 함수입니다.
  • custom_prepare_model_function (Optional, 기본값 None) — 사용자 정의 prepare model 함수입니다.
  • custom_megatron_datasets_provider_function (Optional, 기본값 None) — 사용자 정의 megatron train_valid_test 데이터셋 제공자 함수입니다.
  • custom_get_batch_function (Optional, 기본값 None) — 사용자 정의 get batch 함수입니다.
  • custom_loss_function (Optional, 기본값 None) — 사용자 정의 손실 함수입니다.
  • other_megatron_args (Optional, 기본값 None) — 다른 Megatron-LM 인자입니다. Megatron-LM 문서를 참조하세요.

tensor, pipeline, sequence 및 data 병렬화를 활성화하는 Megatron-LM용 플러그인입니다. 또한 선택적 activation 재계산 및 최적화된 fused kernel을 활성화합니다.

MegatronLMDummyScheduler

class accelerate.utils.MegatronLMDummyScheduler

< >

( optimizertotal_num_steps = Nonewarmup_num_steps = 0**kwargs )

매개변수

  • optimizer (torch.optim.optimizer.Optimizer) — 래핑할 옵티마이저입니다.
  • total_num_steps (int) — 총 스텝 수.
  • warmup_num_steps (int) — Warmup에 사용할 단계 수.
  • **kwargs (추가 키워드 인자, 선택 사항) — 기타 인자.

Dummy scheduler는 모델 파라미터 또는 파라미터 그룹을 제공하며, deepspeed 설정 파일에 스케줄러 구성이 지정된 경우 전통적인 학습 루프를 따르는 데 주로 사용됩니다.

MegatronLMDummyDataLoader

class accelerate.utils.MegatronLMDummyDataLoader

< >

( **dataset_kwargs )

매개변수

  • **dataset_kwargs — Megatron 데이터 인자.

Dummy dataloader는 모델 파라미터 또는 파라미터 그룹을 제공하며, 이는 주로 일반적인 학습을 따르기 위해 사용됩니다.

AbstractTrainStep

클래스 accelerate.utils.AbstractTrainStep

< >

( name )

배치 처리, forward pass 및 손실 처리를 위한 추상 클래스.

GPTTrainStep

클래스 accelerate.utils.GPTTrainStep

< >

( acceleratorargs )

매개변수

  • args (argparse.Namespace) — Megatron-LM 인자.

GPT 학습 단계 클래스.

BertTrainStep

클래스 accelerate.utils.BertTrainStep

< >

( acceleratorargs )

매개변수

  • args (argparse.Namespace) — Megatron-LM 인자.

Bert 학습 단계 클래스.

T5TrainStep

클래스 accelerate.utils.T5TrainStep

< >

( acceleratorargs )

매개변수

  • args (argparse.Namespace) — Megatron-LM 인자.

T5 학습 단계 클래스.

avg_losses_across_data_parallel_group

accelerate.utils.avg_losses_across_data_parallel_group

< >

( losses )

매개변수

  • losses (List[Tensor]) — 데이터 병렬 그룹에 걸쳐 평균할 손실 목록.

데이터 병렬 그룹 전체의 평균 손실.

Update on GitHub