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
29 changes: 29 additions & 0 deletions config/llama-mirror-branch.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2026 bong-water-water-bong
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The branch of 1bit-MONSTER/llama.cpp that mirrors AMD's HRX line, for the daily bump-hrx run
# (scripts/bump-hrx-sync.sh): the first line below that is not a comment. With no such line the mirror is
# `1bit/hrx-vulkan`, as it has always been.
#
# Why this is a file: no branch of the fork is ever force-moved (owner, 2026-11-10). When AMD rewrites its line
# so that its pin no longer descends from the mirror, AMD's new line is pushed to a NEW branch, named for the
# day, the old mirror is left exactly where it is, and that branch's name goes here. The workflow file is not
# edited. Order of work for such a move:
# 1. push AMD's pin to 1bit-MONSTER/llama.cpp as a new branch, e.g. 1bit/hrx-vulkan-20261110 (AMD's history
# carries workflow files, so this push needs a token with `workflow` scope);
# 2. merge that branch into 1bit/hrx-vulkan-patched by an ordinary reviewed PR on the fork;
# 3. name the branch on a line below, and delete any commit line from config/llama-mirror-hold.config.
#
# No branch is named below, so the mirror is 1bit/hrx-vulkan.
7 changes: 7 additions & 0 deletions docs/hrx.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ fails a pin that leaves a gate model's node off HRX.
the mirror's commit `44ee5710d19f`, and the merge of AMD's rebased line is post-release work. It was added for AMD's 2026-11-09 rebase (engine#1945): taking that pin is a merge of
149 conflicted files (538 hunks) into `1bit/hrx-vulkan-patched`, measured against the last AMD commit our
line took.
- **Which branch is the mirror.** [`config/llama-mirror-branch.config`](../config/llama-mirror-branch.config)
names it; with no name there it is `1bit/hrx-vulkan`. The file exists because no branch of the fork is ever
force-moved (owner, 2026-11-10): when AMD rewrites its line, AMD's new line is pushed to a new branch named for
the day, merged into `1bit/hrx-vulkan-patched` by an ordinary reviewed PR on the fork, and then named in this
file, while the old mirror stays where it was. That needs no workflow edit. A name that is not a plain branch
name, or that is our own line, is refused. `scripts/bump-hrx-sync.sh mirror-branch` prints the branch a run
would use.
- **The hold.** While [`config/hrx-system-hold.config`](../config/hrx-system-hold.config)
names a commit, the run does not merge AMD's hrx-system, keeps `third_party/hrx-system`
where it is, and takes only AMD's llama.cpp changes outside the HRX backend paths
Expand Down
48 changes: 36 additions & 12 deletions scripts/bump-hrx-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ cmd=${1:-}
DRY_RUN=${DRY_RUN:-0}
HOLD_FILE=${HOLD_FILE:-config/hrx-system-hold.config}
LLAMA_HOLD_FILE=${LLAMA_HOLD_FILE:-config/llama-mirror-hold.config}
LLAMA_MIRROR_FILE=${LLAMA_MIRROR_FILE:-config/llama-mirror-branch.config}
ENGINE_DIR=$(pwd)
# The HRX backend paths of the llama.cpp tree (what AMD's hrx-graph line adds on top of ggml).
# tests/CMakeLists.txt belongs here: it is where the HRX test targets are registered, so it moves
Expand Down Expand Up @@ -96,6 +97,26 @@ llama_hold_sha() {
grep -v '^[[:space:]]*#' "$f" | grep -oE '^[0-9a-f]{40}' | head -n1 || true
}

# The branch of 1bit-MONSTER/llama.cpp that mirrors AMD's line: the first line of config/llama-mirror-branch.config
# that is not a comment, or 1bit/hrx-vulkan when the file is absent or names nothing.
# 2026-11-10 (engine#1945): AMD rebased its line, and the owner's rule is that no branch is ever force-moved. So the
# old mirror stays where it is, AMD's new line goes to a NEW branch (1bit/hrx-vulkan-<date>), and this file is how the
# sync is pointed at it -- the workflow file is not edited, and cannot be with the token this repository's lanes have.
# A name that is not a plain branch name is refused: it ends up inside a refspec.
llama_mirror_branch() {
local f=$LLAMA_MIRROR_FILE name=""
case "$f" in /*) ;; *) f=$ENGINE_DIR/$f ;; esac
if [ -f "$f" ]; then name=$(grep -v '^[[:space:]]*#' "$f" | grep -v '^[[:space:]]*$' | head -n1 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' || true); fi
[ -n "$name" ] || name=1bit/hrx-vulkan
case "$name" in
*/hrx-vulkan-patched|1bit/hrx-vulkan-patched) die "$LLAMA_MIRROR_FILE names $name, which is our own line, not a mirror of AMD's" >&2 ;;
esac
if ! [[ "$name" =~ ^[A-Za-z0-9._/-]+$ ]] || [[ "$name" == *..* ]] || [[ "$name" == -* ]] || [[ "$name" == refs/* ]]; then
die "$LLAMA_MIRROR_FILE names '$name', which is not a plain branch name" >&2
fi
echo "$name"
}

# What a mirror hold means for this run. Reads repo $1; $2 is the held commit (may be empty), $3 the mirror tip,
# $4 AMD's pin. One word:
# none no commit is held: the sync runs as usual
Expand Down Expand Up @@ -148,32 +169,33 @@ sync_llama() {
warn "could not refresh 1bit-MONSTER/llama.cpp master: $(printf '%s' "$refresh" | head -n1); continuing with the HRX pin sync"
fi

local mirror_branch; mirror_branch=$(llama_mirror_branch)
rm -rf patched && git init -q patched && cd patched
git remote add fork "$(remote_url 1bit-MONSTER/llama.cpp)"
git remote add amd https://github.com/AMD-Ecosystem/llama.cpp.git
git fetch -q --filter=blob:none amd "$AMD_LLAMA"
git fetch -q --filter=blob:none fork \
"1bit/hrx-vulkan:refs/remotes/fork/mirror" "1bit/hrx-vulkan-patched:refs/remotes/fork/patched"
"$mirror_branch:refs/remotes/fork/mirror" "1bit/hrx-vulkan-patched:refs/remotes/fork/patched"
local mirror patched pin=$AMD_LLAMA
mirror=$(git rev-parse refs/remotes/fork/mirror)
patched=$(git rev-parse refs/remotes/fork/patched)
echo "AMD pin $pin, mirror 1bit/hrx-vulkan $mirror, our line 1bit/hrx-vulkan-patched $patched"
echo "AMD pin $pin, mirror $mirror_branch $mirror, our line 1bit/hrx-vulkan-patched $patched"

# 0. A mirror hold (config/llama-mirror-hold.config): the run reports it and moves nothing.
local lhold; lhold=$(llama_hold_sha)
case "$(llama_hold_decision . "$lhold" "$mirror" "$pin")" in
stale)
die "$LLAMA_HOLD_FILE holds 1bit/hrx-vulkan at ${lhold:0:12}, but the mirror is ${mirror:0:12}: the hold is out of date. Name the mirror's commit in it, or delete the commit line to let the sync run." ;;
die "$LLAMA_HOLD_FILE holds $mirror_branch at ${lhold:0:12}, but the mirror is ${mirror:0:12}: the hold is out of date. Name the mirror's commit in it, or delete the commit line to let the sync run." ;;
unneeded)
die "$LLAMA_HOLD_FILE holds 1bit/hrx-vulkan at ${lhold:0:12}, and AMD's pin ${pin:0:12} contains that commit: an ordinary sync would work. Delete the commit line." ;;
die "$LLAMA_HOLD_FILE holds $mirror_branch at ${lhold:0:12}, and AMD's pin ${pin:0:12} contains that commit: an ordinary sync would work. Delete the commit line." ;;
held)
note "1bit/hrx-vulkan is held at ${mirror:0:12} by $LLAMA_HOLD_FILE: AMD's pin ${pin:0:12} does not descend from it (AMD rewrote its line). Nothing was moved; the merge is tracked where the hold file says."
summary "- llama.cpp: mirror \`1bit/hrx-vulkan\` HELD at \`${mirror:0:12}\` ($LLAMA_HOLD_FILE); AMD's pin is \`${pin:0:12}\`, on a line that does not contain it. Not merged."
note "$mirror_branch is held at ${mirror:0:12} by $LLAMA_HOLD_FILE: AMD's pin ${pin:0:12} does not descend from it (AMD rewrote its line). Nothing was moved; the merge is tracked where the hold file says."
summary "- llama.cpp: mirror \`$mirror_branch\` HELD at \`${mirror:0:12}\` ($LLAMA_HOLD_FILE); AMD's pin is \`${pin:0:12}\`, on a line that does not contain it. Not merged."
# The engine's pin does not move while the mirror is held: `rebased` is what the workflow would pin, and
# naming the engine's own pin makes its last step say "nothing to move" (our line may be ahead of the pin;
# moving the pin along it is a reviewed PR of its own, not something a held run does).
output "rebased=${OURS_LLAMA:-$patched}"
output "llama_held=1bit/hrx-vulkan HELD at \`${mirror:0:12}\` by \`$LLAMA_HOLD_FILE\` (AMD's pin is \`${pin:0:12}\`)."
output "llama_held=$mirror_branch HELD at \`${mirror:0:12}\` by \`$LLAMA_HOLD_FILE\` (AMD's pin is \`${pin:0:12}\`)."
output "patches<<EOF
EOF"
return 0 ;;
Expand All @@ -193,10 +215,10 @@ EOF"
foreign=$(sed -n 's/^foreign //p' <<< "$off")
rebased=$(sed -n 's/^rebased //p' <<< "$off")
if [ -n "$foreign" ]; then
die "1bit/hrx-vulkan has commits that are on no branch of AMD-Ecosystem/llama.cpp and have no same-author, same-date, same-subject commit in AMD's pin; the mirror must hold AMD's commits only. Move these to 1bit/hrx-vulkan-patched by hand: $(tr '\n' ';' <<< "$foreign")"
die "$mirror_branch has commits that are on no branch of AMD-Ecosystem/llama.cpp and have no same-author, same-date, same-subject commit in AMD's pin; the mirror must hold AMD's commits only. Move these to 1bit/hrx-vulkan-patched by hand: $(tr '\n' ';' <<< "$foreign")"
fi
if [ -n "$rebased" ]; then
die "AMD rebased its line and dropped the old one: $(wc -l <<< "$rebased" | tr -d ' ') commit(s) of 1bit/hrx-vulkan are on no AMD branch, and each has a commit in AMD's pin ${pin:0:12} with the same author, author date and subject (old new subject: $(tr '\n' ';' <<< "$rebased")). They are AMD's commits, NOT ours: do not move them to 1bit/hrx-vulkan-patched. Merge AMD's pin into 1bit/hrx-vulkan-patched by hand, then move the mirror to the pin."
die "AMD rebased its line and dropped the old one: $(wc -l <<< "$rebased" | tr -d ' ') commit(s) of $mirror_branch are on no AMD branch, and each has a commit in AMD's pin ${pin:0:12} with the same author, author date and subject (old new subject: $(tr '\n' ';' <<< "$rebased")). They are AMD's commits, NOT ours: do not move them to 1bit/hrx-vulkan-patched. Merge AMD's pin into 1bit/hrx-vulkan-patched by hand, then move the mirror to the pin."
fi
# AMD rewrote history. Find the newest commit of the new pin whose tree equals a commit that
# descends from the old mirror on some AMD branch (its pre-rewrite equivalent).
Expand All @@ -208,7 +230,7 @@ EOF"
if [ -n "$equiv" ]; then squash=$c; break; fi
done < <(git -C ../amdrefs log --format='%H %T' "$pin" --not "$mirror")
if [ -z "$squash" ]; then
die "AMD's pin ${pin:0:12} does not contain 1bit/hrx-vulkan ${mirror:0:12} and no AMD commit after it has the same tree as any commit of the new pin; AMD rewrote its history in a way this job cannot map. Merge AMD's pin into 1bit/hrx-vulkan-patched by hand."
die "AMD's pin ${pin:0:12} does not contain $mirror_branch ${mirror:0:12} and no AMD commit after it has the same tree as any commit of the new pin; AMD rewrote its history in a way this job cannot map. Merge AMD's pin into 1bit/hrx-vulkan-patched by hand."
fi
git fetch -q --filter=blob:none amd "$equiv" 2>/dev/null || git fetch -q --filter=blob:none fork "$equiv"
ident replace --graft "$squash" "$equiv"
Expand Down Expand Up @@ -292,9 +314,9 @@ parent here, so a later full merge still brings them in.")
if [ "$rewritten" = 1 ]; then
git tag -f "hrx-vulkan-${mirror:0:12}" "$mirror"
push fork "refs/tags/hrx-vulkan-${mirror:0:12}"
push --force-with-lease="refs/heads/1bit/hrx-vulkan:$mirror" fork "$pin:refs/heads/1bit/hrx-vulkan"
push --force-with-lease="refs/heads/$mirror_branch:$mirror" fork "$pin:refs/heads/$mirror_branch"
else
push fork "$pin:refs/heads/1bit/hrx-vulkan"
push fork "$pin:refs/heads/$mirror_branch"
fi
fi
output "rebased=$rebased"
Expand Down Expand Up @@ -346,5 +368,7 @@ case "$cmd" in
off-branch) off_branch_commits "${2:?repo}" "${3:?mirror}" "${4:?pin}" ;;
# The mirror-hold decision alone, on a local repository: llama-hold <repo> <mirror> <pin>, hold file from LLAMA_HOLD_FILE.
llama-hold) llama_hold_decision "${2:?repo}" "$(llama_hold_sha)" "${3:?mirror}" "${4:?pin}" ;;
# The mirror branch this run would use (config/llama-mirror-branch.config, or LLAMA_MIRROR_FILE).
mirror-branch) llama_mirror_branch ;;
*) echo "usage: $0 llama|hrx" >&2; exit 2 ;;
esac
34 changes: 34 additions & 0 deletions tests/bump_hrx_sync_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,39 @@ else
fail "config/llama-mirror-hold.config is in the tree"
fi

# ---- which branch is the mirror (config/llama-mirror-branch.config) -----------------------------------------
mb=$work/mirror.config
branch() { LLAMA_MIRROR_FILE=$mb bash "$script" mirror-branch 2>&1; }
rm -f "$mb"
expect "no file: the mirror is 1bit/hrx-vulkan, as it always was" "$(branch)" "1bit/hrx-vulkan"
printf '# only comments\n\n# 1bit/hrx-vulkan-20261110\n' > "$mb"
expect "a branch that is only mentioned in a comment changes nothing" "$(branch)" "1bit/hrx-vulkan"
printf '# the dated mirror\n\n 1bit/hrx-vulkan-20261110 \n1bit/ignored-second-line\n' > "$mb"
expect "the first line that is not a comment names the mirror, spaces around it ignored" "$(branch)" "1bit/hrx-vulkan-20261110"
for bad in '1bit/hrx-vulkan-patched' 'refs/heads/1bit/x' '../x' '-x' 'a b' 'x;rm' 'x:y'; do
printf '%s\n' "$bad" > "$mb"
if out=$(branch); then fail "a mirror named '$bad' is refused (got: $out)"; else
case "$out" in *"$mb"*|*llama-mirror*|*mirror*) ok "a mirror named '$bad' is refused, naming the file" ;; *) fail "the refusal of '$bad' names the file (got: $out)" ;; esac
fi
done
# The same refusal through the path the workflow runs: `llama` reads the name inside a command substitution, where a
# message written to stdout is captured into the variable and never printed. The run must fail AND say why.
printf 'x;rm\n' > "$mb"
mkdir -p "$work/empty-scratch"
if out=$(cd "$work/empty-scratch" && env -u GH_TOKEN -u GITHUB_TOKEN DRY_RUN=1 LLAMA_MIRROR_FILE=$mb AMD_LLAMA=$(printf "a%.0s" $(seq 40)) OURS_HRX=$(printf "b%.0s" $(seq 40)) bash "$script" llama 2>&1); then
fail "the llama sync with a mirror named 'x;rm' fails (it exited 0: $out)"
else
case "$out" in
*"::error::"*"not a plain branch name"*) ok "the llama sync refuses a bad mirror name with its ::error:: line, not silently" ;;
*) fail "the llama sync's refusal of a bad mirror name is printed (got: '$out')" ;;
esac
fi
shipped_mb=$(cd "$(dirname "$script")/.." && pwd)/config/llama-mirror-branch.config
if [ -f "$shipped_mb" ]; then
expect "the shipped file names no branch, so the mirror is unchanged" "$(LLAMA_MIRROR_FILE=$shipped_mb bash "$script" mirror-branch)" "1bit/hrx-vulkan"
else
fail "config/llama-mirror-branch.config is in the tree"
fi

if [ "$fails" -ne 0 ]; then echo "$fails check(s) failed"; exit 1; fi
echo "bump_hrx_sync: ok"
Loading