Skip to main content

Crate memra_validate

Crate memra_validate 

Source
Expand description

memra-validate — shared validation-protocol core (Phase D extraction, ARCHITECTURE-H100.md §5).

Pure host logic, zero engine/CUDA dependency: the pieces every gate bin and bench duplicated (kernel_check, gdn_bench, fa_sanitize, dtype_gpu_check5, the N=5 bench protocol). CPU kernel references stay with their kernels; THIS crate owns the protocol: deterministic test vectors, error measures, tolerance banding, N-rep medians, and the ALL-GREEN tally contract.

Extraction law: moved code is verbatim (bit-identical vectors and measures) — the pr generator here is the kernel_check/dtype_gpu_check5 variant; fa_sanitize’s 16-bit variant intentionally stays local to it (different distribution = different test vectors = a silent gate change).

Structs§

GateTally
ALL-GREEN tally: gates print per-case lines and exit nonzero on any failure. check returns the condition so call sites keep their inline { ... "FAIL" } style or use it directly.

Functions§

maxdiff
Max absolute elementwise difference (the universal gate measure).
median
Median of N runs (the repo’s N=5 protocol; N is the caller’s law, this is the math). Sorts a copy; even N takes the lower-middle (matches the existing bench bins).
pr
Deterministic unit-interval-ish test vector generator (Knuth multiplicative hash → [-1, 1)). Verbatim the kernel_check/dtype_gpu_check5 pr — gate vectors must never drift across crates or sessions.
rel_of
Relative error of d against the max-|value| scale of reference (floored to avoid zero-division on all-zero references) — the kernel_check GEMM-band convention.
run_n_median
Run f N times, return (median, all runs). The N=5-medians protocol runner.