הצגת מודל DeepSeek-V3 באמצעות פריסת GPU מרובת מארחים

סקירה כללית

‫Gemini Enterprise Agent Platform תומך בפריסת GPU מרובה לאירוח מודלים שחורגים מיכולת הזיכרון של צומת GPU יחיד, כמו DeepSeek-V3,‏ DeepSeek-R1 ו-Meta LLama 3.1 405B (גרסה לא מכומתת).

במדריך הזה מוסבר איך להפעיל מודל DeepSeek-V3 באמצעות יחידות עיבוד גרפיות (GPU) מרובות מארחים בפלטפורמת הסוכנים של Gemini Enterprise עם vLLM. ההגדרה בדגמים אחרים דומה. מידע נוסף זמין במאמר בנושא הפעלת vLLM עבור מודלים של שפה טקסטואלית ומולטימודלית.

לפני שמתחילים, חשוב לוודא שאתם מכירים את המושגים הבאים:

אפשר להשתמש במחשבון עלויות כדי ליצור הערכת עלויות בהתאם לשימוש החזוי.

קונטיינרים

כדי לתמוך בפריסות של כמה מארחים, במדריך הזה נעשה שימוש בתמונה של מאגר vLLM שנבנה מראש עם שילוב של Ray מ-Model Garden. ‫Ray מאפשר עיבוד מבוזר שנדרש להרצת מודלים בכמה צמתי GPU.

אם רוצים, אפשר ליצור תמונה משלכם של vLLM עם כמה צמתים. חשוב לשים לב שתמונת הקונטיינר המותאמת אישית צריכה להיות תואמת ל-Gemini Enterprise Agent Platform.

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

לפני שמתחילים בפריסת המודל, צריך לוודא שמתקיימים התנאים המוקדמים שמפורטים בקטע הזה.

הגדרת Google Cloud פרויקט

  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 Agent Platform API.

    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 Agent Platform API.

    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. במסוף Google Cloud , מפעילים את Cloud Shell.

    הפעלת Cloud Shell

    בחלק התחתון של Google Cloud המסוף יתחיל סשן של Cloud Shell ותופיע הודעה של שורת הפקודה. Cloud Shell היא סביבת מעטפת שבה ה-CLI של Google Cloud מותקן ומוגדרים ערכים לפרויקט הקיים. הסשן יופעל תוך כמה שניות.

בקשת מכסת GPU

כדי לפרוס את DeepSeek-V3, צריך שתי מכונות וירטואליות a3-highgpu-8g עם שמונה יחידות GPU מסוג H100 בכל אחת, כלומר 16 יחידות GPU מסוג H100 בסך הכול. סביר להניח שתצטרכו לבקש הגדלה של מכסת יחידות ה-GPU מסוג H100, כי ערך ברירת המחדל הוא פחות מ-16.

  1. כדי לראות את מכסת ה-GPU של H100, עוברים לדף Quotas & System Limits במסוף Google Cloud .

    כניסה לדף Quotas & System Limits

  2. שליחת בקשה לשינוי המכסות

העלאת המודל

  1. כדי להעלות את המודל שלכם כמשאב Model ל-Gemini Enterprise Agent Platform, מריצים את הפקודה gcloud ai models upload באופן הבא:

    gcloud ai models upload \
        --region=LOCATION \
        --project=PROJECT_ID \
        --display-name=MODEL_DISPLAY_NAME \
        --container-image-uri=us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/pytorch-vllm-serve:20250312_0916_RC01 \
        --container-args='^;^/vllm-workspace/ray_launcher.sh;python;-m;vllm.entrypoints.api_server;--host=0.0.0.0;--port=7080;--model=deepseek-ai/DeepSeek-V3;--tensor-parallel-size=8;--pipeline-parallel-size=2;--gpu-memory-utilization=0.82;--max-model-len=163840;--max-num-seqs=64;--enable-chunked-prefill;--kv-cache-dtype=auto;--trust-remote-code;--disable-log-requests' \
        --container-deployment-timeout-seconds=7200 \
        --container-ports=7080 \
        --container-env-vars=MODEL_ID=deepseek-ai/DeepSeek-V3
    

    מחליפים את הפרטים הבאים:

    • LOCATION: האזור שבו אתם משתמשים ב-Gemini Enterprise Agent Platform
    • PROJECT_ID: מזהה הפרויקט ב- Google Cloud
    • MODEL_DISPLAY_NAME: השם המוצג שרוצים לתת למודל

יצירת נקודת קצה ייעודית להסקת מסקנות אונליין

כדי לתמוך בבקשות להשלמת צ'אט, קונטיינר Model Garden דורש נקודת קצה ייעודית. נקודות קצה ייעודיות הן בגרסת טרום-השקה (Preview) ולא תומכות ב-Google Cloud CLI, לכן צריך להשתמש ב-API בארכיטקטורת REST כדי ליצור את נקודת הקצה.

  1. כדי ליצור את נקודת הקצה הייעודית, מריצים את הפקודה הבאה:

    PROJECT_ID=PROJECT_ID
    REGION=LOCATION
    ENDPOINT="${REGION}-aiplatform.googleapis.com"
    
    curl \
      -X POST \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "Content-Type: application/json" \
      https://${ENDPOINT}/v1/projects/${PROJECT_ID}/locations/${REGION}/endpoints \
      -d '{
        "displayName": "ENDPOINT_DISPLAY_NAME",
        "dedicatedEndpointEnabled": true
        }'
    

    מחליפים את הפרטים הבאים:

    • ENDPOINT_DISPLAY_NAME: השם המוצג של נקודת הקצה

