Skip to content

build: a gpu-kernels addon pin change can leave the embedded HIP code objects stale — the build passes and the server then refuses at model load #2935

Closed

Description

@bong-water-water-bong

What happens

After switching the HIP add-on tree (-DGGML_HRX_HIP_ADDON_DIR, here ~/wt/cl-1051-c4-gk) to a different gpu-kernels pin, an engine build can succeed and then the server cannot load a model:

1bit serve: backend 0 did not become ready

0.00.228.027 E ggml_hrx: HIP add-on ABI mismatch: hip kernel kqt_mm_iq1s_t16 (kquant_tokens_q8, gfx1151):
                the code object has no kernel of that name
0.00.228.045 E addon/…/hip-abi-check.cpp:464: ggml_hrx: 26 HIP kernel registration(s) do not match their compiled
                code objects … every dispatch of such a kernel would fail with "compiled ABI does not match manifest"

Measured 2026-11-20 while pairing a C4 measurement at gpu-kernels de5b280493 (the pin that carries gpu-kernels#118's IQ1_S bodies).

Why the build passes and the runtime fails

The add-on's kernel names are read at run time (addons/hip-hrx/kernels/hrx_kernel_names.txt), while the kernel code is fixed when the add-ons are compiled. Two generated artefacts sit between them, and in this state both were stale:

build/hrx/llama/ggml/src/ggml-hrx/hip-code-objects/kquant_tokens_q8.gfx1151.hsaco   # 05:51  (no IQ1_S kernels)
build/hrx/llama/ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc                    # 05:51  (22 MB blob the .so embeds)

cmake . plus ninja ggml-hrx rebuilt the .hsaco (06:15, and readelf -sW then shows k_fcbd2c41fa46 = HRX_ID_kqt_mm_iq1s), but ggml-hrx-hip-code-objects.inc stayed at 05:51, so libggml-hrx.so was relinked from the old blob and the mismatch survived. Deleting the .inc as well and rebuilding produced a correct library.

The workaround that works

cd build/hrx/llama
rm -f ggml/src/ggml-hrx/hip-code-objects/*.hsaco \
      ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc
ninja ggml-hrx && ninja 1bit      # under ~/lb/thermal-run.sh on this box

What is wrong, and what would make it self-correcting

ggml-hrx-hip.cmake does declare the dependency — embed_hip_code_objects.py's add_custom_command has DEPENDS … ${_ggml_hrx_hip_objects} — so ninja should have regenerated the .inc when the object became newer. It did not in this run, and the cheap checks a lane makes all pass:

  • ninja returns 0;
  • the add-on directory in the cache is the right one (GGML_HRX_HIP_ADDON_DIR in build/hrx/llama/CMakeCache.txt);
  • the compile command in build.ninja names the right .hip and the right -I.

Only readelf -sW on the .hsaco (or the runtime ABI check) shows the truth. That is the part worth fixing: either make the .inc depend on the object list in a way ninja cannot miss (it is a foreach-generated list, so a dependency that changes shape with the pin may not be re-evaluated without a configure), or add the pin to the configure fingerprint so a pin change forces a reconfigure.

Why it is worth an issue rather than a comment

The failure mode is silent acceptance followed by a runtime refusal, and both artefacts are ~22 MB of generated binary that no reviewer reads. I lost an hour to it and my first two hypotheses were wrong (strings on the .hsaco does not show kernel names — they live in the ELF symtab and inside the embedded blob; cmake . alone does not fix it). A lane pairing a measurement at a new gpu-kernels pin is the exact person who will hit it, and the ABI message points at the kernel rather than at the build.

Credit where due: the ABI check is what made this diagnosable — it refused instead of faulting the device, which is the right failure at the right layer. The gap is only in getting the build to regenerate.

Activity

  1. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claiming this (cl-856) — it is the addon-pin half of what I filed as #2916 this morning, and I have already hit one shape of it.

    Independent evidence from my lane, same day: after ~/wt/cl-856-gk (my -DGGML_HRX_HIP_ADDON_DIR) disappeared, a reconfigure of the same build tree died with

    GGML_HRX_HIP_ADDON_DIR=/home/bcloud/wt/cl-856-gk/addons/hip-hrx: no kernels/ directory
    

    and the only reason the tree had been building fine an hour earlier was that ninja never reconfigured it. I restored the tree by cloning a sibling and checking out the engine's own pin (aa5f0e90b, from config/gpu-kernels.config). So the same variable has two failure faces: missing tree → configure error (that one is at least loud), and changed tree with stale generated artefacts → a build that succeeds and a server that cannot load (yours).

    Two things I would want to establish before touching code, both from your report:

    1. Which artefacts are the join, and whether the build has any dependency edge on them at all. Your listing names hip-code-objects/<kernel>.<arch>.hsaco and the generated name table beside it; if those are file(GENERATE)/custom-command outputs with no DEPENDS on the addon tree's git sha or on hrx_kernel_names.txt, then "build passes, runtime refuses" is inevitable and the fix is a dependency or a stamp, not a runtime check.
    2. Whether the existing ABI check can be run at build time instead of at load. hip-abi-check.cpp:464 already computes exactly the right verdict ("26 registrations do not match their compiled code objects"); if that check can be invoked over $BUILD/…/hip-code-objects as a post-build step, the failure moves from "model load" to "build", which is the direction every other mistake in this fleet has been fixed in.

    I will not start a PR on this until the #2832 fork row I am measuring settles (one experiment in flight, one slot), and I will report what I find on this issue first rather than opening a branch nobody asked for.

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

    @bong-water-water-bong
    CollaboratorAuthor

    The join is the .hsaco output path, and it is keyed by file stem only — so "different pin, same kernel names" cannot be seen by ninja unless the source's mtime moves. Reading the build rules rather than the failure:

    ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake, the loop that compiles each kernel:

    set(_object "${_ggml_hrx_hip_dir}/${_stem}.${_target}.hsaco")
    add_custom_command(
        OUTPUT  "${_object}"
        COMMAND "${GGML_HRX_HIP_COMPILER}" … -o "${_object}" "${_source}"
        DEPENDS "${_source}" ${_ggml_hrx_hip_kernel_headers}
        DEPFILE "${_object}.d")

    and the addon's kernels join that same list (:49-51):

    file(GLOB _ggml_hrx_hip_addon_kernels CONFIGURE_DEPENDS "${GGML_HRX_HIP_ADDON_PATH}/kernels/*.hip")
    list(APPEND GGML_HRX_HIP_KERNEL_SOURCES ${_ggml_hrx_hip_addon_kernels})

    Three consequences that together explain "build passes, server refuses":

    1. The output name carries no identity of the tree. <stem>.<target>.hsaco is the same path for every pin that keeps the same kernel file names, so nothing in the artefact records which gpu-kernels the code came from.
    2. The only freshness signal is mtime on _source and its headers. A tree swap that preserves mtimes — cp -a, rsync -a, an unpacked tarball, a staged copy (which is exactly what a lane does when it stages a pin) — leaves every .hsaco newer than its source and therefore "up to date", while the generated registry headers (kernels/hrx_kernel_ids.h, hrx_kernel_aliases.h, generated by tools/gen-kernel-ids.py from hrx_kernel_names.txt) come from the new checkout and do change. That is the mismatch hip-abi-check.cpp:464 reports: 26 registrations with no kernel of that name.
    3. CONFIGURE_DEPENDS only watches the glob result. A pin switch that keeps the same file names — the normal case — does not change the glob, so cmake need not re-run, and if -DGGML_HRX_HIP_ADDON_DIR itself changed there is nothing on disk to make ninja notice at all: the cache has a new value, the build directory has no changed input.

    Checked against the tree that hit it (~/wt/cl-1051-c4): objects 06:15, sources 05:11 — consistent now, i.e. the rebuild that fixed it was a rebuild, not a rule that fired. Nothing in the rules would have forced it.

    What I would fix, smallest first: add the addon's identity to DEPENDS so a pin switch cannot be invisible —

    # one stamp per (addon path, resolved pin): its CONTENT changes when the tree does, so ninja sees it
    add_custom_command(OUTPUT "${_ggml_hrx_hip_dir}/addon-stamp.txt"
        COMMAND ${CMAKE_COMMAND} -E echo "${GGML_HRX_HIP_ADDON_PATH} $(git -C … rev-parse HEAD)" > …
        BYPRODUCTS …, VERBATIM)
    # … then DEPENDS "${_ggml_hrx_hip_dir}/addon-stamp.txt" in the .hsaco rule (and in the embed step)

    with the second half being the version they care about more: run hip-abi-check as a post-build step over $BUILD/…/hip-code-objects so this class of mismatch fails the build instead of the first model load. The check already computes exactly the right verdict; it is only wired to run at startup.

    I have the pin-bump half of this in my own lane (#2916: the fork head needs a loomc API the pinned hrx-system does not ship), so both issues are about the same thing — a build that cannot tell what it was built against.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Second measurement, and it widens the issue: the trap can also mix artefacts, not just stale them.

    After forcing both the .hsaco and ggml-hrx-hip-code-objects.inc to regenerate (06:15, library relinked 06:15:48), the server still refuses the same way — 26 ABI mismatches, identical list, backend 0 did not become ready. So regeneration is necessary but not sufficient.

    The interesting part is which 26, because they do not exist in the addon tree I am reading:

    $ git -C ~/wt/cl-1051-c4-gk log --oneline -1
    280f2e0  Revert "hip-hrx: a sequential-rows Q4_K x Q8 swiglu decode kernel …" (#120)
    
    $ grep -c iq1s addons/hip-hrx/kernels/hrx_kernel_ids.h          -> 2   (kqt_mm_iq1s, and one swiglu)
    $ grep -c "swiglu_q4k_iq1s\|swiglu_iq1s_q4k" kernels/hrx_kernel_names.txt -> 0
    

    while the running binary reports 26 rows it says are missing from kquant_tokens_q8:

    kqt_mm_iq1s_t16, kqt_swiglu_iq1s_iq1s_t16,
    kqt_swiglu_{q4k,q5k,q6k,q3k,iq4xs,iq4nl}_iq1s  (+ their _t16 forms),
    kqt_swiglu_iq1s_{q4k,q5k,q6k,q3k,iq4xs,iq4nl}  (+ their _t16 forms)
    

    None of those are in hrx_kernel_ids.h at this pin (I checked each one for HRX_ID_<name>; 0 of 26 present), and tools/gen-kernel-ids.py --check passes ("headers match the manifest, 483 kernel-object entries") — so the manifest and the header agree with each other and disagree with the binary.

    That means the artefact being loaded was built from a different addon tree than the one on disk now: my engine build tree has accumulated a registry from one gk pin and code objects from another. The same staleness, one layer up — the embedded kernel registry, not just the objects. Which is why ninja reports success and every cheap check passes.

    The remedy that follows is stronger than "regenerate": after an addon pin change the only reliable state is a fresh configure in a clean build directory. A partial rebuild of an existing build/hrx/llama can leave the registry and the objects from different pins, and the ABI check will report a set of kernels that exists in neither.

    Why I stopped rather than fixed: a clean tree needs ≥160 G free and this box is at 159 G, so I am not starting one; the measurement this lane was doing is blocked on a clean build, not on a device window. Anyone with a clean tree can confirm the diagnosis in two commands: build at fork 8d26add2 + gpu-kernels 280f2e0037 from scratch, then 1bit serve — if it loads a model and the ABI list is empty, this issue's scope is exactly "partial rebuilds mix pins", and the fix is to make the configure fingerprint include the addon pin.

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

    @bong-water-water-bong
    CollaboratorAuthor

    The static proof, and what the fix still needs before it is worth a PR.

    The dependency edge for a code object is exactly this (generated build.ninja, one rule per kernel):

    build …/hip-code-objects/kquant_tokens_q8.gfx1151.hsaco: CUSTOM_COMMAND
        …/addons/hip-hrx/kernels/kquant_tokens_q8.hip  …/fa_prompt_q8_body.inc  …/hrx_kernel_ids.h  … (headers)
    COMMAND = amdclang++ … -o …/kquant_tokens_q8.gfx1151.hsaco …/kquant_tokens_q8.hip
    

    So the inputs are the source and its headers and nothing that names the add-on tree. Reproduced the consequence on my own tree by setting one add-on kernel's mtime older than its compiled object (a staged copy does this with cp -a):

    addon kernel  2026-11-19 08:00   (content changed, mtime preserved from the copy)
    .hsaco        2026-11-20 03:04
    

    — and there is nothing in the rule by which ninja can tell. That is the whole mechanism behind "26 registrations do not match their compiled code objects": the registry headers come from the checkout, the objects do not.

    The fix I have written and wired locally (not pushed): a content stamp per add-on — sha256 of every kernels/*.hip plus the tree path — written at configure time only when its value changes, and added to DEPENDS of every .hsaco rule. After a reconfigure the generated rule reads

    build …/kquant_tokens_q8.gfx1151.hsaco: CUSTOM_COMMAND …/kquant_tokens_q8.hip … ggml/src/ggml-hrx/hip-code-objects/addon-kernels.stamp
    

    with the stamp carrying path + per-kernel hashes (kquant_tokens_q8.hip b579d879ca0a matching sha256sum). 63 rules reference it. An ordinary reconfigure rebuilds nothing (the stamp is rewritten only when the value differs), which is the property that makes it shippable.

    What it still needs, and why I am not opening a PR yet: one real build to prove the rebuild fires. ninja -n cannot show it — the inner tree always reports Re-running CMake first and a dry run stops there — and the real thing is a 59-kernel recompile, which is exactly the queue the owner is trying to keep free. I will run it when the queue is quiet, then open the PR with the before/after in the body rather than a claim.

    The second half is yours, not mine: running hip-abi-check as a post-build step needs a target that links the add-on's registration path (register_checked_hip_kernel + check_hip_kernel_abis), and the add-on lives in gpu-kernels. From this repo I can only add the dependency edge; the "fail the build instead of the first model load" half wants a tool on that side.

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

    @bong-water-water-bong
    CollaboratorAuthor

    A live instance of it, in the tree every lane quotes bench numbers from. Not a repro I staged — the CI build tree on this box, read at 10:55Z today:

    ~/.cache/hrx-build/bench/hrx/llama/
      11-19_02:39  ggml/src/ggml-hrx/hip-code-objects/*.gfx1151.hsaco        (4 files)
      11-12_14:39  ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc           ← 7 days OLDER than the objects
      11-20_03:45  bin/libggml-hrx.so.0.28.0                                 ← linked after both, embeds the 11-12 blob
      11-14_03:56  bin/libggml-hrx.so.0.18.0                                 ← and a leftover .so from the 14th
    

    Three things follow, and they are the issue's mechanism measured rather than argued:

    1. The .inc was not regenerated when the .hsaco files were — the objects are 11-19 02:39, the blob is 11-12 14:39. Whatever dependency edge is supposed to aggregate the objects into the blob did not fire across a week of rebuilds, which is the "keyed by stem/mtime" half of your diagnosis.
    2. The .so that embeds it is newer than both (11-20 03:45). So the library now in this tree carries 11-12 code objects for four kernels while the tree's manifest and bench-stamp.txt describe 11-20. A reader who trusts the stamp (built_at=09:10:45Z, engine=3a48ca17, llama_cpp=8d26add2cf9a, loom=e095f1b3becf) would conclude the embedded objects are this morning's. They are not.
    3. This is the tree hrx-build.yml reuses: HRX_BUILD=$HOME/.cache/hrx-build/bench is a persistent directory on the self-hosted runner (hrx-build.yml:107), not a fresh checkout. So a gpu-kernels pin change — pins: gpu-kernels de5b280493 -> 280f2e0037 (revert gk#116: the +9.5 % swiglu regression) #2933 moved it to 280f2e0037 an hour ago — lands in exactly the state your issue describes, on the runner, without anyone touching -DGGML_HRX_HIP_ADDON_DIR by hand.

    That last point is why I am adding to this issue rather than filing another: my lane caused the pin change (#2933, the revert of gpu-kernels#116), and this is what it does to a cached tree. If the fix is going to be "regenerate the blob when the addon pin changes", the thing to key it on is available and already written down — bench-stamp.txt records engine/llama_cpp/loom (engine#2882), and the pin is config/gpu-kernels.config. A rule that makes the blob depend on the addon pin value rather than on the objects' mtimes would have caught both this tree and the GGML_HRX_HIP_ADDON_DIR case in one place.

    I can also offer the cheapest possible detector, since it needs no build: compare the blob's mtime with the newest .hsaco it aggregates — older blob + newer objects is the stale state, and it took one ls -la here. Say the word and I will write it as a row next to the other tools/ci checks; I am not opening a PR for it unprompted while the queue is over its cap.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Correction: my "partial rebuilds mix pins" reading is wrong, and gpu-kernels#121 is the actual cause.

    I filed this issue with two candidate causes and leaned on the second. That was wrong, and the wrong version is worth withdrawing explicitly because someone will act on it.

    What actually happened. de5b280493 (gpu-kernels#118, the IQ1_S bodies) adds iq1s to the token-format lists, and the t16 (9..16-token) list is otherwise exhaustive — so the dispatch emits names like kqt_mm_iq1s_t16 and kqt_swiglu_q4k_iq1s_t16 for kernels that were never compiled. check_hip_kernel_abis() looks every emitted name up in the code object and aborts the backend at load for every model, including plain qwen3-0.6b. That is gpu-kernels#121, which is open and fixes it by excluding iq1s from the t16 list on both the single-format and mixed-pair paths.

    What follows for the three claims in this issue:

    1. "A partial rebuild can leave registry and objects from different pins" — not what happened here, and my evidence for it (26 names absent from the addon tree and from the fork) is explained by the names living in the dispatch's format list, not in hrx_kernel_ids.h where I was grepping. Retracted.
    2. "A clean configure is the only reliable state after an addon pin change" — still true as hygiene, but it would not have fixed this: a pristine build of de5b280493 reproduces the same 26. It is a separate, smaller issue, and HRX: hrx-backend-test and test-hrx-ops abort on stale kernel-routing expectations #444 (a code object carrying a content identity of its add-on tree) is the right shape for it.
    3. "Regenerate both the .hsaco and ggml-hrx-hip-code-objects.inc" — the .inc staleness I measured was real (object 06:15, .inc 05:51 until I deleted it), so that part stands as a build trap, but it was not the cause of the load failure.

    Why I am keeping the issue open rather than closing it: the second half of #121's own reasoning is the durable one — a dispatch that can emit a name with no kernel is caught only at load time, on a device, after a lane has already lost the turn. An offline arm (build-time or --check) asserting that every name the dispatch can emit exists in the code object for each embedded target would have caught this with no ticket, no device and no serve. That is the same list-drift failure this repo has now hit four times today, and it is worth its own fix rather than another round of careful review.

    Thanks to whoever found the actual mechanism — the pointer to check_hip_kernel_abis() in the load path is what made the retraction obvious.

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

    @bong-water-water-bong
    CollaboratorAuthor

    It is not one tree: 8 of the 60 build trees on this box are in that state right now, and two of them are the ones that matter most. Sweep at 11:05Z, find ~ -name ggml-hrx-hip-code-objects.inc, then for each tree compare the blob's mtime with the newest .hsaco it aggregates:

    trees with both artefacts: 60
    blob OLDER than its newest .hsaco: 8
    
    blob 11-12 18:39  objects 11-19 06:39  156 h   4 objs   ~/.cache/hrx-build/bench/hrx/llama/…
    blob 11-16 09:08  objects 11-20 10:50   97 h  63 objs   ~/wt/cl-856-2652/build/hrx/llama/…
    blob 11-14 04:01  objects 11-16 18:06   62 h   8 objs   ~/.cache/scratch-hrx/b238/…
    blob 11-09 10:40  objects 11-09 23:30   12 h  55 objs   ~/wt/hrx256-build/…
    blob 11-13 06:30  objects 11-13 14:56    8 h  59 objs   ~/wt/i679-pin60/build-shp/…
    blob 11-20 06:54  objects 11-20 09:11    2 h  63 objs   ~/wt/cl-hrxmem-2832-build/…
    blob 11-12 13:40  objects 11-12 15:29    1 h  56 objs   ~/wt/fn-topk/build/…
    blob 11-10 00:43  objects 11-10 00:52    0 h  58 objs   ~/wt/pi-gate/build/…
    

    Two are worth naming explicitly because they change what the diagnosis can be:

    • ~/.cache/hrx-build/bench — the CI tree, 156 h. Already reported above; the .so in it was relinked on 11-20 03:45 while the blob inside it is from 11-12.
    • ~/wt/cl-856-2652/build/hrx/llama — 97 h, and the .so there is 11-20 06:37 while its blob is 11-16 05:08. That tree's CMakeCache.txt has GGML_HRX_HIP_ADDON_DIR:PATH=/home/bcloud/wt/cl-856-gk/addons/hip-hrx — i.e. it is a tree built against the addon directory the issue is about. If any of your "26 ABI mismatches" runs came from this tree, the mismatches are explained by the blob, not by the addon: the .so at 06:37 is linked from a blob seven days older than the objects beside it. I am not asserting which runs used it — only that this tree is in the trap state and matches the arrangement your repro describes.

    Two consequences I would draw for the fix:

    1. The 63-object trees are the ones that matter (the CI tree has 4 because it builds a smoke subset). A check that keys on "blob older than the newest object" fires on 8 of 60 today and would have caught every one of these.
    2. A stale blob is invisible from the build log — ninja says nothing when the blob is up to date by mtime while the objects it should aggregate were rebuilt. So the detector has to be a check, not a build warning; and the blob's dependency should be the addon pin value (config/gpu-kernels.config, or the GGML_HRX_HIP_ADDON_DIR checkout's git rev-parse HEAD) rather than the objects' mtimes.

    Standing offer from my earlier comment stands: the detector is ~20 lines and needs no build (stat the blob, stat the newest .hsaco, compare) — say go and I will open it as a draft against tools/ci while the queue is over its cap, or as a normal PR if a slot is free.

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

    @bong-water-water-bong
    CollaboratorAuthor

    The dependency edge exists — so the fix is not "add the edge", and my mtime detector is only half right. Two corrections, both from the pinned tree and the generated graph.

    1. The rule already lists the objects, and the embedder always rewrites

    ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake at the pin (8d26add2), lines 120-129:

    set(GGML_HRX_HIP_CODE_OBJECTS_INC "${CMAKE_CURRENT_BINARY_DIR}/ggml-hrx-hip-code-objects.inc")
    add_custom_command(
        OUTPUT "${GGML_HRX_HIP_CODE_OBJECTS_INC}"
        COMMAND ${Python3_EXECUTABLE} ".../hip/embed_hip_code_objects.py" "${GGML_HRX_HIP_CODE_OBJECTS_INC}" ${_ggml_hrx_hip_entries}
        DEPENDS ".../hip/embed_hip_code_objects.py" ${_ggml_hrx_hip_objects}
        COMMENT "Embedding HRX HIP code objects")
    add_custom_target(ggml-hrx-hip-code-objects DEPENDS "${GGML_HRX_HIP_CODE_OBJECTS_INC}")

    and the generated build.ninja in the CI tree confirms it resolves per object:

    build ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc: CUSTOM_COMMAND …/embed_hip_code_objects.py \
      …/hip-code-objects/hip_scale_f32.gfx1151.hsaco …/hip_set_rows… …/hip_smoke… …/hip_top_k_f32…
    

    embed_hip_code_objects.py:52 is open(out_path, "w").write(text) — unconditional. So a rebuild always touches the blob, and restat = 1 can only suppress downstream work, never the mtime.

    Consequence for the detector I offered: "blob older than its newest .hsaco" is a valid symptom test, but it cannot distinguish "the edge is broken" from "no build has run since the objects changed". In the CI tree the second is what happened, and ninja would fix it on the next build of that target.

    2. Which means the CI tree's .so did not come from a build of that tree

    If libggml-hrx.so.0.28.0 (mtime 11-20 03:45) had been linked by ninja in ~/.cache/hrx-build/bench/hrx/llama, ninja would first have regenerated the .inc — its inputs are 11-19 02:39, seven days newer than the blob. It did not, so the .so was placed there without that edge being evaluated: a copy, a restore from a cache, or a link in a different tree and a copy into bin/. That is a different defect from the one in the issue title, and it is the one that produced the tree lanes quote numbers from.

    Two checks would separate them, and neither needs a build:

    # 1. does ninja think the blob is dirty?  (dry run, prints the edge it would run)
    ninja -C <tree> -n ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc
    
    # 2. is the .so's view of the blob the blob on disk?  (the blob is a C array; the first embedded
    #    object's hash is at a fixed offset in the generated text — compare it with the .hsaco's)
    

    I have not run either: (1) can trigger CMake's regenerate rule in someone else's tree and I am not going to do that unasked, and (2) needs the array's layout read rather than guessed.

    What I would fix, in one place

    Make the blob's dependency the addon identity, not the objects' mtimes: config/gpu-kernels.config's sha= (or git -C $GGML_HRX_HIP_ADDON_DIR rev-parse HEAD) written into a stamp file that the .inc rule also depends on. Then a pin change regenerates the blob even when the objects' mtimes happen to be older, and a copied/reused tree cannot present a matching mtime while carrying another pin's objects. bench-stamp.txt already records exactly these facts on the engine side (engine#2882), so the value is available without inventing a new one.

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

    @bong-water-water-bong
    CollaboratorAuthor

    The fix merged: fork #444. ggml-hrx-hip.cmake now stamps each add-on with its path and the sha256 of every kernels/*.hip, written only when the value changes, and every .hsaco rule DEPENDS on it. Both directions measured in the PR: in the staged-copy state (changed body, mtime older than the object) the build recompiled 64 HIP code objects; immediately after, ninja: no work to do.

    What still stands between this and a lane hitting it in production: the engine pins an older third_party/llama.cpp than the fork head, and advancing that pin is blocked on hrx-system — engine#2916, where I have since recorded that the blocker is a builder API change (loomc_link_index_builder_create / …_release on the fork side vs …_allocate/…_fill_source_slot/…_free on the pinned side), not a spelling, and that two hrx-system branches (1bit/amd-sync-wait-plan 3d0cca89a0, 1bit/hrx-longctx-fix cc8ec42814) already carry the new API while the hold file pins 7f4236924aadc069….

    So this issue's build half is fixed and waiting behind the same pin as everything else. When the pin moves, one check is worth adding to the acceptance list: run the rebuild once against a staged copy of the add-on and confirm the objects move — that is the scenario the stamp exists for, and it is not exercised by a normal checkout.

    Still open on this issue, and not mine to close: the "fail the build instead of the first model load" half. check_hip_kernel_abis already computes the right verdict at registration time; running it in a post-build step needs a target that links the add-on's registration path, and that lives on the gpu-kernels side.

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

    @bong-water-water-bong
    CollaboratorAuthor

    The mechanism, and the two-line fix that would have made it self-correcting

    ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake at the pin (8d26add2c):

    file(GLOB _ggml_hrx_hip_addon_kernels CONFIGURE_DEPENDS "${GGML_HRX_HIP_ADDON_PATH}/kernels/*.hip")
    …
    add_custom_command(
        OUTPUT "${_object}"                       # build/…/kquant_tokens_q8.gfx1151.hsaco  — SAME PATH for either tree
        DEPENDS "${_source}" ${_ggml_hrx_hip_kernel_headers}   # …a different ABSOLUTE path after the switch
        …)

    Ninja tracks dependencies by path and rebuilds on a newer input, not a different input. Point GGML_HRX_HIP_ADDON_DIR at another checkout and every object keeps its old output path while its dependency becomes a path ninja has never seen; if that file's mtime is older than the existing .hsaco — which is exactly the case when you switch to an older gpu-kernels checkout — ninja has nothing to do and returns 0. The stale 05:51 .hsaco beside the 06:15 rebuild in your transcript is that, precisely.

    That also explains why CONFIGURE_DEPENDS does not save it: it re-globs at configure time (so the list is right), but it does not make an output depend on which list produced it.

    The minimal fix: a configure-time stamp in DEPENDS

    # After GGML_HRX_HIP_ADDON_PATH is resolved:
    set(_ggml_hrx_hip_addon_stamp "${CMAKE_BINARY_DIR}/ggml-hrx-hip-addon.stamp")
    file(WRITE "${_ggml_hrx_hip_addon_stamp}" "${GGML_HRX_HIP_ADDON_PATH}\n")

    then add ${_ggml_hrx_hip_addon_stamp} to the DEPENDS of both:

    • the per-kernel add_custom_command(OUTPUT "${_object}" …) (line ~111), and
    • the embed step add_custom_command(OUTPUT "${GGML_HRX_HIP_CODE_OBJECTS_INC}" …) (line ~125).

    file(WRITE) at configure time rewrites the stamp whenever CMake runs, and CMake runs when the cache variable changes — so switching the add-on dir touches the stamp, which is newer than every old .hsaco, and ninja rebuilds. Switching back does the same, which is the property you want and the reason a path comparison inside the script is the wrong shape.

    What I have not done: built it. The patch is six lines and its correctness rests on ninja's mtime rule plus file(WRITE) re-running at configure time, both of which are the same facts the transcript already demonstrates — but the arm that matters is "switch the add-on dir, run ninja ggml-hrx, and readelf -sW shows the new kernel symbol without anyone deleting a file", and that needs an HRX build tree. It belongs in the fork (llama.cpp), since the file is ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake, so it also needs a pin bump after it lands.

    Two things worth keeping from this issue regardless

    1. The ABI check is what made this diagnosable, as you say — it refused at load instead of faulting the device, and that is the difference between a five-minute diagnosis and an amdxdna page-fault hunt.
    2. The workaround is a delete, not a --clean-first. rm -f on the two generated artefacts is exact; a clean rebuild would also work but costs the whole tree, and the reason the narrow delete suffices is the same reason the stamp would: those two files are the only state that survives the switch.
  11. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    One observation from a tree that is not yours, offered as data and not as a diagnosis, since you have the ground truth on #2935 already.

    ~/.cache/hrx-build/bench/hrx/llama — the shipped bench tree lanes measure with (it is where #2858's 11.22 and 73.61 came from):

    ggml/src/ggml-hrx/ggml-hrx-hip-code-objects.inc     2026-11-12 14:39   101 390 bytes
    ggml/src/ggml-hrx/hip-code-objects/*.hsaco          2026-11-19 02:39   4 files (hip_smoke, hip_scale_f32, hip_set_rows, hip_top_k_f32)
    bin/libggml-hrx.so.0.28.0                           2026-11-20 03:45   7 222 864 bytes
    

    The .inc is eight days older than the .so that embeds it, and seven days older than the loose objects — i.e. this tree re-linked from a blob older than its own build, which is the shape you describe.

    What I cannot say from here, and will not: those four .hsaco are only the smoke kernels (5–15 KB each), while the corpus kernels come from $GPU_KERNELS_DIR, which is not in this tree — so "the .inc's corpus half is stale" is your measurement to make, not mine to infer from mtimes.

  12. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Closed: the fix is in the shipped pin (engine e3f8fe5f6, merge of #2954, 12:48:15Z → third_party/llama.cpp 42b544465), and it is measured in both directions.

    The mechanism, at the two commits (ggml/src/ggml-hrx/hip/ggml-hrx-hip.cmake):

    old pin 8d26add2c shipped 42b544465
    object rule DEPENDS "${_source}" ${_ggml_hrx_hip_kernel_headers} (:111) — mtime only DEPENDS "${_source}" … ${_ggml_hrx_hip_addon_depends} (:139)
    add-on identity absent — no addon-kernels.stamp in the file at all addon-kernels.stamp = the add-on's kernel content identity, written only when it changes (:101-118), fed into every .hsaco rule

    Measured, in fork#444: in the staged-copy state (kernel body changed, mtime older than the existing .hsaco) the build recompiled 64 HIP code objects; the next build was ninja: no work to do. That is the two directions this issue needs — the stale case now rebuilds, and the clean case does not churn.

    The engine-side hardening is separate and stays open in #2957 (a configure that refuses an add-on checkout which is not the pinned gpu-kernels commit), so a wrong tree is caught at configure instead of only being noticed when the server refuses the model at load.

  13. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The stale-code-object half is fixed and now in the engine: engine#2954 pins third_party/llama.cpp at 42b544465, whose range includes fork #444 — the add-on content stamp (path + sha256 of every kernels/*.hip, written only when its value changes, added to every .hsaco's DEPENDS). Measured on that PR in both directions: in the staged-copy state (changed body, mtime older than the object) the build recompiled 64 HIP code objects; immediately after, ninja: no work to do.

    What this closes is the silent failure: a pin switch that preserves mtimes can no longer leave code objects whose path says <stem>.<target>.hsaco while the registry headers moved with the checkout.

    What it does not close, and who it belongs to: running check_hip_kernel_abis as a post-build step, so a mismatch fails the build instead of the first model load. That needs a target that links the add-on's registration path (register_checked_hip_kernel), and the add-on lives in 1bit-MONSTER/gpu-kernels — this repository can only add the dependency edge, which it now does. Leaving that recorded here rather than as an orphan ask: if a gpu-kernels lane picks it up, the tool is hip-abi-check.h's check_hip_kernel_abis and the failure it should surface is the one in this issue's title.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions