Transformers documentation

Nanotron

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

and get access to the augmented documentation experience

to get started

Nanotron

Nanotron은 텐서, 병렬, 데이터 병렬성(3D 병렬성)을 지원하는 분산 학습 프레임워크입니다. 수백 개의 GPU에 걸친 대규모 학습 워크로드를 위해 설계되었습니다.

convert_hf_to_nanotron.py 스크립트를 사용하여 모든 Transformers 모델을 사전 학습을 위한 최적화된 Nanotron transformer 모델 구현으로 변환합니다.

torchrun --nproc_per_node=1 examples/llama/convert_hf_to_nanotron.py \
    --checkpoint_path=meta-llama/Llama-2-7b-hf \
    --save_path=./llama-7b-nanotron

Transformers 통합

  1. Llama와 같은 지원되는 Transformers 모델을 from_pretrained() 함수로 로드합니다. 이 함수는 체크포인트 디렉터리에서 config.json 파일을 읽고 LlamaConfig를 생성합니다.
  2. Nanotron은 LlamaConfig를 자체 설정 형식으로 매핑하고 Nanotron 모델을 생성합니다.
  3. Transformers 가중치를 Nanotron으로 변환합니다. 가중치 매핑은 Nanotron 파라미터 이름을 Transformers 파라미터 이름으로 매핑하는 방법을 안내합니다. 여기에는 QKV 투영 및 gate/up 투영의 병합과 같은 변환 처리가 포함됩니다.

Nanotron은 전처리 및 생성 과정에서 텍스트를 토큰 ID로 변환하는 데 AutoTokenizer를 사용합니다.

리소스

Update on GitHub