פריסת המודל

  1. מריצים את הפקודה gcloud ai endpoints list כדי לקבל את מזהה נקודת הקצה של נקודת הקצה להסקת מסקנות אונליין:

    ENDPOINT_ID=$(gcloud ai endpoints list \
     --project=PROJECT_ID \
     --region=LOCATION \
     --filter=display_name~'ENDPOINT_DISPLAY_NAME' \
     --format="value(name)")
    
  2. מריצים את הפקודה gcloud ai models list כדי לקבל את מזהה המודל:

    MODEL_ID=$(gcloud ai models list \
     --project=PROJECT_ID \
     --region=LOCATION \
     --filter=display_name~'MODEL_DISPLAY_NAME' \
     --format="value(name)")
    
  3. פורסים את המודל בנקודת הקצה באמצעות הפקודה gcloud ai deploy-model:

    gcloud alpha ai endpoints deploy-model $ENDPOINT_ID \
     --project=PROJECT_ID \
     --region=LOCATION \
     --model=$MODEL_ID \
     --display-name="DEPLOYED_MODEL_NAME" \
     --machine-type=a3-highgpu-8g \
     --traffic-split=0=100 \
     --accelerator=type=nvidia-h100-80gb,count=8 \
     --multihost-gpu-node-count=2
    

    מחליפים את DEPLOYED_MODEL_NAME בשם של המודל שנפרס. השם יכול להיות זהה לשם המוצג של המודל (MODEL_DISPLAY_NAME).

    פריסת מודלים גדולים כמו DeepSeek-V3 יכולה להימשך יותר מהזמן הקצוב לתפוגת פריסה שמוגדר כברירת מחדל. אם פסק הזמן של הפקודה deploy-model חלף, תהליך הפריסה ממשיך לפעול ברקע.

    הפקודה deploy-model מחזירה מזהה פעולה שאפשר להשתמש בו כדי לבדוק מתי הפעולה מסתיימת. אפשר לדגום את סטטוס הפעולה עד שהתשובה כוללת את "done": true. כדי לבדוק את הסטטוס, מריצים את הפקודה הבאה:

    gcloud ai operations describe \
    --region=LOCATION \
    OPERATION_ID
    

    מחליפים את OPERATION_ID במזהה הפעולה שהוחזר מהפקודה הקודמת.

קבלת מסקנות אונליין מהמודל שנפרס

בקטע הזה נסביר איך שולחים בקשת הסקה אונליין לנקודת הקצה הציבורית הייעודית שבה מודל DeepSeek-V3 נפרס.

  1. כדי לקבל את מספר הפרויקט, מריצים את הפקודה gcloud projects describe:

    PROJECT_NUMBER=$(gcloud projects describe PROJECT_ID --format="value(projectNumber)")
    
  2. שליחת בקשת חיזוי RAW:

    curl \
    -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    https://${ENDPOINT_ID}.${REGION}-${PROJECT_NUMBER}.prediction.vertexai.goog/v1/projects/${PROJECT_NUMBER}/locations/${REGION}/endpoints/${ENDPOINT_ID}:rawPredict \
    -d '{
       "prompt": "Write a short story about a robot.",
       "stream": false,
       "max_tokens": 50,
       "temperature": 0.7
       }'
    
  3. שליחת בקשה להשלמת צ'אט:

    curl \
    -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    https://${ENDPOINT_ID}.${REGION}-${PROJECT_NUMBER}.prediction.vertexai.goog/v1/projects/${PROJECT_NUMBER}/locations/${REGION}/endpoints/${ENDPOINT_ID}/chat/completions \
    -d '{"stream":false, "messages":[{"role": "user", "content": "Summer travel plan to Paris"}], "max_tokens": 40,"temperature":0.4,"top_k":10,"top_p":0.95, "n":1}'
    

    כדי להפעיל סטרימינג, משנים את הערך של "stream" מ-false ל-true.

הסרת המשאבים

כדי להימנע מחיובים נוספים על Gemini Enterprise Agent Platform, צריך למחוק את Google Cloud המשאבים שיצרתם במהלך המדריך הזה:

  1. כדי לבטל את הפריסה של המודל מנקודת הקצה ולמחוק את נקודת הקצה, מריצים את הפקודות הבאות:

    ENDPOINT_ID=$(gcloud ai endpoints list \
       --region=LOCATION \
       --filter=display_name=ENDPOINT_DISPLAY_NAME \
       --format="value(name)")
    
    DEPLOYED_MODEL_ID=$(gcloud ai endpoints describe $ENDPOINT_ID \
       --region=LOCATION \
       --format="value(deployedModels.id)")
    
    gcloud ai endpoints undeploy-model $ENDPOINT_ID \
      --region=LOCATION \
      --deployed-model-id=$DEPLOYED_MODEL_ID
    
    gcloud ai endpoints delete $ENDPOINT_ID \
       --region=LOCATION \
       --quiet
    
  2. כדי למחוק את המודל, מריצים את הפקודות הבאות:

    MODEL_ID=$(gcloud ai models list \
       --region=LOCATION \
       --filter=display_name=DEPLOYED_MODEL_NAME \
       --format="value(name)")
    
    gcloud ai models delete $MODEL_ID \
       --region=LOCATION \
       --quiet
    

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