Skip to content

hrx: Q4_K prefill at M>2048 is 3.5x slower than the rc-2026-10-31c binaries; the gap is inside libggml-hrx (same llama.cpp pin, same dispatch) #782

Closed

Description

@bong-water-water-bong

Summary

A single Q4_K MUL_MAT, run through the HRX backend by a harness that only links libggml-hrx and libhrx (no engine, no model), is 3.5x slower on today's builds than on the rc-2026-10-31c binaries at M=16384, on the same box, same boot, same dispatch choice. The difference is inside libggml-hrx: crossing it with the older libhrx/libloomc moves the slowdown with the host library, not with the code objects.

arm libggml-hrx libhrx + libloomc M=16384 ms TFLOP-s
A rc31c (packaged) rc31c 18.566 43.95
B today (build-54625e8745, main bcb28cc) today 65.486 12.46
C (mix-a) today rc31c 65.593 12.44
D (mix-b) rc31c today 18.381 44.40

Shape K=2560 N=9728 q4_k, 3 iters after warmup, GGML_HRX_LOG_DISPATCH=1. All four arms pick the same kernel
(hip.dense_prefill.mm) and report the same corpus ("335 kernels match their code objects"), so this is not
dispatch selection and not the code objects.

M=2048 is unaffected (2.78-2.83 ms / ~36 TFLOP-s in every arm) because the dispatcher sends it to
common.mul_mat.q4_k_q8_1_x4_prefill. That path is capped at token_count <= 2048
(ggml-hrx/dispatch_registration/common/dispatch-mul-mat.cpp:799-800, and Q4_K is excluded from the split-tail
relaxation at :789-795 because of the packed Row64 weight layout), so every prefill above 2048 tokens rides
hip.dense_prefill.mm
and pays this.

Why this is not the pin

Both arms share the llama.cpp pin 4a58da9b087d23ac3596b35e58f3e69e29cd9f4b:
rc-2026-10-31c was built from engine 3cddcd6310 with HRX_PIN=4a58da9b0 (~/wt/release-rc/build-candidate18.sh:21-23),
and build-54625e8745 came from ~/wt/release-rc/work/src (bcb28cc), whose submodule is also at 4a58da9b0.
Every locally built tree I could find that is at that pin is slow (work/build, work/os/data.dir, the three
vmtest images, hw-gate-store/build-2bc61b1de8 and build-54625e8745, rlk-build, dsv41-lid), and only the
packaged rc-2026-10-31c binaries are fast. So the variable is how the package's libggml-hrx was built or
configured
, not a source difference in the submodule.

Repro

# any harness that does one ggml_backend_graph_compute on a Q4_K MUL_MAT with M=16384, K=2560, N=9728;
# mine is ~/mosaic-bench/mosaic_bench.cpp (links ggml + ggml-hrx only)
R=/opt/rocm-therock/lib/python3.14/site-packages/_rocm_sdk_core/lib
LD_LIBRARY_PATH=<libdir>:$R GGML_HRX_LOG_DISPATCH=1 IREE_HAL_AMDGPU_LIBHSA_PATH=$R/libhsa-runtime64.so.1 \
HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1 \
  ./mosaic_bench --mode gpu --M 16384 --K 2560 --N 9728 --type q4_k --iters 3
#   <libdir>=~/wt/engine-c18/lemonade-onebit-rc-2026-10-31c/1bit/hrx/llama/bin  -> 18.6 ms
#   <libdir>=~/wt/release-rc/hw-gate-store/build-54625e8745/bin                -> 65.5 ms

~/mosaic-bench/mix-a and mix-b are symlink dirs that reproduce arms C and D (mixrun.sh runs all four).
Everything ran under one gpu-hold claim at a time, HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1,
pp_dpm_sclk at 2895 MHz and Tctl 69-78 C throughout.

What I ruled out (measured, not assumed)

  • Boot/DVFS state, thermal, GTT pressure, co-resident serves: arms A and B ran minutes apart on the same boot
    with the same GTT (~34 GB of 128 GB) and the same die temperature.
  • Code objects / libhrx / libloomc: arm D.
  • Dispatch selection: identical hip.dense_prefill.mm in all arms.
  • The llama.cpp pin: identical 4a58da9b0 on both sides (above).

What I did not chase

Which build knob does it. ONEBIT_*/GGML_HRX_* compile-time options and flags are the obvious suspects
(~/wt/release-rc/work/build/CMakeCache.txt is the slow build; the rc31c package ships no cache). Whoever owns the
HRX build can bisect it with the four arms above, since arm D already proves the boundary is the host library.

