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

branch main Branches Tags History

CUDApp / docs / abft / CONTRACT.md

268 lines · 14607 bytes Raw Blame History Rendered
1# GEMM fault detection and schedule perturbation: evaluator contract
2
3Linear DRA-420 (the numerical/GEMM slice only) and DRA-387 (the evaluator and concurrency slice).
4CUDApp#55 (schedule perturbation) and CUDApp#56 (reduced-concurrency witness) are covered on the
5host only. Weight integrity at load time belongs to the ownmodel loader and is not in this slice.
6
7Status labels: everything here is **SIMULATED/HOST_TESTED**. The candidate is a first-party `.om`
8tiled GEMM run by simulated workers on the host CPU. No GB10 (sm_121) kernel, device output buffer or
9device scheduler has been exercised. Every device edge in section 10 is **NOT_RUN**.
10
11## 1. Files and build
12
13| Path | Role |
14|---|---|
15| `tests/abft/frozen.om` | Frozen plan: 51 rows plus config. Its hash is in `tests/abft/FROZEN.sha256`, committed in `9a16df99` before any checker existed. |
16| `native/abft/lib.om` | Buffered output, splitmix64 streams, FNV-1a, bf16 and f32 decoding. |
17| `native/abft/check.om` | Independent checkers: full recompute, two-sided checksum, sampled recompute, input digest, structural check. |
18| `native/abft/cand.om` | Candidate tiled GEMM (W workers, two barriers per K tile) and the labelled fault injectors. |
19| `native/abft/sched.om` | CUDApp#55 admission. A refused row never forks. |
20| `native/abft/run.om` | Evaluator: fork, deadline, reap, collect, detect, admit, retry, tallies, witnesses, gates. |
21| `native/abft/cul1.om` | `kabft`: the same two-sided checksum on the merged learn53 CUL1 GEMM records. |
22| `tests/abft/cul1-unit.om` | CUL1 checksum unit cases. Uses `tests/learn53/fixtures.om`. |
23| `tests/abft/driver.om` | Seeded Omega driver: pin check, frozen-hash check, build, unit run and full evaluator run. |
24
25```sh
26mkdir -p build && "$OMEGA_OMC" < tests/abft/driver.om > build/abft-driver && chmod +x build/abft-driver
27OMEGA_OMC=/abs/omega-mv/seed/out/omc build/abft-driver build/abft # all 51 rows plus gates
28build/abft/abft FIRST LAST # a row range; gates are skipped
29```
30
31Run the driver from the repository root. It exits 0 when every step and gate passed, 2 when
32`OMEGA_OMC` is unset, 1 on a pin, frozen-hash, input or output failure, and otherwise with the
33failing step's status (omc, `cul1-unit`, then the evaluator).
34
35The compiler must be omega-mv `e5b32567a7aff3ce594e3254a622a846a6cd190b` `seed/out/omc`, sha256
36`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`; the driver refuses any other.
37`build/abft/abft` exits with the number of failed gates (0 when all pass), or 64 for bad arguments.
38
39## 2. Roles and isolation
40
41- **Evaluator.** Owns the frozen plan, the seeds, the input matrices, the nonce, the tolerances, the
42 checkers, the deadline, the retry count, the trusted record and admission.
43- **Candidate.** Runs only in a forked child. Its one channel back is the bytes it writes into an
44 evaluator-created memfd, plus its exit status. Before any check runs, the evaluator reads those
45 bytes into `gobs`.
46- **Fault-free reference.** The evaluator also runs the candidate's own algorithm in-process, with
47 one worker, round-robin and no fault (`cref`, into `gref`). It is used only to label the ground
48 truth "corrupt" for the FP/FN table. No checker reads `gref`. The element order is k-ascending for
49 every element under every schedule, so a fault-free run is bitwise schedule-independent.
50- **Nonce.** The checksum multipliers and the sampled positions come from evaluator stream 1. That
51 stream is seeded with a nonce from `random` after the candidate has exited, so the candidate cannot
52 predict them.
53- **Freeze.** The plan hash was committed before any checker, tolerance or candidate code. Gates 1–9
54 (section 9) were written after the freeze but before the first run. After the first sandbox
55 development runs, gate 8 was revised and gate 10 was added (section 9 says why). The frozen rows,
56 seeds, S, deadline and retry count were never changed.
57
58## 3. Fault model, precision and tolerance
59
60**Fault model.** Errors that reach the output buffer:
61
62- Bit flips in output elements: single and multi-element.
63- Stale output: an uninitialised buffer, a skipped write, or a stale buffer that happens to be
64 identical.
65- Indexing errors: a dropped K tail, a transposed B, a row offset, or an out-of-bounds store.
66- Synchronisation errors: a missing load barrier, a missing compute barrier, a barrier that counts
67 only workers 0..1, or a hang.
68- Corruption of the evaluator's A input after generation (common mode).
69
70Not modelled: faults inside the checker itself, faults in the evaluator's generation code, and
71faults that alter both the candidate and the checker's view of the output identically.
72
73**Precision.**
74
75- **dt 0 (exact).** u32 inputs; products and sums mod 2^32; tolerance 0.
76- **dt 1, profile P1.** bf16 inputs (sign, exponent 120..127, 7-bit mantissa) and an f32 output. The
77 products of two bf16 values are exact in f32. Accumulation is sequential in f32, round-to-nearest-even,
78 with no FMA (OMEGESE float rules).
79
80Bounds with $u = 2^{-24}$, $u' = 2^{-53}$ and $\gamma_n(u) = nu/(1-nu)$:
81
82- **Per element.** Full and sampled modes compare against an f64 recomputation $s$:
83
84 $$|\hat c_{ij} - s| \le \bigl(\gamma_K(u) + \gamma_K(u')\bigr)(1+2^{-20})\,(|A||B|)_{ij}$$
85
86- **Checksum, one side.** $n$ is the summed extent: N for the right side, M for the left side. The
87 bound is $t(n,K)\,g$, with
88
89 $$t(n,K) = \bigl(\gamma_K(u) + \gamma_{n-1}(u')(2+\gamma_K(u)) + \gamma_K(u')(1+\gamma_{n-1}(u'))\bigr)(1+2^{-20})$$
90
91 For the right side, $g_i = \sum_k |a_{ik}| \sum_j |b_{kj}|$, which is $(|A||B|e)_i$ with $|r| = e$.
92 The left side is the mirror image. The multipliers are $\pm 1$ from the nonce stream.
93
94**Wolfram checks** (WolframLanguageEvaluator; definitions $u = 2^{-24}$, $u' = 2^{-53}$,
95$g[n] = nu/(1-nu)$, $g'[n] = nu'/(1-nu')$, $sl = 1 + 2^{-20}$):
96
97- `And @@ Table[(1+up) <= (1-up) sl (1-gp[k]), {k,1,256}]` → `True`.
98- `(1+up) <= (1-up) sl (1-gp[n+k])` for all $n, k \le 256$ → `True`.
99- Values: `GF[80] = 4.768394328e-6`, `GR[48,80] = 4.768394339e-6`, `GF[256] = 1.525902193e-5` and
100 `GR[256,256] = 1.525902198e-5`.
101- The slack actually needed is $5.7065\times10^{-14}$, far below $2^{-20}$.
102- Constants: `2^-24 == 59604644775390625/10^24` → `True`; `2^-20 == 95367431640625/10^20` →
103 `True`; the decimal literal `1.1102230246251565e-16` lies within $2^{-106}$ of $2^{-53}$ → `True`,
104 so it rounds to $2^{-53}$.
105
106Every comparison is written `not le d t`, so a NaN is detected. The structural check also counts
107outputs whose f32 exponent is all ones.
108
109**Rounding and quantisation declaration.** These bounds are for profile P1 only. A device kernel
110that uses FMA, a different accumulation order, split-K, tensor-core fragment accumulation, MUFU, or
111denormal flushing (GB10 flushes denormals) needs its own profile and bound before these checks
112apply. One example is gemm-any #283's bound $n/(2^{18}-n)\cdot\sum|ab|$ with $n = \lceil K/16\rceil$,
113recorded as profile **P2, NOT_RUN**. Inputs avoid denormals by construction (exponent ≥ 120).
114
115## 4. Exact mode (dt 0): checksum miss bound
116
117The two-sided Freivalds check works mod $2^{32}$ with odd multipliers. Let $v$ be the 2-adic
118valuation of the error pattern's combination. The miss probability is at most $2^{v-31}$ per side.
119
120Wolfram enumeration over the scaled model mod $2^6$:
121
122- Every single-element error is detected.
123- The $2^5$ rectangle is always missed.
124- The bound $2^{v-(w-1)}$ is attained.
125
126At 32 bits, an error of $2^{31}$ on the four corners of a 2×2 rectangle is a **deterministic miss**
127(row 40, gate 7). Full recompute catches it. On the merged learn53 CUL1 record, `kabft` misses the
128same rectangle while `keval` (exact) catches it (`tests/abft/cul1-unit.om`, `abrect`). Wolfram:
129`{2^31+21, 2^31+24, 2^31+47, 2^31+54}` → `{2147483669, 2147483672, 2147483695, 2147483702}`, and
130`{{1,2},{3,4}}.{{5,6,7},{8,9,10}}` → `{{21,24,27},{47,54,61}}`.
131
132## 5. Modes, admission and cost
133
134| Mode | Work | In admission |
135|---|---|---|
136| Structural | output length, exit status, nonfinite count | yes |
137| Input digest | FNV-1a over dims, A and B; detects common-mode input corruption | yes |
138| Full recompute (thorough) | $2MNK$ multiply-adds in f64 or mod $2^{32}$ | yes |
139| Checksum (ABFT, Huang–Abraham 1984, doi:10.1109/TC.1984.1676475; Freivalds) | $O(MK + KN + MN)$ per side | yes |
140| Sampled recompute | $S = 64$ elements with replacement; about $SK$ | **no**, reported only |
141
142- **Admission** is structural OR digest OR full OR checksum. Each detection is retried once, under a
143 new schedule. A pass on retry is RECOVERED; detection on both attempts is REJECTED.
144- **Sampled mode** is reported but does not affect admission. Its measured coverage and cost
145 (evidence, REALITY.md) do not justify admission on their own: for a single corrupt element the
146 detection probability is $1-(1-1/MN)^S$.
147- **Performance comparisons.** Check time is never included in `t_cand`. Any performance comparison
148 that uses these checks must charge equal check cost to both sides and disclose the mode.
149
150## 6. Frozen plan
151
152The row fields, fault codes and flags are documented in the header of `tests/abft/frozen.om`.
153
154| Rows | Content |
155|---|---|
156| 1–5 | Fault-free FP rows (bf16 and exact; odd shape 33×17×41). |
157| 6–14 | Single bit. |
158| 15–18 | Multi-element. |
159| 19–22 | Stale. |
160| 23–27 | Index. 26 is the out-of-bounds store and must exit 103. |
161| 28–37 | Sync. 34/35 is the W8/W2 pair; 36 is the hang; 37 is a wait removal without the control flag and must be refused. |
162| 38–39 | Unsupported sites. Must be refused with 69. |
163| 40–42 | Declared misses and common-mode corruption. |
164| 43–44 | Transient and persistent recovery. |
165| 45–49 | Host cost. |
166| 50–51 | Witness pair with a correct barrier. |
167
168Config: S = 64, deadline 20 s, 1 retry, plan version 1.
169
170## 7. CUDApp#55 schedule perturbation
171
172Policies:
173
174| Policy | Behaviour |
175|---|---|
176| 0 | Round-robin. |
177| 1 | Seeded random choice among ready workers. Stream 2, varied by seed, rep and attempt. |
178| 2 | Run-ahead: worker `tgt` goes first whenever it is ready. |
179| 3 | Delay: worker `tgt` is postponed while it sits at `site`, provided another worker is ready. |
180
181Sites: 1 load, 2 compute, 3 barrier arrival. Site 4 (intra-unit atomic) and site 5 (device
182instruction stream) are **refused with 69**, because there is no host atomic and no qualified delay
183opcode. Nothing is guessed (`docs/learn53/DEPENDENCIES.md` on the integration branch: "#55 NOT_RUN …
184no delay opcode guessed").
185
186Each row is validated before the first fork:
187
188| Code | Meaning | Status |
189|---|---|---|
190| 0 | ok | 0 |
191| 1 | unknown policy | 65 |
192| 2 | target out of range | 65 |
193| 3 | atomic site | 69 |
194| 4 | device instruction stream site | 69 |
195| 5 | wait removal without the known-bad control flag | 65 |
196| 6 | shape or worker bounds | 65 |
197| 7 | transposed index on a non-square shape | 65 |
198| 8 | delay policy without a site | 65 |
199| 9 | hang control with W < 2 | 65 |
200
201The SCHED record reports the number of distinct schedules, by an FNV hash of the worker-choice
202sequence, across reps.
203
204## 8. CUDApp#56 reduced-concurrency witness
205
206A row with flag bit 3 is the reduced-concurrency partner of the previous row: same seed and shape,
207fewer workers (W8 → W2). The evaluator compares the first-attempt output digests rep by rep and the
208admission detections:
209
210| Verdict | Meaning |
211|---|---|
212| 1 | Counterexample: the original detected a fault and the reduced run detected none. The fault depends on concurrency. |
213| 2 | The digests differ rep by rep, and there is no counterexample. |
214| 0 | Otherwise. |
215
216A reduced run that is clean is not proof that the original is correct. It is only a witness.
217
218## 9. Output records and gates
219
220Output is numeric, space separated, after the `COLUMNS` header lines printed by the driver. The
221records are PLAN, CASE, SCHED, TALLY, WITNESS, RESOURCES and GATE. In the CASE record, detector
222columns read 0 pass, 1 detect, 2 not evaluated (no usable output). Verdict codes: 0 ACCEPT,
2231 RECOVERED, 2 REJECTED, 4 retry follows. Times are in ns from `monons`.
224
225| Gate | Condition |
226|---|---|
227| 1 | No false positive in any detector, admission included. |
228| 2 | Admission FN = 0, except the declared rows 11 and 17 (low-mantissa flips below the P1 bound). |
229| 3 | Schedule status: row 37 → 65, rows 38/39 → 69, every other row 0. |
230| 4 | Row 43 all RECOVERED and row 44 all REJECTED. |
231| 5 | Resources: forks = reaped, fd first = fd last, no fd or wait errors. |
232| 6 | Row 36: timeouts = 2 × reps (both attempts killed at the deadline). |
233| 7 | Row 40: checksum FN = full TP = corrupt cases (deterministic rectangle miss). |
234| 8 | Row 42 (common mode): digest TP = corrupt cases, and full FN + structural TP = checksum FN + structural TP = corrupt cases. |
235| 9 | Row 51 witness: same = reps and verdict 0. |
236| 10 | Row 26: every attempt ends in Omega trap 3 (exit 103) before the store. |
237
238**Gate revisions after the first sandbox run.**
239
240- **Gate 8** first required full FN = checksum FN = corrupt cases. The frozen row flips bf16 bit 14,
241 which is the exponent MSB. In 2 of 10 sandbox attempts the corrupted A element overflowed the f32
242 product to inf or NaN. The structural check flags those outputs, and full recompute then also
243 fails them, because $|\hat c - s| = \infty$. The revised gate keeps the claim the row exists for:
244 the digest is the only checker that sees finite common-mode corruption.
245- **Gate 10** was added so the out-of-bounds exit status, previously only visible in CASE records, is
246 gated.
247
248## 10. Known misses and pending device evidence
249
250**Known misses (declared before the first run).**
251
252- f32 low-mantissa flips whose magnitude is under the P1 bound (rows 11 and 17). The bound allows
253 them; they are undetectable at this precision by design.
254- The checksum is looser than per-element recompute by roughly the row or column extent: the bound
255 sums $|A||B|$ over N or M elements.
256- The exact $2^{31}$ rectangle: a deterministic checksum miss.
257- The f32 ±e rectangle (row 41): a miss when the random signs cancel. Up to 1/4 per side pair is
258 expected; the measured rate is in the evidence.
259- Common-mode input corruption: only the digest catches it.
260
261**NOT_RUN (needs producer interfaces).**
262
263- Device output acquisition from a GB10 GEMM launch, i.e. a GEMM launch hook or an output dump from
264 gemm-any #283.
265- Device-side #55 instrumentation and a qualified delay opcode.
266- Atomic-site perturbation.
267- A GB10 profile P2 bound check.
268- Hardware fault injection.