Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksKnezevic committed Sep 20, 2024
1 parent 7814970 commit ad37d26
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 98 deletions.
192 changes: 95 additions & 97 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,89 +7,87 @@ on:
branches: [ "main" ]

jobs:
build-ttxla:

# build-ttxla:

# timeout-minutes: 120
# strategy:
# fail-fast: false

# name: Build and test tt-xla
# runs-on: ubuntu-latest

# container:
# image: ghcr.io/tenstorrent/tt-mlir/tt-mlir-ci-ubuntu-22-04:latest #TODO update this to the correct image
# options: --user root

# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# lfs: true

# - name: Set reusable strings
# id: strings
# shell: bash
# run: |
# echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
# echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
# echo "metal-lib-dir=$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib" >> "$GITHUB_OUTPUT"
# echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"

# - name: Git safe dir
# run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}


# # Build project

# - name: Configure CMake
# shell: bash
# run: |
# source venv/activate
# cmake -G Ninja \
# -B ${{ steps.strings.outputs.build-output-dir }} \
# -S ${{ steps.strings.outputs.work-dir }}

# - name: Build
# shell: bash
# run: |
# source venv/activate
# cmake --build ${{ steps.strings.outputs.build-output-dir }}
# cmake --install ${{ steps.strings.outputs.build-output-dir }}


# # This is needed to preserve file permissions
# # https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
# - name: 'Tar install directory and metal lib directory'
# shell: bash
# working-directory: ${{ steps.strings.outputs.install-output-dir }}
# run: |
# tar cvf artifact.tar .

# - name: Upload install folder to archive
# uses: actions/upload-artifact@v4
# with:
# name: install-artifacts
# path: ${{ steps.strings.outputs.build-output-dir }}/artifact.tar

# - name: Get the latest tag
# shell: bash
# run: |
# latest_tag=$(git describe --tags --abbrev=0)
# latest_tag=${latest_tag#v}
# echo "latest_tag=$latest_tag" >> $GITHUB_ENV
# commit_count=$(git rev-list ${{ env.latest_tag }}..HEAD --count)
# echo "commit_count=$commit_count" >> $GITHUB_ENV
# version="${{ env.latest_tag }}.${{ env.commit_count }}"
# echo "version=$version" >> $GITHUB_ENV
# echo $version


# # Run tests on TT hardware

build-and-run-tests:
timeout-minutes: 120
strategy:
fail-fast: false

name: Build tt-xla
runs-on: ubuntu-latest

container:
image: ghcr.io/tenstorrent/tt-mlir/tt-mlir-ci-ubuntu-22-04:latest #TODO update this to the correct image
options: --user root

steps:
- uses: actions/checkout@v4
with:
submodules: recursive
lfs: true

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "metal-lib-dir=$(pwd)/third_party/tt-mlir/src/tt-mlir/third_party/tt-metal/src/tt-metal-build/lib" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
- name: Git safe dir
run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}


# Build project

- name: Configure CMake
shell: bash
run: |
source venv/activate
cmake -G Ninja \
-B ${{ steps.strings.outputs.build-output-dir }} \
-S ${{ steps.strings.outputs.work-dir }}
- name: Build
shell: bash
run: |
source venv/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }}
cmake --install ${{ steps.strings.outputs.build-output-dir }}
# This is needed to preserve file permissions
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: 'Tar install directory and metal lib directory'
shell: bash
working-directory: ${{ steps.strings.outputs.install-output-dir }}
run: |
tar cvf artifact.tar .
- name: Upload install folder to archive
uses: actions/upload-artifact@v4
with:
name: install-artifacts
path: ${{ steps.strings.outputs.build-output-dir }}/artifact.tar

- name: Get the latest tag
shell: bash
run: |
latest_tag=$(git describe --tags --abbrev=0)
latest_tag=${latest_tag#v}
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
commit_count=$(git rev-list ${{ env.latest_tag }}..HEAD --count)
echo "commit_count=$commit_count" >> $GITHUB_ENV
version="${{ env.latest_tag }}.${{ env.commit_count }}"
echo "version=$version" >> $GITHUB_ENV
echo $version
# Run tests on TT hardware

run-tests:

timeout-minutes: 30
needs: build-ttxla
strategy:
fail-fast: false
matrix:
Expand All @@ -115,7 +113,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
lfs: true

- name: Set reusable strings
id: strings
Expand All @@ -125,22 +124,21 @@ jobs:
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
- name: Git safe dir
run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}

- name: Use build artifacts
uses: actions/download-artifact@v4
with:
name: install-artifacts
path: ${{ steps.strings.outputs.install-output-dir }}

# This is needed to preserve file permissions
# https://github.com/actions/upload-artifact?tab=readme-ov-file#permission-loss
- name: 'Untar install directory'
# Build project
- name: Configure CMake
shell: bash
working-directory: ${{ steps.strings.outputs.install-output-dir }}
run: tar xvf artifact.tar
run: |
source venv/activate
cmake -G Ninja \
-B ${{ steps.strings.outputs.build-output-dir }} \
-S ${{ steps.strings.outputs.work-dir }}
- name: Build
shell: bash
run: |
source venv/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }}
cmake --install ${{ steps.strings.outputs.build-output-dir }}
- name: Run tests
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jax._src.xla_bridge as xb

def initialize():
path = os.path.join(os.path.dirname(__file__), "../install/lib/pjrt_plugin_tt.so")
path = os.path.join(os.path.dirname(__file__), "../build/src/tt/pjrt_plugin_tt.so")
if not os.path.exists(path):
raise FileNotFoundError(f"Could not find tt_pjrt C API plugin at {path}, have you compiled the project?")

Expand Down

0 comments on commit ad37d26

Please sign in to comment.