NVIDIA NeMo 프레임워크 교육 작업 실행

NVIDIA NeMo Framework Launcher는 대규모 LLM 교육을 위해 수천 개의 GPU에서 엔드 투 엔드 NeMo Framework 교육 작업을 시작하는 클라우드 네이티브 도구입니다. 이 예에서는 NeMo Framework Launcher를 사용하여 gpt3_5b large 언어 모델, 데이터 준비 및 교육 단계를 실행합니다.

NeMo 및 NeMo 프레임워크 실행 프로그램 모두에 대한 자세한 내용은 NVIDIA 설명서를 참조하십시오.

LLM 교육 워크로드 실행

python을 설치하고 교육 워크로드를 실행합니다.

  1. python 3.8을 설치하고 사용자 opc에 대한 기본 python으로 설정합니다.

    이 Python3는 필수이며 requirements.txt에 나열된 python 모듈도 필요합니다. Oracle Linux 7 및 기타 일부 OS 릴리스는 여전히 python2입니다.

    $ sudo yum install -y oracle-softwarecollection-release-el7
    $ sudo yum -y install scl-utils rh-python38
    $ scl enable rh-python38 bash
    $ cat <<EOF >> ~/.bashrc
    [ -f /opt/rh/rh-python38/enable ] && source /opt/rh/rh-python38/enable
    EOF
  2. https://github.com/NVIDIA/NeMo-Megatron-Launcher.에서 Installation 명령 사용
    $ cd /nfs/scratch
    $ git clone https://github.com/NVIDIA/NeMo-Megatron-Launcher.git
    Cloning into 'NeMo-Megatron-Launcher'...
    remote: Enumerating objects: 29018, done.
    remote: Counting objects: 100% (1062/1062), done.
    remote: Compressing objects: 100% (452/452), done.
    remote: Total 29018 (delta 665), reused 898 (delta 564), pack-reused 27956
    Receiving objects: 100% (29018/29018), 27.66 MiB | 14.16 MiB/s, done.
    Resolving deltas: 100% (18124/18124), done.
    
    $ cd NeMo-Megatron-Launcher
    $ pip install -r requirements.txt --user
    $ pip install --upgrade requests --user

    주:

    opc 이외의 사용자가 클러스터를 공유하는 경우 sudo pip install -r requirements.txt를 사용하는 모든 사용자에 대해 python 모듈을 설치해야 합니다.

데이터 준비

데이터 준비 단계에서는 "the pile" unopyrighted dataset 다운로드, 데이터 추출(압축 해제), 데이터 선행 처리의 세 가지 작업을 수행합니다.

  1. launcher_scripts/conf/config.yaml 편집:
    1. stage 작업을 data_preparation로 설정합니다.
      stages:
        - data_preparation
        #- training
    2. launcher_scripts_path를 설정합니다.
      # Path to NeMo Megatron Launch scripts, should ends with /launcher_scripts
      launcher_scripts_path: /nfs/scratch/NeMo-Megatron-Launcher/launcher_scripts
  2. launcher_scripts 디렉토리에서 main.py를 실행하여 Slurm에 작업을 제출합니다.
    $ cd /nfs/scratch/NeMo-Megatron-Launcher/launcher_scripts
    $ python main.py
    Job nemo-megatron-download_gpt3_pile submission file created at '/nfs/scratch/NeMo-Megatron-Launcher/launcher_scripts/results/download_gpt3_pile/download/nemo-megatron-download_gpt3_pile_submission.sh' 
    . . .
  3. Slurm의 squeue 명령을 사용하여 작업 상태를 관찰합니다.
    $ squeue
                 JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
        191_[20-29%30]       gpu nemo-meg      opc PD       0:00      1 (Resources)
            192_[0-29]       gpu nemo-meg      opc PD       0:00      1 (Dependency,Priority)
            193_[0-29]       gpu nemo-meg      opc PD       0:00      1 (Dependency)
                191_19       gpu nemo-meg      opc  R       0:50      1 gpu-permanent-node-517
                191_18       gpu nemo-meg      opc  R       0:56      1 gpu-permanent-node-878
    

    ST(상태) R를 사용하는 작업은 일부 작업이 실행 중임을 나타냅니다. 표시된 다른 작업은 리소스를 대기하거나 다른 작업이 먼저 완료될 때까지 대기합니다(종속성).

    results/download_gpt3_pile/download에서 완료 및 실행 중인 작업의 출력을 확인합니다. 또한 Slurm 작업을 제출하는 데 사용된 bash 스크립트를 찾을 수 있습니다. 스크립트와 출력은 예상대로 실행되지 않는 작업을 해결하는 데 유용할 수 있습니다.
2노드 클러스터에서 다음 단계를 수행했습니다.
  • 다운로드 90분
  • 46 분 추출
  • 5시간 45분 전처리
최대 30개의 노드에서 데이터 샤드를 병렬화할 수 있는 대규모 클러스터에서는 실행 시간이 상당히 낮아집니다.

교육

