Skip to content
61 changes: 61 additions & 0 deletions .github/actions/run-inference/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Run Inference
description: Run one llama-tornado inference pass and write the metrics + sidecar files.

inputs:
backend:
description: 'GPU backend (opencl or ptx)'
required: true
model_file:
description: 'Model filename inside $MODELS_DIR (e.g. Llama-3.2-1B-Instruct-F16.gguf)'
required: true
model:
description: 'Human-readable model name for the sidecar (e.g. Llama-3.2-1B-Instruct)'
required: true
quantization:
description: 'Quantization type (e.g. F16, Q8_0)'
required: true
configuration:
description: 'Configuration key for the sidecar (e.g. standard, prefill-decode)'
required: true
flags:
description: 'Extra CLI flags passed to llama-tornado (omit for standard run)'
required: false
default: ''
metrics_file:
description: 'Absolute path for the output metrics JSON file'
required: true
prompt:
description: 'Prompt to pass to the model'
required: false
default: 'Say hello'

runs:
using: composite
steps:
- name: Run inference
shell: bash
working-directory: ${{ github.workspace }}
env:
JAVA_TOOL_OPTIONS: >-
-Dllama.metrics.format=json
-Dllama.metrics.output=file
-Dllama.metrics.file=${{ inputs.metrics_file }}
run: |
# Run inference and emit raw metrics JSON via JAVA_TOOL_OPTIONS
./llama-tornado --gpu --${{ inputs.backend }} \
--model $MODELS_DIR/${{ inputs.model_file }} \
--prompt "${{ inputs.prompt }}" \
${{ inputs.flags }}

# Write metadata sidecar so process_metrics.py can identify each metrics file
SIDECAR="${{ inputs.metrics_file }%.json}.meta.json"
python3 scripts/write_metrics_sidecar.py \
--out "$SIDECAR" \
backend="${{ inputs.backend }}" \
task=llama-inference \
model_file=${{ inputs.model_file }} \
model=${{ inputs.model }} \
quantization=${{ inputs.quantization }} \
configuration=${{ inputs.configuration }} \
"flags=${{ inputs.flags }}" \
prompt="${{ inputs.prompt }}"
93 changes: 93 additions & 0 deletions .github/actions/setup-tornadovm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Setup TornadoVM
description: Clone (or restore from cache), build, and configure TornadoVM. Exports TORNADOVM_HOME and updates PATH for all subsequent steps.

inputs:
backend:
description: 'TornadoVM backend to build (opencl or ptx)'
required: true

runs:
using: composite
steps:
- name: Get TornadoVM HEAD SHA
id: tornado_sha
shell: bash
run: |
SHA=$(git ls-remote https://github.com/beehive-lab/TornadoVM HEAD | cut -f1)
Comment on lines +12 to +16
echo "sha=$SHA" >> $GITHUB_OUTPUT

# actions/cache `path:` is an expression — it cannot access the calling
# workflow's env vars via ${{ env.* }}, so we resolve TORNADO_ROOT here.
- name: Resolve TORNADO_ROOT for cache path
id: paths
shell: bash
run: echo "tornado_root=$TORNADO_ROOT" >> $GITHUB_OUTPUT

- name: Restore TornadoVM cache
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.paths.outputs.tornado_root }}
key: tornadovm-${{ inputs.backend }}-${{ steps.tornado_sha.outputs.sha }}

Comment on lines +26 to +32
- name: Clone TornadoVM master
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
git clone --depth 1 --branch master \
https://github.com/beehive-lab/TornadoVM.git \
$TORNADO_ROOT

- name: Set up Python venv for TornadoVM
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
python3 -m venv $TORNADO_ROOT/venv
source $TORNADO_ROOT/venv/bin/activate
python --version

- name: Build TornadoVM
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
cd $TORNADO_ROOT
mkdir -p graalJars && cp $GRAAL_JARS/* graalJars/
source venv/bin/activate
echo "=== Building TornadoVM ==="
make BACKEND=${{ inputs.backend }}

echo "=== Verifying TornadoVM SDK directory ==="
SDK_DIR=$(find dist -type d -maxdepth 3 -path "*/tornadovm-*-${{ inputs.backend }}" | head -n 1)
if [ -z "$SDK_DIR" ]; then
echo "::error::Could not locate TornadoVM SDK directory!"
find dist -maxdepth 5 -type d
exit 1
fi

# Runs on both cache hit and miss — sets TORNADOVM_HOME and PATH for all
# subsequent steps in the calling workflow.
- name: Configure TornadoVM environment
shell: bash
run: |
cd $TORNADO_ROOT
SDK_DIR=$(find dist -type d -maxdepth 3 -path "*/tornadovm-*-${{ inputs.backend }}" | head -n 1)
if [ -z "$SDK_DIR" ]; then
echo "::error::Could not locate TornadoVM SDK directory!"
find dist -maxdepth 5 -type d
exit 1
fi
FULL_SDK="${PWD}/${SDK_DIR}"
echo "Detected TornadoVM SDK: $FULL_SDK"

# Export for current shell session
export TORNADOVM_HOME="$FULL_SDK"
export PATH="$FULL_SDK/bin:$JAVA_HOME/bin:$PATH"

# Save for subsequent steps
echo "TORNADOVM_HOME=$FULL_SDK" >> $GITHUB_ENV
echo "$FULL_SDK/bin" >> $GITHUB_PATH
echo "$JAVA_HOME/bin" >> $GITHUB_PATH

echo "=== Checking tornado CLI ==="
which tornado || { echo "::error::tornado not in PATH"; exit 1; }
tornado --devices
Loading
Loading