Package: compiler-gym
Reinforcement learning environments for compiler optimization tasks.Checkthe websitefor more information.IntroductionCompilerGym is a library of easy to use and performant reinforcement learning
environments for compiler tasks. It allows ML researchers to interact with
important compiler optimization problems in a language and vocabulary with which
they are comfortable, and provides a toolkit for systems developers to expose
new compiler tasks for ML research. We aim to act as a catalyst for making
compilers faster using ML. Key features include:Ease of use:built on the the popularGyminterface - use Python to write your agent. With CompilerGym, building ML
models for compiler research problems is as easy as building ML models to play
video games.Batteries included:includes everything required to get started. Wraps
real world programs and compilers to provide millions of instances for
training. Provides multiple kinds of pre-computed program representations: you
can focus on end-to-end deep learning or features + boosted trees, all the way
up to graph models. Appropriate reward functions and loss functions for
optimization targets are provided out of the box.Reproducible:provides validation for correctness of results, common
baselines, andleaderboardsfor you to submit your results.For a glimpse of what's to come, check outour
roadmap.News & EventsApril 2022: ⭐️ CompilerGym wins thedistinguished paper awardatCGO'22! You can read our workhere.April 2022: 📖 OurtutorialatCGO'22was well attended. If you
missed the event, you can work through the materialshere.September 2021: 📄 CompilerGym was featured on theMeta AI research blog.
You can read the posthere.InstallationInstall the latest CompilerGym release using:pip install -U compiler_gymSeeINSTALL.mdfor further details.UsageStarting with CompilerGym is simple. If you not already familiar with the gym
interface, refer to thegetting started
guidefor
an overview of the key concepts.In Python, importcompiler_gymto use the environments:>>>importcompiler_gym# imports the CompilerGym environments>>>env=compiler_gym.make(# creates a new environment (same as gym.make)..."llvm-v0",# selects the compiler to use...benchmark="cbench-v1/qsort",# selects the program to compile...observation_space="Autophase",# selects the observation space...reward_space="IrInstructionCountOz",# selects the optimization target...)>>>env.reset()# starts a new compilation session>>>env.render()# prints the IR of the program>>>env.step(env.action_space.sample())# applies a random optimization, updates state/reward/actions>>>env.close()# closes the environment, freeing resourcesSee theexamplesdirectory for agent implementations, environment
extensions, and more. See thedocumentation
websitefor the API reference.LeaderboardsThese leaderboards track the performance of user-submitted algorithms for
CompilerGym tasks. To submit a result please seethis document.LLVM Instruction CountLLVM is a popular open source compiler used widely in industry and research. Thellvm-ic-v0environment exposes LLVM's optimizing passes as a set of actions
that can be applied to a particular program. The goal of the agent is to select
the sequence of optimizations that lead to the greatest reduction in instruction
count in the program being compiled. Reward is the reduction in instruction
count achieved scaled to the reduction achieved by LLVM's builtin-Ozpipeline.This leaderboard tracks the results achieved by algorithms on thellvm-ic-v0environment on the 23 benchmarks in thecbench-v1dataset.AuthorAlgorithmLinksDateWalltime (mean)Codesize Reduction (geomean)Robin Schmöcker, Yannik Mahlau, Nicolas FröhlichPPO + Guided Searchwrite-up,results2022-0269.821s1.070×FacebookRandom search (t=10800)write-up,results2021-0310,512.356s1.062×FacebookRandom search (t=3600)write-up,results2021-033,630.821s1.061×FacebookGreedy searchwrite-up,results2021-03169.237s1.055×Anthony. W. JungGATv2 + DD-PPOwrite-up,results2022-06258.149s1.047×FacebookRandom search (t=60)write-up,results2021-0391.215s1.045×Facebooke-Greedy search (e=0.1)write-up,results2021-03351.611s1.041×Jiadong GuoTabular Q (N=5000, H=10)write-up,results2021-042534.3051.036×FacebookRandom search (t=10)write-up,results2021-0342.939s1.031×Patrick HesseDQN (N=4000, H=10)write-up,results2021-0691.018s1.029×Jiadong GuoTabular Q (N=2000, H=5)write-up,results2021-04694.1050.988×ContributingWe welcome contributions to CompilerGym. If you are interested in contributing please seethis document.CitationIf you use CompilerGym in any of your work, please citeour
paper:@inproceedings{CompilerGym,
      title={{CompilerGym: Robust, Performant Compiler Optimization Environments for AI Research}},
      author={Chris Cummins and Bram Wasti and Jiadong Guo and Brandon Cui and Jason Ansel and Sahir Gomez and Somya Jain and Jia Liu and Olivier Teytaud and Benoit Steiner and Yuandong Tian and Hugh Leather},
      booktitle={CGO},
      year={2022},
}