Architecture
Tuning Modes
The Auto Tune tool supports the following two tuning modes:
- Reinforcement Learning (RL)
Supports elewise, broadcast, and reduce operators. For details, see Operators Supporting RL Tuning.
Abstracts the schedule as a decision chain based on Monte Carlo tree search (MCTS), a heuristic search algorithm for some kinds of decision processes, and then employs RL-trained Neural Networks (NNs) to guide decision-making.
- Genetic Algorithm (GA)
Supports cube operators. For details, see Operators Supporting GA Tuning.
Generates a tuning space through multi-level combinations with manual experience for pruning and sorting, improving tuning efficiency and employs the GA to tune parameters in rounds to obtain the optimal tiling policy.
RL Tuning
RL consists of two parts, RL Tuning and RL Repositories.
Figure 6-2 shows the RL architecture.
- Controller controls the operator, including the RL algorithm, MCTS, and Policy Model (optimal model evaluation criteria based on tuned operators).
The following figure shows the principle of the Policy Model of RL tuning.
Figure 6-3 RL Policy Model training- Initialize the neural network.
- Perform sampling by using the neural network and MCTS to obtain the operator's schedule policy.
- Build the operator obtained after sampling, evaluate the operator running performance on the board, and generate the reward to obtain a training sample.
- Train the neural network in a supervised manner.
- Repeat 2 to 4 until the network result is converged.
- Environment is used to evaluate the tuning result. Rules refer to the schedule generation rules, and Estimator refers to the time estimation policy.
- The built-in repository contains the preset tuning policies for frequently-used operators under different shapes. Find it in opp/data/rl/<soc_version>/built-in in the OPP installation path.
- The custom repository stores the tiling policies with better performance than the built-in repository. In the inference scenario, it is stored in the atc/data/rl/<soc_version>/custom directory by default. You can also change the path of the custom repository as required.
GA Tuning
The GA tuning process is as follows: (1) analyze the tuning space; (2) perform tuning using the genetic algorithm; (3) obtain the optimal tiling policy and add it to the repository.
The following figure shows the GA architecture.
- The built-in repository contains the preset tuning policies for frequently-used operators under different shapes. Find it in opp/data/tiling/<soc_version>/built-in in the OPP installation path.
- The custom repository stores the tiling policies generated after GA tuning. In the inference scenario, it is stored in the atc/data/tiling/<soc_version>/custom directory by default.
The following figure shows the GA tuning principles.