Skip to content

v16.3 — Fuzz targets that check what they claim, exhaustive sweeps, and the defects they found

Choose a tag to compare

@danmcleran danmcleran released this 24 Oct 17:47
· 69 commits to master since this release
eabd127

v16.3 — Fuzz targets that check what they claim, exhaustive sweeps, and the defects they found

A fuzz target that only feeds input to a kernel proves one thing: the kernel does not crash. This release makes every tinymind fuzz harness state what "correct" means, adds a suite that checks properties on every input of a domain wherever the domain is small enough to enumerate, and fixes the four defects those checks found on their first runs. The prompt was reading Theorem's OSS Verify (https://theorem.dev/oss-verify/), which proves that fuzz targets cannot crash and makes the same point: a proof covers only what the fuzz target checks.

Defects found and fixed

  • Signed-overflow UB in Requantizer::apply (#230). The fallback path, taken when the multiplier is negative or the shift is below 2, computed acc * (1 << left_shift) in int32. That overflows for a large accumulator under a scale ratio above 1. It now uses the saturating multiplyByQuantizedMultiplier, which already had this fix. Adding the zero point could also overflow near the int32 limits; the result is now clamped to [qmin - zp, qmax - zp] first. Results for in-contract inputs are bit-identical, and the integration golden outputs are unchanged.
  • Wrong knot in the fixed-point LUT activations (#231). LookupTable::getValue compared a table y value with the raw x input where it meant to detect x landing on a knot. Whenever the two happened to be equal it returned the wrong table entry. Q8.8 sigmoid was off by up to 7.5 LSB and decreased in 3 places; tanh was off by 18.6 LSB and decreased in 9. Both are now within about 2 LSB and monotonic on every input. A sampled accuracy test at 1/64 spacing had passed over it.
  • Unsupported LUT formats (#231). Formats with fewer than 4 integer bits (Q1.7, Q2.6, Q3.5, Q1.15, Q2.14, Q3.13) cannot hold the tables' ±6 range and returned values off by up to their full range. Formats with fewer than 3 fractional bits (Q6.2, Q7.1, Q14.2, Q15.1) divided by zero. LookupTable now rejects both at compile time with a clear message. No format in the repository was affected.

Fuzz harnesses with property checks (#230)

  • Every harness states its properties with TINYMIND_FUZZ_CHECK (fuzz/fuzz_check.hpp), which prints the failing expression and traps:
    • requantize: an exact 128-bit reference for multiplyByQuantizedMultiplier; Requantizer and FastRequantizer bit-identical to it.
    • softmax: order, probability mass, accuracy against double precision, shift invariance, row-reversal equivariance.
    • layernorm: accuracy against double precision within a derived error bound, constant rows, shift invariance.
    • FFT: forward and inverse against a double-precision DFT.
    • LSTM, GRU, CfC, softmax attention and multi-head attention: permutation equivariance over every axis; attention's inline softmax equals QSoftmax1D; each attention head equals the same head run alone.
  • One planted in-bounds defect per kernel (a wrong stride, index, rounding term or head slot) is caught by replaying the committed corpus alone.

New CI gates (#230)

  • make -C fuzz agree: the corpus through unsanitized g++ and Clang builds at -O0 and -O3; every build must produce identical output digests.
  • make -C fuzz msan-replay: the corpus under MemorySanitizer, now part of make check-msan.
  • make -C fuzz check-coverage: every property check must execute on the committed corpus.
  • arm_dsp_qemu: two more images build the SMLAD test with GCC and Clang UndefinedBehaviorSanitizer in trap mode on the emulated Cortex-M4.
  • Corpus replay now times out a hung input after 10 s.

Exhaustive sweeps (#231)

New suite unit_test/exhaustive, part of make check, the sanitizer jobs, the Clang jobs and the AVX2 jobs:

  • Fixed-point LUT sigmoid and tanh on every input of every supported 8- and 16-bit signed format, and every input in [-7, 7] of Q8.24, Q16.16 and Q24.8: monotonic, in range, within a derived error bound.
  • The requantizer's one-rounding fast path against the two-step form, and FastRequantizer against Requantizer, for every accumulator up to ±2²² (every int32 in the nightly run).
  • The int8 dot product: the scalar reference for every (x, w, zero point), and the active SIMD backend for every (x, w) in every lane of a 64-element block.
  • QSoftmax1D on every int8 row of 2 and 3 features, and the layernorm integer square root on every input up to 2²⁴ (every uint32 nightly).
  • The SMLAD backend gets the same per-lane sweep on the emulated Cortex-M4: 134 million cases per image.
  • exhaustive-nightly.yml runs the full int32 and uint32 sweeps.

Every new gate and check was shown to fail on a planted defect before it was trusted.

Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/

Full changelog: v16.2...v16.3