Skip to content

test(adm): hold the ADM twins' whole decouple header to the CPU on the host and record the CUDA/HIP angle-flag corner - #2359

Merged
lusoris merged 1 commit into
masterfrom
fix/codeql-adm-twin-header-tests
Oct 6, 2026
Merged

lusoris merged 1 commit into
masterfrom
fix/codeql-adm-twin-header-tests

Conversation

@lusoris

@lusoris lusoris commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Clears 16 open CodeQL cpp/unused-static-function alerts (1464-1479) in the ADM twins' decouple header test by testing the rest of the header, finds a real CUDA/HIP corner on the way, and declares the two cpp/include-non-header findings (1463, 1488) as exceptions.

  • test_adm_decouple_recip_{cuda,hip} compile the twins' own adm_decouple_inline.{cuh,hip} for the host but called only decouple_r_s0(), so every other function of the header was "unused" in a host database (CodeQL does not extract the .cu kernels). The test now also holds decouple_r_s123(), get_best15_from32() and both angle flags to the CPU's adm_decouple_band_s123() / adm_angle_flag() over 400 000 draws each and the corners of the int16 range. Each executable renames run_tests (c_args and cpp_args), since CodeQL merges two variants' extern "C" run_tests and then calls the other variant's helpers unreachable. On the full local database both alerts classes are gone.
  • Found: T-GPU-ADM-ANGLE-FLAG-S0-INT32-CORNER-2026-10-06. With every band at -32768 the CUDA and HIP decouple_angle_flag_s0() add int16 products in int32 and wrap (2^31) where the CPU's int64 sum does not: 17 of 256 corner combinations differ, none of the random draws. Metal's iadm_angle_flag_s0() had the same sums and is fixed here (it compiles in test_metal_integer_adm_host_replay, no Apple device on this host). CUDA/HIP are not fixed: a 64-bit form puts adm_cm_aim_line_kernel_4 past the ADR-1226 register budget (216 with plain int64 sums; 209 and 210 with an unsigned - 1/+ 1 form, a select, and unsigned magnitudes only; 229 for adm_cm_line_kernel_8 with another). The state row is open with the measurements and a decision for the owner; the test holds the 2^31-sum corners to the measured count (17) so a fix flips it, and all other corners to the CPU.
  • .config/lint-exceptions.d/codeql-include-non-header.toml: test_adm_decouple_recip.cpp (includes the device header, named by ADM_TWIN_HEADER) and metal_integer_adm_host_replay_kernels.cpp (includes the MSL source behind a host shim): the included bytes are the object under test; one file, one rule, reason, expiry 2027-06-30. After this lands the two alerts are dismissed as "won't fix" citing the entry.

Verification

  • CUDA (build-cuda, nvcc, sm list of the default build): test_adm_decouple_recip_cuda and _hip (host builds of both headers) pass 5 of 5; test_cuda_adm_cm_register_pressure passes with the headers unchanged (it failed in all four candidate fixes above); test_cuda_adm_parity on the RTX 4090 under the lock: 12 of 12 pass. The device headers are not modified by this PR.
  • HIP: no HIP source changed; the header is compiled for the host by test_adm_decouple_recip_hip.
  • Local CodeQL 2.27.1, security-and-quality, cpu build with -Dcpp_std=c++23: master reproduces the hosted alerts (107 results); the stack of the code-scanning PRs 28 with nothing new; cpp/unused-static-function reports nothing in the touched files, cpp/include-non-header only the two declared files.
  • Planted defect: with the header's old calls only (the test before this change) the 16 alerts are present; python3 scripts/ci/lint_exceptions.py check reports 0 findings, and with LINT_EXCEPTIONS_TODAY=2027-07-01 it reports both new entries expired.
  • tidy: cpu core/test/test_adm_decouple_recip.cpp core/test/test_adm_decouple_recip_cpu.c: 0 findings (container lane, clang-tidy 22.1.8; the test is built once per twin in that lane). The adm_decouple_inline.{cuh,hip} headers are not changed.

Type

  • fix — bug fix
  • refactor — no behavior change

Checklist

  • Commits follow Conventional Commits (the commit-msg hook enforces this).
  • make format && make lint is green locally — commit hooks pass.
  • Unit tests pass: see the verification section.
  • If I touched any SIMD/GPU code path, I ran /cross-backend-diff — see the body.
  • If I touched a feature extractor with SIMD/GPU twins — see the body.
  • If I added a new .c / .cpp / .cu / .h / .hpp — not applicable: no new native file.
  • If this is a breaking change — not applicable.
  • If this PR adds an ADR — not applicable: no ADR.

Netflix golden-data gate (ADR-0024)

  • I did not modify any assertAlmostEqual(...) score in the Netflix golden Python tests.
  • If I believe a golden value must change — not applicable.

Bug-status hygiene (ADR-0165)

  • docs/state.md updated — opened T-GPU-ADM-ANGLE-FLAG-S0-INT32-CORNER-2026-10-06 (CUDA/HIP open, Metal fixed in code).

Deep-dive deliverables (ADR-0108)

  • Research digest — no digest needed: trivial.
  • Decision matrix — in the state row and above: four forms of the 64-bit sum measured against the register budget.
  • AGENTS.md invariant note — core/src/feature/{cuda,hip}/AGENTS.d/adm.md.
  • Reproducer / smoke-test command — below.
  • CHANGELOG fragment — changelog.d/fixed/adm-angle-flag-s0-int64-sums.md.
  • Rebase note — docs/rebase-notes.md, "ADM twins: host test of the device decouple header".

Reproducer

meson setup build core -Denable_cuda=false -Denable_sycl=false && ninja -C build test/test_adm_decouple_recip_cuda
build/test/test_adm_decouple_recip_cuda   # 5 passed; corner count 17 recorded
python3 scripts/ci/lint_exceptions.py check

…e host and record the CUDA/HIP angle-flag corner (#2359)

* test(adm): hold the ADM twins' whole decouple header to the CPU on the host and record the CUDA/HIP angle-flag corner

test_adm_decouple_recip_{cuda,hip} compiled only decouple_r_s0() of the twins' header, so CodeQL reported the rest unused (cpp/unused-static-function, 16 alerts). The test now also holds decouple_r_s123(), get_best15_from32() and both angle flags to the CPU's over 800000 draws and the corners of the int16 range, and each executable has its own run_tests root. The corners expose a real difference: with every band at -32768 the CUDA and HIP scale-0 angle flag adds in int32 and wraps where the CPU's int64 sum does not; a 64-bit form puts adm_cm_aim_line_kernel_4 past its register budget, so the row stays open with the measurements and the test records the count. Metal's iadm_angle_flag_s0() had the same sums and is fixed. The two include-non-header findings of the device-source tests become declared exceptions.
@github-actions github-actions Bot added the type:test Test-only change label Oct 6, 2026
@lusoris
lusoris force-pushed the fix/codeql-adm-twin-header-tests branch from 91314ff to 7660b22 Compare October 6, 2026 20:06
@lusoris
lusoris merged commit 7660b22 into master Oct 6, 2026
6 of 29 checks passed
@lusoris
lusoris deleted the fix/codeql-adm-twin-header-tests branch October 6, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:test Test-only change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant