Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/scripts/container_build.sh
Original file line number Diff line number Diff line change
@@ -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)"
49 changes: 49 additions & 0 deletions .github/scripts/container_exec.sh
Original file line number Diff line number Diff line change
@@ -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 <command>

set -e

# Command is all arguments
COMMAND="$@"
if [ -z "$COMMAND" ]; then
echo "[ERROR] No command provided" >&2
echo "Usage: $0 <command>" >&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
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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: 60
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'
"
44 changes: 44 additions & 0 deletions apptainer/kerneldb.def
Original file line number Diff line number Diff line change
@@ -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"
Loading