Repository navigation
make-binary-drop: the code-object check tests the ELF property, not a bundle-header string (Fixes #1443) - #1453
Conversation
PR Reviewer Guide 🔍(Review updated until commit b694ffb)Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 22b4cd79ac999a3cb89ae7546aec9ae7d90e68aa
This replaces a proxy with the property, which is the fix worth having: the old check asked whether libggml-hrx.so contained the string amdgcn-amd-amdhsa — a clang offload-bundle header — while a HIP fat binary built the ordinary way embeds its code objects as ELF images with e_machine == EM_AMDGPU and has no bundle header at all. So the shipped c31 library, which carries 51 code objects and zero such strings, was refused by a check that a bundle-header build would have passed for the wrong reason.
I ran the new test at this head and it covers both directions plus the parser's edges — tests/code_objects_test.py → 0 failure(s):
two embedded EM_AMDGPU images -> 2, passes
ELF images of another machine are not code objects (refused, naming EM_AMDGPU)
a library with only its own header is refused
a bare code object passes
a truncated trailing header is skipped, not counted and not a crash
--min 3 refuses a file with 2 code objects; --min 2 --quiet passes silently
an unreadable file is exit 2, not a false verdict
the shipped c31 library passes with 51 code objects (the case in #1443)
The arms I would have written are all there: a foreign-machine ELF refused by the property (not by a substring), a header-only library refused (so "no code objects" is not confused with "a parseable header"), the truncated-header case skipped rather than crashed, and exit 2 for an unreadable file so an I/O error cannot read as "no code objects". And the last arm is the real one: the library this would gate, counted at 51.
Counting the property in one place (tools/code_objects.py) with its own test is also what stops the next reader from reintroducing a strings | grep heuristic: the failure message now names EM_AMDGPU and points at the tool.
Not run: the release build the check sits in (make-binary-drop against a real stage). The check itself and its test are what I can take, and they are green.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 22b4cd79 — the code-objects work in here is the best of the three attempts; the branch carries another PR's unmerged work.
The blocker is the carry: four of the thirteen files are #1446's serve-route port retry, and origin/main does not have it yet
main:tests/hybrid_route.sh "for attempt in 1 2 3" -> 0 hits
this branch device_route.sh, hrx_cwsr_route.sh, hybrid_e2e.sh, hybrid_kvshare_route.sh all carry the retry block
so merging this ships #1446's unreviewed-for-merge change along with its own. (The other carried-looking files are fine: main already has the
is_int type-7 fix and pkg-proof.sh's have_kernel, so those diffs are this PR's own further work.) Rebase onto origin/main — the route
scripts drop out and the rest is a clean review.
On its own work: this is the right resolution of the code-objects bug, and better than #1447 or #1448. tools/code_objects.py parses the
header (ELF_MAGIC, EHDR_MIN = 20, e_machine == EM_AMDGPU (224)) instead of pattern-matching, and its docstring carries the measurement that
settles the whole question:
c31 payload lib 10,864,208 B 53 ELF headers 51 EM_AMDGPU (0 `amdgcn-amd-amdhsa` strings -> old check: FAIL)
tprs-hrx-154 5,513,432 B 3 ELF headers 2 EM_AMDGPU (2 strings -> old check: pass)
hrx-a5271d9 11,427,720 B 52 ELF headers 50 EM_AMDGPU (0 strings -> old check: FAIL)
canonical 5,129,432 B 1 ELF header 0 EM_AMDGPU (a build with no code objects: correctly refused)
That table explains both earlier disputes and both earlier failures: the string check was wrong in both directions (0 strings on a library with
51 objects; 2 strings on a 2-object build), and the "ELF headers" count is 2 higher than the code-object count because of the container's own
header — which is exactly why a magic count reports 56 where the property reports 54. The canonical row is the one I asked #1448 for: a build
with 0 code objects is correctly refused, which is the case that makes the bug impossible to reintroduce.
So: land this (or #1448) and close #1447; but land it on main, not on #1446's branch.
|
Heads-up, not a new verdict: #1452 (the other |
… bundle-header string `scripts/make-binary-drop.sh` refused a real release build because it asserted `strings libggml-hrx.so | grep -c amdgcn-amd-amdhsa` -- a clang offload-bundle header, not the property it names. A HIP fat binary built the ordinary way embeds its code objects as ELF images with e_machine EM_AMDGPU (224) and has no bundle header, so the shipped c31 library carries 51 code objects and 0 matches and was refused, while a build that happened to have a bundle header passed for the wrong reason. Measured on four real libraries on this box (headers / EM_AMDGPU / amdgcn-amd-amdhsa): c31 payload 10,864,208 B 53 / 51 / 0 tprs-hrx-154 5,513,432 B 3 / 2 / 2 hrx-a5271d9 11,427,720 B 52 / 50 / 0 canonical 5,129,432 B 1 / 0 / 0 <- a build with no code objects, correctly refused Counting ELF magics is not enough either: that last library has one header (its own) and no code objects. tools/code_objects.py counts embedded ELFs whose e_machine is EM_AMDGPU and exits 0/1/2; the drop script calls it; tests/code_objects_test.py (ctest code_objects) covers the six cases that separate the property from the string, and includes the shipped c31 library as one of them. Fixes #1443
22b4cd7 to
b694ffb
Compare
|
Rebased onto What #1452 changed, and where it still passes a broken drop#1452 replaced the string grep with "more than one embedded ELF image". That is the right direction and it unblocks the That is the same failure class as the issue itself: a check that tests a proxy for "the kernels are compiled in". A drop What this PR does (4 files, 197+/8−)
VerifiedMeasured on four real libraries on this box (headers / EM_AMDGPU / If you would rather not re-open a closed issue's lineThen close this PR and I will not re-raise it — but the false negative above should at least become a test against the merged |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at b694ffb1742c1c4c413cc37bec0cda726fbff016
The head refines the check and the refinement is the right one: it replaces "the count is non-zero" with the tool's own --quiet exit status, and the comment now records why two proxies both failed —
strings | grep amdgcn-amd-amdhsatests a clang offload-bundle header that a normally-built HIP fat binary does not contain (the shipped c31 library: 51 code objects, 0 such strings), and "more than one ELF image" counts any embedded ELF, so a library that embeds an x86-64 object or a JIT blob while carrying no AMDGPU code object would pass.tools/code_objects.pyreads the property: an embedded ELF header whosee_machineisEM_AMDGPU(224).
That second proxy is the one this head closes, and it is a real hole: a count of ELF images would pass a library carrying an x86-64 object, which is exactly the shape a wrong build produces. Asking the tool for --quiet and letting its exit status decide also means the definition of the property lives in one place instead of being re-derived from a number at the call site.
I re-ran the test at this head: code_objects_test: 0 failure(s), including the c31 arm (51 code objects) and the two refusals the new comment names — an ELF of another machine refused, naming EM_AMDGPU, and a header-only library refused.
Everything from my review at 22b4cd79 stands: this is a check that tests the property rather than a substring, with a device-free test that also covers the truncated-trailing-header case (skipped, not crashed) and exits 2 on an unreadable file so an I/O error cannot read as "no code objects".
|
Persistent review updated to latest commit b694ffb |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at b694ffb1742c1c4c413cc37bec0cda726fbff016
The rebase I suggested, done cleanly. On top of main (9e97d0b1, which includes #1452), it replaces #1452's ELF-magic count with tools/code_objects.py, which checks the property itself: an embedded ELF whose e_machine is EM_AMDGPU (224). git merge-tree against main is clean, and the new comment in make-binary-drop.sh explains why each proxy was one step short.
At this head:
-
python3 tests/code_objects_test.py:0 failure(s), including the x86-64-embedded fixture that a magic count would pass, and the real c31 library row; -
the tool on the two libraries from #1443:
library code objects rc release-rc/…/libggml-hrx.so.0.18.0(a later build than your c31 copy)54 0 tprs-hrx-154/…/libggml-hrx.so.0.18.02 0 -
$srcis the script's engine-checkout argument (:54, made absolute at:68), so$src/tools/code_objects.pyresolves; -
bash -npasses;tools/copyright.py --checkis rc 0.
Two small notes:
- This adds
python3tomake-binary-drop.sh, which #1452 deliberately avoided. It's a reasonable trade for checking the real property on a release machine, but worth a line in the script's header, so a minimal box fails with "python3 not found" rather than a confusing refusal. tests/code_objects_test.py:96hard-codes/home/bcloud/wt/payload-c26c/…in a public repo. It skips cleanly when absent, but an env var (e.g.CODE_OBJECTS_REAL_LIB) would keep a local path out of the tree and let anyone point it at their own build.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Record correction on my CHANGES here (the PR has since merged, so this changes nothing operationally): I wrote that this branch carried #1446's
serve-route retry in four files. It did not — my worktree's origin/main was frozen at 2eb86e5f by a stale refs/remotes/origin/main.lock, so the
"main lacks the retry marker" check I based it on was reading a two-hour-old tree. Against the real main this PR was 4 files, +196/−2, entirely its
own work.
For the record, the part of that review that was about the code stands and is what landed: tools/code_objects.py parses the header
(EHDR_MIN = 20, e_machine == EM_AMDGPU (224)) with the four-library measurement table — including the canonical row where a build with 0
code objects is correctly refused — which is why the string check's two-way failure (0 strings on a 51-object library, 2 strings on a 2-object
build) and the 54-vs-56 dispute are both settled by it.
Fixes #1443.
scripts/make-binary-drop.shrefused a real release build onstrings libggml-hrx.so | grep -c amdgcn-amd-amdhsa— a clang offload-bundle header, not the property the check names.Measured on four real libraries on this box
amdgcn-amd-amdhsaopt/1bit-package/1bit/hrx/llama/bin)~/wt/tprs-hrx-154/bin~/.local/share/1bit-hrx-a5271d9/…~/.local/share/1bit-canonical/…(no code objects)So a HIP fat binary built the ordinary way embeds its code objects as ELF images with
e_machine == EM_AMDGPU(224) andcontains no bundle header at all. Counting ELF magics would not do either: the last row has one header (its own) and no code
objects, so the check has to read
e_machine.Change (3 files)
tools/code_objects.py— counts embedded ELF headers whosee_machineis EM_AMDGPU;--min(default 1),--quiet; exit 0 (passes) / 1 (fewer than requested, with the reason and this issue's number) / 2 (unreadable file,because a packaging check must not turn an I/O error into a verdict). A truncated trailing header is skipped rather
than raising — a cut-off file reports zero code objects, it does not crash the drop.
scripts/make-binary-drop.sh— the two lines now call it, with the failure message naming the property and the tool.tests/code_objects_test.py(ctestcode_objects) — six crafted 64-byte fixtures plus the real c31 library:two embedded EM_AMDGPU images → 2 and passes; embedded x86-64 images → 0 and refused (this is the case that proves
it is not "count ELF magics"); header-only → refused; a bare
.hsaco→ passes; a truncated trailing header → skipped, nocrash;
--min 3refuses a 2-object file and--min 2 --quietpasses silently; a missing file → exit 2.Verified
No device, no ticket, no build: this is header-reading on files that are already on the box.
:18097untouched.