[PR #3511] [CLOSED] [Engine] tests: the trellis kernel units join the isa guard, and the TQ tests skip on an upstream ggml (#3409) #4662

Closed
opened 2026-11-07 15:38:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3511
Author: @chaog992
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: gyro-tq-tests


📝 Commits (2)

  • 06a3070 tools: check_isa_guard knows the trellis kernel units (#3409; isa_guard_check failed out of the box)
  • 52a3450 tests: tq_cpu_parity and native_hadamard_test skip on an upstream ggml instead of failing (#3358, #3409)

📊 Changes

5 files changed (+63 additions, -9 deletions)

View changed files

📝 CMakeLists.txt (+6 -4)
📝 src/kernels/cpu/native_hadamard_test.cpp (+8 -2)
📝 src/kernels/cpu/tq_cpu_parity.cpp (+1 -1)
📝 tools/check_isa_guard.py (+4 -2)
📝 tools/test_check_isa_guard.py (+44 -0)

📄 Description

Problem and result

A test build on the default (upstream, pinned) ggml shows four ctest failures out of the box since the Gyro
port: isa_guard_check flags tq_rows_avx512 in the new tq_avx512.cpp unit ("outside the wide-ISA translation
units" here and in #3358; "in an unlisted public function" in #3409's g++ 14.4 build), and tq_cpu_parity, tq_cpu_parity_avx2 and native_hadamard_test exit 1 because this ggml has no
trellis types. Seen on Linux x86-64 CPU builds (here), CUDA (#3409) and HIP (#3358). Result: the guard passes
again on Release and RelWithDebInfo builds, the TQ tests report as Skipped where nothing more can be checked,
and the checks that need no trellis type still run - the suite here goes from 4 failures to 0.

Fixes #3409 (the guard entries are the three it proposes, and the skip its related note asks for; this adds
the unit test and the variant receipts). The same failures on HIP are in #3358's log. Two commits, one problem
(the out-of-the-box failures), separable if you prefer to take either alone.

Approach

Commit 1 (tools/): WIDE_OBJECTS += tq_avx512.cpp, WIDE_PUBLIC += tq_rows_avx512 (wide on purpose,
the nvfp4 shape - cb88d3d2, 82fa92ff: tq_cpu.cpp picks TqIsa::avx512 only behind cpu_avx512_ok(), and
tq_rows()/tq_gu_rows() abort if asked for an ISA the CPU lacks - unconfirmed static analysis; #3409's
AVX-only Xeon saw no illegal instruction). INIT_FREE_OBJECTS += tq_avx2.cpp: no effect today (it has no
static initialiser), but a #2324-shaped constructor table would be flagged on ELF builds instead of missed.
Three test cases added: the ELF and a synthetic MSVC-style name of tq_rows_avx512 are allowed (judge()
reads the leading name); a weak copy of a tq_states.hpp helper in the wide unit stays a violation; and
run_elf flags a mocked AVX-class static initialiser in tq_avx2.cpp.o (#2324) - the receipt that the
INIT_FREE_OBJECTS line is load-bearing. CRLF line endings of the guard file are preserved byte for byte.

Commit 2 (test sources + their ctest entries): return 77 where nothing more can be checked, with
SKIP_RETURN_CODE 77 - the project's own pattern (3d6793a4, #1475). native_hadamard_test runs its Q8_0 fold
check (llama.cpp graph vs the folded CPU path; no trellis type needed) before the probe, so a broken FWHT or
fold still fails on any ggml; its --pack mode refuses on an upstream ggml instead of calling
ggml_row_size() with the fork's type ids 144-146, past the end of upstream's 43-entry type table (a minimal
program making that call against the pinned ggml-base dies with SIGSEGV). On the agentionai fork nothing
changes: the probe fires only when GGML_TYPE_COUNT <= 146.

Validation

Tested: 06a30708 + 52a34500 on main 9ae93f7b (v0.2.1.1), WSL2 Ubuntu 24.04, gcc 13.3, Python 3.12, upstream
ggml at the pin (3cf03257); both commits also merge cleanly onto current main.

Passed:

  • cmake -DCMAKE_BUILD_TYPE=Release -DSTRATA_BUILD_TESTS=ON -DSTRATA_GGML_DIR=<llama.cpp@pin> then
    ctest -j8: 49 tests, 0 failed, 45 passed, 4 Skipped (expert_multi_test + the three TQ skips); at the
    unpatched base the same build fails 4. The guard, its test, the two TQ test sources and the trellis units
    are unchanged from v0.2.0-beta (3d1fb480, where #3409 and #3358 were reported) to v0.2.1.1, and the
    unpatched guard still reports the tq_rows_avx512 violation on this build's archive.
  • python -m unittest tools.test_check_isa_guard: 12 tests OK. Against the unpatched guard, two of the new
    cases fail (the allowlist case and the mocked-initialiser case); with only the INIT_FREE_OBJECTS line
    removed, the initialiser case alone fails. The patched guard on the base build's real
    libstrata_kernels_cpu.a: "488 functions, 70 hold wide-ISA instructions, 0 not allowed".
  • Variant receipts: without the WIDE_PUBLIC entry the guard still fails ("unlisted public function"), so
    both entries are needed; a mutant tq_avx2.cpp with a constructor-built table is flagged ("static
    initialiser ... #2324") only with the INIT_FREE_OBJECTS entry.
  • native_hadamard_test on this ggml: FWHT ok, Q8_0 fold ok ("strata vs llama.cpp graph 0.00e+00"), trellis
    skipped, rc 77; forced-broken FWHT and fold each exit 1. --pack x --gguf y: refuses, rc 1.
  • CUDA (nvcc 13.0, sm_120) and HIP (ROCm clang 22, gfx1201) configures with -DSTRATA_BUILD_TESTS=ON,
    building only the CPU test targets (the change touches no GPU code): in both,
    ctest -R 'tq_cpu_parity|native_hadamard_test|isa_guard_check' gives isa_guard_check Passed and the three
    TQ tests Skipped, 0 failed - the configurations #3409 (CUDA) and #3358 (HIP) report.

Failed: none observed.

Not run: Windows/MSVC (the guard's PE path uses the same judge(); the entries should carry over); the
agentionai fork configuration (guarded by the probe; not present here); AVX-512 hardware; an AVX-only CPU
such as #3409's (STRATA_ISA_FLOOR=avx), where native_hadamard_test's Q8_0 fold check now runs for the first
time on an upstream ggml; full CUDA/HIP backend builds (no GPU source is touched); SYCL (its build registers
none of these tests).

Limits

  • Debug, -Og and MinSizeRel builds still fail isa_guard_check on a weak copy of a tq_states.hpp helper
    (tq_half_to_float) in the wide unit - a pre-existing, separate hazard worth its own follow-up.
  • With the skip, the default build has no ctest of the CPU trellis kernels the packaged engine runs; the fork
    build keeps the full comparison. We prototyped an upstream mode for tq_cpu_parity (+37/-14: AVX2/AVX-512
    vs the scalar kernel, bit for bit, catches one-line AVX2 kernel mutations) and can follow up with it if
    coverage on the default ggml is wanted.
  • hip_prefill_mmq_parity on HIP builds with the default ggml fails for the same type-table reason (#3358's
    log); that test is HIP-only and is not addressed here.
  • --bench and --synthetic on an upstream ggml now exit 77 instead of 1, with the same message.
  • ctest reports the whole native_hadamard_test as Skipped even when its FWHT and Q8_0 fold checks ran and
    passed (SKIP_RETURN_CODE semantics); registering the portable checks as their own test entry would surface
    them - a possible follow-up.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3511 **Author:** [@chaog992](https://github.com/chaog992) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `gyro-tq-tests` --- ### 📝 Commits (2) - [`06a3070`](https://github.com/Niko1221/Strata/commit/06a307083998d2460ed522f2434ccf11eed62735) tools: check_isa_guard knows the trellis kernel units (#3409; isa_guard_check failed out of the box) - [`52a3450`](https://github.com/Niko1221/Strata/commit/52a3450049e279be3605ece28ad72d0608c50421) tests: tq_cpu_parity and native_hadamard_test skip on an upstream ggml instead of failing (#3358, #3409) ### 📊 Changes **5 files changed** (+63 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+6 -4) 📝 `src/kernels/cpu/native_hadamard_test.cpp` (+8 -2) 📝 `src/kernels/cpu/tq_cpu_parity.cpp` (+1 -1) 📝 `tools/check_isa_guard.py` (+4 -2) 📝 `tools/test_check_isa_guard.py` (+44 -0) </details> ### 📄 Description ## Problem and result A test build on the default (upstream, pinned) ggml shows four ctest failures out of the box since the Gyro port: `isa_guard_check` flags `tq_rows_avx512` in the new `tq_avx512.cpp` unit ("outside the wide-ISA translation units" here and in #3358; "in an unlisted public function" in #3409's g++ 14.4 build), and `tq_cpu_parity`, `tq_cpu_parity_avx2` and `native_hadamard_test` exit 1 because this ggml has no trellis types. Seen on Linux x86-64 CPU builds (here), CUDA (#3409) and HIP (#3358). Result: the guard passes again on Release and RelWithDebInfo builds, the TQ tests report as Skipped where nothing more can be checked, and the checks that need no trellis type still run - the suite here goes from 4 failures to 0. ## Related discussion Fixes #3409 (the guard entries are the three it proposes, and the skip its related note asks for; this adds the unit test and the variant receipts). The same failures on HIP are in #3358's log. Two commits, one problem (the out-of-the-box failures), separable if you prefer to take either alone. ## Approach Commit 1 (`tools/`): `WIDE_OBJECTS` += `tq_avx512.cpp`, `WIDE_PUBLIC` += `tq_rows_avx512` (wide on purpose, the nvfp4 shape - cb88d3d2, 82fa92ff: `tq_cpu.cpp` picks `TqIsa::avx512` only behind `cpu_avx512_ok()`, and `tq_rows()`/`tq_gu_rows()` abort if asked for an ISA the CPU lacks - unconfirmed static analysis; #3409's AVX-only Xeon saw no illegal instruction). `INIT_FREE_OBJECTS` += `tq_avx2.cpp`: no effect today (it has no static initialiser), but a #2324-shaped constructor table would be flagged on ELF builds instead of missed. Three test cases added: the ELF and a synthetic MSVC-style name of `tq_rows_avx512` are allowed (judge() reads the leading name); a weak copy of a `tq_states.hpp` helper in the wide unit stays a violation; and `run_elf` flags a mocked AVX-class static initialiser in `tq_avx2.cpp.o` (#2324) - the receipt that the `INIT_FREE_OBJECTS` line is load-bearing. CRLF line endings of the guard file are preserved byte for byte. Commit 2 (test sources + their ctest entries): return 77 where nothing more can be checked, with `SKIP_RETURN_CODE 77` - the project's own pattern (3d6793a4, #1475). `native_hadamard_test` runs its Q8_0 fold check (llama.cpp graph vs the folded CPU path; no trellis type needed) before the probe, so a broken FWHT or fold still fails on any ggml; its `--pack` mode refuses on an upstream ggml instead of calling `ggml_row_size()` with the fork's type ids 144-146, past the end of upstream's 43-entry type table (a minimal program making that call against the pinned ggml-base dies with SIGSEGV). On the agentionai fork nothing changes: the probe fires only when `GGML_TYPE_COUNT <= 146`. ## Validation Tested: 06a30708 + 52a34500 on main 9ae93f7b (v0.2.1.1), WSL2 Ubuntu 24.04, gcc 13.3, Python 3.12, upstream ggml at the pin (3cf03257); both commits also merge cleanly onto current main. Passed: - `cmake -DCMAKE_BUILD_TYPE=Release -DSTRATA_BUILD_TESTS=ON -DSTRATA_GGML_DIR=<llama.cpp@pin>` then `ctest -j8`: 49 tests, 0 failed, 45 passed, 4 Skipped (expert_multi_test + the three TQ skips); at the unpatched base the same build fails 4. The guard, its test, the two TQ test sources and the trellis units are unchanged from v0.2.0-beta (3d1fb480, where #3409 and #3358 were reported) to v0.2.1.1, and the unpatched guard still reports the tq_rows_avx512 violation on this build's archive. - `python -m unittest tools.test_check_isa_guard`: 12 tests OK. Against the unpatched guard, two of the new cases fail (the allowlist case and the mocked-initialiser case); with only the `INIT_FREE_OBJECTS` line removed, the initialiser case alone fails. The patched guard on the base build's real `libstrata_kernels_cpu.a`: "488 functions, 70 hold wide-ISA instructions, 0 not allowed". - Variant receipts: without the `WIDE_PUBLIC` entry the guard still fails ("unlisted public function"), so both entries are needed; a mutant `tq_avx2.cpp` with a constructor-built table is flagged ("static initialiser ... #2324") only with the `INIT_FREE_OBJECTS` entry. - `native_hadamard_test` on this ggml: FWHT ok, Q8_0 fold ok ("strata vs llama.cpp graph 0.00e+00"), trellis skipped, rc 77; forced-broken FWHT and fold each exit 1. `--pack x --gguf y`: refuses, rc 1. - CUDA (nvcc 13.0, sm_120) and HIP (ROCm clang 22, gfx1201) configures with `-DSTRATA_BUILD_TESTS=ON`, building only the CPU test targets (the change touches no GPU code): in both, `ctest -R 'tq_cpu_parity|native_hadamard_test|isa_guard_check'` gives isa_guard_check Passed and the three TQ tests Skipped, 0 failed - the configurations #3409 (CUDA) and #3358 (HIP) report. Failed: none observed. Not run: Windows/MSVC (the guard's PE path uses the same judge(); the entries should carry over); the agentionai fork configuration (guarded by the probe; not present here); AVX-512 hardware; an AVX-only CPU such as #3409's (STRATA_ISA_FLOOR=avx), where native_hadamard_test's Q8_0 fold check now runs for the first time on an upstream ggml; full CUDA/HIP backend builds (no GPU source is touched); SYCL (its build registers none of these tests). ## Limits - Debug, -Og and MinSizeRel builds still fail `isa_guard_check` on a weak copy of a `tq_states.hpp` helper (`tq_half_to_float`) in the wide unit - a pre-existing, separate hazard worth its own follow-up. - With the skip, the default build has no ctest of the CPU trellis kernels the packaged engine runs; the fork build keeps the full comparison. We prototyped an upstream mode for `tq_cpu_parity` (+37/-14: AVX2/AVX-512 vs the scalar kernel, bit for bit, catches one-line AVX2 kernel mutations) and can follow up with it if coverage on the default ggml is wanted. - `hip_prefill_mmq_parity` on HIP builds with the default ggml fails for the same type-table reason (#3358's log); that test is HIP-only and is not addressed here. - `--bench` and `--synthetic` on an upstream ggml now exit 77 instead of 1, with the same message. - ctest reports the whole native_hadamard_test as Skipped even when its FWHT and Q8_0 fold checks ran and passed (SKIP_RETURN_CODE semantics); registering the portable checks as their own test entry would surface them - a possible follow-up. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:38:10 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4662
No description provided.