SUPERSONIC is a tool to automate reinforcement learning (RL) policy searching and tuning. It is designed to help compiler developers to find the right RL architecture and algorithm to use for an optimization task. It finds the right RL exploration algorithm, the reward function and a method for modeling the environment state.
Given an RL search space defined by the Supersonic Python API, the Supersonic meta-optimizer automatically searches for a suitable RL component composition for an optimization task. It also automatically tunes a set of tunable hyperparameters of the chosen components. No RL expertise is needed to use Supersonic.
Fetch the docker image from docker hub.
$ sudo docker pull crazycreate/rl-compiler
Run the docker image.
$ docker run -dit -P --name=supersonic crazycreate/rl-compiler /bin/bash
$ docker start supersonic
$ docker exec -it supersonic /bin/bash
After importing the docker container and getting into bash in the container, run the following command to select the conda environment, before using any of the AE scripts:
$ conda activate ss
Then, go to the root directory of our tool:
(docker) $ cd /home/sys/SUPERSONIC
This task is concerned with determining the LLVM passes and their order to minimize the code size.
This demo corresponds to Figure 5 of the submitted manuscript.
Note:
Make sure the environment can import the compiler_gym.
You may encounter an error of failed tests. This is because we reduce the RL client search steps to make the search time manageable for the demo. Such failure did occur during our full-scale evaluation.
This demo shows how to apply the saved client RL to optimize a test program for Code Size Reduction.
#Client RL search
(docker) $ python SuperSonic/policy_search/supersonic_main.py --env BanditCSREnv-v0 --datapath "tasks/CSR/DATA" --mode policy --total_steps 10
#Client RL Parameter Tuning
(docker) $ python SuperSonic/policy_search/supersonic_main.py --env BanditCSREnv-v0 --datapath "tasks/CSR/DATA" --mode config --iterations 10 --task CSR
#Client RL Deployment
(docker) $ python SuperSonic/policy_search/supersonic_main.py --env BanditCSREnv-v0 --datapath "tasks/CSR/DATA" --mode deploy --training_iterations 50 --task CSR
If you want to run the SuperSonic on the PDCAT dataset, change "tasks/CSR/DATA" to "tasks/CSR/POLYBENCH_DATA".
Note: The current tasks/CSR/POLYBENCH_DATA dataset only contains the PolyBench C files converted into LLVM; it does not include the cBench dataset.
When using the Docker image, please use a version of VS Code earlier than 1.91, because the image is based on Ubuntu 18.04, which has an outdated internal Linux system that lacks the required glibc ≥ 2.28 version needed to run the VS Code Server.
For more details, see: https://github.com/HuantWang/SUPERSONIC/blob/master/AE.md