교육 단계에서는 스크립트를 편집하여 LLM 교육을 수행합니다.

  1. launcher_scripts/conf/config.yaml 편집:
    1. stage 작업을 training로 설정합니다.
      stages:
        #- data_preparation
        - training
    2. OCI에서 NVIDIA NVLink를 구성할 변수를 추가합니다.
      env_vars 섹션에서 해당 변수를 추가하여 OCI에서 NVIDIA NVLink를 구성합니다. 기존 변수는 그대로 두고 새 값으로 바꾸고 있는 변수는 주석 처리합니다.
      env_vars:
        TRANSFORMERS_OFFLINE: 0 # (was 1)
        . . .
        RX_QUEUE_LEN: 8192
        IB_RX_QUEUE_LEN: 8192
        UCX_TLS: tcp
        HCOLL_ENABLE_MCAST_ALL: 0
        coll_hcoll_enable: 0
        UCX_NET_DEVICES: ens300
        NCCL_SOCKET_IFNAME: ens300
        NCCL_IB_TIMEOUT: 16
        NCCL_IB_SL: 0
        NCCL_IB_TC: 41
        NCCL_ALGO: Auto  # tree, ring
        NCCL_IB_GID_INDEX: 3
        NCCL_IB_QPS_PER_CONNECTION: 16  # was 4
        NCCL_IB_HCA: \'mlx5_1,mlx5_2,mlx5_3,mlx5_4,mlx5_5,mlx5_6,mlx5_7,mlx5_8,mlx5_9,mlx5_10,mlx5_11,mlx5_12,mlx5_14,mlx5_15,mlx5_16,mlx5_17\'
        NCCL_DEBUG: INFO # Logging level for NCCL. Set to "INFO" for debug information

      자세한 내용은 https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/env.html을 참조하십시오.

  2. conf/training/gpt3/5b.yaml를 편집합니다.
    run:
      time_limit: "6-00:00:00"  # allow the training job to run for 6 days
    
    trainer:
      num_nodes: 2 # (was 16) set to the size of your cluster
    
    model:
      micro_batch_size: 2           # (was 4) change to fit in A100/40GB memory
      tensor_model_parallel_size: 2 # (was 1) change to fit in A100/40GB memory
    
      optim:
        bucket_cap_mb: 200 # (was 400)
  3. launcher_scripts 디렉토리에서 main.py를 실행하여 Slurm에 작업을 제출합니다. squeue 명령을 사용하여 작업이 실행 중인지 확인합니다("R").
    $ cd /nfs/scratch/NeMo-Megatron-Launcher/launcher_scripts
    $ python main.py
    Job nemo-megatron-gpt3_5b submission file created at '/nfs/scratch/NeMo-Megatron-Launcher/launcher_scripts/results/gpt3_5b/nemo-megatron-gpt3_5b_submission.sh'
    Job nemo-megatron-gpt3_5b submitted with Job ID 285
    $ squeue
                 JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                   285       gpu nemo-meg      opc  R       0:06      2 gpu-permanent-node-[517,878]
  4. results/gpt3_5b/*의 파일을 검토하여 출력 및 오류 메시지를 확인하고 실행 중인 작업의 진행률을 모니터합니다.
    LLM 교육은 gpt3_5b_nnn.out에서 다음과 유사한 라인을 볼 경우 작동합니다.
    Training:   0%|          | 0/75375 [00:00<?]
    Epoch 0: :   0%|          | 0/75375 [00:00<?]
    Epoch 0: :   0%|          | 1/75375 [00:52<1089:12:32]
    Epoch 0: :   0%|          | 1/75375 [00:52<1089:13:02 ... train_step_timing in s=52.00]
    Epoch 0: :   0%|          | 2/75375 [01:33<980:51:18 ... train_step_timing in s=52.00]
    Epoch 0: :   0%|          | 2/75375 [01:33<980:51:33 ... train_step_timing in s=46.80]
    Epoch 0: :   0%|          | 3/75375 [02:15<945:29:05 ... train_step_timing in s=46.80]
    Epoch 0: :   0%|          | 3/75375 [02:15<945:29:14 ... train_step_timing in s=45.20]
    Epoch 0: :   0%|          | 4/75375 [02:57<926:40:09 ... train_step_timing in s=45.20]
    Epoch 0: :   0%|          | 4/75375 [02:57<926:40:16 ... train_step_timing in s=44.30]
    Epoch 0: :   0%|          | 5/75375 [03:38<915:10:14 ... train_step_timing in s=44.30]
    Epoch 0: :   0%|          | 5/75375 [03:38<915:10:20 ... train_step_timing in s=43.70]
    Epoch 0: :   0%|          | 6/75375 [04:20<907:25:47 ... train_step_timing in s=43.70]
    Epoch 0: :   0%|          | 6/75375 [04:20<907:25:52 ... train_step_timing in s=41.60]
    Epoch 0: :   0%|          | 7/75375 [05:01<901:53:34 ... train_step_timing in s=41.60]
    Epoch 0: :   0%|          | 7/75375 [05:01<901:53:38 ... train_step_timing in s=41.60]
    Epoch 0: :   0%|          | 8/75375 [05:43<897:38:17 ... train_step_timing in s=41.60]
    Epoch 0: :   0%|          | 8/75375 [05:43<897:38:21 ... train_step_timing in s=41.50]
    Epoch 0: :   0%|          | 9/75375 [06:24<894:16:56 ... train_step_timing in s=41.50]
    Epoch 0: :   0%|          | 9/75375 [06:24<894:16:59 ... train_step_timing in s=41.50]
    Epoch 0: :   0%|          | 10/75375 [07:05<891:30:50 ... train_step_timing in s=41.50]

    이는 각 교육 단계가 41.5초 내에 완료되었음을 나타냅니다. 클러스터에 더 많은 GPU를 사용하면 훨씬 더 빠른 단계 시간을 달성할 수 있습니다.