opensite-ai/opensite-skills / aws-ai-ml
aws-ai-ml
VerifiedSelects, deploys, and customizes AI models on Amazon SageMaker. Training or Processing jobs, fine-tuning (SFT/DPO/RLVR/RLAIF), model selection, dataset preparation, evaluation, SageMaker or Bedrock deployment, inference optimization and endpoint diagnostics. Covers the full lifecycle from planning through production. Use when fine-tuning models on SageMaker, choosing which base model to customize, fine-tune, or deploy from SageMaker JumpStart or Hub, SageMakerPublicHub, or the SageMaker public model catalog, transforming or validating training data, evaluating model quality, deploying or optimizing endpoints, configuring IAM/S3 for training, or managing SageMaker Managed MLflow. Use for endpoint health, failures, latency, logs, metrics, errors. Covers Serverless Model Customization, Nova and OSS deployment paths, and PySDK v3. NOT for Ground Truth labeling, Feature Store, or general-purpose AWS infrastructure.
references/model-deployment/references/deploy-oss-bedrock.md
View on GitHub# Deploy OSS Merged LoRA to Bedrock CMI
## Scenario
- **Model Type**: OSS (Open Source)
- **Fine-tuning Method**: LoRA
- **Merge Status**: Merged (`merge_weights: true`)
- **Deployment Target**: Bedrock Custom Model Import (CMI)
- **Approach**: SageMaker PySdk `BedrockModelBuilder`
## Overview
Uses the SageMaker PySdk `BedrockModelBuilder` to import a fine-tuned model into Bedrock as a Custom Model Import (CMI). The builder auto-resolves model artifacts from a training job.
**Required inputs** (collected in the steps below):
- Training job name
- Model name
- IAM role ARN (with Bedrock trust policy and S3 read access)
- AWS region (must be us-east-1, us-east-2, us-west-2, or eu-central-1)
## Prerequisites
### Model Size Limit
Bedrock CMI has a 200GB limit for text models (100GB for multimodal). Check before proceeding: run `aws s3api list-objects-v2 --bucket <bucket> --prefix <prefix>/checkpoints/hf_merged/` and sum the `Size` field from all returned objects.
If the model exceeds 200GB, this pathway cannot be used.
### Required Files
The `hf_merged/` folder must contain: `.safetensors` files, `config.json`, `tokenizer.json`, `tokenizer_config.json`.
### SDK Version
Requires `'sagemaker>=3.7.1,<4.0'` with `BedrockModelBuilder` support.
## Workflow
### Step 1: Gather Training Job Name
The training job name was identified in Step 1 of the main workflow. Confirm you have it.
### Step 2: Gather Model Name
Suggest a name for the deployed model based on the training job or use case. Format: lowercase, alphanumeric with hyphens. Confirm with the user.
### Step 3: Verify IAM Role
Use the IAM role from the training job (extracted in Step 1 of the main workflow via `describe-training-job`). We'll assume this role has the necessary permissions for Bedrock deployment.
### Step 4: Confirm Region
Bedrock CMI is available in: us-east-1, us-east-2, us-west-2, eu-central-1 (this matches the AWS Custom Model Import documentation at the time of writing: https://docs.aws.amazon.com/bedrock/latest/userguide/model-customization-import-model.html). There is no public API to query CMI region availability, so this may change over time. Note: attempting CMI in an unsupported region does not return a clean "region not supported" error — it typically fails with an access/authorization-style error — so rely on this list plus the linked docs rather than probing.
The region was identified in Step 1. Confirm it's in the supported list. If not, tell the user that Bedrock deployment is not supported for this model in this region.
### Step 5: Confirm Configuration
> "Here's the deployment setup:
>
> - Deployment target: Bedrock
> - Training Job: [job-name]
> - Model Name: [name]
> - IAM Role: [arn]
> - Region: [region]
>
> Does this look right?"
⏸ Wait for user approval.
### Step 6: Generate Code
Read `../references/code_output_guide.md` for output format rules.
If a project directory already exists (from earlier in the workflow), use it. Otherwise, load the **directory-management** reference to set one up.
⏸ Wait for user.
## Code Structure
### Markdown Header
```json
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Deploy to Bedrock"
]
}
```
### Cells
Each cell's content comes from `../code_templates/deploy-oss-bedrock.py`, split on the `# Cell N:` comments. Each marker starts a new notebook cell — everything between one marker and the next becomes that cell's content.
- **Cell 1**: Setup (pip install)
- **Cell 2**: Configuration
- **Cell 3**: Flatten S3 Structure and Start Import
- **Cell 4**: Wait for Import to Complete
- **Cell 5**: Test Inference
- **Cell 6**: Save Manifest
### Placeholders
Cell 2:
- `[REGION]` → AWS region
- `[TRAINING_JOB_NAME]` → SageMaker training job name
- `[ROLE_ARN]` → IAM role ARN with Bedrock trust policy and S3 read permissions
- `[MODEL_NAME]` → Name for the imported model
All other cells have no placeholders.
### Step 7: Provide Run Instructions
```
To run:
1. Cell 1 — install/upgrade SageMaker SDK
2. Cell 2 — configuration and imports
3. Cell 3 — flattens S3 structure and starts import job via BedrockModelBuilder
4. Cell 4 — waits for import to complete (typically a few minutes)
5. Cell 5 — test inference with a sample prompt
6. Cell 6 — saves the deployment manifest to `manifests/deploy-<name>.json`
```
## Common Issues
- **"Model weights are larger than 200GB"**: Cannot use this pathway.
- **"No module named 'sagemaker.serve.bedrock_model_builder'"**: Upgrade SDK: `pip install --upgrade 'sagemaker>=3.7.1,<4.0'`
- **Import starts but uses wrong region**: Known issue — `BedrockModelBuilder` defaults to us-east-1. The notebook code overrides this.
- **"Access denied to S3"**: Add S3 read permissions to the IAM role for the model bucket.
- **"Provided IAM role could not be assumed"**: Ensure role has trust policy for `bedrock.amazonaws.com`.
## Post-Deployment Summary
After the notebook runs successfully, tell the user:
- **Model**: `[MODEL_NAME]` has been imported to Bedrock
- **How to invoke**: Use the Bedrock `invoke_model` API with the imported model ARN
- **Billing**: Pay per request — no cost while idle
- **Cleanup**: When done, delete the imported model by running `aws bedrock delete-imported-model --model-identifier <model-name>`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |