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
CUDApp / evidence / guard-pred-20261107 / README.md
| 1 | # sm_121 guard predicates: the seeded encoders ignored them on most ops (DRA-483, C1b, 2026-11-07) |
| 2 | |
| 3 | Status: HOST_TESTED. GB10 device NOT_RUN (no chip run of a predicated MOV or STG in this change). |
| 4 | |
| 5 | ## Defect |
| 6 | At main `f1b50cbf`, `om/encoder/bw_enc_sm121.om` built the 4-bit guard field (`fn pred`: 7 always, 0 @P0, 8 @!P0) |
| 7 | only for STG.E.STRONG.SYS (op 22), BRA (46), BSSY (54) and BSYNC (55). EXIT (45) read only `predicate_p0`, so |
| 8 | @!P0 EXIT encoded @P0. Every other op wrote guard 7, so a predicated IR instruction ran unconditionally. The spec |
| 9 | encoder `om/encoder/bw_spec_sm121.om` (`sp_enc`, used by `om/components/encode.om` `bc_encode` on the q38 and |
| 10 | validate paths) had the same gap and refused @!P0 EXIT (its guard bound was 7). The C oracle |
| 11 | `src/omega_blackwell_codegen.c` `bw_c_encode_insn` has the same gap (its only predicate reads are at lines 520, 748, |
| 12 | 763, 770, 790 and 804), so the .om-vs-C corpus diff could not see it. |
| 13 | |
| 14 | ## Exposure (who sets predicate_p0 / predicate_not, and on which ops) |
| 15 | | Producer | Ops predicated | Guard honoured before? | |
| 16 | |---|---|---| |
| 17 | | CUDApp `src/*` Em emitters (`omega_bw_em.h`, `_gemm`, `_tern`, `_bf16`, `_moe`, `_moe2`, `_attn`, `_attn256`, `_pattn`, `_pattn256`, `_dec`, `_gdn`, `_router`), `omega_blackwell_codegen.c` matmul loops, `omega_gpu_elementwise_api.c` / `omega_gpu_attention_api.c` region exits | BRA @P0 and @!P0 | yes | |
| 18 | | `omega_gpu_elementwise_api.c` exit_if_p0, `omega_gpu_gemm.c:155`, `omega_blackwell_codegen_pf.c:16`, `examples/hello_gpu` | EXIT @P0 | yes | |
| 19 | | `om/components/bw_effect.om` bc_branch | BRA @P0 | yes | |
| 20 | | `om/mathlibs/mathlibs_ir.om` exitp, bfwd, bback | EXIT @P0, BRA @P0 / @!P0 | yes | |
| 21 | | tests (`gpu_reconv_test.c`, `bw_hazard_test.c`, `gpu_latmeas_test.c`, `bw_encode_control_test.c`) | BRA, BSSY, BSYNC | yes | |
| 22 | | omega-mv #1044 `seed/oscgpu/gpuir.om` (bw_movi, bw_mov, bw_shl, bw_bool, bw_trap, bw_branch) and its C twin `src/omega_osc_gpu.c` (Movi, Mov, Shl, Bool, Trap, branch), branch head `e70ccc1f`, not on main | MOV_IMM (op 2), STG.E (12), LOP3.LUT as MOV (51), SHF.L.U32 (52) @P0 and @!P0; BRA | **no**: MOV, STG.E, LOP3, SHF ran unconditionally (the ng-gpu finding) | |
| 23 | |
| 24 | No CUDApp producer predicates an op whose guard changed, so the fix changes no byte of the CUDApp corpus. Measured on |
| 25 | the 3191 corpus kernels after the fix (od + awk over `build/om-encoder/k-om/*.bin`, a measuring instrument, not |
| 26 | shipped): 1237248 instruction slots (padding NOPs included), 17489 with a guard other than 7, all of them BRA (opcode 0x947: 15066 @P0, |
| 27 | 2373 @!P0) or EXIT (0x94d: 50 @P0); sum by Wolfram. |
| 28 | |
| 29 | ## Oracles (independent, never shipped) |
| 30 | - NVIDIA `nvdisasm` 13.0.85 `-b SM121 -hex` on our own words. `guard_words.bin` (sha256 `e8484aeb...`) decodes |
| 31 | as `nvdisasm-after.txt`: `@P0` / `@!P0` on all 126 forms of the 63 P-guarded ops, `@UP0` / `@!UP0` on the LDCU |
| 32 | and LDCU.64 probes (why those two refuse a P0 guard), and `MOV R4, 0x0` / `@P0 MOV R4, 0x1` / `@!P0 STG.E |
| 33 | desc[UR4][R8.64], R12` / `@!P0 MOV R5, 0x1` / `@!P0 MOV R4, 0x0` for the #1044 rows. `guard_words_before.bin` |
| 34 | decodes as `nvdisasm-before.txt`: 121 of the 135 guards wrong. |
| 35 | - `make test-om-encoder-guard` reruns the oracle on every run. |
| 36 | |
| 37 | ## Change |
| 38 | - `bw_enc_sm121.om` enc1: after the op's words, a predicated instruction gets `pred o` in w0 bits 12..15 |
| 39 | (`put w 0 or sub x and x 61440 shl pred o 12`); LDCU / LDCU.64 with a P0 guard are refused. |
| 40 | - `bw_spec_sm121.om` sp_enc: the same step (`sp_val R_PRED`) and refusal; the EXIT form's guard bound 7 -> 8. |
| 41 | - Bindings regenerated by `om/units.sh` (omc e5b32567 sha256 2c824805..., omega-bridge bc11b30b bootstrapped from |
| 42 | its audited source rungs): `bw_enc_sm121`, `encode`, `validate`, `q38_emit`, `cudapp_om_units.ident`. |
| 43 | - `om/encoder/guard_pred_test.om`, `om/encoder/guard_spec_test.om`, `make test-om-encoder-guard` (CI step next to |
| 44 | the LDG and ATOMG gates). |
| 45 | |
| 46 | ## Results (Linux AArch64, DGX Spark, cores 8-9 under pool-8-9) |
| 47 | | Check | Before | After | |
| 48 | |---|---|---| |
| 49 | | `test-om-encoder-guard` rows (enc1) | red commit f29378d0: 125 failing forms, exit 1 (`gate-before-f29378d0.log`, `rows-before.txt`) | 0 failures | |
| 50 | | nvdisasm guards | 121 of 135 wrong | 135 of 135 (`gate-after.log`) | |
| 51 | | sp_enc vs enc1 (180 forms) | 111 differ against the fixed enc1 (`spec-before.txt`) | 0 | |
| 52 | | red checks | n/a | guard ignored 121, forced to 7 130, @!P0 as @P0 66, enc1 LDCU refusal removed 4, sp_enc guard removed 106, sp_enc LDCU refusal removed 4; oracle text without @!UP0 exits 4 | |
| 53 | | `test-om-encoder-ldg` | PASS at the base encoder | PASS | |
| 54 | | `test-om-units`, `test-om-encoder-atomg`, `test-om-spec-encoder` (461 cases), `test-drift` | n/a | PASS | |
| 55 | | `test-om-encoder` | n/a | 145 golden instructions, 14 fixture programs SAME; red check aborts | |
| 56 | | `test-om-encoder-mutants` | n/a | 3/3 red | |
| 57 | | `test-om-encoder-corpus` | not run at the base | 3191 distinct kernels identical .om vs C; 4495 program and 399 single-instruction encodes SAME, 0 DIFFER | |
| 58 | |
| 59 | ## C oracle (proposed, not applied) |
| 60 | `bw_c_encode_insn` needs the same step after its switch (`c-oracle-guard-proposal.diff`, applies with `git apply`): refuse LDCU / LDCU64 with `predicate_p0`, then |
| 61 | `w[0] = (w[0] & ~0xF000u) | ((predicate_not ? 0x8u : 0x0u) << 12)`. Exercised in a scratch worktree only: |
| 62 | `test-om-encoder` stays SAME on 145 instructions and 14 programs. Until it lands, the corpus diff cannot catch a |
| 63 | guard regression; `test-om-encoder-guard` does. |