From f41c76e31d64f20c16fc38dacc4841bd7c2b55cd Mon Sep 17 00:00:00 2001 From: Muhammad Awad <112003944+mawad-amd@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:35:55 -0700 Subject: [PATCH 1/4] Add KernelDB def file --- kerneldb.def | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 kerneldb.def diff --git a/kerneldb.def b/kerneldb.def new file mode 100644 index 0000000..12d38ec --- /dev/null +++ b/kerneldb.def @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. + +Bootstrap: docker +From: rocm/pytorch:rocm7.1_ubuntu24.04_py3.13_pytorch_release_2.9.1 + +%post + /bin/bash -c " + # Set environment variables + export TRITON_PATH=/opt/triton + export ROCM_PATH=/opt/rocm + export LD_LIBRARY_PATH=\$ROCM_PATH/lib:\$LD_LIBRARY_PATH + export PATH=\"\$ROCM_PATH/bin:\$PATH\" + + # Install system packages + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + git wget ninja-build cmake python3-pip python3-dev build-essential jq \ + libdwarf-dev && \ + rm -rf /var/lib/apt/lists/* + + # Create groups if they don't exist + groupadd -r video 2>/dev/null || true + groupadd -r render 2>/dev/null || true + + # Install Python packages with pip + pip3 install --upgrade pip && \ + pip3 install wheel jupyter pytest + + # Clone and install Triton + cd /opt + git clone https://github.com/triton-lang/triton.git \$TRITON_PATH + cd \$TRITON_PATH + git checkout f70fe0f0e0380dcd036929b40d98f966bfdda75b + pip3 install -e . + " + +%environment + # Define environment variables + export TRITON_PATH=/opt/triton + export ROCM_PATH=/opt/rocm + export PYTHONPATH=$TRITON_PATH + export LD_LIBRARY_PATH=$ROCM_PATH/lib:$LD_LIBRARY_PATH + export PATH="$ROCM_PATH/bin:$PATH" From 7295d2a956ad4c21c5ac5a3abc1b17dee14462c8 Mon Sep 17 00:00:00 2001 From: Muhammad Awad Date: Tue, 17 Mar 2026 21:58:17 -0500 Subject: [PATCH 2/4] Add CI scripts --- .github/scripts/container_build.sh | 34 +++++++++++++++++++++ .github/scripts/container_exec.sh | 49 ++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 40 ++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 .github/scripts/container_build.sh create mode 100644 .github/scripts/container_exec.sh create mode 100644 .github/workflows/ci.yml diff --git a/.github/scripts/container_build.sh b/.github/scripts/container_build.sh new file mode 100644 index 0000000..1154674 --- /dev/null +++ b/.github/scripts/container_build.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. + +set -e + +# Check if Apptainer is available +if ! command -v apptainer &> /dev/null; then + echo "[ERROR] Apptainer not found. Please install Apptainer to continue" + exit 1 +fi + +# Paths +DEF_FILE="apptainer/kerneldb.def" +IMAGE_FILE=~/apptainer/kerneldb-dev.sif +HASH_FILE=~/apptainer/kerneldb.def.sha256 + +# Create directory +mkdir -p ~/apptainer + +# Calculate current hash +CURRENT_HASH=$(sha256sum "$DEF_FILE" | awk '{print $1}') + +# Check if rebuild is needed +if [ -f "$IMAGE_FILE" ] && [ -f "$HASH_FILE" ] && [ "$CURRENT_HASH" = "$(cat "$HASH_FILE")" ]; then + echo "[INFO] Definition unchanged (hash: $CURRENT_HASH), using cached image" + exit 0 +fi + +# Rebuild +echo "[INFO] Building Apptainer image..." +apptainer build --force "$IMAGE_FILE" "$DEF_FILE" +echo "$CURRENT_HASH" > "$HASH_FILE" +echo "[INFO] Build completed (hash: $CURRENT_HASH)" diff --git a/.github/scripts/container_exec.sh b/.github/scripts/container_exec.sh new file mode 100644 index 0000000..d9f2e97 --- /dev/null +++ b/.github/scripts/container_exec.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. +# +# Simple Apptainer container exec script +# Usage: container_exec.sh + +set -e + +# Command is all arguments +COMMAND="$@" +if [ -z "$COMMAND" ]; then + echo "[ERROR] No command provided" >&2 + echo "Usage: $0 " >&2 + exit 1 +fi + +# Check if Apptainer is available +if ! command -v apptainer &> /dev/null; then + echo "[ERROR] Apptainer not found" >&2 + exit 1 +fi + +# Use fixed image path +IMAGE=~/apptainer/kerneldb-dev.sif +if [ ! -f "$IMAGE" ]; then + echo "[ERROR] Apptainer image not found at $IMAGE" >&2 + exit 1 +fi + +# Create temporary overlay in workspace (auto-cleaned when runner is removed) +OVERLAY="./kerneldb_overlay_$$_$(date +%s%N).img" +if ! apptainer overlay create --size 16384 --create-dir /var/cache/kerneldb "${OVERLAY}" > /dev/null 2>&1; then + echo "[ERROR] Failed to create Apptainer overlay" + exit 1 +fi + +# Build exec command +EXEC_CMD="apptainer exec --overlay ${OVERLAY} --no-home --cleanenv" +EXEC_CMD="$EXEC_CMD --bind ${PWD}:/kerneldb_workspace --cwd /kerneldb_workspace" + +# Execute with cleanup of overlay file +EXIT_CODE=0 +$EXEC_CMD "$IMAGE" bash -c "set -e; $COMMAND" || EXIT_CODE=$? + +# Clean up overlay file (always cleanup, even on failure) +rm -f "${OVERLAY}" 2>/dev/null || true + +exit $EXIT_CODE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2f6435a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. + +name: KernelDB CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} + +permissions: + contents: read + +jobs: + ci: + runs-on: [self-hosted, mi3xx] + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Ensure Apptainer + run: | + if ! command -v apptainer &>/dev/null; then + apt-get update && apt-get install -y software-properties-common + add-apt-repository -y ppa:apptainer/ppa + apt-get update && apt-get install -y apptainer + fi + - name: Build Apptainer image + run: bash .github/scripts/container_build.sh + - name: Editable install + import smoke test + run: | + bash .github/scripts/container_exec.sh " + pip install -e '.[dev]' + python3 -c 'import kerneldb' + " From 64ddd49120f01c95bc4f9bc4e701ebe26c481aa2 Mon Sep 17 00:00:00 2001 From: Muhammad Awad Date: Tue, 17 Mar 2026 22:02:29 -0500 Subject: [PATCH 3/4] Make timeout longer --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f6435a..30dc1b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ permissions: jobs: ci: runs-on: [self-hosted, mi3xx] - timeout-minutes: 30 + timeout-minutes: 60 steps: - uses: actions/checkout@v4 - name: Ensure Apptainer From 20a5fe02c920c63dbcd7df884890a91d8504fe83 Mon Sep 17 00:00:00 2001 From: Muhammad Awad Date: Tue, 17 Mar 2026 22:05:53 -0500 Subject: [PATCH 4/4] Add the def file --- kerneldb.def => apptainer/kerneldb.def | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kerneldb.def => apptainer/kerneldb.def (100%) diff --git a/kerneldb.def b/apptainer/kerneldb.def similarity index 100% rename from kerneldb.def rename to apptainer/kerneldb.def