compiler-gym

Reinforcement learning environments for compiler and program optimization tasks

https://github.com/facebookresearch/compilergym

Science Score: 64.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    4 of 34 committers (11.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.8%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Reinforcement learning environments for compiler and program optimization tasks

Basic Info
  • Host: GitHub
  • Owner: facebookresearch
  • License: mit
  • Language: Python
  • Default Branch: development
  • Homepage: https://compilergym.ai/
  • Size: 23.5 MB
Statistics
  • Stars: 965
  • Watchers: 33
  • Forks: 135
  • Open Issues: 115
  • Releases: 15
Created over 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

CompilerGym

Colab Python versions PyPi Downloads PyPI version License CI status

Reinforcement learning environments for compiler optimization tasks.

Check the website for more information.

Introduction

CompilerGym 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 popular Gym interface - 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, and leaderboards for you to submit your results.

For a glimpse of what's to come, check out our roadmap.

News

  • November 2022: CompilerGym v0.2.5 adds support for Python 3.10 and drops support for 3.7. See release notes for full details.
  • April 2022: ⭐️ CompilerGym wins the distinguished paper award at CGO'22! You can read our work here.
  • April 2022: 📖 Our tutorial at CGO'22 was well attended. If you missed the event, you can work through the materials here.
  • September 2021: 📄 CompilerGym was featured on the Meta AI research blog. You can read the post here.

Installation

Install the latest CompilerGym release using:

pip install -U compiler_gym

See INSTALL.md for further details.

Usage

Starting with CompilerGym is simple. If you not already familiar with the gym interface, refer to the getting started guide for an overview of the key concepts.

In Python, import compiler_gym to use the environments:

```py

import compilergym # imports the CompilerGym environments env = compilergym.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 ... observationspace="Autophase", # selects the observation space ... rewardspace="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 resources ```

See the examples directory for agent implementations, environment extensions, and more. See the documentation website for the API reference.

Leaderboards

These leaderboards track the performance of user-submitted algorithms for CompilerGym tasks. To submit a result please see this document.

LLVM Instruction Count

LLVM is a popular open source compiler used widely in industry and research. The llvm-ic-v0 environment 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 -Oz pipeline.

This leaderboard tracks the results achieved by algorithms on the llvm-ic-v0 environment on the 23 benchmarks in the cbench-v1 dataset.

| Author | Algorithm | Links | Date | Walltime (mean) | Codesize Reduction (geomean) | |--------------------------------------------------| --- | --- | --- |-----------------|------------------------------| | Robin Schmöcker, Yannik Mahlau, Nicolas Fröhlich | PPO + Guided Search | write-up, results | 2022-02 | 69.821s | 1.070× | | Facebook | Random search (t=10800) | write-up, results | 2021-03 | 10,512.356s | 1.062× | | Facebook | Random search (t=3600) | write-up, results | 2021-03 | 3,630.821s | 1.061× | | Facebook | Greedy search | write-up, results | 2021-03 | 169.237s | 1.055× | | Anthony. W. Jung | GATv2 + DD-PPO | write-up, results | 2022-06 | 258.149s | 1.047× | | Facebook | Random search (t=60) | write-up, results | 2021-03 | 91.215s | 1.045× | | Facebook | e-Greedy search (e=0.1) | write-up, results | 2021-03 | 351.611s | 1.041× | | Jiadong Guo | Tabular Q (N=5000, H=10) | write-up, results | 2021-04 | 2534.305 | 1.036× | | Facebook | Random search (t=10) | write-up, results | 2021-03 | 42.939s | 1.031× | | Patrick Hesse | DQN (N=4000, H=10) | write-up, results | 2021-06 | 91.018s | 1.029× | | Jiadong Guo | Tabular Q (N=2000, H=5) | write-up, results | 2021-04 | 694.105 | 0.988× |

Contributing

We welcome contributions to CompilerGym. If you are interested in contributing please see this document.

Citation

If you use CompilerGym in any of your work, please cite our 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}, }

Owner

  • Name: Meta Research
  • Login: facebookresearch
  • Kind: organization
  • Location: Menlo Park, California

Citation (CITATION.cff)

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Cummins"
  given-names: "Chris"
  orcid: "https://orcid.org/https://orcid.org/0000-0002-9382-4302"
- family-names: "Wasti"
  given-names: "Bram"
- family-names: "Guo"
  given-names: "Jiadong"
- family-names: "Cui"
  given-names: "Brandon"
- family-names: "Ansel"
  given-names: "Jason"
- family-names: "Gomez"
  given-names: "Sahir"
- family-names: "Jain"
  given-names: "Somya"
- family-names: "Liu"
  given-names: "Jia"
- family-names: "Teytaud"
  given-names: "Olivier"
- family-names: "Steiner"
  given-names: "Benoit"
- family-names: "Tian"
  given-names: "Yuandong"
- family-names: "Leather"
  given-names: "Hugh"
title: "CompilerGym"
version: 0.2.5
date-released: 2022-11-01
url: "https://github.com/facebookresearch/CompilerGym"
preferred-citation:
  type: conference-paper
  conference: "CGO"
  title: "CompilerGym: Robust, Performant Compiler Optimization Environments for AI Research"
  url: "https://arxiv.org/pdf/2109.08267.pdf"
  year: 2022
  authors:
  - family-names: "Cummins"
    given-names: "Chris"
    orcid: "https://orcid.org/https://orcid.org/0000-0002-9382-4302"
  - family-names: "Wasti"
    given-names: "Bram"
  - family-names: "Guo"
    given-names: "Jiadong"
  - family-names: "Cui"
    given-names: "Brandon"
  - family-names: "Ansel"
    given-names: "Jason"
  - family-names: "Gomez"
    given-names: "Sahir"
  - family-names: "Jain"
    given-names: "Somya"
  - family-names: "Liu"
    given-names: "Jia"
  - family-names: "Teytaud"
    given-names: "Olivier"
  - family-names: "Steiner"
    given-names: "Benoit"
  - family-names: "Tian"
    given-names: "Yuandong"
  - family-names: "Leather"
    given-names: "Hugh"

GitHub Events

Total
  • Issues event: 5
  • Watch event: 57
  • Issue comment event: 12
  • Fork event: 8
Last Year
  • Issues event: 5
  • Watch event: 57
  • Issue comment event: 12
  • Fork event: 8

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 2,188
  • Total Committers: 34
  • Avg Commits per committer: 64.353
  • Development Distribution Score (DDS): 0.244
Past Year
  • Commits: 2
  • Committers: 2
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
Chris Cummins c****1@g****m 1,654
Mostafa Elhoushi m****i@f****m 211
Boian Petkantchin b****n@n****m 94
Sahir Gomez s****r@f****m 55
Wonseok Jung 3****7 38
Hugh Leather h****r@f****m 19
Foivos Tsimpourlas f****s@f****m 19
canesche m****e@g****m 14
Bram Wasti b****i@f****m 12
Jiadong Guo j****o@f****m 11
Ricardo r****s@g****m 8
EC2 Default User e****r@i****l 6
Bjarke Roune b****e@f****m 5
patrick p****1@c****u 5
Jiadong Guo j****o@g****m 4
Ryan Russell g****t@r****g 3
Soumyajit k****t@g****m 3
nluu n****u@u****a 3
thecoblack v****3@g****m 3
Mostafa Elhoushi m****i@h****m 2
Youwei Liang y****l@f****m 2
xtremey m****k@g****m 2
bcui19 b****9@s****u 2
Zeyi Wang i@u****m 2
Parth Chadha p****9@g****m 2
panhaolin p****1@m****n 1
Yongqiang Tian 4****t 1
TrellixVulnTeam c****d@t****m 1
Soumith Chintala s****h@f****m 1
Qingwei Lan 8****k 1
and 4 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 127
  • Total pull requests: 20
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 months
  • Total issue authors: 54
  • Total pull request authors: 6
  • Average comments per issue: 2.66
  • Average comments per pull request: 2.05
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 6
  • Pull requests: 0
  • Average time to close issues: 5 days
  • Average time to close pull requests: N/A
  • Issue authors: 5
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ChrisCummins (33)
  • sunpeng2020 (7)
  • sogartar (6)
  • dejangrubisic (5)
  • anthony0727 (4)
  • uduse (4)
  • Rain0802 (3)
  • sparks-code (3)
  • zcfh (3)
  • dcy11011 (3)
  • libin049 (2)
  • lqwk (2)
  • JD-ETH (2)
  • alexeybelkov (2)
  • chunhualiao (2)
Pull Request Authors
  • ChrisCummins (14)
  • Panhaolin2001 (2)
  • dejangrubisic (1)
  • mostafaelhoushi (1)
  • fivosts (1)
  • j-c-w (1)
  • gmatuz (1)
