אימון של Llama2 באמצעות Megatron-LM במכונות וירטואליות מסוג A3 Mega

סקירה כללית

במדריך למתחילים הזה תלמדו איך להריץ עומס עבודה של PyTorch מבוסס-קונטיינר, Megatron-LM, ב-A3 Mega. הקוד זמין במאגר GitHub הזה: megatron-gke.

לפני שמתחילים

כדי להפעיל את Google Kubernetes Engine (GKE) API, פועלים לפי השלבים הבאים:

  1. נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the GKE API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the GKE API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  8. צריך לוודא שיש לכם בפרויקט את התפקיד או התפקידים הבאים: roles/container.admin, roles/compute.networkAdmin, roles/iam.serviceAccountUser

    בדיקת התפקידים

    1. נכנסים לדף IAM במסוף Google Cloud .

      כניסה לדף IAM
    2. בוחרים את הפרויקט.
    3. בעמודה Principal, מחפשים את כל השורות שמזהות אתכם או קבוצה שאתם נכללים בה. כדי לדעת באילו קבוצות אתם נכללים, פנו לאדמין.

    4. בודקים את העמודה Role בכל השורות שבהן מצוין או מופיע השם שלכם, כדי לראות אם רשימת התפקידים כוללת את התפקידים הנדרשים.

    מתן התפקידים

    1. נכנסים לדף IAM במסוף Google Cloud .

      כניסה לדף IAM
    2. בוחרים את הפרויקט.
    3. לוחצים על Grant access.
    4. בשדה New principals, מזינים את מזהה המשתמש. ‫ בדרך כלל מזהה המשתמש הוא כתובת האימייל של חשבון Google.

      ‫
    5. לוחצים על Select a role ומחפשים את התפקיד.
    6. כדי לתת עוד תפקידים, לוחצים על Add another role ומוסיפים אותם.
    7. לוחצים על Save.

יצירת אשכול A3 Mega

יצירת אשכול GKE מסוג A3 Mega עם GPUDirect-TCPXO ורישות מרובה. מידע נוסף זמין במאמר בנושא שיפור רוחב הפס של רשת ה-GPU באמצעות GPUDirect וריבוי רשתות.

מגדירים את הסביבה

  1. יצירת משתני סביבה לכמה פרמטרים נפוצים

    export CLUSTER_NAME=CLUSTER_NAME
    export CONTROL_PLANE_LOCATION=CONTROL_PLANE_LOCATION
    export PROJECT_ID=PROJECT_ID
    

    מחליפים את מה שכתוב בשדות הבאים:

    • ‫CLUSTER_NAME: השם של אשכול A3 Mega GKE שבו מופעלים GPUDirect-TCPXO וריבוי רשתות.
    • ‫CONTROL_PLANE_LOCATION: המיקום של מישור הבקרה של האשכול ב-Compute Engine. מציינים אזור לאשכולות אזוריים או אזור לאשכולות אזוריים.
    • ‫PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
  2. מגדירים את Google Cloud CLI כך שישתמש בפרטי הכניסה Google Cloud שלכם לצורך אימות:

    gcloud auth login
    

    למידע נוסף, אפשר לקרוא את המאמר אימות ל-Google Cloud CLI.

  3. מתקינים את kubectl ואת הפלאגין של ה-CLI של gcloud של GKE:

    sudo apt-get install kubectl
    sudo apt-get install google-cloud-cli-gke-gcloud-auth-plugin
    
  4. מאחזרים את פרטי הכניסה לאשכול GKE:

    gcloud container clusters get-credentials ${CLUSTER_NAME} \
      --location=${CONTROL_PLANE_LOCATION} \
      --project=${PROJECT_ID}
    
  5. אם עדיין לא התקנתם את Helm, אתם צריכים להתקין אותו:

    curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
    chmod 700 get_helm.sh
    ./get_helm.sh && rm get_helm.sh
    sudo chmod +x /usr/local/bin/helm
    

שימוש במתזמן שמודע לטופולוגיה כדי לפרוס את ה-Pods

אתם יכולים להשתמש בכלי לתזמון שמודע לטופולוגיה כדי לפרוס את ה-Pods של GKE לצמתים עם טופולוגיית GPU מוגדרת.

