Skip to content

test-backend-ops (fork pin 40c4ccb): a run that executes zero cases exits 0 and prints OK #657

Closed

Description

@bong-water-water-bong

The harness is tests/test-backend-ops.cpp in the 1bit-MONSTER/llama.cpp fork at the pin the engine
builds against (third_party/llama.cpp = 40c4ccb76); issues are disabled on the fork, so this is tracked
here.

A test-backend-ops run that executes zero test cases prints OK and exits 0, so a green result can mean "nothing was measured". Two of the three paths below are exactly what a device verification run looks like when it goes wrong.

1. -b is an exact device-name match, so a family name silently skips every device

tests/test-backend-ops.cpp:10635-10639 at the engine's pin third_party/llama.cpp = 40c4ccb76 (10719 on 1bit/528-pad-nan, where the test case below was added):

if (backend_filter != NULL && strcmp(backend_filter, ggml_backend_dev_name(dev)) != 0) {
    output_printer->print_backend_init(
        backend_init_info(i, ggml_backend_dev_count(), ggml_backend_dev_name(dev), true, "Skipping"));
    n_ok++;
    continue;
}

ggml_backend_dev_name() is HRX0, CPU, CUDA0, ... so -b HRX matches nothing, every device is "Skipping", the skip counts as a pass, and the summary is 2/2 backends passed + OK:

$ ./test-backend-ops test -b HRX -o FLASH_ATTN_EXT -p pad_nan
Testing 2 devices

Backend 1/2: HRX0
  Skipping
Backend 2/2: CPU
  Skipping
2/2 backends passed
OK
$ echo $?
0

2. A params regex or an op filter that matches nothing is also a green no-op

$ ./test-backend-ops test -b CPU -o FLASH_ATTN_EXT -p zzz_no_such_param
  0/0 tests passed
  Backend CPU: OK
1/1 backends passed
OK
$ echo $?
0

$ ./test-backend-ops test -b CPU -o NO_SUCH_OP
  0/0 tests passed
  Backend CPU: OK
1/1 backends passed
OK
$ echo $?
0

See filter_test_cases() (tests/test-backend-ops.cpp:10242-10276 at that pin): the case list is regex-filtered down to nothing, and nothing downstream distinguishes "0 of 0 passed" from "all passed". The exit code comes from the backend count only (n_ok != ggml_backend_dev_count() at the end of main).

3. Why this matters for the HRX lane

The HRX backend registers an empty device list when hrx_gpu_initialize() fails (ggml/src/ggml-hrx/ggml-hrx.cpp:1300-1313), which is what happens in a plain llama.cpp build without IREE_HAL_AMDGPU_LIBHSA_PATH pointing at TheRock's libhsa-runtime64.so.1. The run then says Testing 1 devices, tests the CPU only, and exits 0. Combined with (1), two separate real attempts to verify a flash-attention change on the device produced green runs that had tested nothing at all, before the command was finally corrected to -b HRX0 with the HSA path set (2/2 tests passed / Backend HRX0: OK).

Proposed guard

Fail loudly instead of passing when nothing ran. In rough order of value:

  1. Zero-case check, per backend and overall. test_backend()'s result already knows the case count (n_test); if a backend that was selected (not skipped) executes 0 cases, mark it failed with a message naming the filters that emptied it, and make the overall run return 1. An explicit --allow-empty opt-out for the rare scripted case that only wants a load check.
  2. -b names nothing: if no ggml_backend_dev_name() equals the filter, print the valid names and exit 1 instead of skipping everything. (Accepting a comma list of exact names, or treating the filter as a regex/prefix, would also fix the footgun — but the guard is the part that cannot be forgotten.)
  3. Same treatment for -o: if no op in the registry matches, say so and exit 1 rather than 0/0 tests passed.

Nothing here depends on HRX; it is generic test-backend-ops behaviour, so the fix is worth upstreaming to ggml-org/llama.cpp once it is settled here.

Activity

  1. added
    bug
    on Oct 31, 2026
  2. bong-water-water-bong commented on Oct 31, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage: bug, and I am taking it (single-file fix candidate). Re-verified at the pin the engine builds today —
    third_party/llama.cpp = 5e6388a5a, carried onto main by #672 (31d52e1) — both halves still hold, one
    file, test harness only:

    tests/test-backend-ops.cpp:10727   if (backend_filter != NULL && strcmp(backend_filter, ggml_backend_dev_name(dev)) != 0) {
                                         ... n_ok++; continue;     <- a skip is counted as a pass
    tests/test-backend-ops.cpp:10775   if (n_ok != ggml_backend_dev_count()) { return 1; }
    tests/test-backend-ops.cpp:10334   filter_test_cases(...)       <- can empty the case list, exit code does not know
    

    Line numbers moved from the report (10635 / 10242 at 40c4ccb); the behaviour did not.

    What I will raise, as one PR against the fork:

    1. Sum tests_total over the backends that actually ran and return non-zero when it is zero, printing the
      reason (no test case matched -b/-o/-p) — this is the exit-code half, three lines plus the summary line,
      and it makes the two verifications in this issue's §1 and §2 impossible to mistake for green.
    2. A test in the same harness: run with -b NO_SUCH_DEVICE and -o NO_SUCH_OP and assert non-zero exit.

    Deliberately not in the same PR: making -b HRX match the HRX0 family. That is a behaviour change for
    anything that passes -b, including the hardware gate, and it deserves its own diff and its own reviewer. If
    you want it, say so here and I will open it as a follow-up with the gate's invocations as the test corpus.

    This issue stays open until the fix merges; the PR number lands here and on ~/briefs/TISSUES-BOARD.md.

  3. bong-water-water-bong commented on Oct 31, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Merged. fork PR #162 → merge commit 20f958478 on 1bit/hrx-vulkan-patched (23:31:11Z). What that
    commit carries, from the PR's own measured table on this pin (4a58da9b0, same binary, patch stashed/re-applied):

    command before after
    test -b NO_SUCH_DEVICE -o MUL_MAT exit 0, 1/1 backends passed OK exit 1, error: no test case ran (check -b/-o/-p and --test-file): refusing to report a pass
    test -b CPU -o NO_SUCH_OP exit 0, 0/0 tests passed exit 1, same
    test -b CPU -o MUL_MAT -p zzz_no_such_param exit 0, 0/0 tests passed exit 1, same
    test -b CPU -o DUP -p "", -o MUL_MAT -p m=16 (controls) exit 0 unchanged

    This issue stays open on purpose: the engine still pins 4a58da9b0, so the fix is not in any engine build yet.
    Closes when the next pin bump moves third_party/llama.cpp to a commit containing 20f958478 — that bump also
    carries fork #163 (kv share), so it is a two-item bump, and the acceptance I will check is the same three
    commands above run against the engine's built test-backend-ops at the new pin, plus the controls unchanged.

    Not in the merged diff, deliberately (both stated in the PR body): -b is still an exact device-name match
    (-b HRX matches nothing and is now loud instead of green), and support/perf modes still return 0 when an op
    filter matches nothing. Say the word if the -b family-prefix change should be its own issue.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Measured at the fork tip 199165047 (the commit the pending bump would pin), before/after on one tree, and it also corrects a control I reported wrong on 10-31.

    Method: --depth 1 clone of 1bit/hrx-vulkan-patched @ 199165047, -DLLAMA_BUILD_TESTS=ON, -j8, CPU only — no device, no gpu-hold, no env trio. BEFORE = the pin's (4a58da9b0) tests/test-backend-ops.cpp compiled into that tree; AFTER = the tip's. diff of the two files is exactly this fix (+30/−2) and nothing else, so the flip is attributable to it and not to #164–#168.

    command BEFORE (pin's file) AFTER (tip's file)
    -b NO_SUCH_DEVICE exit 0 OK exit 1 error: no test case ran (check -b/-o/-p and --test-file): refusing to report a pass
    -o NO_SUCH_OP exit 0 OK exit 1, same message
    -p zzz_no_such_param exit 0 OK exit 1, same message
    -b CPU -o DUP (control) exit 0 exit 0 — 10/10 passed
    -b CPU -o MUL_MAT -p m=16 (control) exit 0 exit 0 — 776/776 passed
    -o DUP (bare, no -b) exit 0 OK exit 1, same message

    Correction to my own 10-31 numbers, because it matters for the acceptance: bare -o DUP was never a valid control. tests/test-backend-ops.cpp:10747-10753 skips the CPU backend by design when no -b is given (CPU is the reference), so that invocation runs zero cases — pre-fix it reported OK at exit 0, which is this very bug in its purest form, and post-fix it is refused like any other empty run. The valid controls carry -b CPU, and both are unchanged (10/10 and 776/776). The PR body's "controls 0 → 0" line was right about the exit codes and wrong about why.

    Caller check for the bump (the one thing that could have made this fix a regression): every test-backend-ops invocation in the tree passes -b — scripts/hw-gate.sh:449 (test -b HRX0 -o "$OPS" -j "$JOBS") and its retry at :471, docs/hw-gate.md:57, KNOWN-ISSUES.md:25, docs/hrx.md's several rows. No in-tree caller uses the bare -o form, so nothing breaks when the pin moves — stated as a residual risk rather than assumed.

    Still open on the bump, not on this fix: the acceptance in the body is "at new pin, from the engine's build". The engine still pins 4a58da9b0 (fork tip is 8 commits ahead; no bump PR open — #759 was closed as superseded). When it lands I run the same six commands against the engine's own test-backend-ops at the new pin and close this with those numbers.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Closed on the bump: verified from the engine's build at the new pin, which is what this issue's acceptance asked for.

    Pin: engine main 7ba14cde9 (HRX bump #786); third_party/llama.cpp = 1d32c22609d6. I built in a worktree of ~/1bit-engine at 7ba14cde9 with the submodule at the pin, and checked the two agree rather than assuming: TREE PIN: 1d32c22609d6eb2… == ENGINE PIN (recorded in the superproject): 1d32c22609d6eb2…. The fix is fork #162 → 20f958478, which is in this pin (git merge-base --is-ancestor distance: the pin is 10 commits past the old 4a58da9b0, this is one of them).

    Build: cmake -DLLAMA_BUILD_TESTS=ON -DGGML_HRX=OFF -DCMAKE_BUILD_TYPE=Release, -j8, CPU only — no device, no gpu-hold, no no-SVM trio needed. The zero-case paths are CPU-side by construction, which is the point: they are the paths that used to report a green on nothing.

    command engine build @ 1d32c22609d6
    test-backend-ops -b NO_SUCH_DEVICE exit 1 — error: no test case ran (check -b/-o/-p and --test-file): refusing to report a pass
    test-backend-ops -o NO_SUCH_OP exit 1 — same
    test-backend-ops -p zzz_no_such_param exit 1 — same
    test-backend-ops -b CPU -o DUP (control) exit 0 OK — 10/10 passed
    test-backend-ops -b CPU -o MUL_MAT -p m=16 (control) exit 0 OK — 776/776 passed

    All three zero-case paths that used to exit 0 and print OK now refuse, and both controls still pass. Before/after on one tree at the same source (pin's tests/test-backend-ops.cpp vs the patched one, the only diff in that file) is in the comment above, so the flip is attributable to this fix and not to the other nine commits the bump carries.

    Callers checked, not assumed: every test-backend-ops invocation in the tree passes -b — scripts/hw-gate.sh:449 and its retry at :471, docs/hw-gate.md:57, KNOWN-ISSUES.md:25 — so nothing in the repo depended on the old false green.

    One residual worth keeping in the record: a bare -o <op> with no -b also exits 1 now, because tests/test-backend-ops.cpp:10747-10753 skips the CPU backend by design when no backend is named (CPU is the reference) — that invocation runs zero cases, so refusing it is correct. Any future CI job that wants a filtered run must say -b CPU (or the real device). That is the whole behavioural surface of this change.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions