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
94 changes: 17 additions & 77 deletions .github/workflows/bump-hrx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
#
# Keep third_party/llama.cpp and third_party/hrx-system on the pair AMD's
# integration repo (ROCm/ggml-staging-automation) builds and tests together
# (docs/hrx.md, "Staying current"). The engine pins 1bit/hrx-vulkan-patched: AMD's
# commit plus our own commits on top. When AMD moves its pins, this workflow:
# 1. syncs 1bit-MONSTER/llama.cpp: master to ggml-org, 1bit/hrx-vulkan to AMD's pin;
# 2. rebases our commits onto AMD's pin and moves 1bit/hrx-vulkan-patched there,
# tagging the previous tip so the commit the engine pins stays reachable;
# 3. opens a PR here moving both submodules.
# A rebase conflict fails the run: rebase 1bit/hrx-vulkan-patched by hand.
# GitHub-hosted CI builds that PR without HRX; run tests/serve_e2e.sh on
# Strix Halo before merging it.
# (docs/hrx.md): AMD-Ecosystem/llama.cpp (ggml-hrx) and ROCm/hrx-system, unchanged.
# When AMD moves its pair, this opens a PR here moving both submodules.
# GitHub-hosted CI builds that PR without HRX; run tests/serve_e2e.sh on Strix
# Halo before merging it.
#
# Needs the secret HRX_BUMP_TOKEN: a fine-grained token with Contents
# read/write on 1bit-MONSTER/llama.cpp and 1bit-MONSTER/engine, and Pull
# requests read/write on 1bit-MONSTER/engine. (A PR opened with the default
# GITHUB_TOKEN would not start CI, and that token cannot push to the fork.)
# The private trees -DONEBIT_GPU_PRIVATE builds (1bit-MONSTER/gpu-kernels) are not
# moved from here; that repository keeps its own pins.
#
# Uses the secret HRX_BUMP_TOKEN (Contents and Pull requests read/write on
# 1bit-MONSTER/engine): a PR opened with the default GITHUB_TOKEN would not
# start CI.
name: bump-hrx

on:
Expand Down Expand Up @@ -59,9 +56,8 @@ jobs:
- uses: actions/checkout@v4
with:
token: ${{ secrets.HRX_BUMP_TOKEN }}
persist-credentials: true

- name: Read AMD's tested pair and ours
- name: Compare with AMD's tested pair
id: pins
env:
GH_TOKEN: ${{ secrets.HRX_BUMP_TOKEN }}
Expand All @@ -71,63 +67,12 @@ jobs:
amd_hrx=$(gh api repos/ROCm/ggml-staging-automation/contents/hrx-system --jq .sha)
ours_llama=$(git ls-tree HEAD third_party/llama.cpp | awk '{print $3}')
ours_hrx=$(git ls-tree HEAD third_party/hrx-system | awk '{print $3}')
# the AMD commit our patches sit on
ours_base=$(git ls-remote https://github.com/1bit-MONSTER/llama.cpp.git refs/heads/1bit/hrx-vulkan | awk '{print $1}')
echo "AMD: llama.cpp $amd_llama hrx-system $amd_hrx"
echo "ours: llama.cpp $ours_llama (on AMD $ours_base) hrx-system $ours_hrx"
echo "ours: llama.cpp $ours_llama hrx-system $ours_hrx"
{
echo "amd_llama=$amd_llama"; echo "amd_hrx=$amd_hrx"
echo "ours_llama=$ours_llama"; echo "ours_hrx=$ours_hrx"; echo "ours_base=$ours_base"
if [ "$amd_llama" = "$ours_base" ] && [ "$amd_hrx" = "$ours_hrx" ]; then echo "changed=false"; else echo "changed=true"; fi
} >> "$GITHUB_OUTPUT"

- name: Sync the fork and rebase our commits
id: fork
if: steps.pins.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.HRX_BUMP_TOKEN }}
AMD_LLAMA: ${{ steps.pins.outputs.amd_llama }}
OURS_BASE: ${{ steps.pins.outputs.ours_base }}
run: |
set -euo pipefail
# master mirrors ggml-org; 1bit/hrx-vulkan carries no commits of its own, so it
# moves to AMD's pin as long as that pin descends from it (no force needed).
gh api -X POST repos/1bit-MONSTER/llama.cpp/merge-upstream -f branch=master > /dev/null
git init -q fork && cd fork
git remote add fork "https://x-access-token:${GH_TOKEN}@github.com/1bit-MONSTER/llama.cpp.git"
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
if ! git merge-base --is-ancestor FETCH_HEAD "$AMD_LLAMA"; then
echo "::error::1bit/hrx-vulkan has commits that AMD's pin does not contain; rebase them by hand"
exit 1
fi
git push -q fork "$AMD_LLAMA:refs/heads/1bit/hrx-vulkan"

# our commits: OURS_BASE..1bit/hrx-vulkan-patched, replayed onto AMD's pin, in a clone
# whose only (partial) remote is the fork, which now holds AMD's pin too
cd .. && git init -q patched && cd patched
git remote add fork "https://x-access-token:${GH_TOKEN}@github.com/1bit-MONSTER/llama.cpp.git"
git fetch -q --filter=blob:none fork 1bit/hrx-vulkan
git fetch -q --filter=blob:none fork 1bit/hrx-vulkan-patched
patched=$(git rev-parse FETCH_HEAD)
rebased=$patched
if [ "$OURS_BASE" != "$AMD_LLAMA" ]; then
git checkout -q --detach "$patched"
if ! git -c user.name=hrx-bump -c user.email=hrx-bump@users.noreply.github.com rebase -q --onto "$AMD_LLAMA" "$OURS_BASE"; then
git rebase --abort || true
echo "::error::our commits on 1bit/hrx-vulkan-patched do not rebase onto AMD's ${AMD_LLAMA:0:12}; rebase them by hand"
exit 1
fi
rebased=$(git rev-parse HEAD)
# keep the commit the engine pins now reachable before moving the branch
git tag "patched-${patched:0:12}" "$patched"
git push -q fork "refs/tags/patched-${patched:0:12}"
git push -q --force-with-lease="refs/heads/1bit/hrx-vulkan-patched:$patched" fork "$rebased:refs/heads/1bit/hrx-vulkan-patched"
fi
{
echo "rebased=$rebased"
echo "patches<<EOF"; git log --format='- `%h` %s' "$AMD_LLAMA..$rebased"; echo "EOF"
echo "ours_llama=$ours_llama"; echo "ours_hrx=$ours_hrx"
if [ "$amd_llama" = "$ours_llama" ] && [ "$amd_hrx" = "$ours_hrx" ]; then echo "changed=false"; else echo "changed=true"; fi
} >> "$GITHUB_OUTPUT"

- name: Open the bump PR
Expand All @@ -136,8 +81,6 @@ jobs:
GH_TOKEN: ${{ secrets.HRX_BUMP_TOKEN }}
AMD_LLAMA: ${{ steps.pins.outputs.amd_llama }}
AMD_HRX: ${{ steps.pins.outputs.amd_hrx }}
REBASED: ${{ steps.fork.outputs.rebased }}
PATCHES: ${{ steps.fork.outputs.patches }}
OURS_LLAMA: ${{ steps.pins.outputs.ours_llama }}
OURS_HRX: ${{ steps.pins.outputs.ours_hrx }}
run: |
Expand All @@ -149,7 +92,7 @@ jobs:
git config user.name "hrx-bump"
git config user.email "hrx-bump@users.noreply.github.com"
git switch -c "$branch"
git update-index --cacheinfo "160000,$REBASED,third_party/llama.cpp"
git update-index --cacheinfo "160000,$AMD_LLAMA,third_party/llama.cpp"
git update-index --cacheinfo "160000,$AMD_HRX,third_party/hrx-system"
git commit -q -m "Bump HRX: llama.cpp ${AMD_LLAMA:0:12}, hrx-system ${AMD_HRX:0:12} (AMD's tested pair)"
git push -q origin "$branch"
Expand All @@ -159,11 +102,8 @@ jobs:

| | from | to |
|---|---|---|
| third_party/llama.cpp (1bit-MONSTER/llama.cpp 1bit/hrx-vulkan-patched) | \`${OURS_LLAMA:0:12}\` | \`${REBASED:0:12}\` (on AMD \`${AMD_LLAMA:0:12}\`) |
| third_party/llama.cpp (AMD-Ecosystem/llama.cpp) | \`${OURS_LLAMA:0:12}\` | \`${AMD_LLAMA:0:12}\` |
| third_party/hrx-system (ROCm/hrx-system) | \`${OURS_HRX:0:12}\` | \`${AMD_HRX:0:12}\` |

Our commits, rebased onto AMD's pin:
${PATCHES}

CI here builds without HRX. Before merging, on Strix Halo (and \`test-backend-ops -b HRX0\`):
CI here builds without HRX. Before merging, on Strix Halo:
\`cmake -B build -G Ninja -DONEBIT_HRX=ON && cmake --build build --target onebit && for d in vulkan hrx; do tests/serve_e2e.sh build/1bit <Qwen3-0.6B Q4_K_M .gguf> \$d; done\`"
53 changes: 14 additions & 39 deletions .github/workflows/bump-rocmfpx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Keep third_party/llama.cpp-vulkan on upstream llama.cpp's latest release
# Keeps third_party/llama.cpp-rocmfpx (the lean option, docs/lean.md) on upstream
# charlie12345/ROCmFPX's main: once a week, when main has moved, it opens a PR here
# moving the submodule. ROCmFPX publishes no releases, and its main moves many times a
# day, so weekly. GitHub-hosted CI has no GPU: rerun docs/lean.md's table on Strix Halo
# before merging.
#
# Keeps third_party/llama.cpp-rocmfpx (the lean option, docs/lean.md) current. The engine
# pins 1bit/vulkan-rocmi4 on our fork 1bit-MONSTER/ROCmFPX: charlie12345/ROCmFPX's main plus
# our commits (ROCmI4 on Vulkan). Once a week, when upstream main has moved past our base, it
# 1. syncs the fork's main with upstream,
# 2. rebases our commits onto upstream main and moves 1bit/vulkan-rocmi4 there (the old
# head is kept as a tag, rocmi4-<sha>),
# 3. opens a PR here moving the submodule to the rebased head.
# A rebase conflict fails the run: rebase 1bit/vulkan-rocmi4 by hand.
# ROCmFPX publishes no releases, and its main moves many times a day, so weekly.
# GitHub-hosted CI has no GPU: rerun docs/lean.md's table on Strix Halo before merging.
# The private ROCmFPX tree -DONEBIT_GPU_PRIVATE builds (1bit-MONSTER/gpu-kernels) is not
# moved from here; that repository keeps its own pin.
#
# Uses the secret HRX_BUMP_TOKEN (Contents and Pull requests read/write on
# 1bit-MONSTER/engine): a PR opened with the default GITHUB_TOKEN would not start CI.
Expand Down Expand Up @@ -59,38 +55,18 @@ jobs:
with:
token: ${{ secrets.HRX_BUMP_TOKEN }}

- name: Rebase our commits onto ROCmFPX main
- name: Compare with ROCmFPX main
id: pins
env:
GH_TOKEN: ${{ secrets.HRX_BUMP_TOKEN }}
run: |
set -euo pipefail
upstream=$(gh api repos/charlie12345/ROCmFPX/commits/main --jq .sha)
ours=$(git ls-tree HEAD third_party/llama.cpp-rocmfpx | awk '{print $3}')
git init -q /tmp/fork && cd /tmp/fork
git remote add up https://github.com/charlie12345/ROCmFPX.git
git remote add fork "https://x-access-token:${GH_TOKEN}@github.com/1bit-MONSTER/ROCmFPX.git"
git fetch -q --filter=blob:none up main
git fetch -q --filter=blob:none fork 1bit/vulkan-rocmi4
head=$(git rev-parse FETCH_HEAD)
base=$(git merge-base "$head" "$upstream")
echo "upstream ${upstream}, our base ${base}, our head ${head}, engine pin ${ours}"
if [ "$base" = "$upstream" ]; then
{ echo "changed=false"; } >> "$GITHUB_OUTPUT"; exit 0
fi
gh api -X POST repos/1bit-MONSTER/ROCmFPX/merge-upstream -f branch=main > /dev/null
git checkout -q --detach "$head"
if ! git -c user.name=rocmfpx-bump -c user.email=rocmfpx-bump@users.noreply.github.com rebase -q --onto "$upstream" "$base"; then
git rebase --abort || true
echo "::error::our commits on 1bit/vulkan-rocmi4 do not rebase onto ROCmFPX ${upstream:0:12}; rebase them by hand"
exit 1
fi
rebased=$(git rev-parse HEAD)
git tag "rocmi4-${head:0:12}" "$head"
git push -q fork "refs/tags/rocmi4-${head:0:12}"
git push -q --force-with-lease="refs/heads/1bit/vulkan-rocmi4:$head" fork "$rebased:refs/heads/1bit/vulkan-rocmi4"
echo "upstream ${upstream}, ours ${ours}"
{
echo "changed=true"; echo "upstream=$rebased"; echo "ours=$ours"; echo "base=$upstream"
echo "upstream=$upstream"; echo "ours=$ours"
if [ "$upstream" = "$ours" ]; then echo "changed=false"; else echo "changed=true"; fi
} >> "$GITHUB_OUTPUT"

- name: Open the bump PR
Expand All @@ -99,22 +75,21 @@ jobs:
GH_TOKEN: ${{ secrets.HRX_BUMP_TOKEN }}
UPSTREAM: ${{ steps.pins.outputs.upstream }}
OURS: ${{ steps.pins.outputs.ours }}
BASE: ${{ steps.pins.outputs.base }}
run: |
set -euo pipefail
branch="bump-rocmfpx/${UPSTREAM:0:12}"
if git ls-remote --exit-code origin "refs/heads/$branch" > /dev/null; then
echo "$branch already exists"; exit 0
fi
count=$(gh api "repos/charlie12345/ROCmFPX/compare/${OURS}...${BASE}" --jq .ahead_by 2>/dev/null || echo "?")
count=$(gh api "repos/charlie12345/ROCmFPX/compare/${OURS}...${UPSTREAM}" --jq .ahead_by 2>/dev/null || echo "?")
git config user.name "rocmfpx-bump"
git config user.email "rocmfpx-bump@users.noreply.github.com"
git switch -c "$branch"
git update-index --cacheinfo "160000,$UPSTREAM,third_party/llama.cpp-rocmfpx"
git commit -q -m "Bump ROCmFPX (lean): 1bit/vulkan-rocmi4 ${UPSTREAM:0:12} on charlie12345/ROCmFPX ${BASE:0:12}"
git commit -q -m "Bump ROCmFPX (lean): charlie12345/ROCmFPX ${UPSTREAM:0:12}"
git push -q origin "$branch"
gh pr create --base main --head "$branch" \
--title "Bump ROCmFPX (lean): ${UPSTREAM:0:12}" \
--body "Moves third_party/llama.cpp-rocmfpx from \`${OURS:0:12}\` to \`${UPSTREAM:0:12}\`: our commits (ROCmI4 on Vulkan) rebased onto ROCmFPX main \`${BASE:0:12}\` (${count} upstream commits).
--body "Moves third_party/llama.cpp-rocmfpx from \`${OURS:0:12}\` to ROCmFPX main \`${UPSTREAM:0:12}\` (${count} commits).

CI here has no GPU. Before merging, on Strix Halo: build with \`-DONEBIT_LEAN=ON -DONEBIT_LEAN_ROCM=ON\`, run \`ctest -R serve_e2e_lean\`, and rerun the table in docs/lean.md."
13 changes: 8 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
# limitations under the License.
#
# HRX + Vulkan (docs/hrx.md). Only needed with -DONEBIT_HRX=ON. The pair is AMD's
# tested integration (ROCm/ggml-staging-automation); .github/workflows/bump-hrx.yml keeps it current.
# tested integration (ROCm/ggml-staging-automation), unchanged; .github/workflows/bump-hrx.yml
# keeps it current. -DONEBIT_GPU_PRIVATE builds other trees instead (docs/hrx.md).
[submodule "third_party/hrx-system"]
path = third_party/hrx-system
url = https://github.com/ROCm/hrx-system.git
branch = main
shallow = true
[submodule "third_party/llama.cpp"]
path = third_party/llama.cpp
url = https://github.com/1bit-MONSTER/llama.cpp.git
branch = 1bit/hrx-vulkan-patched
url = https://github.com/AMD-Ecosystem/llama.cpp.git
branch = hrx-graph-develop-v2
shallow = true
[submodule "third_party/xdna-driver"]
path = third_party/xdna-driver
Expand Down Expand Up @@ -59,11 +60,13 @@
path = third_party/llama.cpp-vulkan
url = https://github.com/ggml-org/llama.cpp.git
shallow = true
# The lean option (docs/lean.md): upstream charlie12345/ROCmFPX;
# .github/workflows/bump-rocmfpx.yml keeps it on its main.
[submodule "third_party/llama.cpp-rocmfpx"]
path = third_party/llama.cpp-rocmfpx
url = https://github.com/1bit-MONSTER/ROCmFPX.git
url = https://github.com/charlie12345/ROCmFPX.git
shallow = true
branch = 1bit/vulkan-rocmi4
branch = main
[submodule "third_party/comfyui.cpp"]
path = third_party/comfyui.cpp
url = https://github.com/1bit-MONSTER/comfyui.cpp.git
Expand Down
27 changes: 24 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ if(ONEBIT_VULKAN)
endif()
endif()

# ── Private GPU trees (docs/hrx.md, "Private GPU build") ──────────────────
# The public pins are AMD's ggml-hrx pair (ONEBIT_HRX) and upstream ROCmFPX (ONEBIT_LEAN).
# ONEBIT_GPU_PRIVATE points at a checkout of the private gpu-kernels repository (branch
# addons/gpu, submodules initialised); its addons/gpu/gpu.cmake names the llama.cpp,
# hrx-system and ROCmFPX trees those builds use instead.
set(ONEBIT_GPU_PRIVATE "" CACHE PATH "A gpu-kernels checkout whose trees ONEBIT_HRX and ONEBIT_LEAN build")
set(ONEBIT_GPU_LLAMA_SOURCE "${CMAKE_SOURCE_DIR}/third_party/llama.cpp")
set(ONEBIT_GPU_HRX_SYSTEM_SOURCE "${CMAKE_SOURCE_DIR}/third_party/hrx-system")
set(ONEBIT_GPU_ROCMFPX_SOURCE "${CMAKE_SOURCE_DIR}/third_party/llama.cpp-rocmfpx")
if(ONEBIT_GPU_PRIVATE)
if(NOT EXISTS "${ONEBIT_GPU_PRIVATE}/addons/gpu/gpu.cmake")
message(FATAL_ERROR "ONEBIT_GPU_PRIVATE=${ONEBIT_GPU_PRIVATE} has no addons/gpu/gpu.cmake")
endif()
include(${ONEBIT_GPU_PRIVATE}/addons/gpu/gpu.cmake)
message(STATUS "ONEBIT_GPU_PRIVATE: llama.cpp ${ONEBIT_GPU_LLAMA_SOURCE}, hrx-system ${ONEBIT_GPU_HRX_SYSTEM_SOURCE}, ROCmFPX ${ONEBIT_GPU_ROCMFPX_SOURCE}")
target_compile_definitions(onebit PRIVATE ONEBIT_GPU_PRIVATE)
endif()

# ── The lean option: ROCmFPX's formats (docs/lean.md) ─────────────────────
# Off by default. Builds llama-server + llama-quantize from third_party/llama.cpp-rocmfpx
# on Vulkan: `1bit serve --lean` runs ROCmFP4 files with it. ONEBIT_LEAN_ROCM adds the
Expand Down Expand Up @@ -118,9 +136,12 @@ if(ONEBIT_HRX)
add_test(NAME serve_e2e_${_dev}
COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_e2e.sh $<TARGET_FILE:onebit> ${ONEBIT_SERVE_TEST_GGUF} ${_dev})
endforeach()
# Vulkan decode with prompt prefill on HRX over one shared KV cache (docs/hrx.md)
add_test(NAME serve_e2e_vulkan_prefill_hrx
COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_e2e.sh $<TARGET_FILE:onebit> ${ONEBIT_SERVE_TEST_GGUF} vulkan --prefill-device hrx)
# Vulkan decode with prompt prefill on HRX over one shared KV cache (docs/hrx.md);
# only the private trees have it
if(ONEBIT_GPU_PRIVATE)
add_test(NAME serve_e2e_vulkan_prefill_hrx
COMMAND ${CMAKE_SOURCE_DIR}/tests/serve_e2e.sh $<TARGET_FILE:onebit> ${ONEBIT_SERVE_TEST_GGUF} vulkan --prefill-device hrx)
endif()
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Peano, llvm-aie (third_party/llvm-aie)
Copyright the LLVM Project authors and Xilinx, Inc. / Advanced Micro Devices, Inc.
License: Apache-2.0 WITH LLVM-exception

llama.cpp (third_party/llama.cpp: 1bit-MONSTER/llama.cpp, a fork of
llama.cpp (third_party/llama.cpp: AMD-Ecosystem/llama.cpp, a fork of
ggml-org/llama.cpp carrying AMD's HRX integration; third_party/llama.cpp-vulkan:
ggml-org/llama.cpp, an upstream release)
https://github.com/ggml-org/llama.cpp
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ serves each model behind an OpenAI-compatible API (`1bit serve`), whatever devic
> upstream XDNA stack pinned ([docs/npu.md](docs/npu.md); its layer kernel is not yet built from
> source), ZINC ([docs/zinc.md](docs/zinc.md)) and MLX ([docs/apple.md](docs/apple.md)). Experimental,
> and closed source: Qwen3.6-35B-A3B on the NPU through a private add-on, parity against fp64 passes,
> 16.3-16.5 tok/s decode ([docs/npu.md](docs/npu.md#private-routes)). Next is step 4,
> 16.3-16.5 tok/s decode ([docs/npu.md](docs/npu.md#private-routes)). Our GPU kernel work is
> closed source as well: the public build runs AMD's HRX pair and upstream ROCmFPX as they are,
> and `-DONEBIT_GPU_PRIVATE` builds in our fixes (MoE models above 128 experts on HRX, the HRX
> prefill split, ROCmI4 on Vulkan; [docs/hrx.md](docs/hrx.md#private-gpu-build)). Next is step 4,
> the Laya router. The working engine is being ported from 1bit-MONSTER, our private development
> repository; see [docs/PORTING.md](docs/PORTING.md).
> Measured results are on the [wiki](https://github.com/1bit-MONSTER/engine/wiki). This repository
Expand Down
Loading
Loading