How pku-dair/hetu-galvatron works
Overview:
Step 1: Identify Main Components
• Galvatron Profiler: This module handles hardware and model profiling. It includes subcomponents that collect information on device capabilities (e.g., via the profile_hardware directory and nccl-tests) and model computation patterns (located in several “models” directories).
• Galvatron Search Engine: This is the optimization “brain” which, using sophisticated cost modeling and dynamic programming techniques, explores the space of parallel strategies. Its source files, especially within galvatron/core/search_engine, indicate the presence of cost model evaluation and strategy generation functions.
• Galvatron Runtime Framework: This module is responsible for translating high-level strategies into execution instructions. It encompasses both the parallelism execution logic and runtime configurations (found in galvatron/core/runtime and related pipeline and tensor parallel submodules).
Step 2: Capture Additional System Elements
• Model Implementations: A variety of Transformer models (T5, BERT, GPT, Llama, Swin, ViT, etc.) are provided under galvatron/models, each with their own configuration, dataloader, and profiling scripts. Represent these as a component or submodule that feeds into the profiling and runtime modules.
• Hardware Configuration and Profiling Tools: The galvatron/profile_hardware folder (and related scripts in this directory) should be shown as part of the Profiler’s input channel.
• Datasets and Checkpointing: The site_package and tools directories include additional capabilities such as distributed checkpoint strategies, dataset utilities, and inference modules. They can be shown as auxiliary services that integrate with the runtime layer when needed.
• User Interface and Integration: Command scripts (in scripts, Makefile files, etc.) and installation procedures indicate a user-friendly interface. Consider denoting an “Interface/Controller” block that receives the user-specified hardware settings and model configurations, then triggers the profiling, search, and runtime procedures.
– Data flows from the “Hardware & Model Profiling” block to the “Search Engine.”
– The optimized parallel strategy configuration then moves to the “Runtime Framework.”
– The runtime outputs feed into training execution and possibly interact with the dataloader and checkpoint modules.
• Inter-module relationships, for example:
– The Profiler gathers metrics and passes computed profiles (memory, compute, communication) to the Search Engine.
– The Search Engine applies algorithmic searches (via dynamic programming) to select an optimal hybrid parallel strategy.
– The Runtime Framework employs these strategies to orchestrate distributed training.
• Technology details (e.g., “PyTorch ≥ 2.1.0”) and mention that strategies include DP, TP, PP, SP, and activation checkpointing.
– Core modules (e.g., use rectangles with bold borders).
– Supporting libraries/tools (e.g., use rounded rectangles).
Step 4: Tailoring for This Project Type
Since Galvatron is a full-fledged distributed training framework:
1. Separation and interaction between the profiling, strategy optimization, and runtime execution. This is essential to capture the high-level architecture of automatic parallelism.
2. Subcomponents that are customized for specific Transformer models. For instance, within the “Model” component, list out variants like T5, BERT, GPT, Llama, etc., and note that each has dedicated configurations, dataloaders, and parallel strategy scripts.
3. Integration of external tools such as nccl-tests for hardware profiling and the associated scripts deployed under galvatron/scripts and galvatron/tools.
• Galvatron Profiler (including hardware profiling, model profiling)
• Galvatron Search Engine (with cost model, dynamic programming algorithm)
• Galvatron Runtime Framework (with execution engine, distributed parallel execution)
• Model Library (with sub-blocks for T5, BERT, GPT, Llama, etc.)
• External/Supporting Tools (nccl-tests, checkpointing, dataset modules)
• Flow from profiling to search engine.
• Flow from search engine to runtime framework.
• Feedback loops if any (e.g., iterative optimization adjustments).
• Labels and Annotations describing:
• The specific parallelism techniques (DP, TP, PP, SP, CKPT).
• Hardware and model configuration details.
• Integration with frameworks like PyTorch.