How mosaicml/streaming works
Main Components
• Client/Training Applications: Represented by the entry points that users interact with (e.g., PyTorch DataLoader using StreamingDataset).
• Streaming Core Engine: Centered in the “streaming” directory. This module handles:
– Data ingestion and shuffling
– Local caching and disk usage limits
– Data formatting (supporting MDS, CSV/TSV, JSONL, etc.)
– Integration for different data modalities (text, image, video, multimodal)
• Data Conversion and Preparation Tools: Found in examples, scripts, and conversion subfolders (e.g., “scripts/compression”, “streaming/multimodal/convert”, “streaming/text/convert”) that prepare raw data into MDS shards.
• Simulation and Testing: The “simulation” directory contains components for simulating a distributed environment, handling reproducibility (determinism), establishing interfaces for CLI, UI, and testing components.
• Cloud Storage Integration and Remote Data Access: Indicated via the README usage examples – the system streams from remote sources (AWS S3, OCI, GCS, etc.) and caches data locally.
• Utilities and Frameworks: The “scripts”, “tests”, and “docs” folders suggest the presence of various utilities for performance monitoring (hashing, compression, partitioning) as well as rigorous testing and documentation.
Relationships and Interactions
• Clients/Training Applications interact with the StreamingDataset (from the streaming module), fetching data which triggers:
– Caching to a local directory, managed by internal logic that deletes least-recently used shards based on a configurable cache limit.
– Data shuffling and mixing (utilizing submodules in “streaming/base/shuffle” and “streaming/base/batching”) that maintain reproducibility.
• Simulation services (in the “simulation” directory) can be represented as optional scaffolding that can simulate multi-node distributed behavior as well as provide CLI or GUI interfaces (modules in “simulation/interfaces”).
• Testing and utilities are separate from core operations but confirm the performance and correctness of the system. They should be depicted as peripheral components fed into the quality assurance of the core system.
Architectural Patterns and Design Principles
• Modularity: The separation into directories such as streaming, simulation, scripts, and tests indicates a modular design where each component (e.g., core streaming, simulation interfaces, conversion utilities) is loosely coupled.
• Separation of Concerns: Distinct concerns are split among data ingestion, conversion, streaming/shuffling/data handling, and interfacing with external systems. This supports ease of maintenance and extensibility.
• Distributed / Multi-node Determinism: Emphasize the design principle of absolute ordering across nodes/GPU devices which provides true determinism and instant resumption.
• Extensibility: The design supports many data modalities (image, text, video, multimodal) and cloud providers through the use of configurable modules.