GetBatch: Distributed Multi-Object Retrieval
GetBatch: Distributed Multi-Object Retrieval
Paper: GetBatch: Distributed Multi-Object Retrieval for ML Data Loading - implementation, benchmarks, and discussion.
GetBatch is AIStore’s high-performance API for retrieving multiple objects and/or archived files in a single request. Behind the scenes, GetBatch assembles the requested data from across the cluster and delivers the result as a continuous serialized stream.
Regardless of retrieval source (in-cluster objects, remote objects, or shard extractions), GetBatch always preserves the exact ordering of request entries in both streaming and buffered modes.
Other supported capabilities include:
- Fetching thousands of objects in strict user-specified order
- Extracting specific files from distributed shard archives (TAR, TAR.GZ, TAR.LZ4, ZIP)
- Cross-bucket retrieval in a single request
- Graceful handling of missing data
- Streaming or buffered delivery
GetBatch is implemented by the eXtended Action (job). Internally, the job is codenamed
x-moss. The respective API endpoint is:/v1/ml/moss.
Note: buffered mode always returns both metadata (that describes the output) and the resulting serialized archive containing all requested data items.
Note: for TAR.GZ, both .tgz and .tar.gz are accepted (and interchangeable) aliases - both denote the same exact format.
A Note on HTTP Semantics
GetBatch uses HTTP GET with a JSON request body, which is:
- Permitted by RFC 9110 - HTTP semantics allow message bodies in GET requests.
- Necessary for this API, as the list of requested objects can contain thousands of entries that would exceed URL length limits.
- Semantically correct - the operation is idempotent (pure data retrieval with no server-side state changes).
The rest of this document is structured as follows:
Table of Contents
- Supported APIs
- Terminology
- When to Use GetBatch
- When NOT to Use GetBatch
- Go API Structure
- Python Integrations
- Usage Examples
- Direct Access to Archived Data
- Performance and Access Patterns
- Performance Tips
- Error Handling
- Configuration
- Output Formats
- Naming Conventions
- Monitoring & Observability
- Advanced Use Cases
- Limitations & Future Work
- References
Supported APIs
GetBatch is typically called from:
- Go services via the
api/ml.goclient bindings, and - Python via the AIStore SDK, and
- Third-party tooling such as Lhotse.
The respective Go and Python-based usage examples follow below, in the sections that include:
Terminology
When to Use GetBatch
ML Training Pipelines
- Loading training data in deterministic order (reproducible epochs)
- Fetching 1000s-100Ks of objects per training batch
- Consuming sharded datasets where each shard contains many samples
Distributed Shard Processing
- Extracting specific files from archives distributed across the cluster
- Processing subsets of large TAR/ZIP collections
- Parallel extraction from 1000s of shards
Ordered Batch Retrieval
- Any workflow requiring strict ordering guarantees
- Sequential processing pipelines
- Deterministic data sampling
When NOT to Use GetBatch
- Single objects => Use regular GET
- Small batches (<16 entries) => Overhead not justified; use parallel GETs
- Latency-critical single-item random access => Use regular GET or a purpose-built lookup path; GetBatch is optimized for amortized multi-entry retrieval.
Whether a batch is “small” depends on the workload and cluster. Any specific numbers in this document should be treated as rules of thumb, not as hard limits.
Go API Structure
Request: apc.MossReq
Field Details:
Request Entry: apc.MossIn
Each entry in the in array can specify:
Response: apc.MossResp
Streaming mode (strm: true):
- Single HTTP response body containing TAR stream
- Files appear in exact order requested
- No separate metadata structure
Buffered mode (strm: false):
- Multipart HTTP response with two parts:
- Metadata part (
MossRespJSON) - Data part (TAR archive)
- Metadata part (
Response Entry: apc.MossOut
Python Integrations
GetBatch also offers robust integration with Python data pipelines, with official support in both the AIStore Python SDK and third-party libraries:
1. AIStore Python SDK
The Python SDK provides a Batch class that wraps the /v1/ml/moss endpoint with a Pythonic fluent API.
Key features:
- Pydantic models (
MossReq,MossIn,MossOut) that mirror Go structs exactly - Fluent interface for building batch requests
- Automatic TAR stream extraction
- Support for archpath (shard extraction), opaque metadata, and cross-bucket requests
The SDK mirrors Go structures, with minor naming conventions:
This mapping helps translate examples between Go and Python.
Basic usage:
Batch class methods:
add(obj, archpath=None, opaque=None, start=None, length=None)- Add object with advanced parametersget(raw=False, decode_as_stream=False, clear_batch=True)- Execute and return generator of(MossOut, bytes)tuplesclear()- Clear batch for reuse
Response structure:
- Streaming mode (
streaming_get=True, default): Returns TAR stream,MossOutmetadata inferred from request - Multipart mode (
streaming_get=False): Returns server-validatedMossOutwith actual sizes, errors
See Python SDK Batch API for complete documentation.
2. Lhotse Integration
Lhotse is a speech/audio data toolkit used by NVIDIA NeMo and other frameworks. It includes native AIStore support via AISBatchLoader.
How it works:
- CutSet Manifests - Lhotse manages audio/feature manifests with AIStore URLs
- Batch Loading -
AISBatchLoadercollects all URLs from a CutSet batch - GetBatch Execution - Issues single batch request via AIStore Python SDK
- Archive Extraction - Automatically extracts files from sharded archives (TAR/TGZ)
- In-Memory Injection - Returns CutSet with data loaded into memory
Usage:
See also:
A complete, runnable example for batch loading audio from AIStore with Lhotse is available here:
Archive extraction example:
Lhotse URLs like ais://mybucket/shard-0000.tar.gz/audio/sample_42.wav automatically:
- Split into object (
shard-0000.tar.gz) + archpath (audio/sample_42.wav) - Send to GetBatch with
archpathparameter - AIStore extracts the file server-side
- Returns raw audio bytes directly to training loop
Architecture:
Key benefits:
- Single batch request instead of N individual GETs
- Server-side extraction from sharded archives
- Deterministic ordering for reproducible training
- Zero client-side decompression overhead
See also:
- AIStore in NeMo workflows (data loading section)
3. NeMo Framework Integration
NVIDIA NeMo is an end-to-end platform for building and training state-of-the-art AI models, including Automatic Speech Recognition (ASR), Natural Language Processing (NLP), and Text-to-Speech (TTS).
GetBatch is now integrated into the Lhotse-based ASR dataloader. Instead of fetching individual audio files from AIStore during training, the dataloader now batches all required samples for an epoch or mini-batch into a single GetBatch request. This reduces network overhead and improves data loading throughput for large-scale ASR training.
Enabling GetBatch:
A single environment variable activates batch loading for ASR training pipelines using Lhotse+AIStore. No code changes required.
How it works:
- Dataloader collects all audio file paths needed for the current batch
- Issues single GetBatch request to AIStore (replaces N individual GETs)
- AIStore returns TAR archive with all samples in order
- Dataloader extracts and feeds samples to the training loop
This same pattern can be integrated in other NeMo training pipelines (NLP, TTS, multimodal) where datasets are stored in AIStore, providing similar performance benefits for data-intensive workloads.
See also:
4. PyTorch Integration
The AIStore PyTorch Plugin provides AISBatchIterDataset, an iterable-style dataset that uses GetBatch API for efficient multi-worker data loading with automatic batching and streaming support.
Usage Examples
In the
curlexamples below, replaceaistore-gatewayand the bucket/object names with your own.
Example 1: Retrieve Plain Objects
Result: batch.tar containing:
Example 2: Extract Files from Shards
Result: extracted.tar containing:
Example 3: Cross-Bucket Retrieval
The request bucket (
default-bucketin URL) is used when bucket is omitted in an in entry.
Result: TAR containing objects from three different buckets in one request.
Example 4: Handle Missing Data Gracefully
Response metadata shows which items failed:
TAR contains:
Example 5: Range Reads (Partial Object Retrieval)
Per-entry start/length fields request a byte range instead of the whole object. When
archpath is empty the range applies to the object bytes as stored (a raw byte range); when
archpath is set the range applies to the extracted archived file.
Three forms are supported:
(start=0, length=0)- the entire object/file (no range)(start=N, length=L)withL>0- exactlyLbytes starting at offsetN(MossOut.size == L)(start=N, length=-1)- open-ended: from offsetNto the end of the object/file
A non-zero start requires a length (use -1 to read to the end). Ranges that fall outside
the object’s bounds are reported as ErrRangeNotSatisfiable.
With the Python SDK:
Direct Access to Archived Data
GetBatch can avoid sequential scans when the request provides enough information to locate the requested bytes directly.
This matters most for large sharded datasets, where each shard is an archive such as TAR and each training sample is stored as an archived file inside the shard.
There are two related cases:
Indexed archive extraction
When archive shards are indexed, AIS can resolve an archived file by name and use the stored offset metadata to access it directly.
For example, a request entry with both objname and archpath:
selects samples/000123.bin inside shard-000042.tar.
With a shard index available, AIS does not need to scan the archive sequentially from the beginning to find the requested file.
Range reads
GetBatch also supports byte ranges via start and length.
The range is interpreted relative to the thing being requested:
- If
archpathis empty, the range applies to the raw object bytes as stored in AIS. - If
archpathis set, AIS first resolves the archived file named byarchpath, and the range then applies to that archived file.
In other words:
For example:
returns 256 KiB starting at offset 1 MiB within samples/000123.bin, not within shard-000042.tar.
Why this matters
Without direct access, retrieving a file from a large archive may require scanning entries from the beginning until the requested file is found.
With indexing and/or client-provided range metadata, GetBatch can seek much closer to the requested data and read only the required bytes.
For large TAR objects, especially when requested files are located deep inside the archive, this can improve retrieval latency by orders of magnitude.
Performance and Access Patterns
Note: Actual throughput will vary significantly based on object sizes, network topology, storage backend, CPU capability, and cluster configuration. Numbers below are purely indicative ranges rather than guaranteed performance targets.
Note: Archived file extraction from compressed formats is CPU-intensive. A single target extracting from 1000s of TAR/ZIP shards will see significant CPU load.
Latency Components
First-byte latency: 50-500ms (can vary based on cluster size and load)
- Designated Target (DT) selection
- Peer coordination
- First data arrival
Streaming throughput: Wire-speed after first byte
- Limited by network bandwidth or disk I/O
- No additional per-object overhead once streaming starts
Shard index fast path
See Direct Access to Archived Data for the access semantics.
For a complete feature overview, see Shard Index.
To prepare TAR objects for direct archpath reads:
Indexes live in the system bucket called ais://.sys-shardidx, are consulted transparently by GET and GetBatch, and are validated against the source TAR object’s size and checksum.
For batches that fan out across many archived files in different shards, this changes per-file extraction from O(archive size) to O(1) + read.
Memory & Resource Usage
Memory: Bounded by DT capacity + load-based throttling
- System monitors memory pressure
- Automatically throttles or rejects (429) new requests under stress
- See Monitoring GetBatch for observability
CPU: Varies by workload
- Plain objects: minimal CPU (file I/O bound)
- Compressed archives: moderate CPU (decompression)
- Many small files: higher CPU (archive parsing overhead)
Performance Tips
For best performance, try to make each GetBatch request easy to assemble and cheap to read.
Use direct access when possible
For large archive shards, avoid repeated sequential scans. See Direct Access to Archived Data.
Use shard indexes when selecting archived files by archpath. Use range reads when the client already knows the byte offset and length of the required data.
Use colocation hints when the client knows the layout
By default, GetBatch assumes that requested objects are distributed uniformly across the cluster.
If the client knows that the batch is concentrated on a small number of targets or shards, set the colocation hint accordingly:
0: no colocation hint; suitable for uniformly distributed object names.1: target-aware; use when requested objects are likely collocated on a small number of targets.2: target- and shard-aware; use when requestedarchpathentries are likely concentrated in a small number of archive shards.
The hint helps AIS to select a better designated target and can reduce cross-cluster data movement. Level 2 can also improve archive handle reuse when many requested files come from the same shard.
Prefer larger batches, but avoid unbounded requests
GetBatch is designed to amortize request overhead across many entries. Very small batches may be faster as regular concurrent GETs, while very large batches can increase memory pressure, queueing, and retry cost.
Treat batch size as workload-dependent and validate it under realistic cluster load.
Prefer uncompressed TAR for maximum throughput
Compressed archive formats reduce network bytes but add CPU overhead for decompression.
When storage and network bandwidth are not the bottleneck, plain .tar is usually the best output format for maximum throughput.
Prefetch or cold-GET remote data
GetBatch operates on in-cluster data. For remote buckets, pre-load or prefetch before running.
Error Handling
Strict Mode (coer: false)
Behavior: First error aborts entire request
Use when:
- Data completeness is critical
- Prefer fail-fast over partial results
- Small batches where retry cost is low
Error response: HTTP 4xx/5xx, no partial data
Graceful Mode (coer: true) ✅ Recommended
Behavior: Continue processing, mark missing items
Use when:
- Large batches (1000s+ items)
- Some missing data is acceptable
- Want to maximize throughput despite occasional 404s
Missing items:
- Appear in TAR under
__404__/bucket/objectwith size=0 - Metadata includes
err_msgdescribing failure - Extracting the TAR shows all missing items grouped under
__404__/
Soft error limit: Configurable per work item (default: 6)
- Prevents cascading failures
- Aborts work item after N transient errors
- See Configuration section below
Configuration
get_batch.max_soft_errs (default: 6)
Maximum transient errors per work item before aborting.
When to increase:
- Large batches with expected missing data
- Tolerate more GFN (get-from-neighbor) fallbacks
- Unstable network environments
When to decrease:
- Strict availability requirements
- Fail faster on systemic issues
get_batch.warmup_workers (default: 2)
Pagecache warming pool size (best-effort read-ahead).
When to increase:
- Fast NVMe storage
- Reduce first-access latency
- CPU/memory headroom available
When to disable (set to -1):
- High memory pressure
- Slow disks where read-ahead adds no value
- CPU-constrained environments
To disable warmup/look-ahead operation:
Output Formats
GetBatch supports multiple archive formats via the mime field:
Recommendation: Use .tar for maximum throughput unless network bandwidth is constrained.
Naming Conventions
Default Naming (onob: false)
Files in output TAR include bucket prefix:
Object-Only Naming (onob: true)
Files in output TAR omit bucket:
Archived Files
When extracting from shards with archpath:
Default (onob: false):
Object-only (onob: true):
Monitoring & Observability
GetBatch exposes Prometheus metrics for:
- Throughput (objects vs archived files)
- Resource pressure (throttling, RxWait stalls)
- Error rates (soft vs hard errors)
See: Monitoring GetBatch for detailed metrics, PromQL queries, and operational guidance.
CLI monitoring example
CLI will render
CtlMsgoutput on multiple lines when it includes multiple aggregated messages.
Advanced Use Cases
ML Training: Deterministic Epoch Loading
Distributed Processing: Scatter-Gather Pattern
Limitations & Future Work
Supported scope
GetBatch works on in-cluster data: sharded (with shards of any kind — TAR, TAR.GZ, TAR.LZ4, ZIP), or plain monolithic objects, or chunked objects. As long as the requested data is stored on the cluster’s target disks, GetBatch will assemble and return it.
Per-entry range reads are supported for objects (chunked or monolithic) as well as for archived files: set start/length to retrieve a byte range instead of the whole object (see Example 5).
For TAR objects with shard indexes, GetBatch reads files via the shard index fast path — extracting an archpath entry becomes direct random access into the archive instead of a linear scan. The index is persisted in the ais://.sys-shardidx system bucket and is consulted transparently by both GET and GetBatch.
Known limitations
Remote (cold) GET is not supported.
When GetBatch is invoked on a remote bucket (s3://, gs://, az://, oc://) and one or more requested objects are not already stored on any target’s disks, GetBatch will not fetch them from the backend. Instead, each missing object is recorded as a soft-error placeholder (__404__/<objname> in the output archive), and the request as a whole may fail when the soft-error budget (max_soft_errs) is exceeded. The requested objects must be pre-loaded into the cluster (e.g., via ais bucket prefetch, an explicit ais get, or a separate warmup pass) before issuing GetBatch.
Cluster membership changes are disruptive to in-flight requests. Any event that mutates the cluster map (target restart, pod reschedule, scale-up, scale-down, primary proxy failover) will:
- Abort all currently-running GetBatch work items with
reason: starting x-rebalance[...]and surface asErrNotFound: (prep-rx not done?)on the client. - Trigger an automatic global rebalance.
- May leave inter-target shared-DM streams in an unrecoverable state until the affected targets are re-bounced. Re-issuing GetBatch immediately after a membership event may fail with
context deadline exceededfor several minutes.
Clients should retry GetBatch after a brief backoff once the rebalance completes. For long-running training pipelines, treat GetBatch failures during/after a membership event as expected and rely on the client-side retry path.
Shard extraction is sequential within each archive. When multiple files are requested from the same shard, they are extracted in sequence rather than in parallel. This is a performance limitation, not a correctness issue — and is largely mitigated when the shard index is enabled, which converts each per-file lookup from a linear scan into direct random access.
Roadmap
- Self-healing shared-DM bundles across Smap version changes
- Multi-file parallel extraction from a single shard
- Finer-grained work item abort controls
References
- Release Notes 4.0 - GetBatch introduction
- Go API - API control structures
- Python Integrations
- Monitoring GetBatch - Metrics and observability
- AIS CLI - Command-line tools