interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / sm80 / README.md

122 lines · 8077 bytes Raw Blame History Rendered
1# seed/sm80/: a second GPU table for asm2 (Ampere sm_80/86/87, Ada sm_89)
2
3`seed/sm121/` taught `asm2` (rung 2, unchanged) the GB10's instructions with a plain-text table. This directory
4does the same for an older NVIDIA generation: Ampere (A100 is sm_80; RTX 30xx and A-series workstation cards
5are sm_86; Jetson Orin is sm_87) and Ada (RTX 40xx, L4, L40 are sm_89), which share one instruction encoding.
6Nothing was compiled to add it. The new part is text, plus a check.
7
8Status: IMPLEMENTED and host-verified against Mesa NAK's encoder. No sm_80/86/87/89 GPU has run any of it
9(NOT_RUN). The hardware needed is listed at the end. `gate80.sh` is a host-only gate: it proves the table writes
10NAK's words, not that an sm_80/86/87/89 chip runs them.
11
12## What is here
13
14- `sm80.tbl`: the instruction table, same format as `seed/sm121/sm121.tbl` (`= name 0xBASE field...`). Each
15 instruction is four 32-bit lines: `.0` opcode, guard predicate, destination, first source; `.1` second source
16 or memory fields; `.2` modifiers and third source; `c` the scheduling word (stall, yield, write scoreboard,
17 read scoreboard, wait mask, reuse). Unlike sm121.tbl, the guard predicate and every scheduling field are
18 operands, so no `ctl` override is needed.
19- `vecadd.s2`: the vector add (`c[i] = a[i] + b[i]`), written by hand with the table's names. It is the GB10
20 kernel from `seed/sm121/vecadd.s2` moved to sm_80 forms: `ULDC` instead of `LDCU`, and global memory as
21 `[R.64]` with no uniform descriptor. `vecadd.bin` is what `asm2` makes of it (320 bytes, 20 instructions).
22- `gate80.sh`: the checks (below). Results go to `evidence/SEED-0/sm80/`, which is not committed.
23- `vectors/`: the referee's output. `edges.s2.gz` is a listing in the table's language (13,889 cases, 124,066
24 instructions). `edges.nak.bin.gz` holds the bytes NAK writes for the same instructions. `cases.tsv.gz` maps
25 each case to its first instruction, form, kind and operands. `vecadd.nak.bin` is NAK's bytes for the vector
26 add. `sched80.tsv` holds NAK's own schedule for the vector add, for reference. `SHA256SUMS` covers the
27 uncompressed files.
28- `nakref.sha256`: the sha256 of every source file of the referee that wrote `vectors/` (below).
29
30## Sources
31
32Every base word and field was read by hand from Mesa NAK, `src/nouveau/compiler/nak/sm70_encode.rs` at mesa
33`02f13375231bf0a9ed20b09cb21171351053be52`. NAK is MIT-licensed, Copyright (c) 2022 Collabora, Ltd. No code was
34copied: the table is field positions and opcode numbers, written in this repo's own format. No NVIDIA compiler,
35assembler or disassembler was run to write or check any of it, and no NVIDIA binary was read.
36
37## The referee: nakref
38
39The vectors come from `nakref`, a small Rust program kept outside this repo. It links the pinned NAK sources
40unmodified and uses NAK as a library: for each case it builds NAK's own IR instruction and calls NAK's encoder
41(`ShaderModelInfo::encode_shader`). It writes the asm2 listing for the same instruction next to NAK's bytes.
42
43Each listing field is turned into NAK's own enum (comparison, rounding mode, memory order and so on) and NAK
44encodes it, so a table that puts the right number in the right place under the wrong meaning fails. Operand
45combinations NAK refuses, or that are not valid instructions (misaligned register pairs, reserved encodings),
46are not emitted: 11,244 were refused and none of them came from a NAK assertion. Cases per form:
47
48- every guard predicate (0..6, PT, and their negations);
49- each field at low, high and default, at low + 1 and high - 1, and at powers of two and their neighbours;
50- each scheduling field at its edges;
51- branch distances 0, 1, 2, 3, 7, 63, 64, 1000, 4095, -2, -3, -64, -1000 and -4096;
52- 64 random valid combinations, using a fixed seed.
53
54The program and its build files are in `/home/drakestapleton/handoffs/CudaArch/nakref` (Spark). They are pinned
55by `nakref.sha256` here: one line per source file of the harness (`sha256sum -c` format, paths relative to the
56harness root; oracle `main.rs` sha256 `5f443516812e855109f5ba99da8735f6164b2615407ea66988c0d3847b039e32`). The
57harness compiles the NAK files of the Mesa clone at `02f13375` (clean) through absolute `#[path]` attributes, and
58its only crate from crates.io is `rustc-hash` 2.1.3 (`Cargo.lock`). Rebuilt from these files on 2026-10-30
59(rustc 1.98.1, `cargo build --offline --locked -p nakref`), it writes `edges`, `cases`, `vecadd` and `sched` for
60sm_80 byte-identical to `vectors/` (`SHA256SUMS`, `sched80.tsv`). `gate80.sh` needs none of this: it reads the
61committed vectors. Whether the harness should live in this repo is open. It is Rust, and seed referees are .om
62or the existing C precedent (`seed/sm121/sm121list.c`).
63
64The same oracle shows that NAK's bytes for all 124,066 instructions, and for the vector add, are identical at
65sm_80, 86, 87 and 89. sm_90 (Hopper) differs: NAK changes float atomics and other forms from sm_90 on
66(`sm70_encode.rs` 1183, 3799, 3828, 4537, 4593). This table does not cover sm_90.
67
68## How the table was checked, and what was corrected
69
70The table was written once, from reading the source, before any comparison. The first comparison found 136
71differing words out of 496,264. Each one came from the oracle, not the table: NAK rewrites four operand
72choices into a different encoding.
73
74- An immediate 0 becomes the zero register, which uses the register form.
75- `URZ` as a uniform source uses the register form with `RZ`.
76- `ULDC` with no destination becomes `LDC` to `RZ`.
77- `ATOMG` with no destination becomes `RED`.
78
79The oracle now builds those operands explicitly (an `Imm32(0)`, UGPR 63, GPR 255), so the listing keeps the
80encoding it names. No table line changed. After that, all 124,066 instructions were bit-identical.
81
82## Checks (`sh seed/sm80/gate80.sh`, from the repo root)
83
841. The vectors match `vectors/SHA256SUMS`.
852. `asm2` with `sm80.tbl` assembles the edge listing. Every word must equal NAK's, bit for bit.
863. `vecadd.s2` assembles twice to the same bytes, and those bytes equal NAK's for the same instructions.
874. Controls, each of which must change the output: a wrong register, a wrong constant offset, an out-of-range
88 register (`asm2` error 8), a flipped table bit, a field moved one bit, and a moved field in a form only the
89 edge listing uses (SHFL with two immediates). As a whole-gate negative control, flipping one bit of
90 `isetp.2`'s base word makes GATE80 FAIL with exit status 1.
91
92## The vector add's schedule
93
94The scheduling words are the ones the GB10 ran in `seed/sm121/vecadd.s2`, carried over. `sched80.tsv` sets them
95beside the schedule NAK's own pass gives the same instructions (`calc_instr_deps` with `SM80Latency`). Every
96stall is at least NAK's, and every scoreboard NAK waits on before a read is also waited on here, except in two
97places, where this kernel takes NAK's stricter words:
98
99- The store holds its registers on read scoreboard 0 with stall 2, where the GB10 kernel used stall 1 and no
100 read scoreboard.
101- The final `EXIT` waits on that scoreboard.
102
103Total stall cycles are 65 here and 48 in NAK's schedule. Whether the GB10 schedule is also correct on sm_80
104cannot be known without running it: NOT_RUN.
105
106## Not covered (no open referee, so not in the table)
107
108- HMMA with BF16 or TF32 inputs: NAK encodes F16 inputs only.
109- F2FP.BF16 and the packing variants.
110- Source modifiers (absolute value, negation) on ALU sources: the oracle never sets them.
111- Uniform-datapath arithmetic and `CS2R`.
112- Everything above sm_89.
113
114Branch distances above 28 bits (`bra.2`'s high field) are checked only at 0 and -1, because a listing that
115branches farther would exceed `asm2`'s 8 MiB output.
116
117## Running it on hardware (NOT_RUN)
118
119Nothing here has been on an sm_80/86/87/89 GPU. To qualify it, one of these is needed: an A100 (sm_80); an
120RTX 30xx or A-series workstation card such as an A5000 (sm_86); a Jetson Orin (sm_87); or an L4, L40 or RTX
12140xx (sm_89). It also needs a launcher for that chip: CUDA++'s runtime builds sm_121 launch descriptors
122(QMD 5.0), and Ampere and Ada use QMD 3.0.