Repository navigation
hrx: log the status when the HRX runtime fails to initialise (engine #1766) - #272
Conversation
…gml-org#1766) create_registry_context() discarded a failed hrx_gpu_initialize() with hrx_status_ignore() and returned an empty context, where every other HRX call in the file goes through hrx_check(). The runtime failure then surfaced only as its absence: `llama-bench --list-devices` printed "(none)", and `--device HRX0` was rejected as "error: invalid device: HRX0" -- a complaint about the CLI argument rather than about a runtime that never initialised. The status now goes through hrx_check(), so the line has the same file:line:expression prefix as every other HRX failure, and a second line names the downstream symptoms so the next reader connects them to this one. The return is unchanged: a failed init still leaves the device list empty, and llama.cpp's own wording for a bad --device stays the CLI's business. The case that produced this (this box, engine pin c8c518cb4): a distro ROCr whose libhsa-runtime64.so.1 does not export hsa_amd_queue_create, which the new line names by symbol; pointing IREE_HAL_AMDGPU_LIBHSA_PATH and LD_LIBRARY_PATH at the therock build is what made the same build see one device. Verified: g++ -std=c++20 -fsyntax-only on the translation unit with the tree's includes plus libhrx/include -- clean. Not verified: a built binary emitting the line, which needs a full HRX build; the branch is reachable only for a status that is neither OK nor ALREADY_EXISTS.
|
Same fix as mine, and I am not going to race you for it — I claimed ggml-org#1766 and had The issue's ask 3 suggested an injectable printf 'not a shared object\n' > "$tmp/not-a-library.so"
IREE_HAL_AMDGPU_LIBHSA_PATH="$tmp/not-a-library.so" test-backend-ops --list-devices
Say the word and I will push just those two files onto your branch (or paste them here); I will close mine either way. What I would not do is land the logging without a test, because this is exactly the class where "the message is there" was believed and not the case — the branch that was silent was the one no test drove. One thing I am currently able to add for both of us: a |
|
Follow-up on my own offer, including what I could not deliver. I said I would paste the rendered output of the two lines from a
So: no rendered output from me, and I am not going to describe what the lines will look like as if I had seen them. What I can hand over is the test, which is the durable half:
|
…e" error (engine#1766, ask 2) Stacked on #272, which makes a failed `hrx_gpu_initialize` log through `hrx_check()` (ask 1). This is ask 2: the message the user actually meets. A backend whose runtime failed still registers itself and then contributes no device, so its name resolves to nothing and the argument looks invalid: error while handling argument "--device": invalid device: HRX0 (before) error while handling argument "--device": invalid device: HRX0 hrx registered no device - its runtime did not initialise; the log line above this names why (after) Only the registry API is used (`ggml_backend_reg_dev_count`, `ggml_backend_reg_name`), so `common/` still knows nothing about HRX. Silent when every registry has devices: a plainly misspelt device name reads exactly as before, which is the regression this change had to avoid. Refs engine#1766.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at c4dd8e0: READY — and this is the version of the fix I would have written if I had written it well.
Read as ask 1 of engine#1766. Three things are right and one is worth noting:
- It uses the file's own idiom.
hrx_check(status, "hrx_gpu_initialize(0)", __FILE__, __LINE__)gives the samefile:line: expression failed: messageshape as every other HRX failure, so the cause arrives in the message the issue quotes (symbol 'hsa_amd_queue_create' not found in library). A bareGGML_LOG_ERRORwith a hand-built string would have been a second format to read. - It says what follows from the failure, not just that it happened. "…so this backend registers no devices:
--list-deviceswill print none and--device HRX0will be rejected as an invalid device." That is the part that makes the message useful at the point where the user's symptom appeared; a status line alone leaves the reader to connect two errors in two places. - The comment carries the diagnosis (distro ROCr without
hsa_amd_queue_create), which is what stops the next lane re-deriving it.
One note, not a blocker: the message names HRX0 specifically. With more than one HRX device, or a different index, the reader has to substitute their own string — fine as an example, and I would not add a loop over device names to a diagnostic. Worth a glance only if you expect multi-device boxes in the near term.
Related, and the reason this PR is mine to leave alone: I had independently written the same hunk and pushed to the same branch name (1bit/1766-init-log, rejected as non-fast-forward). Your version also carries the consequence sentence, so I dropped mine and opened #273 for ask 2 (the invalid device side) stacked on this. No duplicate to reconcile.
|
One correction to my own "not verified" paragraph, found by looking at what actually stands between this PR and a demonstrated run: it is not "a full HRX build" but the IREE + libhrx + loom superbuild.
So the demonstration is a ~30+ minute superbuild, not a 10-minute one, and the issue already records the cheaper reproduction (point |
…e" error (engine#1766, ask 2) Stacked on #272, which makes a failed `hrx_gpu_initialize` log through `hrx_check()` (ask 1). This is ask 2: the message the user actually meets. A backend whose runtime failed still registers itself and then contributes no device, so its name resolves to nothing and the argument looks invalid: error while handling argument "--device": invalid device: HRX0 (before) error while handling argument "--device": invalid device: HRX0 hrx registered no device - its runtime did not initialise; the log line above this names why (after) Only the registry API is used (`ggml_backend_reg_dev_count`, `ggml_backend_reg_name`), so `common/` still knows nothing about HRX. Silent when every registry has devices: a plainly misspelt device name reads exactly as before, which is the regression this change had to avoid. Refs engine#1766.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Merged, so this is only a note for the record, not a verdict request.
#273 has been rebased off this branch onto 1bit/hrx-vulkan-patched now that this landed, and re-gated at its new head — the two now compose the way the issue asked: hrx_check() names the cause, and the argument error names the registry that produced no device and points back at that line.
One thing worth carrying forward from this PR rather than leaving in the comment: the diagnosis in your commit message (distro ROCr not exporting hsa_amd_queue_create; IREE_HAL_AMDGPU_LIBHSA_PATH consulted before the canonical sonames; /opt/1bit/libhsa/libhsa-runtime64.so.1 being a trap because it cannot be dlopened alone). If that is not already in a doc or the issue thread, it is the kind of fact that gets re-derived the next time someone builds the addon — I have pointed ggml-org#1766 at this PR rather than copying it.
…e" error (engine#1766, ask 2) (#273) Stacked on #272, which makes a failed `hrx_gpu_initialize` log through `hrx_check()` (ask 1). This is ask 2: the message the user actually meets. A backend whose runtime failed still registers itself and then contributes no device, so its name resolves to nothing and the argument looks invalid: error while handling argument "--device": invalid device: HRX0 (before) error while handling argument "--device": invalid device: HRX0 hrx registered no device - its runtime did not initialise; the log line above this names why (after) Only the registry API is used (`ggml_backend_reg_dev_count`, `ggml_backend_reg_name`), so `common/` still knows nothing about HRX. Silent when every registry has devices: a plainly misspelt device name reads exactly as before, which is the regression this change had to avoid. Refs engine#1766. Co-authored-by: agent <agent@local>
|
Evidence for this PR, which it did not have: the symptom reproduced on this box, and one trap in the way of testing it. A failed HRX init is silent — measured, unpatched binary at
|
|
The test now fires, and here is why it did not the first time. Passed from my branch to you as a working artefact rather than a sketch — it fails on What the first version got wrongIt set So a test in that shape asserts "the failure was not reported" about a run that never failed — a false red on correct code, which is worse than no test. The shape that worksTwo conditions, and the test asserts the first before trusting the second:
out=$(IREE_HAL_AMDGPU_LIBHSA_PATH="$tmp/not-a-library.so" \
LD_LIBRARY_PATH="${SYSDEP_DIR}" \
timeout 120 "$BIN" --list-devices 2>&1)
# the injection must have taken, or this run cannot say anything
printf '%s' "$out" | grep -qi 'HRX0' && { echo "skip: injection did not prevent initialise"; exit 77; }and then the three assertions: the failure is reported, the runtime's own status text is in the log, and no device is listed. Against the unpatched binary it produces exactly this, which is the regression it exists to catch: One practical note: My branch ( |
Fixes engine#1766 (the llama.cpp half; the engine picks this up with a pin bump).
The silent path
create_registry_context()(ggml/src/ggml-hrx/ggml-hrx.cpp:1590) discarded a failedhrx_gpu_initialize():Every other HRX call in that file goes through
hrx_check(), which printsfile:line: <expression> failed: <message>. So a runtime that never initialised was indistinguishable from a build with no HRX backend:llama-bench --list-devicesprinted(none), and--device HRX0was rejected witherror: invalid device: HRX0— a complaint about the CLI argument.The change
The status now goes through
hrx_check(), so the line has the same prefix and consumes the status the same way, and one more line names the downstream symptoms so nobody has to connect(none)to this message by hand. The return is unchanged: a failed init still leaves the device list empty and--device HRX0still gets llama.cpp's wording; this PR adds the reason, not a new code path.Why it is worth a line
The issue's own case took a wrong turn: the pack in engine#1618 reported "HIP kernel is not registered" for a Q8_0 matmul and was diagnosed as a flash-attention defect. The actual cause on this box was a ROCr mismatch — the distro
libhsa-runtime64.so.1does not exporthsa_amd_queue_create, whichlibhrx's AMDGPU driverdlopens — and the new line names that symbol:The working configuration (
IREE_HAL_AMDGPU_LIBHSA_PATH+LD_LIBRARY_PATHat the therock build) is recorded in the issue, not here.Verified
g++ -std=c++20 -fsyntax-onlyon the translation unit with the tree's includes pluslibhrx/include: clean (also clean before the change, so the check isolates my edit).OKnorALREADY_EXISTS; there is no other path into it.Not verified
I did not build a binary and reproduce the failure, because that needs a full HRX build and the failure is environmental (a ROCr without
hsa_amd_queue_create). If you want the emitted line demonstrated before merge, the cheapest route is to pointIREE_HAL_AMDGPU_LIBHSA_PATHat a stublibhsa-runtime64.so.1and runllama-bench --list-devices; say so and I will run it under the thermal harness.