Official agent skill

SageMaker Production Defaults

by huggingface in huggingface/skills

Deploys SageMaker endpoints with autoscaling, CloudWatch alarms and tags on by default, using scripts for real-time, scale-to-zero and async setups.

OfficialApache-2.0Auto-check passedDevOps & Cloud

Install SageMaker Production Defaults

skills CLI
$ npx skills add huggingface/skills --skill hf-cloud-sagemaker-production-defaults -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install huggingface/skills hf-cloud-sagemaker-production-defaults --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/huggingface/skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/hf-cloud-sagemaker-production-defaults .claude/skills/hf-cloud-sagemaker-production-defaults && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hf-cloud-sagemaker-production-defaults
GitHub stars
11k
Used in
1 other repo
Token cost
~6.9k tokens
SKILL.md length
2,950 words
Files
8 (incl. scripts, references)
Skills in repo
25
Repo updated
First seen
Licence
Apache-2.0

At a glance

Deploys SageMaker endpoints with autoscaling, CloudWatch alarms and tags on by default, using scripts for real-time, scale-to-zero and async setups.

  • Works in 5 steps: SageMaker Model — image + env vars +… → Endpoint config — instance type, initial… → Endpoint — the real-time endpoint… → …
  • Creating a SageMaker endpoint for an LLM or embedding model
  • SKILL.md covers What gets created, Running the deployment, InService is not success —… and Testing a real-time endpoint, plus 6 more sections
  • Runs Python scripts from its folder; calls python, aws and python3

What it does

This is the last step of a SageMaker deployment workflow. Once the planner has chosen an endpoint type, IAM has a role and image selection has a container URI, the skill turns them into a deployment. Each endpoint gets a model, an endpoint config, the endpoint itself, an autoscaling target and policy that tracks invocations per instance, and CloudWatch alarms for latency, errors and platform overhead, all tagged CreatedBy=agentic-deploy-skills for later cleanup.

Three scripts cover the variants: deploy.py for real-time endpoints, deploy_ic.py for real-time endpoints that scale to zero through inference components, and deploy_async.py for async endpoints. Helper scripts invoke and tear down endpoints. Data capture to S3 is off by default because of ongoing costs and is enabled with a flag. For vLLM text generation the model snapshot is first packaged as a model.tar.gz in an account-controlled S3 bucket, and TEI embedding deployments use simpler environment variables and no inference AMI version.

When your agent uses it

  • Creating a SageMaker endpoint for an LLM or embedding model
  • Writing deployment code that calls create_endpoint
  • Deploying a scale-to-zero or async inference endpoint
  • Adding alarms and autoscaling to a planned deployment

Example prompts

  • “Deploy our fine-tuned model to a real-time SageMaker endpoint with autoscaling and alarms.”
  • “Set up an async SageMaker endpoint that scales to zero for batch document embedding.”
  • “Tear down the endpoint we created yesterday along with its alarms.”

Requirements

  • An AWS account with SageMaker access and an IAM execution role
  • A container image URI for the model
  • Python for the deployment scripts

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  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

What it can do on your machine

Read from SKILL.md and the folder at commit c3ff942. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 6 files in scripts/ (Python), which the agent can run.

    Shell commands in SKILL.md call:

    • python
    • aws
    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • aws.github.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

SageMaker Production Defaults loads about 6.9k tokens when it runs, and up to ~7.8k if it reads all its reference files. Until then it costs about 190 tokens; SKILL.md has 2,950 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~190
When it runs · the whole SKILL.md, loaded when a task matches
~6.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from huggingface/skills at commit c3ff942, republished under its Apache-2.0 licence (© huggingface). 2,950 words, ~6,873 tokens.

Download SKILL.mdSave it as .claude/skills/hf-cloud-sagemaker-production-defaults/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
hf-cloud-sagemaker-production-defaults
description
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 a bare `create_endpoint` call without these defaults — endpoints without autoscaling or alarms are demos, not deployments.

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:

bash
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):

bash
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:

ParameterSource
--image-urihf-cloud-serving-image-selection — agent reads from the AWS DLC catalog page
--inference-ami-versionhf-cloud-serving-image-selection — required for vLLM tags containing cu130+
--role-arnhf-cloud-sagemaker-iam-preflight (check_role.py)
--regionhf-cloud-aws-context-discovery
--instance-typeUser input or planner recommendation
--envModel-specific; see hf-cloud-serving-image-selection for required SM_VLLM_* vars
--model-s3-uriPreferred 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.

InService is not success — smoke-test before declaring victory

InService only means the container answered /ping. In MMS-based containers (HF Inference Toolkit) the Java front-end answers pings even while the Python worker crash-loops — an endpoint can be InService and serve nothing. Two checks, always:

  1. One real invocation.

    • Real-time: invoke_endpoint.py (below) with a minimal payload; require an HTTP 200 with a sane body.
    • Async: upload one input to S3, call invoke-endpoint-async, poll the output URI for a few minutes (see "Invoking async endpoints"). A result object = success; an object at the failure URI, or nothing appearing, = broken.
  2. Scan the endpoint logs for worker-crash markers — catches the crash-loop case even when the smoke request merely times out:

    bash
    aws logs filter-log-events \
        --log-group-name /aws/sagemaker/Endpoints/<endpoint-name> \
        --filter-pattern '?"Worker died" ?"Load model failed" ?"ImportError"' \
        --region <region> --max-items 5

    Inference-component deployments log to /aws/sagemaker/InferenceComponents/<component-name> instead. deploy_ic.py scans that group automatically while it waits.

General rule for denied diagnostics: when a read-only call the workflow uses for diagnosis is denied (a restricted role without logs:FilterLogEvents, servicequotas:ListServiceQuotas, and so on), say so in one line and carry on with the checks that do work. Never block a deployment on a permission needed only for diagnosis, and never read a denied call as evidence that nothing is wrong.

Only report the deployment complete after both pass. If the log scan hits, surface the actual traceback from CloudWatch — not the InService status.

Testing a real-time endpoint

Once the endpoint is InService, test it with the bundled helper. It is cross-platform and BOM-safe — use it instead of hand-writing a payload file and calling invoke-endpoint directly:

bash
# macOS / Linux
python3 scripts/invoke_endpoint.py \
    --endpoint-name <endpoint-name> \
    --payload '{"inputs": "Hello"}' \
    --region "$REGION"
powershell
# Windows (PowerShell)
python scripts\invoke_endpoint.py `
    --endpoint-name <endpoint-name> `
    --payload-file payload.json `
    --region $REGION

It accepts either --payload '<json>' (inline) or --payload-file <path>, validates JSON, writes the request body as plain UTF-8, invokes the endpoint, and prints the response body to stdout.

The UTF-8 BOM gotcha (Windows)

If you write the request payload yourself on Windows, do not use Set-Content -Encoding UTF8 — depending on the PowerShell version it prepends a UTF-8 byte-order mark (BOM). SageMaker's JSON parser rejects a BOM with a 400 ModelError:

Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

This is not a model, endpoint-health, or image problem — only the file encoding of the request body. invoke_endpoint.py avoids it entirely (it even strips a BOM from a --payload-file that already has one). If you must call the CLI directly, write the body as BOM-free UTF-8:

powershell
# BOM-free UTF-8 — use this
[System.IO.File]::WriteAllText((Resolve-Path "payload.json"), $json, [System.Text.UTF8Encoding]::new($false))

aws sagemaker-runtime invoke-endpoint `
    --endpoint-name <endpoint-name> `
    --content-type application/json `
    --body fileb://payload.json `
    --region $REGION `
    response.json

Fallback: if any invocation fails with Unexpected UTF-8 BOM, rewrite the payload as BOM-free UTF-8 (or re-run via invoke_endpoint.py) and retry once before treating the endpoint or model as broken.

Invoking a generative reranker (vLLM)

Generative rerankers (Qwen3-Reranker etc. — routed to the HuggingFace vLLM DLC by hf-cloud-serving-image-selection) are causal LMs scored by their first generated token, not chat models. Use the completions API with a raw prompt, not the messages/chat API: chat templating does not reliably honor chat_template_kwargs such as {"enable_thinking": false}, and a wrong template silently returns near-identical scores for every query–document pair instead of erroring.

Payload shape (Qwen3-Reranker's expected format — substitute {query} / {document}):

json
{
  "prompt": "<|im_start|>system\nJudge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be \"yes\" or \"no\".<|im_end|>\n<|im_start|>user\n<Instruct>: Given a web search query, retrieve relevant passages that answer the query\n<Query>: {query}\n<Document>: {document}<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n",
  "max_tokens": 1,
  "temperature": 0,
  "logprobs": 20
}

The trailing <|im_start|>assistant\n<think>\n\n</think>\n\n suffix is load-bearing: it pre-fills an empty thinking block so the first generated token is the yes/no judgment. Score from the returned logprobs: P("yes") / (P("yes") + P("no")). Sanity check the endpoint with one relevant pair (expect >0.9) and one irrelevant pair (expect <0.05) — near-identical scores across pairs mean the prompt template is wrong, not that the model is broken.

The same rule generalizes: for any thinking-mode model where the prompt must be byte-exact, prefer the raw completions API over chat.

Picking the image URI

The agent reads the image URI from AWS's Deep Learning Containers catalog — pick the row that matches the model family (HuggingFace vLLM for LLMs, TEI for embeddings, etc.), substitute <region> with the deployment region, and pass to deploy.py --image-uri.

For vLLM images specifically (both huggingface-vllm and the AWS vllm fallback), also check the tag's CUDA version:

bash
# Example: HuggingFace vLLM 0.21.0 from the catalog
IMAGE_URI="763104351884.dkr.ecr.eu-west-1.amazonaws.com/huggingface-vllm:0.21.0-transformers5.8.1-gpu-py312-cu130-ubuntu22.04"

# cu130 tag → must pass --inference-ami-version
python deploy.py --image-uri "$IMAGE_URI" \
    --inference-ami-version al2-ami-sagemaker-inference-gpu-3-1 \
    ...

For tags with cu129 or lower, omit --inference-ami-version. See hf-cloud-serving-image-selection for the full vLLM AMI lookup table and the env-var requirements for each image family.

Scale to zero for real-time endpoints

A real-time endpoint reaches zero instances only when it hosts inference components. The variant-scoped target that deploy.py registers cannot go below one instance. deploy_ic.py builds the component-based shape instead.

Use it when traffic is sparse or scheduled, and the client tolerates a multi-minute first request. Do not use it for interactive traffic with an SLA: the wake takes minutes, and every request during the wake fails.

bash
python scripts/deploy_ic.py \
    --model-name qwen3-scale-to-zero \
    --image-uri "$IMAGE_URI" \
    --inference-ami-version "$AMI" \
    --role-arn "$ROLE_ARN" \
    --model-s3-uri "s3://<your-model-bucket>/qwen3-scale-to-zero/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
How it differs from deploy.py
PieceModel-based (deploy.py)Component-based (deploy_ic.py)
Execution roleon the Modelon the endpoint config (ExecutionRoleArn)
Model referenceProductionVariants[].ModelNameInferenceComponent.Specification.ModelName; the variant has no ModelName
Instance floorInitialInstanceCount, min 1ManagedInstanceScaling {Status: ENABLED, MinInstanceCount: 0}
Scaling targetendpoint/<ep>/variant/AllTraffic, sagemaker:variant:DesiredInstanceCountinference-component/<ic>, sagemaker:inference-component:DesiredCopyCount
Scaling metricSageMakerVariantInvocationsPerInstance (20/min)SageMakerInferenceComponentConcurrentRequestsPerCopyHighResolution (5 concurrent/copy)
Wake from zeronot applicablestep policy + NoCapacityInvocationFailures alarm
Invocationendpoint nameendpoint name plus InferenceComponentName

InferenceAmiVersion still belongs on the variant, and it coexists with ManagedInstanceScaling (verified on cu130 + ml.g5.xlarge).

Four pieces make zero work, and all four are required. Target tracking cannot leave zero, because it cannot divide by zero copies. Drop the step policy or its alarm and the endpoint scales to zero once, then never answers again. deploy_ic.py wires all four.

Measured behaviour

Qwen/Qwen3-0.6B from the Hub, ml.g5.xlarge, us-east-1, July 2026:

StepTime
Endpoint InService (it starts empty, no model loads)4 min
Component InService (Hub download + vLLM boot + CUDA graphs)+6 min
Idle to 0 copies11 min after the last request
0 copies to 0 instances+12 min
First request at zero → HTTP 400 has no capacityimmediate
NoCapacityInvocationFailures alarm → ALARM+67 s
Step policy raises desired copies and instances to 1+1 min 42 s
HTTP 200+9 min 24 s

Scale-in is not tunable through this skill: Application Auto Scaling creates the AlarmLow itself with a 10 s period and 90 evaluation periods, so 15 minutes of idle datapoints are required before it fires.

Pre-stage production weights and pass --model-s3-uri. Besides avoiding runtime Hub access, this shortens every wake: model artifacts are loaded again on every wake, so their retrieval sits on the critical path of the first request after each idle period.

Sizing the component

ComputeResourceRequirements is a scheduling reservation, not a cap. A component that requests 1024 MB runs vLLM with several GB of host memory without trouble.

The schedulable pool is far smaller than the instance memory. On ml.g5.xlarge (16 GiB) the scheduler accepts 1024 MB and rejects 4096 MB. Over-asking gives an instant, confusing failure:

There is not enough hardware resources on the instances for this endpoint to
create a copy of the inference component.

That message appears even when the endpoint has a healthy instance. Treat it as "the request is too large", not "add instances". Start at the 1024 MB default and raise it only when several components share one instance.

--accelerator-devices must match SM_VLLM_TENSOR_PARALLEL_SIZE for multi-GPU models.

Invoking and testing

Pass the component name, and allow for the wake:

bash
python3 scripts/invoke_endpoint.py \
    --endpoint-name <endpoint-name> \
    --inference-component-name <component-name> \
    --payload '{"prompt": "hello", "max_tokens": 16}' \
    --wait-for-capacity 900 --region "$REGION"

The 400 has no capacity error is the wake signal, not a fault: it publishes the metric that triggers the step policy. With --wait-for-capacity the helper retries every 30 s until a copy serves the request. Without it, a cold endpoint always looks broken.

Teardown order

teardown.py handles both shapes, but the order is load-bearing:

  1. alarms (<endpoint>-* and <component>-*)
  2. scaling policies and the scalable target, on the component resource id
  3. inference components
  4. endpoint, endpoint config, model

Two behaviours make this necessary:

  • delete-endpoint does not delete the components. They survive, keep reporting InService, and block a new component with the same name. Always delete components first.
  • Component deletion is refused during transient states — CREATE_IN_PROGRESS while the container boots, and UPDATE_RC_IN_PROGRESS while a scaling action changes the copy count. The script retries every 15 s for 15 min; a teardown right after a scaling event legitimately takes several minutes.

The TargetTracking-inference-component/<ic>-AlarmHigh|Low alarms belong to Application Auto Scaling. Deleting the policy removes them, so the script does not touch them (verified: no alarms remain after teardown).

Show full SKILL.md (1,176 more words)Show less

Async inference deployments

For long-running inferences (>60s), large payloads, or workloads that are bursty/sparse enough to benefit from scale-to-zero, use deploy_async.py instead of deploy.py. Async supports MinCapacity=0 on the variant itself. Real-time endpoints also reach zero, but only through inference components — see "Scale to zero for real-time endpoints" below. Async remains the right choice when a single inference exceeds the 60s InvokeEndpoint response limit.

bash
python scripts/deploy_async.py \
    --model-name flux-text-to-image \
    --image-uri "$IMAGE_URI" \
    --role-arn "$ROLE_ARN" \
    --instance-type ml.g5.2xlarge \
    --region "$REGION" \
    --output-s3-uri s3://amzn-s3-demo-async-output/async-output/ \
    --env HF_MODEL_ID=black-forest-labs/FLUX.1-dev

Required extras over deploy.py:

  • --output-s3-uri — where async results land (results are not returned synchronously)

Optional async-specific flags:

  • --failure-s3-uri — separate path for failed invocations
  • --success-sns-topic, --error-sns-topic — get notified when async results are ready or fail
  • --min-capacity 0 (the default) — scale to zero between batches
  • --backlog-per-instance-target N — target queue depth per instance (default 5)
  • --max-concurrent-invocations-per-instance N — default 4
How scale-to-zero works

The async script registers two autoscaling policies on the variant:

  1. Target-tracking on ApproximateBacklogSizePerInstance — handles ongoing scaling between min and max
  2. Step-scaling triggered by a HasBacklogWithoutCapacity CloudWatch alarm — handles 0→1 wake-from-zero

Both are needed. Target-tracking alone cannot transition from zero (it can't divide by zero instances), so without the step policy the endpoint comes up, scales to zero after the first batch, and never wakes again. The script wires this up automatically.

Async alarms

The script creates three CloudWatch alarms:

  • ApproximateBacklogSize > 50 — queue is building faster than capacity can drain it
  • InvocationsFailed > 5 — repeated processing failures
  • HasBacklogWithoutCapacity — drives the wake-from-zero policy (not a notification alarm; its action is the step-scaling policy, not the SNS topic)

If you pass --sns-alarm-topic <arn>, the first two notify on that topic. The wake alarm always points at the step policy.

Invoking async endpoints

Async endpoints aren't called synchronously. You upload the input to S3, call invoke-endpoint-async with the S3 input location, and SageMaker writes the result to your --output-s3-uri when done:

bash
# Upload your input first
aws s3 cp input.json s3://amzn-s3-demo-input/job1/input.json

# Invoke
aws sagemaker-runtime invoke-endpoint-async \
    --endpoint-name <endpoint-name> \
    --input-location s3://amzn-s3-demo-input/job1/input.json \
    --content-type application/json \
    --region <region>

# Poll for the result at your output URI
aws s3 cp s3://amzn-s3-demo-async-output/async-output/<inference-id>.out result.json

The same UTF-8 BOM caveat applies to the input.json you upload (see "The UTF-8 BOM gotcha" above) — if you build it on Windows, write it as BOM-free UTF-8 or the container's JSON parser will reject it.

Teardown works the same as real-time: python3 scripts/teardown.py <endpoint-name> (the teardown script discovers policies and alarms by name prefix, so it handles both deployment modes).

Defaults at a glance

SettingDefaultOverride
Initial instance count1--initial-instance-count
Autoscaling min / max1 / 4--min-capacity, --max-capacity
Autoscaling target20 invocations/min/instance--target-invocations-per-instance
Data capturedisabled (opt-in)--enable-data-capture
CloudWatch alarms3 alarms--no-alarms
SNS notificationnone (alarms created but won't notify)--sns-alarm-topic <arn>
Environment tagdev--environment
InferenceAmiVersionnone (SageMaker default)--inference-ami-version (REQUIRED for vLLM CUDA 13+)

Not defaulted (user-specific input needed): VPC config, KMS key, multi-variant, async inference.

Autoscaling target — tune by model type

The default --target-invocations-per-instance 20 is conservative and tuned for LLM workloads where each request takes 1–5 seconds. For embedding deployments (TEI), each request is much faster (typically <100ms on CPU, <20ms on GPU), so a single instance can handle far more throughput. For embedding deployments, raise the target to 100–500 depending on instance and model size. The default of 20 will trigger autoscaling far too aggressively for embeddings and waste money.

A rule of thumb: target value ≈ 60 / (typical request latency in seconds). LLM at 3s latency → target 20. Embedding at 100ms → target 600. Generative rerankers sit in between — they generate a single token per request, so ~40–100 is a reasonable target.

Data capture + IAM gotcha

If the user enables data capture, the execution role needs S3 write access to the capture prefix. The default URI (s3://sagemaker-<region>-<account>/<endpoint>/data-capture/) is typically a different bucket than the model artifact bucket. If hf-cloud-sagemaker-iam-preflight scoped the inline policy narrowly to just the model bucket, capture writes fail silently — endpoint keeps serving but no data appears.

If the user reports "data capture isn't showing up", check the role's S3 access. Either widen the inline policy or pass --data-capture-s3-uri pointing to a bucket the role can write.

Teardown

bash
python3 scripts/teardown.py <endpoint-name> <region>   # macOS / Linux
python  scripts\teardown.py <endpoint-name> <region>   # Windows

Deletes in safe order: alarms → autoscaling → endpoint (stops billing) → endpoint config → model. Idempotent.

Does not delete: the IAM execution role (might be shared), data capture S3 objects (user might want to keep), SNS topic, original model artifacts.

Always tell the user about the teardown command after the deployment summary. Users forget; endpoints accrue cost.

When the deployment fails

CannotStartContainerError + no CloudWatch logs ever created — the InferenceAmiVersion problem. If the image tag contains cu130 or later and you didn't pass --inference-ami-version al2-ami-sagemaker-inference-gpu-3-1, this is the cause. See hf-cloud-serving-image-selection. Do NOT chase images, IAM roles, env vars, or instance types — the failure signature is identical for many other things but the cause here is the AMI.

"Failed to pass ping health check" — the container did start and produced logs, but /ping isn't responding. Check CloudWatch at /aws/sagemaker/Endpoints/<endpoint-name>. Usually: wrong image for model architecture, missing HF token, or OOM.

"Container failed to start" (with logs present) — entrypoint ran, then exited. Check CloudWatch. Common: missing required env vars (SM_VLLM_MODEL, SM_VLLM_HOST, SM_VLLM_TRUST_REMOTE_CODE), wrong ModelDataUrl format, unreadable model artifacts.

ResourceLimitExceeded — no quota for the instance type in this region. Request increase or pick a different type (the planner should have checked quotas up front — see hf-cloud-sagemaker-deployment-planner).

ImportError: libtorch_cuda.so: undefined symbol: ncclCommResume in CloudWatch logs — known packaging defect in huggingface-pytorch-inference GPU images (see "Known-broken images" in hf-cloud-serving-image-selection). Inside the container, so no env var, AMI, instance type, or sibling tag fixes it. Switch to DJL Inference.

InService, but invocations time out / async outputs never appear — dead Python worker behind a live MMS front-end. Run the log scan from "InService is not success" above; the traceback in CloudWatch is the real error.

403 Forbidden downloading weights from HF Hub during startup — the container's bundled huggingface_hub predates HF's XET CDN auth. Add --env HF_HUB_ENABLE_HF_TRANSFER=0, or pre-stage the weights in S3. Note: this can mask a deeper failure (the worker may still crash after the download succeeds) — re-check logs after fixing it.

Diagnostic rule: when failures look identical across multiple configurations (different images, roles, instance types) and no logs are ever produced, the cause is almost always below the container — host AMI, networking, account-level — not the deployment config. Stop iterating on config; check the AMI version and account state.

Component stuck in Creating, no FailureReason — the container is crash-looping and supervisord restarts it, so the status never changes. The component holds Creating until ContainerStartupHealthCheckTimeoutInSeconds expires, up to an hour. Read /aws/sagemaker/InferenceComponents/<component-name> and look for exited: app, not expected, or api_server.py: error:. deploy_ic.py does this scan on every poll and aborts in about a minute.

There is not enough hardware resources on the instances for this endpoint — the component's ComputeResourceRequirements exceed the schedulable pool, which is much smaller than the instance memory. Lower --min-memory-mb (1024 works on ml.g5.xlarge; 4096 is rejected there). Do not add instances: the message appears with a healthy instance present.

Cannot delete inference component ... while it is in state CREATE_IN_PROGRESS / UPDATE_RC_IN_PROGRESS — normal, not an error. Retry; teardown.py retries for 15 min. UPDATE_RC_IN_PROGRESS means a scaling action is changing the copy count.

A component outlives its endpoint — delete-endpoint leaves components behind, still reporting InService. They block reuse of the name. Delete components first, which is what teardown.py does.

Don't retry blindly. The script prints the specific FailureReason from describe-endpoint — fix the root cause before retrying.

© huggingface, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (scripts, references) in skills/hf-cloud-sagemaker-production-defaults of huggingface/skills.

  • SKILL.md
  • references/deployment-template.md
  • scripts/_common.py
  • scripts/deploy.py
  • scripts/deploy_async.py
  • scripts/deploy_ic.py
  • scripts/invoke_endpoint.py
  • scripts/teardown.py

Open the folder on GitHubat commit c3ff942

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in huggingface/skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

SageMaker Production Defaults next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

SageMaker Production Defaults compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
SageMaker Production Defaults this skillhuggingface/skills11k1 repos~6.9kAutomated safety check: PassApache-2.0
Hf Cloud Serving Image Selectionwaybarrios/opencode-power-pack533—~4.3kAutomated safety check: PassApache-2.0
vLLM Model ServingOrchestra-Research/AI-Research-SKILLs13k5 repos~2.3kAutomated safety check: PassMIT
Aqua Metricsoracle/accelerated-data-science125—~1.5kAutomated safety check: PassUPL-1.0
Vllm Deploy K8svllm-project/vllm-skills103—~2kAutomated safety check: PassApache-2.0
Hf Cloud Sagemaker Production Defaultswaybarrios/opencode-power-pack533—~4.6kAutomated safety check: PassApache-2.0

Similar skills

  • Hf Cloud Serving Image Selection

    waybarrios/opencode-power-pack

    Select and verify the current region-specific serving container URI for a SageMaker model deployment.

    533 GitHub stars~4.3k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • vLLM Model Serving

    Orchestra-Research/AI-Research-SKILLs

    Deploys LLMs with vLLM for high-throughput serving, covering the OpenAI-compatible server, offline batch inference, monitoring and a Docker rollout.

    13k GitHub starsUsed in 5 repos~2.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Aqua Metrics

    oracle/accelerated-data-science

    Official

    Set up Prometheus and Grafana monitoring for AQUA vLLM model deployments on OCI.

    125 GitHub stars~1.5k tokensUpdated 1 mo ago
    DevOps & CloudAuto-check passed
  • Vllm Deploy K8s

    vllm-project/vllm-skills

    Deploy vLLM to Kubernetes (K8s) with GPU support, health probes, and OpenAI-compatible API endpoint.

    103 GitHub stars~2k tokensUpdated 6 mo ago
    AI & LLM EngineeringAuto-check passed
  • Hf Cloud Sagemaker Production Defaults

    waybarrios/opencode-power-pack

    Implement a production SageMaker endpoint with autoscaling, CloudWatch alarms, and tags.

    533 GitHub stars~4.6k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed
  • AWS AI ML

    aws/agent-toolkit-for-aws

    Official

    Selects, deploys, and customizes AI models on Amazon SageMaker.

    2.8k GitHub stars~1.7k tokensUpdated today
    AI & LLM EngineeringAuto-check passed

More from huggingface/skills

All 25 skills in this repo
  • Official

    Finds or validates a usable SageMaker execution role before deploying or training, so scripts do not try to create IAM roles they lack permission to create.

    11k GitHub starsUsed in 1 repo~1.8k tokens
    Auto-check passed
  • Official

    Chooses the right serving container and current image URI for deploying a Hugging Face model to a SageMaker endpoint, preferring Hugging Face images over generic ones.

    11k GitHub starsUsed in 1 repo~4.6k tokens
    Auto-check passed
  • Official

    Routes a sentence-transformers training task to the right model type and required reference docs and example scripts, covering bi-encoders, rerankers, sparse and multi-vector models.

    11k GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed
  • Official

    Sets up an isolated Python environment with a supported interpreter and current boto3 before any SageMaker deployment, training or AWS automation code runs.

    11k GitHub starsUsed in 2 repos~1.7k tokens
    Auto-check passed
  • Official

    Runs evaluations of Hugging Face Hub models on local hardware with inspect-ai or lighteval, and helps choose between vLLM, Transformers and accelerate backends.

    11k GitHub starsUsed in 2 repos~1.6k tokens
    Auto-check passed
  • Official

    Indexes research papers on the Hugging Face Hub from arXiv, links them to models and datasets, claims authorship and generates markdown research articles from templates.

    11k GitHub starsUsed in 4 repos~4.2k tokens
    Auto-check passed

Questions about SageMaker Production Defaults

What does SageMaker Production Defaults do?

Deploys SageMaker endpoints with autoscaling, CloudWatch alarms and tags on by default, using scripts for real-time, scale-to-zero and async setups. This is the last step of a SageMaker deployment workflow. Once the planner has chosen an endpoint type, IAM has a role and image selection has a container URI, the skill turns them into a deployment.

When should I use SageMaker Production Defaults?

SageMaker Production Defaults fits situations like: creating a SageMaker endpoint for an LLM or embedding model; writing deployment code that calls create_endpoint; deploying a scale-to-zero or async inference endpoint; adding alarms and autoscaling to a planned deployment.

How do I install SageMaker Production Defaults in Claude Code?

Run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-production-defaults -a claude-code`. Or copy the skill folder (skills/hf-cloud-sagemaker-production-defaults in huggingface/skills) into .claude/skills/hf-cloud-sagemaker-production-defaults in your project. Claude Code loads it when a task matches its description.

How do I install SageMaker Production Defaults in Codex?

Run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-production-defaults -a codex`. Or copy the skill folder (skills/hf-cloud-sagemaker-production-defaults in huggingface/skills) into .agents/skills/hf-cloud-sagemaker-production-defaults in your project. Codex loads it when a task matches its description.

Can I use SageMaker Production Defaults in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add huggingface/skills --skill hf-cloud-sagemaker-production-defaults -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hf-cloud-sagemaker-production-defaults, .gemini/skills/hf-cloud-sagemaker-production-defaults, .github/skills/hf-cloud-sagemaker-production-defaults and .opencode/skills/hf-cloud-sagemaker-production-defaults in your project.

What does SageMaker Production Defaults need to run?

Going by SKILL.md and its folder, SageMaker Production Defaults needs Python for the scripts in its folder and the command-line tools its instructions call (python, aws and python3). Our summary lists: An AWS account with SageMaker access and an IAM execution role; A container image URI for the model; Python for the deployment scripts.

Does SageMaker Production Defaults access the network?

SKILL.md names 1 domain. As links in the text: aws.github.io. This is read from the text; nothing was executed.

Is SageMaker Production Defaults safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does SageMaker Production Defaults use?

SageMaker Production Defaults is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does SageMaker Production Defaults use?

About 6.9k tokens (SKILL.md is roughly 27k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 916 tokens, read only when the agent opens those files.

What are the alternatives to SageMaker Production Defaults?

Skills that share tags, products or a category with SageMaker Production Defaults: Hf Cloud Serving Image Selection (waybarrios/opencode-power-pack, 533 stars), vLLM Model Serving (Orchestra-Research/AI-Research-SKILLs, 13k stars), Aqua Metrics (oracle/accelerated-data-science, 125 stars) and Vllm Deploy K8s (vllm-project/vllm-skills, 103 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains SageMaker Production Defaults?

huggingface (a GitHub organization, an official publisher) maintains it in huggingface/skills, which has 11,151 GitHub stars. The repository holds 25 skills in this directory. The repository was last updated on October 8, 2026.

Source: huggingface/skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.