Skip to content

Commit

Permalink
Merge pull request #686 from facebookresearch/release/v0.2.4
Browse files Browse the repository at this point in the history
CompilerGym v0.2.4
  • Loading branch information
ChrisCummins authored May 25, 2022
2 parents 3afdfbe + c2c2f96 commit 697d012
Show file tree
Hide file tree
Showing 287 changed files with 12,797 additions and 2,022 deletions.
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/--bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@ Steps to reproduce the behavior:
Please fill in this checklist:

- CompilerGym:
- How you installed CompilerGym (conda, pip, source):
- How you installed CompilerGym (pip, source):
- OS:
- Python version:
- Build command you used (if compiling from source):
- GCC/clang version (if compiling from source):
- Bazel version (if compiling from source):
- Versions of any other relevant libraries:

You may use the PyTorch
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
You may use the
[environment collection script](https://raw.githubusercontent.com/facebookresearch/CompilerGym/stable/build_tools/collect_env.py)
to generate most of this information. You can get the script and run it with:

```sh
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
wget https://raw.githubusercontent.com/facebookresearch/CompilerGym/stable/build_tools/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
brew install bazelisk ccache cmake zlib
else
# Compiler
sudo apt-get install -y bzip2 clang-9 clang++-9 lld-9 tar bzip2 ninja-build tar ninja-build
sudo apt install -y bzip2 clang-9 lld tar bzip2 ninja-build tar
# CMake
wget https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-linux-x86_64.sh -O /tmp/cmake.sh
sudo bash /tmp/cmake.sh --prefix=/usr/local --exclude-subdir --skip-license
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/install-mlir-env-runtime-dependencies/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Install runtime dependencies
description: Install the runtime dependencies for CompilerGym.
runs:
using: composite
steps:
- uses: ./.github/actions/install-runtime-dependencies

- name: Install MLIR env runtime dependencies
run: |
if [ "$(uname)" = "Darwin" ]; then
# TODO(boian): figure out how to install the C++ std library.
echo "Error: Darwin is not supported"
exit 1
else
sudo apt-get install libstdc++-9-dev
fi
shell: bash
99 changes: 92 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ jobs:
-GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXE_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_MODULE_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCMAKE_SHARED_LINKER_FLAGS_INIT="-fuse-ld=lld" \
-DCOMPILER_GYM_LLVM_PROVIDER=external \
-DLLVM_DIR=$HOME/llvm/lib/cmake/llvm \
-DPython3_FIND_VIRTUALENV=FIRST \
-DPython3_FIND_UNVERSIONED_NAMES=FIRST \
-DCOMPILER_GYM_BUILD_TESTS=ON \
-DCOMPILER_GYM_BUILD_EXAMPLES=ON \
-S . \
Expand All @@ -92,6 +89,58 @@ jobs:
if-no-files-found: error
retention-days: 7

build-mlir-env-linux-cmake:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install build dependencies
uses: ./.github/actions/install-cmake-build-dependencies

- name: Download LLVM 14.0.0 release
run: |
if [ "$(uname)" = "Darwin" ]; then
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz -O ~/llvm.tar.xz
else
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz -O ~/llvm.tar.xz
fi
mkdir ~/llvm && tar xvf ~/llvm.tar.xz --strip-components 1 -C ~/llvm
rm ~/llvm.tar.xz
echo "Unpacked, testing for expected file:"
test -d ~/llvm/lib/cmake/llvm
- name: CMake Build
run: |
cmake \
-GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCOMPILER_GYM_LLVM_PROVIDER=external \
-DLLVM_DIR=$HOME/llvm/lib/cmake/llvm \
-DMLIR_DIR=$HOME/llvm/lib/cmake/mlir \
-DClang_DIR=$HOME/llvm/lib/cmake/clang \
-DPython3_FIND_UNVERSIONED_NAMES=FIRST \
-DCOMPILER_GYM_ENABLE_MLIR_ENV=ON \
-DCOMPILER_GYM_ENABLE_LLVM_ENV=OFF \
-DCOMPILER_GYM_BUILD_TESTS=ON \
-DCOMPILER_GYM_BUILD_EXAMPLES=ON \
-S . \
-B ~/cmake_build
cmake --build ~/cmake_build
shell: bash

- name: Upload Python wheel
uses: actions/upload-artifact@v2
with:
name: mlir-env-linux-wheel-cmake
path: ~/cmake_build/py_pkg/dist/*.whl
if-no-files-found: error
retention-days: 7

build-macos:
runs-on: macos-latest
steps:
Expand Down Expand Up @@ -149,7 +198,9 @@ jobs:
run: python -m pip install -r tests/requirements.txt

- name: Run the test suite
run: make install-test-cov PYTEST_ARGS="--ignore tests/llvm --ignore tests/gcc --ignore tests/loop_tool"
run: |
make install-test-cov \
PYTEST_ARGS="--ignore tests/llvm --ignore tests/gcc --ignore tests/loop_tool --ignore tests/mlir"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v2
Expand Down Expand Up @@ -184,7 +235,39 @@ jobs:
run: python -m pip install -r tests/requirements.txt

- name: Run the test suite
run: make install-test
run: make install-test PYTEST_ARGS="--ignore tests/mlir"

test-mlir-env-linux-cmake:
needs: build-mlir-env-linux-cmake
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download Python wheel
uses: actions/download-artifact@v2
with:
name: mlir-env-linux-wheel-cmake

- name: Install wheel
run: python -m pip install *.whl

- name: Install runtime dependencies
uses: ./.github/actions/install-mlir-env-runtime-dependencies

- name: Install test dependencies
run: python -m pip install -r tests/requirements.txt

- name: Run the test suite
run: make install-test-cov TEST_TARGET="tests/mlir"

test-macos:
needs: build-macos
Expand Down Expand Up @@ -216,7 +299,9 @@ jobs:
run: python -m pip install -r tests/requirements.txt

- name: Run the test suite
run: make install-test-cov PYTEST_ARGS="--ignore tests/llvm --ignore tests/gcc --ignore tests/loop_tool"
run: |
make install-test-cov \
PYTEST_ARGS="--ignore tests/llvm --ignore tests/gcc --ignore tests/loop_tool --ignore tests/mlir"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v2
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/pre_commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:

- name: Install buildifier
run: |
go get github.com/bazelbuild/buildtools/buildifier
go install github.com/bazelbuild/buildtools/buildifier@latest
buildifier --version
- name: Install prototool
run: |
GO111MODULE=on go get github.com/uber/prototool/cmd/prototool@dev
GO111MODULE=on go install github.com/uber/prototool/cmd/prototool@dev
prototool version
- name: Install hadolint
Expand All @@ -54,7 +54,6 @@ jobs:
python3 -m pip install --upgrade wheel
python3 -m pip install -r requirements_pre_commit.txt
python3 -m isort --version
python3 -m black --version
python3 -m pre_commit --version
- name: Run pre-commit checks
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.1.0
rev: 750078a4aedba5d63c04442e697ccda3ddf71351
hooks:
- id: yamlfmt
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.3.0
hooks:
- id: black
language_version: python3.8
Expand Down
108 changes: 108 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,111 @@
## Release 0.2.4 (2022-05-24)

This release adds a new compiler environment, new APIs, and a suite of backend
improvements to improve the flexibility of CompilerGym environments. Many thanks
to code contributors: @sogartar, @KyleHerndon, @SoumyajitKarmakar@uduse, and
@anthony0727!

Highlights of this release include:

- [mlir] Began work on a new environment for matrix multiplication using MLIR
([#652](https://github.com/facebookresearch/CompilerGym/pull/652), thanks
@KyleHerndon and @sogartar!). Note this environment is not yet included in the
pypi package and must be [compiled from
source](https://github.com/facebookresearch/CompilerGym/blob/development/INSTALL.md#building-from-source-with-cmake).
- [llvm] Added a new `env.benchmark_from_clang_invocation()` method
([#577](https://github.com/facebookresearch/CompilerGym/pull/577)) that can be
used for constructing LLVM environment automatically from C/C++ compiler
invocations. This makes it much easier to integrate CompilerGym with your
existing build scripts.
- Added three new wrapper classes: `Counter`, that provides op counts for
analysis ([#683](https://github.com/facebookresearch/CompilerGym/pull/683));
`SynchronousSqliteLogger`, that provides logging of environment interactions
to a relational database
([#679](https://github.com/facebookresearch/CompilerGym/pull/679)), and
`ForkOnStep` that provides an `undo()` operation
([#682](https://github.com/facebookresearch/CompilerGym/pull/682)).
- Added `reward_space` and `observation_space` parameters to `env.reset()`
([#659](https://github.com/facebookresearch/CompilerGym/pull/659), thanks
@SoumyajitKarmakar!)

This release includes a number of improvements to the backend APIs that make it
easier to write new CompilerGym environments:

- Refactored the backend to make `CompilerEnv` an abstract interface, and
`ClientServiceCompilerEnv` the concrete implementation of this interface. This
enables new environments to be implemented without using gRPC
([#633](https://github.com/facebookresearch/CompilerGym/pull/633), thanks
@sogartar!).
- Extended the support for different types of action and observation spaces
([#641](https://github.com/facebookresearch/CompilerGym/pull/641),
[#643](https://github.com/facebookresearch/CompilerGym/pull/643), thanks
@sogartar!), including new `Permutation` and `SpaceSequence` spaces
([#645](https://github.com/facebookresearch/CompilerGym/pull/645), thanks
@sogartar!)..
- Added a new `disk/` subdirectory to compiler service's working directories,
which is symlinked to an on-disk location for devices which support in-memory
working directories. This fixes a bug with leftover temporary directories from
LLVM ([#672](https://github.com/facebookresearch/CompilerGym/pull/672)).

This release also includes numerous bug fixes and improvements, many of which
were reported or fixed by the community. For example, fixing a bug in cache file
locations ([#656](https://github.com/facebookresearch/CompilerGym/pull/656),
thanks @uduse!), and a missing flag definition in example code
([#684](https://github.com/facebookresearch/CompilerGym/pull/684), thanks
@anthony0727!).

**Full Changelog**:
https://github.com/facebookresearch/CompilerGym/compare/v0.2.3...v0.2.4


## Release 0.2.3 (2022-03-18)

This release brings in deprecating changes to the core `env.step()` routine, and
lays the groundwork for enabling new types of compiler optimizations to be
exposed through CompilerGym. Many thanks to code contributors: @mostafaelhoushi,
@sogartar, @KyleHerndon, @uduse, @parthchadha, and @xtremey!

Highlights of this release include:

- Added a new `TextSizeInBytes` observation space for LLVM
([#575](https://github.com/facebookresearch/CompilerGym/pull/575)).
* Added a new PPO leaderboard entry
([#580](https://github.com/facebookresearch/CompilerGym/pull/580). Thanks
@xtremey!
- Fixed a bug in which temporary directories created by the LLVM environment
were not cleaned up
([#592](https://github.com/facebookresearch/CompilerGym/pull/592)).
- **[Backend]** The function `createAndRunCompilerGymService` now returns an
int, which is the exit return code
([#592](https://github.com/facebookresearch/CompilerGym/pull/592)).
- Improvements to the examples documentation
([#548](https://github.com/facebookresearch/CompilerGym/pull/548)) and FAQ
([#586](https://github.com/facebookresearch/CompilerGym/pull/586))

Deprecations and breaking changes:

- `CompilerEnv.step` no longer accepts a list of actions
([#627](https://github.com/facebookresearch/CompilerGym/pull/627)). A new
method, `CompilerEnv.multistep` provides this functionality. This is to
provide compatibility with environments whose action spaces are lists. To
update your code, replace any calls to `env.step()` which take a list of
actions to use `env.multistep()`. Thanks @sogartar!
- The arguments `observations` and `rewards` to `step()` have been renamed
`observation_spaces` and `reward_spaces`, respectively
([#627](https://github.com/facebookresearch/CompilerGym/pull/627)).
- `Reward.id` has been renamed `Reward.name`
([#565](https://github.com/facebookresearch/CompilerGym/pull/565),
[#612](https://github.com/facebookresearch/CompilerGym/pull/612)). Thanks
@parthchadha!
* The backend protocol buffer schema has been updated to natively support more
types of observation and action, and to support nested spaces
([#531](https://github.com/facebookresearch/CompilerGym/pull/531)). Thanks
@sogartar!

**Full Changelog**:
https://github.com/facebookresearch/CompilerGym/compare/v0.2.2...v0.2.3


## Release 0.2.2 (2022-01-19)

Amongst the highlights of this release are support for building with CMake and a
Expand Down
13 changes: 7 additions & 6 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ authors:
- family-names: "Leather"
given-names: "Hugh"
title: "CompilerGym"
version: 0.2.3
date-released: 2022-03-18
version: 0.2.4
date-released: 2022-05-24
url: "https://github.com/facebookresearch/CompilerGym"
preferred-citation:
type: article
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"
Expand All @@ -62,6 +66,3 @@ preferred-citation:
given-names: "Yuandong"
- family-names: "Leather"
given-names: "Hugh"
journal: "arXiv:2109.08267"
title: "CompilerGym: Robust, Performant Compiler Optimization Environments for AI Research"
year: 2021
Loading

0 comments on commit 697d012

Please sign in to comment.