Accelerate documentation

Công cụ tiện ích của 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

Công cụ tiện ích của 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 )

Tham số

  • tp_degree (int, mặc định là None) — Độ song song tensor.
  • pp_degree (int, mặc định là None) — Độ song song hóa pipeline.
  • num_micro_batches (int, mặc định là None) — Số lượng micro-batch.
  • gradient_clipping (float, mặc định là None) — Giá trị cắt gradient dựa trên chuẩn L2 toàn cục (0 để tắt).
  • sequence_parallelism (bool, mặc định là None) — Bật song song hóa chuỗi (sequence parallelism).
  • recompute_activations (bool, mặc định là None) — Bật tính toán lại kích hoạt có chọn lọc.
  • use_distributed_optimizer (bool, mặc định là None) — Bật distributed optimizer.
  • pipeline_model_parallel_split_rank (int, mặc định là None) — Rank nơi encoder và decoder nên được tách ra.
  • num_layers_per_virtual_pipeline_stage (int, mặc định là None) — Số lượng lớp cho mỗi giai đoạn pipeline ảo.
  • is_train_batch_min (str, mặc định là True) — Nếu cả hai dataloader cho train & eval được chỉ định, tham số này sẽ quyết định micro_batch_size.
  • train_iters (int, mặc định là None) — Tổng số mẫu cần huấn luyện trên tất cả các lần chạy huấn luyện. Lưu ý rằng khi sử dụng MegatronLMDummyScheduler, bạn cần cung cấp train-iters hoặc train-samples.
  • train_samples (int, mặc định là None) — Tổng số mẫu để huấn luyện trên tất cả các lần chạy huấn luyện. Lưu ý rằng khi sử dụng MegatronLMDummyScheduler, bạn cần cung cấp train-iters hoặc train-samples.
  • weight_decay_incr_style (str, mặc định là 'constant') — Hàm tăng dần weight decay. choices=[“constant”, “linear”, “cosine”].
  • start_weight_decay (float, mặc định là None) — Hệ số suy giảm trọng số ban đầu cho quy tắc hóa L2.
  • end_weight_decay (float, mặc định là None) — Hệ số suy giảm trọng số cuối của quá trình chạy cho quy tắc hóa L2.
  • lr_decay_style (str, mặc định là 'linear') — Hàm suy giảm tốc độ học. choices=[‘constant’, ‘linear’, ‘cosine’].
  • lr_decay_iters (int, mặc định là None) — Số lần lặp cho việc suy giảm tốc độ học. Nếu là None, mặc định sẽ là train_iters.
  • lr_decay_samples (int, mặc định là None) — Số lượng mẫu cho việc suy giảm tốc độ học. Nếu là None, mặc định sẽ là train_samples.
  • lr_warmup_iters (int, mặc định là None) — Số lần lặp để tăng tuyến tính tốc độ học.
  • lr_warmup_samples (int, mặc định là None) — Số lượng mẫu để tăng tuyến tính tốc độ học.
  • lr_warmup_fraction (float, mặc định là None) — Tỷ lệ phần trăm của lr-warmup-(iters/samples) để làm nóng dần (warmup) tuyến tính tốc độ học (learning rate).
  • min_lr (float, mặc định là 0) — Giá trị tối thiểu cho tốc độ học. Trình lập lịch sẽ cắt các giá trị nằm dưới ngưỡng này.
  • consumed_samples (List, mặc định là None) — Số lượng mẫu đã được sử dụng theo cùng thứ tự với các dataloader trong lời gọi accelerator.prepare.
  • no_wd_decay_cond (Optional, mặc định là None) — Điều kiện để vô hiệu hóa weight decay.
  • scale_lr_cond (Optional, mặc định là None) — Điều kiện để điều chỉnh tốc độ học.
  • lr_mult (float, mặc định là 1.0) — Hệ số nhân tốc độ học.
  • megatron_dataset_flag (bool, mặc định là False) — Xác định xem định dạng của dataset có tuân theo định dạng Indexed/Cached/MemoryMapped của Megatron-LM hay không.
  • seq_length (int, mặc định là None) — Chiều dài tối đa của chuỗi để xử lý.
  • encoder_seq_length (int, mặc định là None) — Chiều dài tối đa của chuỗi để xử lý cho bộ mã hóa.
  • decoder_seq_length (int, mặc định là None) — Chiều dài tối đa của chuỗi để xử lý cho bộ giải mã.
  • tensorboard_dir (str, mặc định là None) — Đường dẫn để lưu các log tensorboard.
  • set_all_logging_options (bool, mặc định là False) — Có nên thiết lập tất cả các tùy chọn ghi log hay không.
  • eval_iters (int, mặc định là 100) — Số lần lặp chạy để đánh giá kiểm chứng/kiểm thử.
  • eval_interval (int, mặc định là 1000) — Khoảng thời gian giữa các lần chạy đánh giá trên tập kiểm tra.
  • return_logits (bool, mặc định là False) — Có nên trả về logits từ mô hình hay không.
  • custom_train_step_class (Optional, mặc định là None) — Lớp train step tùy chỉnh.
  • custom_train_step_kwargs (Optional, mặc định là None) — Các tham số kwargs tùy chỉnh cho bước huấn luyện.
  • custom_model_provider_function (Optional, mặc định là None) — Hàm cung cấp model tùy chỉnh.
  • custom_prepare_model_function (Optional, mặc định là None) — Hàm chuẩn bị mô hình tùy chỉnh.
  • custom_megatron_datasets_provider_function (Optional, mặc định là None) — Hàm cung cấp bộ dữ liệu train_valid_test megatron tùy chỉnh.
  • custom_get_batch_function (Optional, mặc định là None) — Hàm lấy batch tùy chỉnh.
  • custom_loss_function (Optional, mặc định là None) — Hàm loss tùy chỉnh.
  • other_megatron_args (Optional, mặc định là None) — Các đối số Megatron-LM khác. Vui lòng tham khảo Megatron-LM.

