Multi-Tenant LLM Fine-Tuning Service on AWS: Platform Design
System DesignModel answerLast updated
Design a managed AWS platform where customers fine-tune open-weight LLMs on their own data, with isolation, budgets, resumable distributed training, evaluation and endpoint deployment.
Context
Your team is building a managed service on AWS that lets customers adapt a large language model to their own data without managing GPUs themselves. Customers range from small teams running quick experiments to enterprises with strict security demands.
What the platform must let a user do
- Upload training data: plain text, plus optional instruction/response pairs.
- Select a base model and a tuning approach: full fine-tuning, LoRA, QLoRA, or adapter layers.
- Start a training job, follow its progress, and assess the quality of the result.
- Publish the tuned model behind an inference endpoint.
Non-functional requirements
- Isolation and security: tenants must be separated (network, identity, encryption).
- Spend control: per-tenant quotas and budget limits.
- Scale-out training: multi-GPU / multi-node jobs with checkpointing.
- Reproducibility: a run can be re-created from its recorded configuration, code version and dataset version.
- Operability: metrics, logs and traces, plus recovery from failures.
What to present
- State your assumptions about scale (tenants, concurrent jobs, model and dataset sizes).
- Overall architecture, split into control plane and data plane.
- Key API surface and the core data model.
- The end-to-end training workflow.
- Data management (upload, validation, versioning).
- Evaluation strategy.
- Deep dives on isolation, cost control, distributed training and failure recovery, and serving.
Be explicit about trade-offs and what you would build first.
Hints
Hint 1
Separate a control plane (APIs, metadata, quotas, workflow orchestration) from a data plane (GPU training, storage, serving), then spend your time on the hard parts of the data plane.
Hint 2
Do the arithmetic early: a full fine-tune of a 70B model with Adam in mixed precision needs roughly 16 bytes per parameter (about 1 TB per checkpoint), while a LoRA adapter is only tens to hundreds of MB. This drives checkpointing, scheduling and serving choices.
Hint 3
Think about what you do per tenant versus what you share: dedicated nodes and scoped IAM roles during training, but a shared base model with many hot-swapped adapters at serving time.
Hint 4
Make every job fully described by an immutable record (config, image digest, git SHA, base-model revision, dataset version, seed) so you can resume, audit and reproduce it.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Framing
Split the system into a control plane (APIs, metadata, quotas, orchestration) and a data plane (GPU training, storage, serving). The difficult parts are GPU scheduling under quotas, fault-tolerant distributed training, tenant isolation, and cost-efficient serving of many tuned models.
1. Assumptions
- About 1,000 tenants and about 200 concurrent jobs; roughly 80% LoRA/QLoRA.
- Datasets from 10 MB to 100 GB of text.
- LoRA on a 7B model fits on one 8-GPU A100/H100 node. Full fine-tuning of 70B needs 32-64 GPUs with FSDP or ZeRO-3 over EFA.
- Full FT of 70B with mixed-precision Adam is about 16 bytes/param, so roughly 1.1 TB per checkpoint. A LoRA adapter is 50-500 MB.
- Serving: thousands of adapters on a few base models, each with low, long-tail traffic.
Consequences: sharded asynchronous checkpoints for big jobs, and multi-adapter serving on shared base models instead of one GPU per customer.
2. API sketch
POST /v1/datasetsreturns a presigned multipart upload URL;POST /v1/datasets/{id}/versionstriggers validation and returns an immutable version with hash and stats.POST /v1/fine_tuning/jobswith base model revision, method, dataset version, hyperparameters, compute limits, optional budget, seed and an idempotency key. Returns job id,queued, and an estimated cost.GET /jobs/{id}(status, metrics, checkpoints),GET /jobs/{id}/events(SSE stream),POST /jobs/{id}/cancel.POST /v1/evaluations,POST /v1/deployments, and an OpenAI-compatible invoke route.
3. Data model (Aurora Postgres)
- Tenant: KMS key ARN, GPU-hour quota, max concurrent GPUs, budget.
- DatasetVersion: immutable; S3 URI, content hash, schema, token count, validation report.
- Job: frozen config JSON, image digest, git SHA, base-model revision, dataset version, seed, accrued cost, state.
- Checkpoint: job, step, URI, manifest hash, final flag.
- Model registry: lineage (job, base, dataset), eval results, stage (draft, approved, deployed).
- Deployment: model, endpoint, scaling config, status.
4. Architecture
- Edge/control plane: API Gateway with Cognito or SigV4 auth, WAF and rate limits; stateless services on EKS/ECS; Aurora for metadata; DynamoDB counters for quota and spend.
- Orchestration: a Step Functions or Temporal workflow per job: validate, tokenize, schedule, train, evaluate, register. Each step is idempotent with retries.
- Data pipeline: direct-to-S3 upload under a per-tenant prefix with SSE-KMS (tenant key). Validation (Lambda for small, Batch/Spark for large) checks schema, dedup, PII/toxicity flags and length histograms, then emits tokenized, sharded, hashed artifacts.
- Training compute: EKS GPU node groups (p4d/p5 with EFA) or SageMaker HyperPod for the largest jobs. Kueue or Volcano supplies gang scheduling, priorities and fair share. FSx for Lustre linked to S3 caches base weights and data. Containers run PyTorch with FSDP/DeepSpeed, PEFT for LoRA/QLoRA, bitsandbytes for 4-bit.
- Registry/artifacts: versioned S3 (Object Lock for finals) plus registry rows.
- Evaluation: batch inference workers run public benchmarks and the customer's holdout set; results go to the registry.
- Serving: vLLM or TGI with multi-LoRA. Base models stay resident; adapters are hot-loaded from S3 into an LRU cache. Full-FT models get dedicated endpoints. A router maps model id to the right pool.
- Observability: Prometheus/Grafana for GPU utilization, tokens/s, loss, MFU; CloudWatch and OpenTelemetry for logs and traces; per-job metrics streamed to users.
5. Deep dives
Isolation and security
- Training pods in private subnets with no internet egress; S3, ECR and KMS via VPC endpoints.
- Each job uses a scoped IRSA role limited to that tenant's prefix and key. Support bring-your-own-key.
- Dedicated nodes per job, wiped after use, to avoid GPU memory remanence. Enterprise tenants can get a dedicated account/VPC.
- At serving time, isolate by adapter ID with per-request authorization. Never train on one tenant's data for another. Audit through CloudTrail.
Cost control
- Admission: estimate cost as tokens x epochs x FLOPs/token / (GPU FLOPs x MFU); reject if over remaining budget or concurrency cap.
- Runtime: accrue spend each minute; on breach, checkpoint and stop gracefully.
- Capacity mix: spot for resumable LoRA jobs, reserved/on-demand for large gang-scheduled jobs.
- Defaults: LoRA first, automatic batch size, early stopping on eval loss.
Distributed training and recovery
- Choose the parallelism plan automatically from model size and method (single node for LoRA on 7-13B, FSDP across nodes for 70B full FT).
- Checkpoint asynchronously and sharded: write to FSx, then drain to S3. Store a manifest with hashes; mark a checkpoint valid only when all shards land.
- On node failure or spot reclaim, the workflow reschedules and resumes from the last valid checkpoint, restoring optimizer state, data-loader position and RNG state. Cap retries and surface a clear terminal error.
- Watch for loss spikes/NaNs and auto-rollback to an earlier checkpoint.
Reproducibility
- Immutable dataset versions, pinned base-model revision, container digest, git SHA, seed, and frozen config. Note that bit-exact reruns are not guaranteed across hardware or non-deterministic kernels; promise "statistically equivalent" and record the caveat.
Evaluation
- Automated gates before a model can be deployed: held-out loss/perplexity, task metrics, a regression check against the base model on general benchmarks (catastrophic forgetting), safety checks, and optionally an LLM judge with calibration against human samples. Compare to the base model and to the previous version. Block promotion on failed gates.
Deployment
- Registering a LoRA adapter is cheap: copy to the adapter store and hot-load. Autoscale base-model pools on queue depth and tokens/s; use canary rollout and per-tenant rate limits.
Trade-offs and common mistakes
- Giving every tenant a dedicated endpoint: unaffordable for long-tail LoRA models; use multi-adapter serving.
- Sharing GPU nodes between tenants during training for utilization: weakens isolation; accept lower utilization or use dedicated-account tiers.
- Checkpointing synchronously to S3: stalls GPUs; use async staging.
- Ignoring gang scheduling: partial allocations deadlock large jobs.
- Estimating cost only at submit time with no runtime enforcement.
- Not versioning datasets, so results cannot be traced or reproduced.
MVP order
Start with LoRA/QLoRA on single nodes, immutable datasets, quotas, multi-adapter serving and basic evals. Add multi-node full FT, spot optimization, and dedicated-account tiers afterwards.