Skip to content

Commit

Permalink
Add pulp-nnx test docker image and move neureka tests to github actio…
Browse files Browse the repository at this point in the history
…ns (#12)

* Add docker build and push action
* Add github action neureka test
* Remove neureka testing from gitlab-ci
  • Loading branch information
lukamac authored Dec 17, 2024
1 parent 246b8da commit 6e539c4
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 10 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build-and-push-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# The workflow copied from [docker docs](https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages)
# with some changes. Notably the trigger is changed to `workflow_dispatch` and there is a suffix `-test` added to the generated tag in the metadata step.
name: Create and publish a Docker image

# Configures this workflow to run only on manual dispatch
on: workflow_dispatch

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.vendor=pulp-platform
org.opencontainers.image.description=Image for testing the pulp-nnx library
tags: |
type=ref,suffix=-test,event=tag
type=ref,suffix=-test,event=branch
- run: echo "Docker tags ${{ steps.meta.outputs.tags }}"
- run: echo "Docker labels ${{ steps.meta.outputs.labels }}"

# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: ./test
file: ./test/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
15 changes: 15 additions & 0 deletions .github/workflows/test-neureka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Test Neureka
on: push
jobs:
test:
runs-on: ubuntu-latest
container: ghcr.io/pulp-platform/pulp-nnx:main-test
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run test
shell: bash
working-directory: test
run: |
source /pulp-sdk/configs/siracusa.sh
pytest test.py -T tests -R -A neureka
9 changes: 0 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,3 @@ run_ne16_test:
untracked: true
script:
- cd test && pytest test.py --test-dir tests --recursive -A ne16

run_neureka_test:
stage: test
tags:
- siracusa-sdk
artifacts:
untracked: true
script:
- cd test && pytest test.py --test-dir tests --recursive -A neureka
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- github action for testing neureka
- add NnxMapping dictionary that maps accelerator name to the accelerator specific classes
- choice of data generation method (ones, incremented, or random)
- N-EUREKA accelerator support: 3x3, 1x1, and 3x3 depthwise convolution kernels
Expand All @@ -17,6 +18,7 @@

### Changed

- python requirements are changed into requirements-pip and requirements-conda
- conftest now passes only strings to test.py to improve readability of pytest logs
- NnxMemoryLayout is now NnxWeight and also has a method for source generation
- the `wmem` field in the test configurations is now required
Expand Down
33 changes: 33 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM ubuntu:22.04

RUN DEBIAN_FRONTEND=noninteractive \
apt-get update && \
apt-get upgrade && \
apt-get install -y --no-install-recommends \
bzip2 \
ca-certificates \
cmake \
curl \
gcc \
git \
git-lfs \
g++ \
make \
python3 \
python3-pip \
python-is-python3 \
zlib1g-dev \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY requirements-pip.txt docker/requirements-pulp-sdk.txt ./
RUN pip3 install --no-cache-dir -r requirements-pip.txt -r requirements-pulp-sdk.txt --extra-index-url https://download.pytorch.org/whl/cpu

ENV PULP_SDK_HOME="/pulp-sdk"
ENV PULP_RISCV_GCC_TOOLCHAIN="/toolchains/pulp-riscv-gnu-toolchain"

COPY docker/get_pulp_riscv_gnu_toolchain.sh ./
RUN ./get_pulp_riscv_gnu_toolchain.sh

COPY docker/get_pulp_sdk.sh ./
RUN ./get_pulp_sdk.sh
9 changes: 9 additions & 0 deletions test/docker/get_pulp_riscv_gnu_toolchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -euo pipefail

curl -L https://github.com/pulp-platform/pulp-riscv-gnu-toolchain/releases/download/v1.0.16/v1.0.16-pulp-riscv-gcc-ubuntu-18.tar.bz2 > pulp-riscv-gnu-toolchain.tar.bz2
mkdir toolchains
tar -xvjf ./pulp-riscv-gnu-toolchain.tar.bz2 -C ./toolchains
mv ./toolchains/v1.0.16-pulp-riscv-gcc-ubuntu-18 ./toolchains/pulp-riscv-gnu-toolchain
rm ./pulp-riscv-gnu-toolchain.tar.bz2
10 changes: 10 additions & 0 deletions test/docker/get_pulp_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -eo pipefail

git clone https://github.com/Scheremo/pulp-sdk.git --branch scheremo --depth=1 && rm -rf pulp-sdk/.git

cd pulp-sdk

source configs/siracusa.sh
make all
4 changes: 4 additions & 0 deletions test/docker/requirements-pulp-sdk.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
argcomplete
pyelftools
scons
six
2 changes: 1 addition & 1 deletion test/requirements.txt → test/requirements-conda.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy
numpy==1.26.4
pydantic
pytest
pytorch==1.11.0
Expand Down
6 changes: 6 additions & 0 deletions test/requirements-pip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
numpy==1.26.4
pydantic
pytest
torch==1.11.0
toml
ninja

0 comments on commit 6e539c4

Please sign in to comment.