hf-cloud-sagemaker-production-defaults
它能做什么
这个技能会创建一个实时的 SageMaker 模型端点,并将其设置为随流量扩展、并报告问题。适合希望部署能够长期运行、之后也便于排查问题的人。
适用场景
- ✓当即将创建 SageMaker 端点的时候。
- ✓当你希望在创建端点的同时设置自动扩缩容和告警时。
- ✓当镜像和角色都已确定,你希望完成部署时。
技能链接
https://github.com/huggingface/skills/blob/main/skills/hf-cloud-sagemaker-production-defaults/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把选定的模型部署为实时端点,并设置自动扩缩容和告警,以便它能够持续运行。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会创建一组相互关联的资源:模型、它的端点配置、端点本身、自动扩缩容目标,以及针对延迟和错误的 CloudWatch 告警。除非你开启,否则数据捕获保持关闭。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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:
- SageMaker Model — image + env vars + execution role + S3 artifacts
- Endpoint config — instance type, initial count, optional data capture
- Endpoint — the real-time endpoint serving inference
- Autoscaling target + policy — target tracking on invocations per instance
- 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
常见问题
数据捕获是开启的吗?
不是。默认关闭把请求和响应记录到 S3,因为这会产生持续的存储费用。
自动扩缩容有什么作用?
它会根据流量调整实例数量,使用按每个实例的调用次数设定的目标。
端点可以缩容到零吗?
可以。实时缩容到零是它支持的端点类型之一。
详情
作者的原始描述
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
热度
- GitHub 星标
- 11k
- 排名
- #11770
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/30
评论
- …
同一仓库的更多技能
hf-cli
11k帮你的智能体使用 Hugging Face 命令行工具,下载、上传和管理模型、数据集、Spaces、仓库以及本地缓存。
hf-cloud-aws-context-discovery
11k帮你的智能体在进行任何云端工作之前,找到你的 AWS 配置文件、区域和账户信息,避免猜测该使用哪个账户。
hf-cloud-python-env-setup
11k帮你的智能体设置一个干净的 Python 环境,使用合适的 Python 版本和最新的库,然后再运行 SageMaker 或 AWS 自动化脚本。
hf-cloud-sagemaker-deployment-planner
11k帮你的智能体规划如何把模型部署到 Amazon SageMaker,在实时、无服务器、异步或批量托管之间进行选择,并使用合理的默认设置。