ColossalAI
ColossalAI copied to clipboard
[FEATURE]: Implement LayoutConverter
Describe the feature
LayoutConverter mainly has three main functions:
- Search an efficient transform path for the given pair of source_layout and target_layout.
- Estimate the converting cost for the given pair of source_layout and target_layout.
- Apply the layout converting path to redistribute a tensor from source_layout to target_layout.
To search the transform path, we use a heuristic algorithm which could be simplily describe as:
- Step1: Generate all one-step transform sequences from source_layout.
- Step2: Pick the 'best' layout following the heuristic function.
- Step3: Repeat above steps until the source layout transform to target layout.
To estimate the total converting cost, we implement a method to estimate the communication cost of each communication operation under the instruction of CommSpec. Then, we just need sum the costs of CommSpec in the transform_sequence up to get the total converting cost.