Top Labels
Issue Labels
Question (48) Bug (29) Enhancement (21) Documentation (10) Testing & Tooling (8) good first issue (7) www (3) Wontfix (2) Help wanted (1)
Pull Request Labels
CLA Signed (19) Documentation (2) LLVM (1) Bug (1) Testing & Tooling (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 256 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 47
  • Total maintainers: 1
proxy.golang.org: github.com/facebookresearch/compilergym
  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
proxy.golang.org: github.com/facebookresearch/CompilerGym
  • Versions: 16
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 6 months ago
pypi.org: compiler-gym

Reinforcement learning environments for compiler research

  • Versions: 15
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 256 Last month
Rankings
Stargazers count: 2.2%
Forks count: 4.3%
Dependent packages count: 4.8%
Average: 8.9%
Downloads: 11.6%
Dependent repos count: 21.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

www/frontends/compiler_gym/package-lock.json npm
  • 1450 dependencies
www/frontends/compiler_gym/package.json npm
  • @testing-library/jest-dom ^5.14.1
  • @testing-library/react ^11.2.7
  • @testing-library/user-event ^12.8.3
  • autoprefixer 10.4.5
  • bootstrap ^5.0.2
  • bootstrap-icons ^1.5.0
  • clone ^2.1.2
  • highcharts ^9.1.2
  • highcharts-react-official ^3.0.0
  • node-sass ^7.0.1
  • npm ^8.12.1
  • react ^17.0.2
  • react-bootstrap ^2.0.4
  • react-d3-tree ^3.1.1
  • react-dom ^17.0.2
  • react-highlight ^0.14.0
  • react-router-dom ^5.2.0
  • react-scripts ^5.0.1
  • web-vitals ^1.1.2
compiler_gym/requirements.txt pypi
  • absl-py >=0.10.0
  • deprecated >=1.2.12
  • docker >=4.0.0
  • fasteners >=0.15
  • grpcio >=1.32.0,<1.44.0
  • gym >=0.18.0,<0.21
  • humanize >=2.6.0
  • loop_tool_py ==0.0.7
  • networkx >=2.5
  • numpy >=1.19.3
  • protobuf >=3.13.0,<4.21.0
  • pydantic >=1.8.0
  • requests >=2.24.0
  • tabulate >=0.8.7
compiler_gym/requirements_build.txt pypi
  • grpcio_tools >=1.32.0
  • setuptools *
docs/requirements.txt pypi
  • breathe ==4.30.0
  • sphinx ==4.0.2
  • sphinx-autobuild *
  • sphinx-rtd-theme ==1.0.0
  • sphinxemoji *
examples/requirements.txt pypi
  • aioredis <2.0.0
  • dgl ==0.6.1
  • geneticalgorithm >=1.0.2
  • hydra-core ==1.1.0
  • keras ==2.6.0
  • matplotlib >=3.3.4
  • nevergrad >=0.4.3
  • opentuner >=0.8.5
  • pandas >=1.1.5
  • ray ==1.9.0
  • submitit >=1.2.0
  • tensorflow ==2.6.1
  • torch >=1.6.0
  • typer >=0.3.2
requirements_pre_commit.txt pypi
  • flake8 ==3.9.2
  • isort ==4.3.21
  • pre-commit >=2.12.1
  • setuptools *
tests/requirements.txt pypi
  • coverage <6.0
  • flaky ==3.7.0
  • psutil ==5.8.0
  • pytest ==6.2.5
  • pytest-benchmark ==3.4.1
  • pytest-cov ==2.12.1
  • pytest-mock ==3.6.1
  • pytest-shard ==0.1.2
  • pytest-stress ==1.0.1
  • pytest-sugar ==0.9.4
  • pytest-timeout ==1.4.2
  • pytest-xdist ==2.4.0
  • ray *
  • setuptools <59
  • torch *
www/requirements.txt pypi
  • Flask ==2.0.1
  • Flask-Cors ==3.0.10
  • compiler_gym ==0.2.4
.github/actions/install-cmake-build-dependencies/action.yaml actions
  • ./.github/actions/install-build-dependencies * composite
.github/actions/install-mlir-env-runtime-dependencies/action.yaml actions
  • ./.github/actions/install-runtime-dependencies * composite
.github/workflows/build.yaml actions
  • ./.github/actions/install-build-dependencies * composite
  • ./.github/actions/install-runtime-dependencies * composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
.github/workflows/ci.yaml actions
  • ./.github/actions/install-build-dependencies * composite
  • ./.github/actions/install-cmake-build-dependencies * composite
  • ./.github/actions/install-mlir-env-runtime-dependencies * composite
  • ./.github/actions/install-runtime-dependencies * composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-node v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • codecov/codecov-action v2 composite
.github/workflows/codeql.yaml actions
  • actions/checkout v3 composite
  • github/codeql-action/analyze v1 composite
  • github/codeql-action/autobuild v1 composite
  • github/codeql-action/init v1 composite
.github/workflows/fuzz.yaml actions
  • ./.github/actions/install-build-dependencies * composite
  • ./.github/actions/install-runtime-dependencies * composite
  • actions/cache v2 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/pip_install_test.yaml actions
  • actions/setup-python v4 composite
.github/workflows/pre_commit.yaml actions
  • actions/checkout v3 composite
  • actions/setup-go v3 composite
  • actions/setup-python v4 composite
packaging/compiler_gym/Dockerfile docker
  • python 3.8-slim-buster build
packaging/compiler_gym-local-wheel/Dockerfile docker
  • python 3.8-slim-buster build
packaging/compiler_gym-manylinux-build/Dockerfile docker
  • ubuntu 18.04 build
www/Dockerfile docker
  • python 3.8-slim-buster build
.github/actions/install-build-dependencies/action.yaml actions
.github/actions/install-docker/action.yaml actions
.github/actions/install-runtime-dependencies/action.yaml actions
examples/setup.py pypi
requirements.txt pypi
setup.py pypi