interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

models: make mxcheck dimension-capacity guards overflow-safe

Closed · #129 · open 2026-10-27 05:33 UTC · closed 2026-10-29 02:30 UTC (reason completed)

Imported from GitHub aien-dev/CUDApp#129, by drakestapleton

drakestapleton wrote on 2026-10-27 05:33 UTC

Finding

At merge 67f3135ef88d8f520dfc15a2b2bc3264f53f0d6a (#111), the documented mxmm(..., d view ulong 4) entry can accept dimensions larger than its fixed buffers and return without computing anything.

mxcheck compares mul m n, mul kb m, mul kb n, mul eb m and mul eb n against capacities after unsigned multiplication. The pinned compiler's language contract specifies that ulong multiplication wraps modulo 2^64; bo_mul implements that distinction.

Static counterexample

Call the library entry with zero-filled, correctly sized arrays and:

d = { fmt: 0, m: 9223372036854775808, n: 2, k: 32 }
bs = 16
kb = 2
eb = 16

The five compared products become {0, 0, 4, 0, 32} modulo 2^64. All capacity guards pass. Then mxmm lines 155–158 also computes m*n == 0, skips its loop and returns with C unchanged.

Expected: refuse this shape with trap 5, consistent with the documented capacity contract.

Exact arithmetic check (Wolfram):

With[{m = 2^63, n = 2, k = 32},
 Mod[{m*n, (k/16)*m, (k/16)*n, (k/2)*m, (k/2)*n}, 2^64]]
(* {0, 0, 4, 0, 32} *)

Coverage and next step

The existing binary driver reads m and n from single bytes. It cannot represent this counterexample, so the existing 275 refusal checks do not cover the full-width library contract.

Smallest follow-up: add a direct-call full-width-dimension refusal fixture, then make all five capacity comparisons overflow-safe, preserving the intended zero-dimension policy. Run the fixture and positive boundary controls with the pinned AArch64 compiler and retain the receipt. Keep the fix in .om.

Evidence level: independently checked static finding plus exact modular arithmetic. Native reproduction is NOT_RUN in this review (x86_64 environment); no emulator or foreign-language implementation substituted. This demonstrates a refusal-contract defect, not memory corruption, GPU execution, or a model-quality failure.

Existing implementation/review context is #111 (ModelKernels / TrainFixes2). A search for existing mxcheck/mxdot issues found none before filing. No source changes in this report.

No comments.

Sign in to comment