Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/docs/numeric/FB1_CUT4_ELEMENTWISE.md # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / docs / numeric / FB1_CUT4_ELEMENTWISE.md` 65 lines ยท 5382 bytes Raw Blame History Rendered 1 # FB-1 cut 4: native rmsnorm, rope, swiglu (own codegen, no CUDA) 2 3 Written 2026-10-04. Program: `~/handoffs/2026-10-04-fb1-cuts-2-6-plan.md` section 4. 4 Code: `src/omega_gpu_elementwise_api.{h,c}`, `tests/gpu_elementwise_test.c`, 5 `tools/run_gpu_elementwise_chip.sh`; four additive IR ops in `src/omega_blackwell_codegen.{h,c}`. 6 7 ## DOCS READ (gate record `docs-read omega`, 2026-10-04) 8 - nvdisasm 13.0 `-b SM121` decode of every instruction form the kernels use (the method of 9 `tools/divsqrt_nvdisasm_check.sh`). The new words: 10 - `0x7308 / w2 0x00000800` decodes `MUFU.EX2 R2, R4` (RCP is `0x1000`, RSQ `0x1400`). 11 - `0x7b1d / 0 / 0x00010000 / 0x000fec00` decodes `BAR.SYNC.DEFER_BLOCKING 0x0`; the same words 12 `src/omega_numeric.c:885` runs on the chip (LDS_STS op, 148/148 specs). 13 - `0x7984 / 0xff / 0x08000800` decodes `LDS R9, [R10+URZ]` and `0x7988 / Rb / 0x080008ff` 14 decodes `STS [R8+URZ], R2` (`src/omega_numeric.c:884-886`). The codegen's older `BW_IR_LDS` and 15 `BW_IR_STS` decode as `LDS.U8` / `STS.U8` (byte wide); they are left untouched and the 32-bit 16 forms are new ops `BW_IR_LDS32` / `BW_IR_STS32`. 17 - DOCS SILENT on the SASS-level error bound of MUFU.EX2; the PTX ISA bound for `ex2.approx.f32` 18 (maximum relative error 2^-22.5 in the primary range) is used, with 2x margin. 19 - `nvos.h:1112` (nvidia-open-580.173.02): GPU-cached system memory is not coherent with CPU 20 mappings. Every buffer in the launcher is `nvrm_alloc_gpu_uncached`, as in the matmul path. 21 - Scheduling rules come from the chip-learned checks in `src/omega_numeric.c` 22 (`omega_numeric_check_patch`): scoreboard producers stall >= 2 and are waited on; fixed-latency 23 producers stall >= 5 (the codegen uses 6); ISETP stalls 13 before a predicated consumer (codegen default). 24 The emitter serialises every dependency (slow, safe); speed is a later cut. 25 26 ## Kernels (one per op; shape read from the four argument words c[0x0][0x398..0x3a4]) 27 | op | CTA | grid | math on the chip | oracle (tensor.rs, sovereign-core `5fdab70`) | tolerance | 28 |---|---|---|---|---|---| 29 | ex2 probe | 128 | ceil(n/128) | `MUFU.EX2` | `exp2` in f64 | 1e-6 rel | 30 | xchg probe | 128 | n/128 | `STS`, `BAR.SYNC`, `LDS` partner word | `a[i ^ 127]` | exact | 31 | rmsnorm | 128 (4 warps) per row | rows | f32 `FFMA` strided sum of squares, `SHFL.DOWN` 16..1 tree, lane partials to shared, `BAR.SYNC`, 4 `LDS`, `MUFU.RSQ` + one Newton step, `(x*scale)*w` | f64 sum, `(1/sqrt(mean+eps)) as f32`, `x*scale*weight` | 1e-5 rel + 1e-6 abs | 32 | rope | head_dim/2 per head | heads | `FMUL, FMUL, FADD/FSUB` on (q0,q1) with host cos/sin | same f32 ops, same order (rotate_half, cos/sin cast from f64) | exact (bitwise) | 33 | swiglu | 128 | ceil(n/128) | `t=g*-log2e; e=EX2(t); d=e+1; r=RCP(d); (g*r)*up` | f64 `g/(1+exp(-g))*up` | 1e-5 rel + 1e-6 abs | 34 35 Rope note: the trait is in-place on q and k; the API takes a vector of heads and writes `out` 36 (which may alias the input). The host builds the per-head cos|sin table once per call. 37 38 Launch envelope: at most 64 CTAs per launch (matmul sweep 2026-10-03 lost tiles at 128, 39 investigation I42, cause UNKNOWN); the API splits rows / heads / elements on the host. 40 41 ## Mutants (the same parity check must fail against them, in the same chip run) 42 EX2: `2^(x+1)`. XCHG: reads its own word. RMSNORM: warp tree drops the last `SHFL` step. 43 ROPE: `out0 = q0*cos + q1*sin`. SWIGLU: `exp(+g)`. 44 45 ## Register-allocation rule the loops rely on 46 The IR allocator is a linear scan over textual intervals and knows nothing about back-edges. 47 `loop_end()` extends every value defined before a loop and read inside it to the back-branch; 48 `check_loop_invariant()` refuses a kernel that reads, after a loop, a value first defined inside 49 it without redefining it first. Both are in `omega_gpu_elementwise_api.c`. 50 51 ## Status 52 Shader-cache invalidate: every launch emits `INVALIDATE_SHADER_CACHES` (instruction, data, constant) right after the channel setup words, shared constants `OMEGA_BW_MTHD_INVALIDATE_SHADER_CACHES` / `OMEGA_BW_INVALIDATE_SHADER_CACHES_ALL` in `omega_blackwell_submit.h` used by the matmul launcher too (cut 1b finding: stale SM instruction cache after code-address reuse; local driver clcec0.h is a stub, bits from NVIDIA open-gpu-doc, chip-proven FB1-CUT1B-`4345406`). Test case `icache_reuse_rotation` cycles 10 distinct kernels twice as a guard (red seen by cut 1b on matmul, not re-observed here: one chip run rule). 53 54 Host: `make test-gpu-elementwise` (fixtures, refusals, codegen, register budget, nvdisasm listing of 55 all five kernels) PASS at this head. Chip: see the PR title tags and the receipt folder 56 `~/workspace/evidence-out/FB1-CUT4-/` (receipt.json, device.txt, run.log, SHA256SUMS). 57 58 ## Limits (what this does not prove) 59 - One chip run per op is a correctness receipt, not a rate; no load test, no repeat statistics. 60 - The xchg mutant proves the check can say no; it does not prove the barrier is necessary (a 61 no-barrier variant might pass by timing luck and would be a flaky negative control). 62 - rmsnorm's f32 sum differs from the f64 oracle by design; the 1e-5 tolerance covers dims up to 63 16384 on data of unit scale. Inputs with huge dynamic range would need an f64 or Kahan sum. 64 - Speed is not measured beyond `elapsed_ns`; the serialised schedule and one device open per 65 launch are the known price until the resident-device work of cut 1b lands.