Plugin cho Megatron-LM để kích hoạt song song hóa tensor, pipeline, sequence và dữ liệu. Đồng thời kích hoạt tính toán lại kích hoạt có chọn lọc và các kernel hợp nhất được tối ưu hóa.

MegatronLMDummyScheduler

lớp accelerate.utils.MegatronLMDummyScheduler

< >

( optimizertotal_num_steps = Nonewarmup_num_steps = 0**kwargs )

Tham số

  • optimizer (torch.optim.optimizer.Optimizer) — Optimizer cần bọc.
  • total_num_steps (int) — Tổng số bước.
  • warmup_num_steps (int) — Số bước cho quá trình warmup.
  • **kwargs (các đối số từ khóa bổ sung, tùy chọn) — Các đối số khác.

Dummy scheduler cung cấp các tham số mô hình hoặc các nhóm tham số, chủ yếu được sử dụng để tuân theo vòng lặp huấn luyện thông thường khi cấu hình scheduler được chỉ định trong tệp cấu hình deepspeed.

MegatronLMDummyDataLoader

lớp accelerate.utils.MegatronLMDummyDataLoader

< >

( **dataset_kwargs )

Tham số

  • **dataset_kwargs — Các đối số dữ liệu của Megatron.

Dataloader giả lập cung cấp các tham số mô hình hoặc các nhóm tham số, chủ yếu được sử dụng để tuân theo quy trình huấn luyện thông thường

AbstractTrainStep

lớp accelerate.utils.AbstractTrainStep

< >

( name )

Lớp trừu tượng cho việc nhóm dữ liệu, truyền tiến và xử lý hàm mất mát.

GPTTrainStep

lớp accelerate.utils.GPTTrainStep

< >

( acceleratorargs )

Tham số

  • args (argparse.Namespace) — Các đối số của Megatron-LM.

Lớp bước huấn luyện GPT.

BertTrainStep

lớp accelerate.utils.BertTrainStep

< >

( acceleratorargs )

Tham số

  • args (argparse.Namespace) — Các đối số của Megatron-LM.

Lớp bước huấn luyện Bert.

T5TrainStep

lớp accelerate.utils.T5TrainStep

< >

( acceleratorargs )

Tham số

  • args (argparse.Namespace) — Các đối số của Megatron-LM.

Lớp bước huấn luyện T5.

avg_losses_across_data_parallel_group

accelerate.utils.avg_losses_across_data_parallel_group

< >

( losses )

Tham số

  • losses (List[Tensor]) — Danh sách các loss để lấy trung bình trên nhóm data parallel.

Mất trung bình trên nhóm song song dữ liệu.

Update on GitHub