Repository navigation
make-binary-drop: count the embedded ELF images, not the fatbin's spelling of amdgcn-amd-amdhsa - #1452
Conversation
…lling of amdgcn-amd-amdhsa The check refused the shipped c31 library while accepting a smaller build: the c31 libggml-hrx.so carries 56 embedded code objects and zero occurrences of the string `amdgcn-amd-amdhsa`, and a 3-object build carries two -- the string depends on how the fatbin was assembled, so it cannot stand in for "the kernels are compiled in" (engine#1443). Count the embedded ELF images instead: the library's own header is one and every code object adds one, so a library with the kernels compiled in always has more than one. The count goes into the failure message so a future refusal is diagnosable from the log alone. Measured on the two libraries the issue names, python3 and this grep agree: c31 payload 11,213,184 B ELF images 56 old string 0 -> old FAIL, new PASS tprs-hrx-154 5,513,432 B ELF images 3 old string 2 -> old PASS, new PASS No new dependency (the script uses no python3 today, so the grep stays in the shell). Fixes #1443
|
ready for review at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at d56c5b101d8326b4303e4b190c0d64dda752ccb9
The right fix for #1443: count what the property is (embedded code-object ELF images), not a string whose presence depends on how the fatbin was assembled.
Reproduced with the PR's exact expression (LC_ALL=C grep -ao $'\x7fELF' … | wc -l) on the two libraries it measured:
~/wt/release-rc/work/lemonade/1bit/hrx/llama/bin/libggml-hrx.so.0.18.0 elf_images=56 amdgcn-amd-amdhsa=0 old FAIL, new PASS
~/wt/tprs-hrx-154/bin/libggml-hrx.so.0.18.0 elf_images=3 amdgcn-amd-amdhsa=2 old PASS, new PASS
My copy of the release-rc library is 11,235,176 B against your 11,213,184 B (a later build at the same path), with the same counts. bash -n passes at this head, and the failure message now carries the count, which makes a future refusal readable from the log.
Two notes for the future, not blocking:
- Compressed offload bundles would defeat this. With
--offload-compress, each code object is aCCOBblob and its ELF magic isn't in the file, so a library full of kernels would count 1 and be refused. Both libraries above have 0CCOBoccurrences, so it's not today's problem, and it fails loudly rather than silently. A comment saying "if the build ever compresses offload bundles, countCCOBtoo" would save the next person the search. - "More than one ELF image" proves kernels are present, not that they're for this GPU. A gfx1100-only build passes too. Since the drop is a gfx1151 artifact, adding
grep -c gfx1151as a second condition (the library above has 64) would make the check say the whole property.
Fixes #1443The bug, reproduced
scripts/make-binary-drop.sh(:158-159on currentmain; the report cites:222-224, the script has moved since) refused theshipped library and accepted a different one:
Exact byte counts (
python3over the files, and the shell check agrees):\x7fELFimagesgfx1151amdgcn-amd-amdhsa…/1bit/hrx/llama/bin/libggml-hrx.so.0.18.0~/wt/tprs-hrx-154/bin/libggml-hrx.so.0.18.0So the 56-code-object library was refused and the 3-code-object one accepted: the string is an artefact of how the fatbin was
assembled, not evidence that kernels are in it.
The change
Count the embedded ELF images instead — the library's own header is one, every embedded code object adds one, so a library with kernels
compiled in always has more than one — and put the count in the failure message so a future refusal is diagnosable from the log alone:
No new dependency: the script uses no
python3today, so this stays in the shell. I did not take thellvm-readobj --offloadingoption (authoritative, but it adds an SDK tool to a path whose whole job is to work on a machine that may not have one); the
gfx1151-either-spelling option was also skipped because a count of embedded images says the property rather than two spellings of it.Verification
bash -n scripts/make-binary-drop.sh— clean.shellcheck -S warning— only the pre-existingSC2043at line 103 (single-itemforloop), untouched by this change.make-binary-drop.sh. It needs a release build to stage, and the box was at load 78 with the GPU queue12 deep; the one thing this PR changes is the check, and the check is exercised on the two libraries the issue measured. A reviewer
with a build should run the full script once before this merges — that is the only step I could not do at the time.