self-hosted-llm-batch-inference
Skill25 starsChanged 44 days agoApache-2.0View on GitHub
This skill should be used when a startup without a dedicated ML platform team needs recurring, latency-tolerant offline inference for a self-hosted 1B to 8B generative language model on AWS while minimizing GPU spend and recovering automatically from Spot interruption. It prescribes AWS Batch backed by Amazon ECS Managed Instances Spot, with model artifacts staged in Amazon S3, deterministic input shards, vLLM offline inference on one GPU, bounded retries, and output reconciliation before success. Covers sizing from the real prompt and model footprint, choosing networking without an avoidable idle cost floor, and verifying that results are complete and GPU capacity is gone. Not for online endpoints, training, embeddings, other inference engines, multi-GPU or distributed inference, or one-off experiments where manual rerun is acceptable.
In this repository23 other files it gives its agents.
- advisor/AGENTS.mdAGENTS.md
- migrate/plugins/migration-to-aws/fixtures/agent-advisor-openai-demo/CLAUDE.mdCLAUDE.md
- agent-advisorSkill
- architect-for-startupsSkill
- azure-to-awsSkill
- contextual-offers-for-startupsSkill
- gcp-to-awsSkill
- heroku-to-awsSkill
- knowledge-base-for-startupsSkill
- llm-to-bedrockSkill
- prompt-library-for-startupsSkill
- start-building-for-startupsSkill
- tf-best-practicesSkill
- agent-advisorSkill
- azure-to-awsSkill
- gcp-to-awsSkill
- heroku-to-awsSkill
- llm-to-bedrockSkill
- tf-best-practicesSkill
- agentcore-patternsSkill
- cost-regression-checkSkill
- hcls-stack-checkSkill
- multi-tenant-isolationSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Keep the infrastructure stack separate from each run.
- Distinctive: line 33
Do not apply this skill to online endpoints, training or fine-tuning, embedding models, other inference engines, multi-GPU or distributed …
- Very specific: line 39
Read references/prepare-model-and-input.md and define the immutable model artifact, prompt contract, deterministic shard manifest, output …
- Very specific: line 42
Read references/run-with-aws-batch.md and author the reusable infrastructure plus the separate SubmitJob invocation.
- Very specific: line 44
Read references/verify-and-optimize.md before the canary and again after the full run.
- Very specific: line 79
references/prepare-model-and-input.md: Read before choosing GPU capacity or writing infrastructure. - Very specific: line 82
references/run-with-aws-batch.md: Read before authoring the stack or submitting a run. - Very specific: line 85
references/verify-and-optimize.md: Read before the canary and after every full run.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Self-Hosted LLM Batch Inference
Build a repeatable offline inference path for a startup that needs GPU economics without operating an ML platform. Use one AWS Batch job for one corpus run, backed by Amazon ECS Managed Instances Spot. Stage model weights in Amazon S3, divide the corpus into deterministic shards, and process those shards sequentially with vLLM on one GPU.
Keep the infrastructure stack separate from each run. Provision reusable Batch, ECR, IAM, logging, and optional networking resources with infrastructure as code. Submit each run separately with immutable image, model, prompt, input manifest, and output identifiers.
Set scaleInAfter to 0 for this architecture. No follow-up task is expected on the instance after
the Batch job ends, so retaining idle GPU capacity adds cost without improving the run.
Scope
Apply this skill only when all of these conditions hold:
- The workload is recurring, latency-tolerant, generative offline inference.
- The model is approximately 1B to 8B parameters and fits on one GPU after measurement.
- The team accepts Spot interruption and requires automatic recovery.
- One model is loaded once and reused across many input shards in a corpus run.
- Persistent artifacts and completion records can live in Amazon S3.
Do not apply this skill to online endpoints, training or fine-tuning, embedding models, other inference engines, multi-GPU or distributed inference, or one-off experiments where an operator can rerun the command manually.
Workflow
- Read
references/prepare-model-and-input.mdand define the immutable model artifact, prompt contract, deterministic shard manifest, output schema, quarantine schema, and measured sizing inputs. - Read
references/run-with-aws-batch.mdand author the reusable infrastructure plus the separateSubmitJobinvocation. Preserve one Batch job per corpus run. - Read
references/verify-and-optimize.mdbefore the canary and again after the full run. Reconcile records, confirm retry behavior, measure cost inputs, and verify that GPU capacity has terminated.
Required deliverables
- A reusable infrastructure stack for the Batch compute environment, queue, job definition, ECR repository, IAM roles and instance profile, log group, and only the networking resources that the chosen path requires.
- An immutable model artifact and manifest in Amazon S3.
- Deterministic input shards and an input manifest in Amazon S3.
- A separate
SubmitJobinvocation containing immutable image, model, prompt, input manifest, and output prefix identifiers. - Output, quarantine, and run metadata that survive infrastructure deletion.
- A verification record proving completion, record reconciliation, and GPU capacity release.
Upstream skills
Invoke upstream skills only when authoring the artifacts they own:
Skill("aws-core:aws-containers"): ECS Managed Instances, ECR, and container mechanics.Skill("aws-core:aws-cloudformation")orSkill("aws-core:aws-cdk"): the selected infrastructure-as-code implementation.Skill("aws-core:aws-iam"): role and policy implementation.Skill("aws-core:aws-storage"): S3 storage and transfer implementation.Skill("aws-core:aws-compute"): actual single-GPU instance candidates after measuring the workload.Skill("aws-core:aws-billing-and-cost-management"): current rates and cost calculations using the measurements defined here.Skill("aws-core:aws-messaging-and-streaming"): Batch state-change notifications when unattended completion needs a notification path.Skill("aws-core:aws-secrets-manager"): gated model credentials during staging only.
Reference files
references/prepare-model-and-input.md: Read before choosing GPU capacity or writing infrastructure. Defines model staging, prompt and record contracts, deterministic shards, manifests, output and quarantine schemas, and measurement inputs.references/run-with-aws-batch.md: Read before authoring the stack or submitting a run. Defines the AWS Batch architecture,scaleInAfter, networking decision, job lifecycle, retries, resumability, IAM boundaries, and stack-to-run contract.references/verify-and-optimize.md: Read before the canary and after every full run. Defines acceptance checks, reconciliation, interruption testing, capacity-release verification, and the measurements passed to cost analysis.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

