-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] run benchmarks and comment on PR
- Loading branch information
Showing
1 changed file
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
name: Continuous Benchmark | ||
|
||
on: | ||
pull_request: | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
benchmark_cpu: | ||
name: CPU Pytest benchmark | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Who triggered this? | ||
run: | | ||
echo "Action triggered by ${{ github.event.pull_request.html_url }}" | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 50 # this is to make sure we obtain the target base commit | ||
- name: Python Setup | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Setup Environment | ||
run: | | ||
pip install -e . | ||
pip install pytest pytest-benchmark | ||
- name: Setup benchmarks | ||
run: | | ||
echo "BASE_SHA=$(echo ${{ github.event.pull_request.base.sha }} | cut -c1-8)" >> $GITHUB_ENV | ||
echo "HEAD_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)" >> $GITHUB_ENV | ||
echo "BASELINE_JSON=$(mktemp)" >> $GITHUB_ENV | ||
echo "CONTENDER_JSON=$(mktemp)" >> $GITHUB_ENV | ||
echo "PR_COMMENT=$(mktemp)" >> $GITHUB_ENV | ||
- name: Run benchmarks | ||
run: | | ||
cd benchmarks/ | ||
RUN_BENCHMARK="pytest --rank 0 --benchmark-json " | ||
git checkout ${{ github.event.pull_request.base.sha }} | ||
$RUN_BENCHMARK ${{ env.BASELINE_JSON }} | ||
git checkout ${{ github.event.pull_request.head.sha }} | ||
$RUN_BENCHMARK ${{ env.CONTENDER_JSON }} | ||
- name: Publish results | ||
uses: apbard/pytest-benchmark-commenter@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
benchmark-file: ${{ env.BASELINE_JSON }} | ||
comparison-benchmark-file: ${{ env.CONTENDER_JSON }} | ||
benchmark-metrics: 'name,max,mean,ops' | ||
comparison-benchmark-metric: 'ops' | ||
comparison-higher-is-better: true | ||
comparison-threshold: 5 | ||
benchmark-title: 'Result of CPU Benchmark Tests' | ||
|
||
benchmark_gpu: | ||
name: GPU Pytest benchmark | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
include: | ||
- os: linux.4xlarge.nvidia.gpu | ||
python-version: 3.8 | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
container: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu18.04 | ||
steps: | ||
- name: Who triggered this? | ||
run: | | ||
echo "Action triggered by ${{ github.event.pull_request.html_url }}" | ||
- name: Install deps | ||
run: | | ||
apt-get update -y | ||
apt-get install software-properties-common -y | ||
add-apt-repository ppa:git-core/candidate -y | ||
apt-get update -y | ||
apt-get upgrade -y | ||
apt-get -y install libglu1-mesa libgl1-mesa-glx libosmesa6 gcc curl g++ unzip wget libglfw3-dev libgles2-mesa-dev libglew-dev sudo git cmake libz-dev | ||
- name: Check ldd --version | ||
run: ldd --version | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 50 # this is to make sure we obtain the target base commit | ||
- name: Python Setup | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- name: Setup conda | ||
run: | | ||
rm -rf $HOME/miniconda | ||
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh | ||
bash ~/miniconda.sh -b -p $HOME/miniconda | ||
- name: setup Path | ||
run: | | ||
echo "$HOME/miniconda/bin" >> $GITHUB_PATH | ||
echo "CONDA=$HOME/miniconda" >> $GITHUB_PATH | ||
- name: create and activate conda env | ||
run: | | ||
$HOME/miniconda/bin/conda create --name build_binary python=${{ matrix.python-version }} | ||
$HOME/miniconda/bin/conda info | ||
$HOME/miniconda/bin/activate build_binary | ||
- name: Setup git | ||
run: git config --global --add safe.directory /__w/tensordict/tensordict | ||
- name: setup Path | ||
run: | | ||
echo /usr/local/bin >> $GITHUB_PATH | ||
- name: Setup Environment | ||
run: | | ||
python -m pip install -e . | ||
python -m pip install pytest pytest-benchmark | ||
- name: Setup benchmarks | ||
run: | | ||
echo "BASE_SHA=$(echo ${{ github.event.pull_request.base.sha }} | cut -c1-8)" >> $GITHUB_ENV | ||
echo "HEAD_SHA=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)" >> $GITHUB_ENV | ||
echo "BASELINE_JSON=$(mktemp)" >> $GITHUB_ENV | ||
echo "CONTENDER_JSON=$(mktemp)" >> $GITHUB_ENV | ||
echo "PR_COMMENT=$(mktemp)" >> $GITHUB_ENV | ||
- name: Run benchmarks | ||
run: | | ||
cd benchmarks/ | ||
RUN_BENCHMARK="pytest --rank 0 --benchmark-json " | ||
git checkout ${{ github.event.pull_request.base.sha }} | ||
$RUN_BENCHMARK ${{ env.BASELINE_JSON }} | ||
git checkout ${{ github.event.pull_request.head.sha }} | ||
$RUN_BENCHMARK ${{ env.CONTENDER_JSON }} | ||
- name: Publish results | ||
uses: apbard/pytest-benchmark-commenter@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
benchmark-file: ${{ env.BASELINE_JSON }} | ||
comparison-benchmark-file: ${{ env.CONTENDER_JSON }} | ||
benchmark-metrics: 'name,max,mean,ops' | ||
comparison-benchmark-metric: 'ops' | ||
comparison-higher-is-better: true | ||
comparison-threshold: 5 | ||
benchmark-title: 'Result of GPU Benchmark Tests' |