בפקודות kubectl הבאות, תשתמשו בקבצים ישירות ממאגר. לחלופין, אפשר לשכפל את המאגר באופן מקומי, ואז הפקודות kubectl יוכלו להתייחס לקבצים המקומיים.

מידע נוסף זמין במאמר מתזמן הטופולוגיה.

  1. מגדירים את חשבון השירות:

    kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/gpudirect-tcpxo/topology-scheduler/service-account.yaml
    
  2. מתקינים את הסקריפטים של מתזמן הטופולוגיה ב-configmap:

    curl -OL  https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/gpudirect-tcpxo/topology-scheduler/schedule-daemon.py
    curl -OL  https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/gpudirect-tcpxo/topology-scheduler/label-nodes-daemon.py
    
    kubectl -n kube-system create configmap topology-scheduler-scripts \
        --from-file=schedule-daemon.py=schedule-daemon.py \
        --from-file=label-nodes-daemon.py=label-nodes-daemon.py
    
  3. מתקינים את ה-DaemonSet של התווית של הטופולוגיה ואת ה-Pod של מתזמן הטופולוגיה:

    kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/gpudirect-tcpxo/topology-scheduler/label-nodes-daemon.yaml
    $ kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/container-engine-accelerators/master/gpudirect-tcpxo/topology-scheduler/schedule-daemon.yaml
    
  4. בדיקת הפעולות של מתזמן הטופולוגיה:

    kubectl -n kube-system logs topology-scheduler-pod
    

הרצת עומס העבודה

פיתוח קובץ Docker והעברה בדחיפה אל Google Cloud Artifact Registry

  1. יוצרים קטגוריה של Cloud Storage ומאגר Docker. ב-scripts/setup-and-configure-resources.sh script, מחליפים את שמות הקטגוריה והמאגר בשמות שיצרתם, ואז מריצים את הסקריפט:

    bash scripts/setup-and-configure-resources.sh
    
  2. יוצרים את קובץ האימג' pytorch-megatron:23.11-py3 ומעבירים אותו בדחיפה למאגר. מוודאים ששם המאגר ב-Docker בקובץ scripts/build-and-push-docker-image.sh זהה לשם המאגר שבו השתמשתם בסקריפט scripts/setup-and-configure-resources.sh. אפשר גם לערוך את שם התג של קובץ האימג' של Docker לפני שמעבירים אותו.

    bash scripts/build-and-push-docker-image.sh
    

הפעלת הערכת הביצועים של Megatron-LM Llama2

  1. עורכים את הקובץ helm/values.yaml כדי לציין את הקטגוריה של Cloud Storage ואת קובץ אימג' של Docker שיצרתם בקטעים הקודמים. דוגמאות להגדרות מופיעות במאמר sample-configurations.

  2. אופציונלי: אפשר גם לערוך את הקובץ selected-configuration.sh כדי לציין שינויים שביצעתם בהגדרת ברירת המחדל של Helm.

    helm install HELM_EXPERIMENT_NAME helm/ --values helm/values.yaml
    

    מחליפים את HELM_EXPERIMENT_NAME בשם שרוצים לתת לניסוי.

הניסוי כותב מדדים מכלי הפרופיילינג של Nsight Systems לקטגוריה של Cloud Storage שצוינה בספרייה megatron-experiments.

הסרת המשאבים

כדי לא לצבור חיובים לחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה:

מוחקים את אשכול GKE:

נכנסים לדף Clusters:

מעבר אל Clusters

  1. מסמנים את התיבה של CLUSTER_NAME.
  2. לוחצים על מחיקה.
  3. כדי לאשר את המחיקה, מקלידים CLUSTER_NAME ולוחצים על מחיקה.

מחיקת הקטגוריה של Cloud Storage

נכנסים לדף Buckets:

כניסה לדף Buckets

  1. מסמנים את התיבה של קטגוריה של Cloud Storage שיצרתם בשביל המדריך למתחילים הזה.

  2. לוחצים על מחיקה.

  3. כדי לאשר את המחיקה, מקלידים DELETE ולוחצים על מחיקה.

המאמרים הבאים