Context: I found this while re-measuring my own HeteroMosaic numbers (engine#755 / #777) after the 2026-11-01 11:13
GPU reset - the mismatch was a 3.3x gap between the pre-reset and post-reset iGPU rows, which turned out to be this.
It affects every prefill number above 2048 tokens measured on current main.

Activity

  1. added
    perf
    hrx
    on Nov 1, 2026
  2. bong-water-water-bong commented on Nov 1, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage: perf + hrx; owner pi-release (it holds both trees — ~/wt/release-rc/build-candidate18.sh for rc31c and ~/wt/release-rc/work/src for build-54625e8745); it is also #713's subject.

    What the mixed arms already prove. A (rc31c ggml-hrx + rc31c libhrx/loomc) 18.566 ms / 43.95 TFLOP-s vs B (today + today) 65.486 / 12.46, C (today ggml-hrx + rc31c host) 65.593 / 12.44, D (rc31c ggml-hrx + today host) 18.381 / 44.40. The slowdown tracks libggml-hrx, never the host libraries, and both arms share the pin 4a58da9b087d, pick the same kernel (hip.dense_prefill.mm) and report the same 335-object corpus. So the variable is how libggml-hrx was built, not the source, not the dispatch, not the code objects.

    The one fact needed to close that gap (and the reason this is #713-shaped): the build identity of the two libggml-hrx.so — hipcc --version, the ROCm/TheRock root it was built against, CMAKE_BUILD_TYPE, the ggml-hrx -O level and --offload-arch, plus ldd of each showing which libhsa-runtime64 it pulls. Same source + same objects + different speed is either a compile-flag difference or a different HSA runtime linked into the library; those two are distinguishable from that printout alone, and arm D already excludes everything on the host-library side.

    One confound to state, not to conflate. #777 (merged 166b5fe5c) measured that the box state itself changed after the 11:13 reset and the 12:04 reboot: every iGPU row at M=16384 is 1.4–3.3× slower with a hard knee between M=2048 and M=4096 — the same shape as this report. Its arms are inside one boot, so they exclude the boot-state effect for the A-vs-B comparison above, but the 43.95 TFLOP-s absolute is a pre-reset number and should not be quoted as today's achievable ceiling.

    Closing condition: an arm today at M=16384 within a few percent of 18.4–18.6 ms with the dispatch unchanged, or the flag/toolchain difference named as by-design.

  3. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Build identity of both libraries, as asked (CPU-side, measured on the two files themselves). Short version: they were built by the same toolchain on the same box from the same llama.cpp pin, and the compile-flag sets are near-identical — so the 3.5x is not "one library built by a different compiler", it is something a compile-time difference selects inside the source. The one artifact-level asymmetry is that the packaged library is stripped and the local one is not, which is packaging, not codegen.

    The two artifacts

    A (fast) B (slow)
    path ~/wt/engine-c18/lemonade-onebit-rc-2026-10-31c/1bit/hrx/llama/bin/libggml-hrx.so.0.18.0 ~/wt/release-rc/hw-gate-store/build-54625e8745/bin/libggml-hrx.so.0.18.0
    size 11,035,088 B 11,368,920 B
    sha256 (first 16) 5a098bc0ee60a4ca 15eae1b3d96a71d3
    mtime 2026-10-31 13:55 2026-11-01 09:05
    .comment (compiler) absent — stripped AMD clang version 24.0.0git (…/llvm-project.git e095f1b3becf0c1bfdc5e7647003d60976a2460b), Linker: AMD LLD 24.0.0 (same revision)
    .symtab / .debug_* absent / absent present / absent
    exported dynsyms 1520 1521
    ggml_hrx_hip_addon_register exported (1) exported (1)
    NEEDED libggml-base, libhrx, libloomc, libstdc++, libm, libgcc_s, libc, ld-linux (identical in both) same
    RUNPATH $ORIGIN (patchelf'd by packaging) the build tree's paths + _rocm_sdk_core/lib/llvm/lib/…
    ggml version / dispatch strings 0.18.0; "…match their code objects"; hip.dense_prefill.mm — same in both same
    host SIMD in the disassembly 0 %zmm, 0 %ymm 0 %zmm, 0 %ymm

    Toolchain identity (shared — this is the box both were built on)

    hipcc --version   HIP version: 7.18.26434-0000000
                      AMD clang version 24.0.0git (ROCm/llvm-project e095f1b3becf0c1bfdc5e7647003d60976a2460b), x86_64
    amdclang --version  same clang revision
    TheRock SDK        rocm-sdk-core 10.3.0a20261031  (/opt/rocm-therock, pip-installed layout)
                       libhsa-runtime64.so.1 sha256 21a6682452e159cfcdc6bdc84676f6b7
    

    CMake flags

    B (the slow one) — measured, from its own CMakeCache.txt:

    CMAKE_BUILD_TYPE=Release            -> CMAKE_C_FLAGS_RELEASE=-O3 -DNDEBUG (same for CXX)
    CMAKE_C_COMPILER=/opt/rocm-therock/bin/amdclang
    CMAKE_CXX_COMPILER=/opt/rocm-therock/bin/amdclang++   (one compiler, no second hipcc invocation)
    CMAKE_C_COMPILER_LAUNCHER=ccache    CMAKE_CXX_COMPILER_LAUNCHER=ccache    (CCACHE_BASEDIR set)
    GGML_HRX=ON   GGML_NATIVE=ON   GGML_CPU=ON   GGML_VULKAN=OFF   GGML_CUDA=OFF   GGML_HIP=OFF
    LLAMA_BUILD_SERVER=ON   LLAMA_CURL=OFF
    

    A (the fast one) — reconstructed from the build that produced it, not measured (the packaged library is stripped and ships no cache): ~/wt/release-rc/build-candidate18.sh built engine 3cddcd6310 with HRX_PIN=4a58da9b0, and cmake/hrx.cmake at that pin passed

    -DCMAKE_BUILD_TYPE=Release
    -DCMAKE_C_COMPILER=<toolchain>/bin/amdclang  -DCMAKE_CXX_COMPILER=<toolchain>/bin/amdclang++
    -DGGML_HRX=ON -DGGML_VULKAN=OFF -DGGML_CUDA=OFF -DGGML_HIP=OFF -DGGML_NATIVE=ON -DGGML_CPU=ON
    -DLLAMA_BUILD_SERVER=ON -DLLAMA_CURL=OFF
    

    i.e. the same list. The only flag-level deltas I can see between that pin and today's are the ones that changed after the release and are therefore not in A: -DGGML_HRX_HIP_COMPILER / -DGGML_HRX_HIP_FLAGS (engine #771, merged tonight), --rocm-device-lib-path=… in CMAKE_C/CXX_FLAGS, and -ffile-prefix-map=<tree>=. (path scrubbing + a --rocm-device-lib-path token). None of those should change host codegen, and since #771/#786 merged after B was built (09:05), B does not contain them either.

    What that rules in and out

    • Not the compiler, not the SDK, not the target flags: same clang revision, same SDK build id, same -O3 -DNDEBUG, same GGML_NATIVE, same NEEDED set, same dispatch and kernel-corpus strings, same absence of host SIMD either side.
    • Not strip/build-type: A is stripped by packaging; stripping does not change code.
    • That leaves a compile-time-selectable path inside the sources (a GGML_HRX_*/ONEBIT_* define, or a private-addon file that only one tree had at that moment) — i.e. the boundary you already narrowed with arm D. Worth diffing next: the ggml-hrx sources actually compiled into each (the addon's addon.cmake file list and any #ifdef that gates the dense_prefill launcher), since the flags themselves are equal.

    A/B re-measurement: the queue was empty at 19:45, so the four arms (A/B/C/D) are running now in one gpu-hold -l "pi release" claim with HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1; the numbers will be posted here as a second comment when it returns.

  4. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    A/B re-measured — the original numbers reproduce exactly, in one gpu-hold -l "pi release" -t 12 claim, one claim for all four arms, trio on (HSA_USE_SVM=0 HSA_USERPTR_FOR_PAGED_MEM=0 HRX_ALLOW_NO_SVM=1, ~/mosaic-bench/mixrun.sh, claim held 3 s, die 69 °C at entry, pp_dpm_sclk untouched):

    arm libggml-hrx libhrx + libloomc M=16384 ms TFLOP/s dispatch corpus
    A fast rc31c (packaged) rc31c 18.453 44.223 hip.dense_prefill.mm 335 match
    B slow today (build-54625e8745) today 65.544 12.450 same same
    C mix-a today rc31c 65.590 12.442 same same
    D mix-b rc31c today 18.785 43.441 same same

    So your table stands as posted, and the conclusion is unchanged and now repeated on a fresh claim: the 3.5× moves with libggml-hrx and only with it (C slow like B, D fast like A), with the same kernel name, the same corpus count, and the same libggml-base/libhrx/libloomc NEEDED set.

    One extra lead from the identity pass, since the dyndsym counts differ by exactly one

    Exporting symbol sets (1520 in A vs 1521 in B) differ in a single symbol, and only in the slow build:

    _ZNSt6vectorIjSaIjEE13_M_assign_auxIPKjEEvT_S5_St20forward_iterator_tag
      -> std::vector<unsigned int>::_M_assign_aux<unsigned int const*>(...)
    

    Nothing is missing from A; B simply instantiates one more std::vector<uint32_t> bulk-assign template than A does, which means one translation unit in the slow tree contains code the fast tree did not compile — the compiler emitted it because it is reachable there. That is consistent with a compile-time-selected path (an #ifdef/addon file present in one tree and not the other) rather than a flag: same clang, same SDK, same -O3 -DNDEBUG, same GGML_NATIVE, no host SIMD in either, and A is additionally stripped by packaging.

    Where I would look first, given that: the addon file list in addons/hip-hrx/addon.cmake and any #ifdef around the dense_prefill launcher in ggml-hrx/hip/… between the tree that produced rc31c and build-54625e8745 — i.e. which .cpps joined libggml-hrx in each. I can produce that file list for both build trees if it helps; the packaged side has no sources, but its tarball does carry the licence/NOTICE so the pin set is recoverable.

    Everything above is measurement only — I have not changed any code for #782, and I hold no GPU claim now (the one claim was released at 20:13:23 AST, exit 0).

  5. bong-water-water-bong commented on Nov 2, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The compiled file list, as asked — and it rules out the hypothesis the row is resting on

    Produced statically (source + artifacts, no device, no claim). The libggml-hrx source list grows by exactly two entries between rc-2026-10-31c's fork commit 4a58da9b0 and the pin d8bd0ff6052a, and nothing is removed:

    ggml/src/ggml-hrx/CMakeLists.txt      86 sources -> 87    + host-weight-placement.cpp        (fork #173)
    ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake  ...             + hip/dispatch-hip-top-k.cpp       (fork #161)
                                                              + hip/kernels/hip_top_k_f32.hip
    

    Artifact side corroborates it: the two ggml-hrx.dir trees on this box differ by exactly those two objects — ~/wt/trel3 (built 11-01 00:23) 130 objects, no top_k; ~/wt/release-rc/work/src (built 11-02 08:31) 132 objects, nm -DC | grep -c top_k = 3, strings | grep -c hip.top_k_f32 = 8 vs 0.

    So the dyndsym delta is not a missing TU. The extra std::vector<uint32_t> bulk-assign instantiation lives in a file that is compiled in both trees and comes out different — i.e. the cause is a source change inside a shared TU, and "which TU got compiled in/out" is a dead end. That is worth knowing before anyone spends another build on it.

    Both additions are inert at default flags, so neither can be the 3.5×

    • host-weight-placement.cpp is 65 lines, one function (host_weight_exceeds_residency), and it returns immediately at if (limit == 0) return false.
    • HostWeightCache::residency_limit() is 0 by default — the code says so in as many words: "OFF by default (engine HRX route pins ~107 GiB outside process RSS on a 217 GiB mmap (DeepSeek-V4.1 UD-IQ1_S), independent of -ngl/ubatch/prefetch #669) … The default is 0: per-weight residency, exactly today's behaviour", with GGML_HRX_HOST_WEIGHT_LIMIT_MB=<MiB> turning "the bound (and the arena)" on.
    • Consequently the one thing added to the per-execution hot path, HostWeightExecutionScope residency_scope(context.host_weights) in command-program-executor.cpp, no-ops on a null cache, and rebind_prepared_host_weights() returns at its first empty() test.
    • dispatch-hip-top-k.cpp only adds a GGML_OP_TOP_K claim and a kernel; a dense-prefill MUL_MAT never touches it.

    What is left, with the numbers

    The range 4a58da9b0..d8bd0ff6052a is 10 fork commits; the ggml-hrx diffstat over it is dominated by modified files, which is where the answer has to be:

    file delta
    runtime/host-memory.cpp +522 / −
    ggml-hrx.cpp +149
    runtime/command-program-executor.cpp +110
    runtime/host-memory.h +96
    hrx-1bit-safety.cpp +54 (GTT sysfs reads at pool-budget computation — cheap, not per-GEMM)
    backend-context.h +8

    How to bisect it cheaply (two things about this tree that cost the lane time)

    1. ~/wt/release-rc/work/src/third_party/llama.cpp is a shallow clone (git rev-parse --is-shallow-repository → true), so git log <range> there prints only the tip and it looks like one squashed commit. It is not squashed — the pins are intact (199165047 = serve --moe-subst: routing that prefers resident experts (pin llama.cpp-vulkan 546800c) #161, then RFC: the registry follows the pins (CI check + regeneration in the bump workflows) #164/CI: the registry follows the pins (ctest registry_pins); bump workflows regenerate it #165/MoE streaming: Qwen3.8-Flash-Next streamed and measured; serve maps per-layer embeddings #166/MoE streaming: expert reads in 256 KiB chunks by 16 threads (pin llama.cpp-vulkan cecf3ee) #167/Pin llama.cpp 358cafc: ZAYA1-8B decodes 1.9x faster on HRX; concurrent ZAYA on Vulkan 2.5x #168/serve: --moe-slots auto, --moe-prefetch (off by default) #169/HRX: fix the MoE router expert-id fault (engine#123) #170/Census 2026-09-27 #171/docs: census figures of 2026-09-27 (94.88% mapped, 64.33% checked) #172/weekly: 1bit OS image builds under cron; the guard reports real failures #173), all reachable from a full clone. A commit-level bisect is available, no file-group surgery needed.
    2. Cheapest order, one claim, no new ELFs, ~4 min per arm:
      • reproduce at the pin (expect ~12.4 TFLOP/s);
      • arm: pin minus the two added TUs (delete them from the two cmake lists — both are additive, nothing else changes). If it stays ~12.4, the additions are exonerated for good;
      • then walk the commits forward from 4a58da9b0 (or revert by file in the order host-memory → command-program-executor → ggml-hrx.cpp). The first arm that returns to ~18.5 ms names the commit/file.

    Caveats kept: rc-2026-10-31c's .so (11,035,088 B) does not byte-match either on-disk tree (11,368,920 / 11,427,768), so only builds compare cleanly; and 43.95 TFLOP/s is a pre-reset absolute (#777 measured the box itself 1.4–3.3× slower at M=16384 afterwards), so the ratio is the number to trust, not the ceiling.

  6. bong-water-water-bong commented on Nov 3, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Root cause: the toolchain, not the pin — and the fix is one default

    The pin hypothesis in this thread is wrong, by measurement. Building the rc31c pin (4a58da9b0) today is just as
    slow as today's pin: 72.15 / 81.77 ms at M=16384, against 22.77 / 22.55 ms for the packaged rc31c library, with the
    same reproducer, same boot, one claim, and everything but libggml-hrx held fixed. So "bisect the 13 commits" would
    have found nothing, and the issue body's original framing ("how libggml-hrx was built") was right.

    What actually differs is the compiler that built the embedded device code. Extracted hrx_dense_prefill from both
    libraries (dlopen each .so, call its own hip_code_object_data) and read the code objects:

    rc-2026-10-31c (fast) today (slow)
    code object 2,528,824 B 2,350,392 B
    compiler in it AMD clang 23.0.0git (ROCm 0bace190…) AMD clang 24.0.0git (e095f1b3…)
    kernel symbols 250 same 250

    Same source, same symbol set, different compiler. The resource metadata says what changed — every _sb ("B lane-half
    pairs") instantiation spills to scratch under clang 24
    :

    kernel clang 23 clang 24
    hrx_dp_mm_q4_k_r64_m128_w8_f2_sb (what M=16384 launches) vgpr 240, scratch 0 vgpr 241, scratch 576
    hrx_dp_mm_q4_k_m128_w8_f2_sb 238, 0 240, 576
    hrx_dp_swiglu_q4_k_r64_m128_w8_f1_sb 246, 0 241, 576
    hrx_dp_mm_q4_k_r64_m64_w8_f2_sb 150, 0 154, 320
    hrx_dp_mm_q4_k_r64_m128_w8_f2 (non-sb) 239, 0 246, 0

    All 19 _sb kernels in kernels/hrx_dense_prefill.hip carry 320–576 B/lane where clang 23 had none — for every format,
    and in every weight-prefetch slot (recompiled with dp_rf_m128_sb RF = 0/1/2/3: 576 B in all four). The tile tables in
    dispatch-hip-dense-prefill.cpp were tuned on 2026-10-20 under clang 23, and the criterion is quoted in the source
    (dp_rf_m128_sb): "the slot that compiles without scratch in the K loop at the best occupancy". That precondition is
    false now, so the dispatcher keeps choosing a tile that spills.

    Fix: gpu-kernels #48

    m128_sb() defaults to off, so Q4_K/Q5_K/Q6_K take the scratch-free m128_w8_f2 tile;
    GGML_HRX_HIP_DENSE_PREFILL_M128_SB=1 restores the old behaviour on a clean toolchain. One behavioural line + docs.

    arm M=16384 TFLOP-s M=2048 (control)
    before (default _sb, scratch 576) 77.27 ms 10.56 3.34 ms
    after (m128_w8_f2, scratch 0) 23.91 / 24.26 ms 33.6 3.32 ms
    M128_SB=1, same binary 80.81 ms 10.10 —
    M128=0 (m64 tile) 27.12 ms 30.09 —
    rc-2026-10-31c (reference) 22.86 ms 35.69 3.27 ms

    3.2–3.4x recovered, within 4–6 % of rc31c, dispatch unchanged (hip.dense_prefill.mm in every arm), M=2048 untouched
    as this issue predicted. Known answer at T=4096 (above the 2048-token cap, so it really reaches dense_prefill.mm,
    confirmed in the dispatch log): both tiles give NMSE 1.65e-05 / max 4.06e-03 of max|ref| against the CPU backend,
    identical to the printed precision — the tile swap does not move the numbers.

    Named as by-design / still open

    • The _sb kernels still spill on clang 24 (241 VGPRs allocated while spilling 576 B where 240 sufficed). That is a
      register-allocation regression in ROCm/llvm-project e095f1b3 vs 0bace190; the knob is where a future workaround or
      a toolchain fix lands.
    • The residual ~10 % to rc31c is clang-23-vs-24 codegen on the non-sb tile, so it is not recoverable by tile choice.
    • Two more sites carry the same defect and are deliberately not in Docs chat on 1bit.gg: Context7 widget + context7.json #48 because their alternatives are unmeasured
      geometries: swiglu_tile() returns sb=true unconditionally (and the non-sb swiglu kernels are not even registered),
      and mm_tile()'s K >= 8192 branch returns {64,8,2,true} (320 B scratch).
    • Unrelated but found on the way, worth its own issue: common.mul_mat.q4_k_q8_1_x4_prefill is selected at T=512 for
      a bare f32 activation input and returns NaN
      (timing looks healthy: 0.7 ms). My known-answer probe caught it before I
      raised T above the 2048 cap; I have not investigated it.

    Also for the record on the box-state question in this thread: the ratio is what reproduces; the absolute 43.95 TFLOP-s
    from before the 11:13 reset is not something today's box reaches (33.6–35.7 here, and rc31c's own packaged libs read
    35.69 in the same claim).

  7. bong-water-water-bong commented on Nov 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The number the SUPREME scoreboard prints for our prefill cell is probably measuring this spill, not our engine

    Static, host-side, no device (so nothing here needs a ticket to check):

    $P = ~/.local/share/1bit-hrx-a5271d9            # the package the SUPREME `onebit:hrx` arm runs (launch_onebit.sh)
    libggml-hrx.so.0.18.0 (Nov 2 07:03, main a5271d9):
      "AMD clang version 24.0.0git"  x51 occurrences in the embedded code objects   <- the spilling compiler
      "GGML_HRX_HIP_DENSE_PREFILL_M128_SB"                                          <- the knob is live
      "hrx_dp_mm_q4_k_r64_m128_w8_f2_sb"                                            <- the tile is in there
    

    Two consequences, one of which changes what the scoreboard's prefill row means:

    1. The knob already exists in the shipped binary, so the A/B this issue asks for does not need Docs chat on 1bit.gg: Context7 widget + context7.json #48 to be built:
      gpu-kernels addons/hip-hrx/dispatch-hip-dense-prefill.cpp:179-186 reads GGML_HRX_HIP_DENSE_PREFILL_M128_SB
      and m128_sb() returns false for Q4_K/Q5_K/Q6_K when it is 0, i.e. the scratch-free m128_w8_f2 tile. Docs chat on 1bit.gg: Context7 widget + context7.json #48 only
      flips the default (and the docs) — which is worth saying plainly, because it means the regression can be
      measured and worked around on any binary built from today's pin, M128_SB=0 in the environment.
    2. Qwen3.8-27B UD-Q4_K_XL at pp4096 is above the 2048-token cap, so that cell runs hip.dense_prefill.mm — the
      path this issue is about — while pp512 is below the cap and runs q4_k_q8_1_x4_prefill, which the tile change
      cannot touch. The SUPREME scoreboard measured pp4096 = 193.55 tok/s against gufo's 574.67 and concluded "prefill
      is our one real gap, a scheduling gap". If the _sb tile is in play there, a 3.2x tile-vs-tile difference is the
      same order as the whole 2.97x gap, so that conclusion is premature: the first thing to try on that cell is the
      default flip, before anyone writes prefill kernels.

    I am measuring exactly that on the scoreboard's own arm (same package pin, same GGUF, its bench.py, pp512 as the
    control cell and pp4096 as the affected one, default vs M128_SB=0, one gpu-hold claim, two launches) and will post
    the two medians here and on the scoreboard. Filed the shapes only; no numbers leave the box (blog rule).

    Related, from the same sweep in dispatch-hip-dense-prefill.cpp that this issue already names as out of #48's scope:
    swiglu_tile() still returns sb=true unconditionally at :190-ish and the K >= 8192 branch still returns
    {64,8,2,true}, so a format/K pair that misses m128_fits() can still take a spilling tile — the flip closes the one
    path the scoreboard measures, not the class.

  8. bong-water-water-bong commented on Nov 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    End-to-end on the SUPREME cell: the same package that prints pp4096 193-238 prints 229 → 301 with GGML_HRX_HIP_DENSE_PREFILL_M128_SB=0, and the spread collapses with it

    The 20:23 comment above argued the scoreboard's prefill cell was probably measuring this spill, and that the knob was
    measurable today because gpu-kernels#48 only flips a default. That is now measured, not argued. Design was fixed before
    the run, because the previous attempt was confounded: one gpu-hold claim, WARMUP (discarded), then A B B A, so knob
    and arm position are separable and the discarded arm takes the cold-cache transient.

    Package pin 1bit-hrx-a5271d9 (sha256(1bit)=abd84dea…, libggml-hrx=bae07098…) — the scoreboard's own onebit:hrx
    arm, its own bench.py, 5 reps, ctx 8192, Qwen3.8-27B UD-Q4_K_XL, cells pp512 + pp4096:

    arm (chronological) knob pp512 median (spread) pp4096 median (spread) Tctl max
    WARMUP (discarded) default 206.76 (4.8 %) 206.54 (22.4 %) 72 C
    A1 default 138.88 (27.3 %) 232.64 (29.6 %) 72 C
    B1 M128_SB=0 243.15 (20.0 %) 298.55 (8.7 %) 79 C
    B2 M128_SB=0 261.36 (18.8 %) 304.20 (11.9 %) 73 C
    A2 default 171.86 (8.9 %) 228.73 (36.9 %) 76 C
    knob (median of 2+2) +62.4 % +30.6 %
    knob (conservative: best A vs worst B) +41.5 % +30.5 %

    This is a knob split, not a position split. ABBA balances positions exactly, the two A arms agree (232.64 / 228.73,
    1.7 % apart) and both sit ~70 tok/s below either B arm (298.55 / 304.20, 1.9 % apart); a position effect would make the
    fourth arm the fastest, and it is second slowest. Correctness on all five arms: sane, output lengths
    [934, 927, 219] identical — same answers, so this is not computing something cheaper.

    Disclosure that cuts the number down rather than up: an NPU TDR landed at 21:50:23, inside arm A1's window (a GPU arm;
    this run never touches the NPU — other lanes' tickets held it and recovered it). That is why the conservative bracket
    above is quoted: +30.5 % at pp4096.

    The control I expected to be inert was not, and the dispatcher explains why

    I assumed pp512 (below the 2048 cap) would be knob-blind, so its earlier +49 % was read as "the box moved". That reading
    was wrong. take() in dispatch-hip-dense-prefill.cpp is !loom_aligned(tokens) || !loom_fast(type, swiglu), with
    loom_aligned true for 256-aligned batches in 256..2048 and loom_fast covering only Q4_K (and Q6_K non-swiglu). At
    M=512 the Q5_K matmuls — most attn_qkv, attn_gate, ssm_out, the Q5_K ffn_* — still reach the dense-prefill
    tile, and so still see the knob. Only Q4_K/Q6_K defer to Loom at those batch sizes. pp512 is a second affected cell, and
    its +41.5 % is the same effect at a shape whose tile is more of the work.

    How much of prefill the knob can reach, computed from this GGUF

    Replicating mm_tile()/m128_fits()/m128_sb() over every tensor at M=4096 (FLOPs 2·M·K·N), with the fused-swiglu rule
    applied per layer (the fused kernel needs gate and up of the same type, and this GGUF mismatches them in 25 of 65
    layers):

    TFLOP share
    reachable by M128_SB 111.7 49.9 %
    fused swiglu (swiglu_tile() returns Tile{…,true} for every pair at ≥256 tokens) — knob-blind 58.4 26.1 %
    ffn_down in the IQ4_XS layers (K=17408 → mm_tile()'s K >= 8192 branch, {64,8,2,true}) — knob-blind 11.7 5.2 %

    So gpu-kernels#48 is half the FLOPs, and the ~1.5x it should be worth at this cell is what the +30.5 % is; the 3.5x the
    M=16384 reproducer shows is not what to expect from a model, because 31.3 % of prefill FLOPs stay on the spilled tile
    after #48
    : the two call sites above need making switchable before the next 3x is on the table. That is the follow-up I
    would file against this issue, and it is a kernel change, not a measurement.

    Reproduce: ~/supreme-npu/tile-ab2.sh (one gpu-hold claim, WARMUP + A B B A, per-arm Tctl trace, leak guard), output
    ~/supreme-npu/tile-ab2-20261104T214357/.

  9. bong-water-water-bong commented on Nov 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Kernel level, per shape: the spilled tile is 2.12-2.90x slower at the exact 27B shapes — and the fused-swiglu call site is a dispatch fix, not a kernel build. Correction to what I wrote above.

    Follow-up to the serve-level A/B in the previous comment. Same question asked of the device code directly:
    addons/hip-hrx/tools/dense-prefill-bench on real Qwen3.8-27B UD-Q4_K_XL tensors, T=4096, A B B A per shape (A =
    ..._m128_w8_f2, B = ..._m128_w8_f2_sb), every run checked against the bench's own CPU reference. It uses
    pi-fnprefill's gpu-kernels build (428937ae6, code object hrx_dense_prefill.gfx1151.hsaco), so the absolute ms are
    that build's; the tile-vs-tile ratio is the point.

    tensor family plain (knob=0) _sb (default) ratio within-tile spread (A / B)
    blk.16.ffn_down Q4_K, K=17408 N=5120 mm 24.29 ms / 30.09 TF-s 70.35 ms / 10.38 TF-s 2.90x 6.9 % / 0.7 %
    blk.24.ffn_down Q5_K, K=17408 N=5120 mm 25.96 ms / 28.14 TF-s 68.73 ms / 10.62 TF-s 2.65x 5.2 % / 0.5 %
    blk.58.ffn_down Q6_K, K=17408 N=5120 mm 45.27 ms / 17.22 TF-s 96.16 ms / 7.64 TF-s 2.12x 50 % / 15 % (noisy row)
    blk.24.ffn_gate Q5_K, benched as mm mm 43.91 ms 76.87 ms 1.75x 84 % / 19 % (noisy row)
    blk.24.ffn_gate+up Q5_K, mode=swiglu swiglu 70.34 ms / 20.76 TF-s 201.19 ms / 7.44 TF-s 2.86x 2.1 % / 31 %

    All rows max_err=4.44e-04 (swiglu) or better, bad=0: the tiles agree numerically, so this is speed, not a different
    computation. The two rows I would not lean on are the Q6_K and the gate-as-mm ones (their A-side spread is 50 % / 84 %);
    the load-bearing rows are ffn_down Q4_K/Q5_K (5-7 % spread) and the swiglu row (2.1 %).

    Correction: the 26.1 % swiglu share does not need a new kernel

    In my previous comment I wrote that the two knob-blind call sites "need a kernel change". That is wrong for the bigger
    of the two, and the measurement says so: hrx_dp_swiglu_q5_k_m128_w8_f1 — the plain, non-_sb fused swiglu kernel —
    is already exported by this build and is 2.86x faster
    than the _sb variant that swiglu_tile() forces. So
    swiglu_tile() returning Tile{128,8,1,true} unconditionally is a one-line dispatch change with no new build, worth
    most of the 26.1 % of prefill FLOPs I attributed to it — not a kernel job.

    (Why this matters beyond bookkeeping: the reason it was never reachable is that swiglu_tile() does not consult
    m128_sb() at all, so the GGML_HRX_HIP_DENSE_PREFILL_M128_SB knob has never had any effect on an FFN pair. A model
    with a large fused-swiglu share therefore kept the full spill even with gpu-kernels#48 merged.)

    What is left after that

    mm_tile()'s K >= 8192 branch ({64,8,2,true}) is the other forced-sb site (5.2 % of FLOPs, ffn_down in this
    GGUF's IQ4_XS layers). I have not measured its non-sb alternative, so it stays a claim, not a number — and unlike
    swiglu it needs the m64_w8_f2 tile checked for existence and speed on that shape before anyone promises anything.

    Reproduce: ~/supreme-npu/tile-kernel-ab.sh (+ --check-discovery, host-only) and
    ~/supreme-npu/tile-kernel-ab-summary.py <outdir>; output ~/supreme-npu/tile-kernel-20261104T230313/.

  10. bong-water-water-bong commented on Nov 5, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The reach depends on the batch size, and the smaller cell gained more — which is worth knowing before anyone reads pp512 as noise

    Apply take() (not just m128_fits()) per tensor and the reachable share changes with M, because at 256-aligned
    batches in 256..2048 loom_fast() hands Q4_K (and Q6_K non-swiglu) to Loom:

    M knob-reachable of total FLOPs measured served gain from M128_SB=0
    512 8.5 TFLOP 31.9 % +41.5 % (conservative bracket)
    2048 34.1 TFLOP 31.9 % not measured
    4096 122.1 TFLOP 57.2 % +30.5 % (conservative bracket)

    with the fused FFN pair (26.1 % of FLOPs at every M, knob-blind until gpu-kernels#51) and the unfused pairs counted
    separately. Both served figures are the conservative bracket from the A/B above; the pp512 arms' own spreads are 8.9-27 %,
    so it is a bracket and not a precise number.

    The ordering is the interesting part and my simple model does not explain it. If the gain tracked reachable FLOPs,
    pp512 should have gained about half what pp4096 did; it gained more. The most likely reason is that the spilled tile's
    cost per FLOP rises as M falls — at small M the same weight traffic feeds fewer tokens, so a tile that loses occupancy to
    scratch loses more of the wall clock. That is consistent with #48's own reproducer being "unaffected at M=2048" only
    because 2048 rides Loom, and 3.5x at M=16384.

    Practical consequence for the scoreboard: the prefill cells that a served model actually hits (short prompts, 512-2048
    tokens) are the ones where the tile choice matters most per FLOP, and two thirds of their FLOPs are still knob-blind
    because loom_fast() only covers Q4_K/Q6_K. So a per-cell reading of "our prefill gap" should not assume the same
    reach across pp512 and pp4096 -- the two cells are covered by different matcher paths, and #51's swiglu line is
    the part that raises both.

  11. bong-water-water-bong commented on Nov 6, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Resolved: attributed, fixed by the default flip, and shipped in the pinned kernels.

    The attribution (measured, same llama.cpp pin, same hip.dense_prefill.mm dispatch)

    The rc-2026-10-31c binaries embed clang-23 code objects (49× clang 23, 0× 24); the fork tip builds clang 24 (52×). Clang-24 _sb tiles carry 320-576 B/lane of scratch (engine#1064's measurement), so they spill — and the default GGML_HRX_HIP_DENSE_PREFILL_M128_SB=1 selected them. Q4_K M=16384 K=2560 N=9728, clock-matched pairs:

    arm ms TFLOP/s
    rc lib (clang-23 objects) 20.33 / 20.48 40.1
    tip, old default (_sb) 70.81 / 70.92 11.5 (3.47x)
    tip, new default (plain tiles) 21.11 / 20.42 38.7 / 40.0
    tip, M128_SB=1 (old behaviour) 68.61 / 69.22 11.9

    The rc lib is ~20-21 ms either way because clang-23's _sb does not spill; the regression was toolchain × default, not the pin or the dispatch.

    The fix and where it lives

    gpu-kernels #48 ("keep m128_w8_f2_sb off by default") was rebased onto main after #59/#1064 rewrote the same m128_sb/m128_fits region (both changes kept: swiglu_tile still follows m128_sb(), the flip lives inside sb_enabled()), merged, and the engine pin moved in #1248 (config/gpu-kernels.config 94bc42e5 -> 262c2f9a). Verified with the add-on's own tools/check.sh gfx1151 (409 kernel ids, 45 objects, 93 artifacts; only the pre-existing engine#52 fingerprint failures) and check-probes.sh (plain table when unset, old _sb table at =1). A fresh engine build recompiles the add-on, so no env is needed.

    What this does not fix

    The residual ~5 % vs the rc binary on the scratch-free tile is clang 24.0.0git (e095f1b3) vs clang 23 (0bace190) codegen — ROCm/llvm side, not the fork. The box has only /opt/rocm-therock clang 24, so closing it needs a clang-23 build environment or an LLVM fix. Interim mitigation for an already-built binary remains GGML_HRX_HIP_DENSE_PREFILL_M128_SB=0.

    Closing on the default flip being shipped in the pinned kernels; the toolchain gap is recorded here rather than claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hrxperf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions