Transformers documentation

DeepSpeed

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

and get access to the augmented documentation experience

to get started

DeepSpeed

DeepSpeed는 Zero Redundancy Optimizer(ZeRO)를 기반으로 하며, 매우 큰 모델을 GPU에 훈련 및 적합하도록 하는 최적화 라이브러리입니다. 여러 ZeRO 단계로 제공되며, 각 단계에서 옵티마이저 상태, 그래디언트, 파라미터를 분할하고 CPU 또는 NVMe로 오프로딩을 활성화하여 GPU 메모리를 점진적으로 더 많이 절약합니다. Trainer 클래스와 통합되어 있으며, 대부분의 설정은 자동으로 처리됩니다.

반면, Trainer 없이 DeepSpeed를 사용하려는 경우 Transformers는 HfDeepSpeedConfig 클래스를 제공합니다.

DeepSpeed 가이드에서 Trainer와 함께 DeepSpeed를 사용하는 방법에 대해 자세히 알아보세요.

HfDeepSpeedConfig

class transformers.integrations.HfDeepSpeedConfig

< >

( config_file_or_dict )

매개변수

  • config_file_or_dict (Union[str, Dict]) — DeepSpeed 설정 파일의 경로 또는 dict.

이 객체에는 DeepSpeed 구성 사전이 포함되어 있으며, zero stage와 같은 항목을 빠르게 조회할 수 있습니다.

이 객체의 weakref가 모듈의 전역 변수에 저장되어, Trainer 객체와 같은 객체를 사용할 수 없는 영역(예: from_pretrained, _get_resized_embeddings)에서도 config에 접근할 수 있습니다. 따라서 프로그램이 실행 중인 동안 이 객체가 살아 있어야 하는 것이 중요합니다.

Trainer는 HfTrainerDeepSpeedConfig 하위 클래스를 대신 사용합니다. 이 하위 클래스는 "auto"와 같은 특수한 플레이스홀더 값을 TrainingArguments의 값으로 치환하여 구성을 동기화하는 로직을 포함합니다. 이 특수 로직이 없으면 DeepSpeed 구성은 어떤 방식으로든 수정되지 않습니다.

Update on GitHub