Expand description
§Object Storage Module
The object module provides traits and implementations for storing KV cache blocks in object storage systems (S3, MinIO). This corresponds to the G4 (object store) tier in the storage hierarchy.
§ObjectBlockOps Trait
The primary trait for block-level object storage operations:
| Method | Purpose |
|---|---|
has_blocks(keys) | Check existence and size of blocks |
put_blocks(keys, src_layout, block_ids) | Upload blocks using logical layout handle |
get_blocks(keys, dst_layout, block_ids) | Download blocks using logical layout handle |
put_blocks_with_layout(keys, layout, block_ids) | Upload using resolved physical layout |
get_blocks_with_layout(keys, layout, block_ids) | Download using resolved physical layout |
§Logical vs Physical Layout
The trait offers two APIs for put/get:
- Logical (
put_blocks/get_blocks): Takes aLogicalLayoutHandle(G1, G2, G3). Workers resolve this to their own physical layout internally. Used by the leader (which doesn’t have physical layouts) and byCoordinatedWorker. - Physical (
put_blocks_with_layout/get_blocks_with_layout): Takes a resolvedPhysicalLayoutdirectly. Used byPhysicalWorkerafter resolving its handles, and byS3ObjectBlockClientwhich performs the actual I/O.
§Key Formatting
Keys map SequenceHash values to object storage paths:
DefaultKeyFormatter: Uses the hash’s Display representation (e.g.,0:abc123). Suitable for single-worker scenarios.RankPrefixedKeyFormatter: Prefixes with worker rank (e.g.,0/0:abc123). Required for SPMD workers where multiple workers store the same logical block with different physical data.
The create_key_formatter(rank) factory returns the appropriate formatter.
§ObjectLockManager
Distributed locking protocol for coordinated offloads to prevent duplicate uploads:
has_meta(hash)
→ true → skip (already offloaded)
→ false → try_acquire_lock(hash)
→ true → transfer → create_meta(hash) → release_lock(hash)
→ false → skip (another instance owns it)Uses conditional PUT (If-None-Match: *) for lock acquisition with deadline-based
expiry for stale lock recovery.
§S3 Implementation
The s3 submodule (feature-gated behind s3) provides:
S3ObjectBlockClient: ImplementsObjectBlockOpsfor S3-compatible storage. Supports concurrent uploads/downloads viarayonthread pool and contiguous memory fast paths for aligned block data.S3LockManager: ImplementsObjectLockManagerusing S3 conditional writes.
§Factory Functions
create_object_client(config, rank): Creates anArc<dyn ObjectBlockOps>from configuration. Selects the backend (S3 or future alternatives) based onObjectClientConfig.create_lock_manager(config, instance_id): Creates anArc<dyn ObjectLockManager>for distributed lock coordination. Object storage module for distributed block management.
This module provides traits and implementations for storing KV cache blocks in object storage systems like S3/MinIO.
§Architecture
Traits are defined here; implementations are in feature-gated submodules:
ObjectBlockOps- High-level block operations (put, get, has)ObjectLockManager- Distributed locking for coordinated offloads
Consumers should use factory functions to obtain trait objects without depending on specific feature flags.
Modules§
- s3
- S3-compatible object storage implementations.
Structs§
- Default
KeyFormatter - Default key formatter - uses Display representation of PositionalLineageHash.
- Lock
File Content - Lock file content structure for distributed locking.
- Rank
Prefixed KeyFormatter - Rank-prefixed key formatter for SPMD workers.
Traits§
- KeyFormatter
- Trait for converting SequenceHash to object storage keys.
- Layout
Config Ext - Extension methods for LayoutConfig to support object storage operations.
- Object
Block Ops - Unified object block operations trait.
- Object
Client - Low-level object storage client trait.
- Object
Lock Manager - Object lock manager trait for distributed locking in object storage.
Functions§
- create_
key_ formatter - Create a key formatter appropriate for the given rank.
- create_
lock_ manager - Create a lock manager from configuration.
- create_
object_ client - Create an object client from configuration.