Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)11k · #11770

hf-cloud-sagemaker-production-defaults

Skill này làm gì

Skill này tạo một endpoint model SageMaker đang chạy, được thiết lập để mở rộng theo lưu lượng và báo cáo sự cố. Skill dành cho người muốn một triển khai có thể chạy lâu dài và gỡ lỗi về sau.

Khi nào nên dùng

  • ✓Khi một SageMaker endpoint sắp được tạo.
  • ✓Khi bạn muốn thiết lập autoscaling và cảnh báo cùng với endpoint.
  • ✓Khi bạn muốn hoàn tất triển khai sau khi đã biết image và role.

Liên kết skill

https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-production-defaults/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-production-defaults/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Triển khai model đã chọn thành endpoint thời gian thực có autoscaling và cảnh báo, để endpoint có thể chạy liên tục.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI tạo một nhóm tài nguyên liên kết: model, cấu hình endpoint, chính endpoint, mục tiêu autoscaling và cảnh báo CloudWatch cho độ trễ và lỗi. Thu thập dữ liệu được tắt trừ khi bạn bật nó.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

SageMaker Production Defaults

The difference between a demo endpoint and one you can leave running is: it scales with traffic, it tells you when it breaks, and you can debug it later. This skill makes those three the default rather than optional extras.

By the time this skill runs, the planner has chosen a real-time endpoint, IAM has a usable role, and image-selection has resolved a container URI + AMI version. This skill turns those into an actual deployment.

What gets created

For every endpoint, the skill creates these as a unit:

  1. SageMaker Model — image + env vars + execution role + S3 artifacts
  2. Endpoint config — instance type, initial count, optional data capture
  3. Endpoint — the real-time endpoint serving inference
  4. Autoscaling target + policy — target tracking on invocations per instance
  5. CloudWatch alarms — latency, errors, platform overhead

An inference-component deployment (deploy_ic.py) creates the same set with two changes: the endpoint config carries the execution role and ManagedInstanceScaling, and an inference component carries the model. Its autoscaling target is the component, not the variant.

Data capture (logging requests/responses to S3) is off by default — useful for debugging but creates ongoing S3 costs the user didn't necessarily ask for. Enable with --enable-data-capture.

All resources get a consistent tag set including CreatedBy=agentic-deploy-skills for later cleanup.

Defaults and reasoning in references/deployment-template.md.

Running the deployment

For a text-generation LLM (vLLM), first package the pinned model snapshot as a SageMaker model.tar.gz artifact and upload it to an account-controlled S3 bucket. SageMaker extracts it under /opt/ml/model, so the deployment does not fetch or execute repository code at runtime:

python scripts/deploy.py \
    --model-name qwen3-medical \
    --image-uri "$IMAGE_URI" \
    --inference-ami-version "$AMI" \
    --role-arn "$ROLE_ARN" \
    --model-s3-uri "s3://<your-model-bucket>/qwen3-medical/model.tar.gz" \
    --instance-type ml.g5.xlarge \
    --region "$REGION" \
    --env SM_VLLM_MODEL=/opt/ml/model \
    --env SM_VLLM_HOST=0.0.0.0 \
    --env SM_VLLM_TRUST_REMOTE_CODE=false \
    --env SM_VLLM_MAX_MODEL_LEN=4096

For an embedding model (TEI, often on CPU):

python scripts/deploy.py \
    --model-name bge-large-embeddings \
    --image-uri "$IMAGE_URI" \
    --role-arn "$ROLE_ARN" \
    --instance-type ml.c6i.2xlarge \
    --region "$REGION" \
    --env HF_MODEL_ID=BAAI/bge-large-en-v1.5

Note: TEI deployments do not need --inference-ami-version. That flag is vLLM-specific. TEI env vars are also simpler (HF_MODEL_ID instead of SM_VLLM_*, no host or trust-remote-code to configure).

Where each value comes from:

Parameter Source
--image-uri hf-cloud-serving-image-selection — agent reads from the AWS DLC catalog page
--inference-ami-version hf-cloud-serving-image-selection — required for vLLM tags containing cu130+
--role-arn hf-cloud-sagemaker-iam-preflight (check_role.py)
--region hf-cloud-aws-context-discovery
--instance-type User input or planner recommendation
--env Model-specific; see hf-cloud-serving-image-selection for required SM_VLLM_* vars
--model-s3-uri Preferred for production — S3 URI of the pinned model artifact extracted to /opt/ml/model; omit only for the Hub-at-runtime exception

The script creates resources in order with error handling, waits for InService (up to 30 min), surfaces failure reasons, registers autoscaling and alarms, and prints a summary including the teardown command. Outputs a JSON blob on stdout with endpoint/config/model names for downstream scripting.

The scripts ship with this skill. If the installed copy is missing the scripts/ directory (some harnesses copy only SKILL.md on install), fetch them from the source repo rather than re-implementing them from this description.

Model-loading default: pre-stage pinned weights in S3 and pass --model-s3-uri; the container loads them from /opt/ml/model without a runtime Hub dependency. Loading from the Hub is an explicit exception: expect a 5–15+ minute download after endpoint startup, provide a token for gated models, and keep SM_VLLM_TRUST_REMOTE_CODE=false unless the specific architecture requires reviewed custom code. deploy.py waits 30 minutes.

InServi

Câu hỏi thường gặp

Thu thập dữ liệu có được bật không?

Không. Việc ghi lại request và response vào S3 được tắt mặc định, vì nó tạo ra chi phí lưu trữ liên tục.

Autoscaling làm gì?

Nó điều chỉnh số lượng instance theo lưu lượng, dựa trên một mục tiêu về số lượt gọi trên mỗi instance.

Endpoint có thể thu nhỏ về không không?

Có. Tùy chọn scale-to-zero thời gian thực là một trong những loại endpoint mà skill hỗ trợ.

Chi tiết

Mô tả gốc của tác giả

Create a SageMaker endpoint (real-time, real-time scale-to-zero, or async) with autoscaling, CloudWatch alarms, and tagging enabled by default. Use this skill whenever about to create a SageMaker endpoint, write deployment code that calls `create_endpoint`, or finalize a deployment after the image URI and IAM role are known. Provides deploy.py for real-time endpoints, deploy_ic.py for real-time endpoints that scale to zero instances via inference components, and deploy_async.py for async endpoints (also scale-to-zero). This is the last step in the SageMaker deployment workflow. Never generate

repo: huggingface/skills

Độ phổ biến

Sao GitHub
11k
Vị trí xếp hạng
#11770
Giấy phép
Apache-2.0
Cập nhật
30/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự