From 3bea478db5807ebcf24e7fd3f670a7a3f8f5fce0 Mon Sep 17 00:00:00 2001 From: Donato Capitella Date: Fri, 8 Aug 2025 09:36:36 +0100 Subject: [PATCH] Poll workflow to trigger toolbox build automatically on llama.cpp master changes --- .github/workflows/poll-llama-cpp.yaml | 126 ++++++++++++++++---------- README.md | 19 ++-- 2 files changed, 88 insertions(+), 57 deletions(-) diff --git a/.github/workflows/poll-llama-cpp.yaml b/.github/workflows/poll-llama-cpp.yaml index 65d8178..1b019db 100644 --- a/.github/workflows/poll-llama-cpp.yaml +++ b/.github/workflows/poll-llama-cpp.yaml @@ -1,77 +1,105 @@ -name: Poll llama.cpp and Trigger Docker Build +name: Poll llama.cpp & Trigger Build on: schedule: - - cron: '*/30 * * * *' # Every 30 minutes + - cron: '0 0,12 * * *' workflow_dispatch: +permissions: + contents: read + actions: write + jobs: poll-and-trigger: runs-on: ubuntu-latest - steps: - - name: Checkout (needed for artifact access) - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Get latest commit from llama.cpp/main - id: fetch + - id: fetch + shell: bash run: | - echo "๐Ÿ” Fetching latest commit SHA from llama.cpp..." - LATEST_SHA=$(curl -s https://api.github.com/repos/ggml-org/llama.cpp/commits/main | jq -r .sha) + set -euo pipefail + REPO_URL="https://github.com/ggml-org/llama.cpp.git" + DEFAULT_REF=$(git ls-remote --symref "$REPO_URL" HEAD | awk '/^ref:/ {print $2}') + echo "๐Ÿ“Œ Default branch: ${DEFAULT_REF#refs/heads/}" + LATEST_SHA=$(git ls-remote "$REPO_URL" "$DEFAULT_REF" | cut -f1) + if [[ -z "$LATEST_SHA" ]]; then echo "โŒ No SHA found"; exit 1; fi echo "โœ… Latest SHA: $LATEST_SHA" - echo "latest_sha=$LATEST_SHA" >> $GITHUB_OUTPUT + echo "latest_sha=$LATEST_SHA" >> "$GITHUB_OUTPUT" - - name: Download last known SHA artifact - uses: actions/download-artifact@v4 - with: - name: last-llama-sha - continue-on-error: true - - - name: Read last known SHA - id: last + - id: previous + shell: bash + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if [[ -f .last_commit_sha ]]; then - LAST_SHA=$(cat .last_commit_sha) - echo "๐Ÿ“ฆ Found previous SHA: $LAST_SHA" - echo "last_sha=$LAST_SHA" >> $GITHUB_OUTPUT + set -euo pipefail + echo "๐Ÿ”Ž Checking for prior artifact 'last-llama-sha'โ€ฆ" + ART_ID=$(curl -fsSL -H "Authorization: Bearer $GH_TOKEN" \ + "https://api.github.com/repos/${GH_REPO}/actions/artifacts?per_page=100" \ + | jq -r '.artifacts | map(select(.name=="last-llama-sha" and .expired==false)) | sort_by(.created_at) | reverse | .[0].id // empty') + if [[ -n "$ART_ID" ]]; then + echo "๐Ÿ“ฆ Found artifact id: $ART_ID (downloading)" + curl -fsSL -H "Authorization: Bearer $GH_TOKEN" -L \ + "https://api.github.com/repos/${GH_REPO}/actions/artifacts/${ART_ID}/zip" -o artifact.zip + unzip -l artifact.zip || true + unzip -p artifact.zip last_commit_sha > last_commit_sha || true else - echo "โš ๏ธ No previous SHA found (first run or artifact missing)" - echo "last_sha=" >> $GITHUB_OUTPUT + echo "โ„น๏ธ No prior artifact found" + fi + PREV_SHA="" + if [[ -f last_commit_sha ]]; then PREV_SHA=$(cat last_commit_sha); fi + echo "๐Ÿ•“ Previous SHA: $PREV_SHA" + echo "previous_sha=$PREV_SHA" >> "$GITHUB_OUTPUT" + + - id: compare + shell: bash + run: | + set -euo pipefail + echo "๐Ÿงฎ Comparing SHAsโ€ฆ" + echo "prev: ${{ steps.previous.outputs.previous_sha }}" + echo "curr: ${{ steps.fetch.outputs.latest_sha }}" + if [[ "${{ steps.fetch.outputs.latest_sha }}" != "${{ steps.previous.outputs.previous_sha }}" ]]; then + echo "๐Ÿ” New commit detected" + echo "changed=true" >> "$GITHUB_OUTPUT" + else + echo "โœ… No change" + echo "changed=false" >> "$GITHUB_OUTPUT" fi - - name: Compare SHAs - id: compare - run: | - echo "๐Ÿงฎ Comparing SHAs..." - echo "Previous: ${{ steps.last.outputs.last_sha }}" - echo "Current: ${{ steps.fetch.outputs.latest_sha }}" - if [[ "${{ steps.fetch.outputs.latest_sha }}" != "${{ steps.last.outputs.last_sha }}" ]]; then - echo "๐Ÿ” Detected new commit. Triggering build workflow." - echo "changed=true" >> $GITHUB_OUTPUT - else - echo "โœ… No changes detected. Skipping trigger." - echo "changed=false" >> $GITHUB_OUTPUT - fi - - - name: Trigger Build & Publish Workflow + - name: Trigger build_and_publish.yml on main if: steps.compare.outputs.changed == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash run: | - echo "๐Ÿš€ Sending workflow_dispatch event to trigger Docker build..." - curl -X POST https://api.github.com/repos/${{ github.repository }}/actions/workflows/build-publish-strix.yml/dispatches \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GH_TOKEN" \ - -d '{"ref":"main","inputs":{"backends":"all"}}' + set -euo pipefail + WF="build_and_publish.yml" + REF="main" + echo "๐Ÿš€ Dispatching $WF on $REFโ€ฆ" + CODE=$(curl -s -o /tmp/resp -w "%{http_code}" \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GH_TOKEN" \ + -d "{\"ref\":\"$REF\",\"inputs\":{\"backends\":\"all\"}}" \ + "https://api.github.com/repos/${{ github.repository }}/actions/workflows/$WF/dispatches") + echo "HTTP $CODE" + if [[ "$CODE" != "204" ]]; then echo "Response:"; cat /tmp/resp; exit 1; fi + - - name: Save latest SHA to file + - name: Save new SHA if: steps.compare.outputs.changed == 'true' - run: echo "${{ steps.fetch.outputs.latest_sha }}" > .last_commit_sha + shell: bash + run: | + set -euo pipefail + printf "%s" "${{ steps.fetch.outputs.latest_sha }}" > last_commit_sha + echo "๐Ÿ’พ Saved $(wc -c < last_commit_sha) bytes to $(pwd)/last_commit_sha" + ls -la last_commit_sha - - name: Upload updated SHA artifact + - name: Upload last-SHA artifact if: steps.compare.outputs.changed == 'true' uses: actions/upload-artifact@v4 with: name: last-llama-sha - path: .last_commit_sha - retention-days: 2 + path: last_commit_sha + retention-days: 7 diff --git a/README.md b/README.md index 4e236c7..f5565a9 100644 --- a/README.md +++ b/README.md @@ -239,17 +239,19 @@ This should work on any Strix Halo. For a complete list of available hardware, s ### 6.2 Kernel Parameters (tested on Fedora 42) -Add these boot parameters to enable unified memory and optimal performance: +Add these these boot parameters to enable unified memory and optimal performance: ``` -amd_iommu=off amdgpu.gttsize=131072 ttm.pages_limit=335544321 -``` +amd_iommu=off amdgpu.gttsize=131072 ttm.pages_limit=33554432 -| Parameter | Purpose | -| --------------------------- | ------------------------------------------------ | -| `amd_iommu=off` | Disables IOMMU for lower latency | -| `amdgpu.gttsize=131072` | Enables unified GPU/system memory (up to 128 GB) | -| `ttm.pages_limit=335544321` | Allows large pinned memory allocations | +``` +| Parameter | Purpose | +| --------------------------- | ----------------------------------------------------------------------------------------- | +| `amd_iommu=off` | Disables IOMMU for lower latency | +| `amdgpu.gttsize=131072` | Enables unified GPU/system memory (up to 128 GiB); 131072 MiB รท 1024 = 128 GiB | +| `ttm.pages_limit=33554432` | Allows large pinned memory allocations; 33554432 ร— 4 KiB = 134217728 KiB รท 1024ยฒ = 128 GiB | + +Source: https://www.reddit.com/r/LocalLLaMA/comments/1m9wcdc/comment/n5gf53d/?context=3&utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button. **Apply the changes:** @@ -277,3 +279,4 @@ Follow this guide by TechnigmaAI for a working configuration on Ubuntu 24.04: * Most comprehesive repostiry of test builds for Strix Halo by lhl -> [https://github.com/lhl/strix-halo-testing/tree/main](https://github.com/lhl/strix-halo-testing/tree/main) * Ubuntu 24.04 configuration [https://github.com/technigmaai/technigmaai-wiki/wiki/AMD-Ryzen-AI-Max--395:-GTT--Memory-Step%E2%80%90by%E2%80%90Step-Instructions-(Ubuntu-24.04)](https://github.com/technigmaai/technigmaai-wiki/wiki/AMD-Ryzen-AI-Max--395:-GTT--Memory-Step%E2%80%90by%E2%80%90Step-Instructions-%28Ubuntu-24.04%29) +