Design a Scalable ML Model Weight Distribution System
System DesignModel answerLast updated
Design a robust, distributed infrastructure to distribute, version, and activate multi-gigabyte machine learning model weights across thousands of regional GPU inference instances safely.
In modern AI platforms, modern LLMs and foundation models range from tens to hundreds of gigabytes in size. These models are split into multiple tensor-parallel or pipeline-parallel shards and must be deployed rapidly to thousands of GPU inference nodes distributed across multiple cloud regions.
Design an end-to-end architecture to manage the publication, distribution, verification, and zero-downtime activation of large ML model weight files across thousands of inference servers.
System Scope & Requirements
-
Scale & Performance:
- Model weights range from 20 GB to 500 GB per release, partitioned into 8 to 64 shards (e.g., 2 GB to 15 GB per shard).
- The fleet consists of 10,000 GPU hosts spread across 4–6 geographic regions, organized by hardware capabilities (e.g., A100 vs. H100 hosts).
- Target update frequency: up to 5 model releases per day.
- Rollout completion time target: under 15 minutes for full fleet deployment without overloading cross-region network links or storage backends.
-
Core Functionality:
- Publication & Storage: Ingest model artifacts as immutable, versioned objects with chunking and cryptographic signatures.
- Distribution & Caching: Efficient multi-tier distribution (e.g., regional caches, peer-to-peer, or origin offloading) supporting content deduplication and chunk-level resumable downloads.
- Worker Orchestration: Pull-based or hybrid worker agents handling state machines: target discovery, background downloading, integrity verification, local caching, and seamless memory activation.
- Rollout & Control: Canary deployment stages (e.g., 1% -> 10% -> 50% -> 100%), automated health monitoring, and instant (<30 second) metadata-driven rollbacks.
- Security & Integrity: End-to-end cryptographic checksum verification, per-host access authorization via short-lived credentials, and strict isolation.
Required Deliverables
Your design should cover:
- High-level architecture and component interaction.
- Data structures and schemas for manifests, releases, and deployment targets.
- API definitions for publishing, client discovery, and download flow.
- Weight distribution and local activation strategies (avoiding serving downtime and disk exhaustion).
- Handling edge cases (network drops, corrupt disk blocks, host restarts mid-download, rollbacks).
- Operational trade-offs (e.g., push vs. pull, P2P vs. CDN/regional origin servers, eager loading vs. lazy loading).
Hints
Hint 1
Calculate the bandwidth required to push a 200 GB file to 10,000 nodes simultaneously from a single storage bucket to illustrate the necessity of hierarchical caching or P2P fan-out.
Hint 2
Distinguish clearly between downloading weights to local host storage and activating weights into GPU/VRAM memory. Think about host disk constraints and blue/green warm loading.
Hint 3
Consider how content-addressable storage (using SHA-256 block hashing) allows deduplicating unchanged transformer layers across incremental fine-tunes or release iterations.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. High-Level System Architecture
A robust model distribution system must decouple control plane metadata management from data plane artifact transfer. Pushing a 200 GB model to 10,000 hosts directly from a central object store would demand an aggregate bandwidth of $200 \text{ GB} \times 10,000 = 2 \text{ Petabytes}$. At a 15-minute rollout target, this translates to $2 \text{ PB} / 900 \text{ s} \approx 2.22 \text{ TB/s}$ (~17.8 Tbps), which would saturate central storage limits and incur massive cross-region egress costs.
To solve this, we employ a multi-tier distribution architecture:
+-----------------------------------------------------------------------------------+
| CONTROL PLANE |
| +---------------------+ +---------------------+ +---------------------------+ |
| | Publishing Service | | Deployment Service | | Metadata Store (Cockroach)| |
| +----------+----------+ +----------+----------+ +-------------+-------------+ |
+------------|-------------------------|----------------------------|---------------+
| (1. Register) | (4. Assign Target Version) | (Polling API)
v v v
+-----------------------------------------------------------------------------------+
| DATA PLANE |
| +-------------------------------------------------------------------------------+ |
| | Global Object Store (Primary S3 Bucket - Immutable Raw Artifacts) | |
| +------------------------------------+------------------------------------------+ |
| | |
| +-------------------+-------------------+ |
| v v |
| +----------------------------+ +----------------------------+ |
| | Region A Cache (Nginx/S3) | | Region B Cache (Nginx/S3) | |
| +--------------+-------------+ +--------------+-------------+ |
| | | |
| +-------+-------+ +-------+-------+ |
| v v v v |
| +---------+ +---------+ +---------+ +---------+ |
| | Worker | <-> | Worker | | Worker | <-> | Worker | |
| | Agent 1 | P2P | Agent 2 | | Agent 3 | P2P | Agent 4 | |
| +---------+ +---------+ +---------+ +---------+ |
+-----------------------------------------------------------------------------------+
Core Components
- Model Registry & Control Plane: Exposes APIs to publish artifacts, create release targets, declare canary rules, and track fleet convergence.
- Global Object Store (Origin): S3/GCS bucket containing master copies of immutable model shards and block chunks.
- Regional Distribution Nodes (T2 Caches): In-region read-through proxy caches (e.g., regional S3 buckets or high-throughput Nginx/varnish clusters) to localize cross-region bandwidth.
- Peer-to-Peer (P2P) Overlay / BitTorrent (T1 Local Distribution): Host agents form intra-rack/intra-AZ P2P meshes (e.g., using Dragonfly or custom BitTorrent-over-gRPC) to fan out chunks without overloading regional caches.
- Inference Worker Agent: A daemon running on every GPU host. It polls the deployment service, retrieves model manifests, downloads missing chunks concurrently, verifies checksums, writes to local NVMe, and signals local inference containers to trigger hot-reloads.
2. Data Model & Schema Design
Model Manifest Structure (Immutable Metadata)
Models are split into content-addressed chunks (e.g., 64 MB chunks). Identical chunks between fine-tuned versions are automatically deduplicated.
{
"model_id": "llm-70b-instruct",
"version": "v2.4.0",
"created_at": 1710000000,
"signature": "MEQCID... (ECDSA signature over hash of hashes)",
"shards": [
{
"shard_index": 0,
"filename": "model-00001-of-00008.safetensors",
"total_size_bytes": 17179869184,
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"chunks": [
{
"chunk_index": 0,
"offset": 0,
"length": 67108864,
"sha256": "8f4e24... "
}
]
}
],
"hardware_requirements": {
"min_vram_gb": 80,
"tensor_parallel_degree": 8
}
}
Database Schema (Control Plane)
CREATE TABLE models (
model_id VARCHAR(64) PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE model_versions (
model_id VARCHAR(64) REFERENCES models(model_id),
version VARCHAR(32),
manifest_uri VARCHAR(512) NOT NULL,
manifest_hash VARCHAR(64) NOT NULL,
status VARCHAR(16) CHECK (status IN ('uploading', 'published', 'deprecated')),
PRIMARY KEY (model_id, version)
);
CREATE TABLE deployment_targets (
target_id UUID PRIMARY KEY,
model_id VARCHAR(64) NOT NULL,
version VARCHAR(32) NOT NULL,
region VARCHAR(32) NOT NULL,
hardware_cohort VARCHAR(32) NOT NULL, -- e.g., "g5.12xlarge", "h100-8x"
rollout_percentage INT CHECK (rollout_percentage BETWEEN 0 AND 100),
status VARCHAR(16) CHECK (status IN ('active', 'paused', 'rolled_back')),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE TABLE worker_status (
worker_id VARCHAR(64) PRIMARY KEY,
region VARCHAR(32) NOT NULL,
current_version VARCHAR(32),
target_version VARCHAR(32),
download_progress FLOAT DEFAULT 0.0,
state VARCHAR(32) CHECK (state IN ('IDLE', 'DOWNLOADING', 'VERIFYING', 'READY_TO_SWAP', 'ACTIVE', 'FAILED')),
last_heartbeat TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
3. API Specs
Publisher API: Publish New Version
POST /v1/models/{model_id}/versions
Content-Type: application/json
Request:
{
"version": "v2.4.0",
"shards": [...],
"signature": "..."
}
Response:
201 Created
{
"model_id": "llm-70b-instruct",
"version": "v2.4.0",
"upload_urls": [
{"shard": 0, "chunk": 0, "url": "https://s3.us-east-1.amazonaws.com/..."},
...
]
}
Worker API: Get Assigned Target (Polling)
GET /v1/workers/{worker_id}/assignment?region=us-east-1&cohort=h100-8x
Authorization: Bearer <mTLS-or-Host-Token>
Response:
200 OK
{
"model_id": "llm-70b-instruct",
"target_version": "v2.4.0",
"manifest_url": "https://cache.us-east-1.internal/manifests/v2.4.0.json",
"force_immediate": false
}
Worker API: Report Status (Heartbeat)
POST /v1/workers/{worker_id}/heartbeat
Content-Type: application/json
Request:
{
"current_active_version": "v2.3.9",
"target_version": "v2.4.0",
"state": "DOWNLOADING",
"download_progress_pct": 68.5,
"error_message": null
}
Response:
200 OK
4. Step-by-Step Distribution & Activation Workflow
Publisher Control Plane Regional Cache Worker Host (Agent) GPU Inference Engine
| | | | |
|-- 1. Upload Model->| | | |
| & Manifest | | | |
| |-- 2. Update Target | | |
| | Version Config ->| | |
| | | | |
| |<------------------- 3. Poll Target Version -| |
| |--- Returns Target Version Metadata--------->| |
| | | | |
| | |<-- 4. Download Chunks -| |
| | | (Parallel HTTP/P2P) | |
| | |----------------------->| |
| | | |-- 5. Checksum Verification
| | | | (SHA-256 + Signatures)
| | | | |
| | | |-- 6. Shadow Load into -|
| | | | RAM/VRAM (Warmup) |
| | | | |---> (Inference Server)
| | | |-- 7. Atomic Pointer Swap
| | | | (Zero Downtime) |
| |<-- 8. Report "ACTIVE" Status ---------------+ |
- Publishing: Model trainer generates shards, produces SHA-256 hashes for 64MB chunks, signs the manifest using a private key, and uploads shards to the Global Object Store.
- Target Assignment: Release engineers configure
deployment_targets(e.g., 10% canary inus-east-1). - Discovery & Polling: Worker Agent polls the Control Plane every 15 seconds. It detects a target version (
v2.4.0) different from its active version (v2.3.9). - Multi-Threaded Download & Dedup:
- The Agent checks local NVMe storage for chunk SHA-256 hashes. If chunks match
v2.3.9, they are hard-linked directly to thev2.4.0cache directory (zero download overhead for unchanged weights). - Missing chunks are fetched using HTTP Range requests from regional caches or via intra-rack P2P connections.
- The Agent checks local NVMe storage for chunk SHA-256 hashes. If chunks match
- Validation: Checksums are validated block-by-block during streaming download. Once complete, the total manifest cryptographic signature is verified against public key certificates.
- Activation (Zero Downtime):
- NVMe Cache Management: Weights sit on local fast NVMe arrays (
/var/models/llm-70b-instruct/v2.4.0/). - VRAM Warmup / Blue-Green Swap:
- Scenario A (Sufficient VRAM / Host Memory): The inference engine (e.g., vLLM or Triton) loads
v2.4.0weights into spare RAM/VRAM alongsidev2.3.9. - Scenario B (Constrained VRAM): The agent coordinates with the load balancer to drain traffic on the host, unloads
v2.3.9from VRAM, loadsv2.4.0, runs self-diagnostics (forward pass on synthetic prompts), and re-enables traffic.
- Scenario A (Sufficient VRAM / Host Memory): The inference engine (e.g., vLLM or Triton) loads
- NVMe Cache Management: Weights sit on local fast NVMe arrays (
- Heartbeat & Telemetry: Agent updates Control Plane state to
ACTIVE.
5. Rollout Strategy & Automatic Rollback
Staged Rollout Pipeline
- Canary (1-2%): Deployed to isolated worker pool in one region. Monitored for 10 minutes.
- Regional Ramp (10% -> 50%): Deployed across host cohorts.
- Global Rollout (100%): Full fleet update.
Automated Safety Controls & Fast Rollback
- Metrics Evaluated: HTTP 5xx rates, GPU Out-Of-Memory (OOM) errors, tail latency (P99), model generation sanity scores.
- Rollback Procedure:
- If error budget is breached, Control Plane updates
deployment_targetsback tov2.3.9instantly. - Workers retain the previous
N-2versions on local NVMe storage (/var/models/cache). - Upon receiving the rollback target signal, the Worker Agent skips downloading entirely and initiates an immediate local memory re-activation, achieving target rollback in < 30 seconds.
- If error budget is breached, Control Plane updates
6. Edge Cases & Resilience
| Failure Scenario | Mitigation Strategy |
|---|---|
| Network Interruption during download | Resumable chunk downloading using standard HTTP range headers (Range: bytes=X-Y). Completed 64MB chunks are persisted and validated independently. |
| Bit Rot / Corrupt File on Disk | Continuous background file system auditing using SHA-256 validation. Corrupt chunks trigger automatic re-fetching from regional storage before activation. |
| Worker Host Reboot mid-upgrade | State machine is fully persistent on disk (/var/models/agent_state.json). Upon boot, the agent reads target state, verifies existing chunks, and resumes download seamlessly. |
| Regional Storage Outage | Agents fall back to secondary regional caches or directly to the primary cross-region Object Store using exponential backoff with jitter. |
| Disk Space Exhaustion | Strict LRU (Least Recently Used) cache eviction policy. The agent never deletes the currently ACTIVE version or the immediate PREVIOUS backup version. |
7. Trade-offs & Deep Dive Considerations
-
P2P (BitTorrent-style) vs. Hierarchical Regional CDN:
- P2P Advantages: Substantially decreases regional egress bandwidth costs; throughput scales linearly with host count.
- P2P Disadvantages: Complex network topology, potential cross-rack network congestion, unpredictable peer availability.
- Recommendation: Use hierarchical regional caches (S3 buckets/Nginx proxies per Availability Zone) as primary source, with light intra-rack P2P chunk sharing enabled for large clusters.
-
Eager Fetching vs. Lazy Streaming:
- Lazy Streaming (e.g., mounting weights via FUSE/S3FS): Fast initial process start time, but causes catastrophic GPU starvation and unpredictable latency spikes during request execution.
- Eager Fetching: Download and verify 100% of weights to local NVMe prior to process activation. Guarantees deterministic inference latencies and robust fault isolation.
-
In-Process Hot-Swap vs. Container Recycling:
- In-Process Hot-Swap: Requires complex custom memory allocation in C++/CUDA to swap weight tensors without restarting the RPC server. Zero socket disruption.
- Container/Process Restart (Blue-Green): Simpler, prevents CUDA memory fragmentation leaks, but requires load balancer draining logic. Blue-Green process execution is preferred for stability.