Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
CK prefill: silent Triton fallback test, build.sh for the ROCm image, README line
YanissAmzdd7842927479
diff --git a/README.strix-halo.md b/README.strix-halo.mdindex c65506b..29b1b0f 100644--- a/README.strix-halo.md+++ b/README.strix-halo.md@@ -240,6 +240,9 @@ source tools/strix_halo/env.sh # runtime env (LD_PRELOAD Ubuntupython tools/strix_halo/bench_mtp.py -n 128 -ndt 2 -dds -g```+Optional prefill attention (CK `fmha_fwd`, hd128/hd256, +24-62 % kernel, ~-7 % TTFT at 108K): `CK_FETCH=1 tools/strix_halo/ck_fmha/build.sh`+(~33 s, built into the Docker image; `EXL3_PF_CK=auto` uses it when `libckpf.so` exists, else Triton silently; `0` = off).+Build and bench in **separate shells** — `env.sh build` exports `ROCM_PATH`/`HIP_PATH`/`PYTORCH_ROCM_ARCH` and a bench in the same shell fails model load with a spurious"Insufficient VRAM".diff --git a/docker/Dockerfile b/docker/Dockerfileindex b6b71df..3dc86a2 100644--- a/docker/Dockerfile+++ b/docker/Dockerfile@@ -61,6 +61,12 @@ RUN --mount=type=cache,target=/root/.cache/pip \&& ./build.sh \&& python -c "import torch, exllamav3_ext" \&& rm -rf build .rebuild.* .sdk-deps /tmp/*+# --- Layer B2: Composable Kernel prefill attention (EXL3_PF_CK=auto, ~33 s). Optional: a failed fetch/build leaves no library and the+# server silently keeps the Triton prefill kernel. Invalidated only by the ck_fmha sources.+COPY tools/strix_halo/ck_fmha/ ./tools/strix_halo/ck_fmha/+ENV EXL3_PF_CK_SO=/opt/kyojin/ck-fmha/libckpf.so+RUN (CK_FETCH=1 EXL3_CK_OUT=$EXL3_PF_CK_SO CK_JOBS=$(nproc) tools/strix_halo/ck_fmha/build.sh \+ || echo "ck_fmha build skipped: prefill attention stays on Triton")# --- Layer C: everything else (python, tools, docker/). Python-only edits land here. ---COPY . ./RUN python -c "import torch, exllamav3_ext"diff --git a/tests/test_prefill_ck_fallback.py b/tests/test_prefill_ck_fallback.pynew file mode 100644index 0000000..b19d218--- /dev/null+++ b/tests/test_prefill_ck_fallback.py@@ -0,0 +1,31 @@+import pytest+import torch++from exllamav3.modules.attention_fn import triton_paged as tp+++def no_lib(monkeypatch, tmp_path):+ monkeypatch.setenv("EXL3_PF_CK_SO", str(tmp_path / "absent" / "libckpf.so"))+ monkeypatch.setattr(tp, "_pf_ck_fn", None)+ monkeypatch.setattr(tp, "_pf_ck", True)+++def _call():+ q = torch.zeros(1, 8, 24, 256, dtype = torch.half)+ kv = torch.zeros(1, 16, 4, 256, dtype = torch.half)+ return tp._prefill_ck_contig(q, kv, kv, 0, 4, 256, 0.0625, torch.zeros_like(q))+++def test_auto_missing_library_falls_back_silently(monkeypatch, no_lib, capsys):+ monkeypatch.setattr(tp, "_pf_ck_mode", "auto")+ assert _call() is None # caller keeps the Triton kernel+ assert tp._pf_ck is False # not retried on every chunk+ out = capsys.readouterr()+ assert out.out == "" and out.err == ""+++def test_forced_missing_library_warns_and_falls_back(monkeypatch, no_lib, capsys):+ monkeypatch.setattr(tp, "_pf_ck_mode", "1")+ assert _call() is None+ assert "EXL3_PF_CK=1" in capsys.readouterr().outdiff --git a/tools/strix_halo/ck_fmha/build.sh b/tools/strix_halo/ck_fmha/build.shindex 7801917..0f9ac7c 100755--- a/tools/strix_halo/ck_fmha/build.sh+++ b/tools/strix_halo/ck_fmha/build.sh@@ -1,22 +1,33 @@#!/usr/bin/env bash# Build libckpf.so: Composable Kernel fmha_fwd (stock gfx115 fp16 tiles, hd128 + hd256, batch mode, causal/none) behind-# a C ABI (ckpf_fwd) used by EXL3_PF_CK=1. Nothing is fetched here: CK_SRC is a local ROCm/composable_kernel checkout-# (tested at 6f44fdf90f69adee742ec3660b95d32963b9bd2d). Output: $EXL3_CK_OUT (default ~/.cache/kyojin/ck-fmha/libckpf.so).-# Needs the ROCm clang (ROCM_CLANG, default /opt/rocm/bin/amdclang++) and a libstdc++ GCC install dir (GCC_DIR, default 13).+# a C ABI (ckpf_fwd) used by EXL3_PF_CK (auto: used when the library exists). CK_SRC is a local ROCm/composable_kernel checkout+# (tested at 6f44fdf90f69adee742ec3660b95d32963b9bd2d); with CK_FETCH=1 and no CK_SRC that commit is fetched (shallow) into a temp dir.+# Output: $EXL3_CK_OUT (default ~/.cache/kyojin/ck-fmha/libckpf.so). ~33 s on 8 cores.+# Compiler: ROCM_CLANG, else amdclang++ of the rocm-sdk-devel wheel ($EXL3_ROCM_SDK), else /opt/rocm. GCC_DIR = libstdc++ install dir (default 13).set -euo pipefail-: "${CK_SRC:?set CK_SRC to a composable_kernel checkout}"+CK_PIN=6f44fdf90f69adee742ec3660b95d32963b9bd2d+if [ -z "${CK_SRC:-}" ] && [ "${CK_FETCH:-0}" = 1 ]; then+ CK_SRC=$(mktemp -d); FETCHED=$CK_SRC+ git -C "$CK_SRC" init -q && git -C "$CK_SRC" fetch -q --depth 1 https://github.com/ROCm/composable_kernel.git "$CK_PIN" \+ && git -C "$CK_SRC" checkout -q FETCH_HEAD+fi+: "${CK_SRC:?set CK_SRC to a composable_kernel checkout (or CK_FETCH=1)}"HERE=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)OUT=${EXL3_CK_OUT:-${XDG_CACHE_HOME:-$HOME/.cache}/kyojin/ck-fmha/libckpf.so}-CXX=${ROCM_CLANG:-/opt/rocm/bin/amdclang++}+CXX=${ROCM_CLANG:-}+for c in "${EXL3_ROCM_SDK:-/nonexistent}/lib/llvm/bin/amdclang++" "${EXL3_ROCM_SDK:-/nonexistent}/llvm/bin/amdclang++" /opt/rocm/bin/amdclang++; do+ if [ -z "$CXX" ] && [ -x "$c" ]; then CXX=$c; fi+done+: "${CXX:?no amdclang++ found: set ROCM_CLANG}"GCC_DIR=${GCC_DIR:-/usr/lib/gcc/x86_64-linux-gnu/13}F=$CK_SRC/example/ck_tile/01_fmha-B=$(mktemp -d); trap 'rm -rf "$B"' EXIT+B=$(mktemp -d); trap 'rm -rf "$B" "${FETCHED:-}"' EXITmkdir -p "$B/gen" "$B/obj" "$(dirname "$OUT")"python3 "$F/generate.py" --targets gfx1151 --api fwd --optdim 128,256 -r 0 \-f "*fp16*batch*_nlogits_nbias_*_nlse_ndropout_nskip_nqscale*_nsink*" -o "$B/gen" >/dev/nullFLAGS="--gcc-install-dir=$GCC_DIR -std=c++20 -O3 -fPIC -x hip --offload-arch=gfx1151 -I$CK_SRC/include -I$F -I$B/gen \-DCK_TILE_FMHA_FWD_FAST_EXP2=1 -fgpu-flush-denormals-to-zero -DCK_TILE_FMHA_FWD_SPLITKV_API=0 -DCK_TILE_FMHA_FWD_APPENDKV_API=0 \-DCK_TILE_FMHA_FWD_PAGEDKV_API=0 -DCK_TILE_FMHA_FWD_BATCH_PREFILL_API=0 -w"-ls "$B"/gen/*.cpp "$HERE/ckpf_shim.cpp" | nice -n 19 taskset -c 16-31 xargs -P 8 -I{} sh -c "$CXX $FLAGS -c {} -o $B/obj/\$(basename {} .cpp).o"+ls "$B"/gen/*.cpp "$HERE/ckpf_shim.cpp" | xargs -P "${CK_JOBS:-8}" -I{} sh -c "$CXX $FLAGS -c {} -o $B/obj/\$(basename {} .cpp).o""$CXX" --gcc-install-dir="$GCC_DIR" -shared -fPIC --offload-arch=gfx1151 "$B"/obj/*.o -o "$OUT"echo "built $OUT"