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 / gpu / nvidia / om / components / realize.om

355 lines · 6865 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note CUDApp157 canonical realization v1. Concatenate after quant.om.
3note Wire is 1152 used bytes in uchar4096; trailing bytes MUST zero.
4note 64 LE64 metadata, eight SHA256 digests, exact QuantSchema384.
5note Digests semantic/compiler/encoder/spec/unsolvedIR/code/launch/lineage.
6note A nonzero digest is not evidence: caller must hash actual bytes and qualify.
7fn compose_word b view uchar 4096 k ulong to ulong
8v = ulong 0
9for j ulong 8
10v = or v shl ulong get b add mul k 8 j mul j 8
11end
12ret v
13end
14fn compose_put b edit uchar 4096 k ulong v ulong to void
15for j ulong 8
16put b add mul k 8 j uchar and shr v mul j 8 255
17end
18end
19fn compose_digest b view uchar 4096 slot ulong h view uchar 32 to bool
20if ge slot 8
21ret false
22end
23for j ulong 32
24if ne get b add add 512 mul slot 32 j get h j
25ret false
26end
27end
28ret true
29end
30fn compose_codeid b view uchar 4096 h view uchar 32 to bool
31ret compose_digest b 5 h
32end
33fn compose_launchid b view uchar 4096 h view uchar 32 to bool
34ret compose_digest b 6 h
35end
36note Family3 structural subset mirrors sg_valid, not artifact qualification.
37fn compose_staged b view uchar 4096 to uint
38mt = compose_word b 14
39tk = compose_word b 16
40w = compose_word b 17
41if and ne mt 1 and ne mt 2 and ne mt 4 ne mt 8
42ret 2
43end
44if ne compose_word b 15 1
45ret 2
46end
47if and ne tk 256 ne tk 512
48ret 2
49end
50if or eq w 0 gt w 32
51ret 3
52end
53if ne and w sub w 1 0
54ret 3
55end
56lb = div tk 32
57if ne rem mul mt lb w 0
58ret 2
59end
60if gt div mul mt lb w 8
61ret 2
62end
63if or gt compose_word b 6 16384 ne rem compose_word b 6 tk 0
64ret 2
65end
66ks = div compose_word b 6 tk
67if and ne rem ks 2 0 gt ks 3
68ret 2
69end
70u = ks
71if eq rem ks 2 0
72u = 2
73end
74note Word18 is emitted K-step unroll U for family3, not buffer depth.
75if ne compose_word b 18 u
76ret 2
77end
78required = mul mul mt 128 lb
79if or lt compose_word b 21 required ne rem compose_word b 21 128 0
80ret 3
81end
82note Keep the existing launch declaration granularity; peak+2 needs actual out8.
83if or lt compose_word b 22 16 ne rem compose_word b 22 8 0
84ret 3
85end
86if or ne compose_word b 23 6 ne compose_word b 24 1
87ret 3
88end
89if or gt compose_word b 26 4294967295 gt compose_word b 27 4294967295
90ret 3
91end
92if or ne compose_word b 28 1 gt mul compose_word b 26 w 4294967295
93ret 3
94end
95note This FFMA family has seven non-MMA component declarations; IDs remain opaque.
96if or ne compose_word b 29 7 ne compose_word b 32 0
97ret 2
98end
99for k ulong 8
100if ne k 2
101if eq compose_word b add k 30 0
102ret 2
103end
104end
105end
106ret 0
107end
108fn compose_check b view uchar 4096 n ulong to uint
109d = new ulong 48 0
110q = new uchar 384 0
111if ne n 1152
112ret 1
113end
114if or ne compose_word b 0 1 ne compose_word b 1 1152
115ret 1
116end
117if ne compose_word b 2 121
118ret 2
119end
120note v1 no optional feature bits: SM121 warp instruction path only, no TMA/TMEM.
121if ne compose_word b 3 0
122ret 2
123end
124for k ulong 3
125v = compose_word b add k 4
126if or eq v 0 gt v 16777216
127ret 3
128end
129end
130note type tags1F32 2BF16 3E4M3 4E5M2. This bounded realization uses folded E4M3.
131if or ne compose_word b 7 1 ne compose_word b 8 3
132ret 2
133end
134if or ne compose_word b 9 1 ne compose_word b 10 1
135ret 2
136end
137if or ne compose_word b 11 1 ne compose_word b 12 0
138ret 2
139end
140note alias0 means disjoint input weights scales output. Admission must prove addresses.
141if ne compose_word b 13 0
142ret 2
143end
144for k ulong 6
145if eq compose_word b add k 14 0
146ret 3
147end
148end
149if gt compose_word b 17 32
150ret 3
151end
152if gt compose_word b 18 16
153ret 3
154end
155if gt compose_word b 19 3
156ret 2
157end
158if gt compose_word b 20 127
159ret 2
160end
161if gt compose_word b 21 16384
162ret 3
163end
164if or lt compose_word b 22 3 gt compose_word b 22 246
165ret 3
166end
167if or lt compose_word b 23 4 gt compose_word b 23 32
168ret 3
169end
170if gt compose_word b 24 16
171ret 3
172end
173if ne compose_word b 25 mul compose_word b 17 32
174ret 3
175end
176if gt mul compose_word b 25 compose_word b 22 65536
177ret 3
178end
179for k ulong 3
180if eq compose_word b add k 26 0
181ret 3
182end
183end
184cnt = ulong 0
185for k ulong 8
186if ne compose_word b add k 30 0
187cnt = add cnt 1
188end
189end
190if or eq cnt 0 ne cnt compose_word b 29
191ret 1
192end
193for k ulong 26
194if ne compose_word b add k 38 0
195ret 1
196end
197end
198for k ulong 8
199nz = uchar 0
200for j ulong 32
201nz = or nz get b add add 512 mul k 32 j
202end
203if eq nz 0
204ret 1
205end
206end
207for j ulong 384
208put q j get b add j 768
209end
210rc = quant_read q d
211if ne rc 0
212ret 4
213end
214rc = quant_check d
215if ne rc 0
216ret 4
217end
218if eq compose_word b 19 3
219rc = compose_staged b
220if ne rc 0
221ret rc
222end
223end
224note Quant descriptor describes a load-time chunk, NOT necessarily entire MNK.
225if or ne get d 1 2 ne get d 24 3
226ret 2
227end
228if or ne get d 40 1 ne get d 32 0
229ret 2
230end
231for j ulong 2944
232if ne get b add j 1152 0
233ret 1
234end
235end
236ret 0
237end
238fn compose_match a view uchar 4096 b view uchar 4096 to bool
239if ne compose_check a 1152 0
240ret false
241end
242if ne compose_check b 1152 0
243ret false
244end
245for k ulong 12
246if ne compose_word a add k 2 compose_word b add k 2
247ret false
248end
249end
250note semantic and pinned tool identities only; qualification remains candidate-specific.
251for j ulong 128
252if ne get a add j 512 get b add j 512
253ret false
254end
255end
256for j ulong 384
257if ne get a add j 768 get b add j 768
258ret false
259end
260end
261ret true
262end
263note launch template is32 LE64 words: v1,gridXYZ,blockXYZ,shared,gpr,ugpr,barriers,
264note cbankOffset,argWords,paramABI,relocationPolicy;15..18parameterABI SHA256 limbs,
265note 19..22constantbank SHA256 limbs,23..26zeroVA QMD templates SHA256 limbs;27..31zero.
266note Address-free templates only; blockY=blockZ=1; args remain immutable artifact data.
267fn compose_launch b view uchar 4096 l view ulong 32 to uint
268if ne compose_check b 1152 0
269ret 1
270end
271if or ne get l 0 1 ne get l 4 compose_word b 25
272ret 1
273end
274if or ne get l 5 1 ne get l 6 1
275ret 1
276end
277for j ulong 3
278if ne get l add j 1 compose_word b add j 26
279ret 1
280end
281end
282for j ulong 4
283if ne get l add j 7 compose_word b add j 21
284ret 1
285end
286end
287if or eq get l 11 0 gt get l 12 32
288ret 1
289end
290if or eq get l 12 0 ne get l 13 1
291ret 1
292end
293if ne get l 14 1
294ret 1
295end
296if eq compose_word b 19 3
297if ne get l 11 896
298ret 1
299end
300if and ne get l 12 8 ne get l 12 12
301ret 1
302end
303if and eq get l 12 12 gt compose_word b 14 4
304ret 1
305end
306end
307for k ulong 3
308v = ulong 0
309for j ulong 4
310v = or v get l add add 15 mul k 4 j
311end
312if eq v 0
313ret 1
314end
315end
316for j ulong 5
317if ne get l add j 27 0
318ret 1
319end
320end
321ret 0
322end
323fn compose_launchread b view uchar 4096 wire view uchar 4096 n ulong to uint
324l = new ulong 32 0
325if ne n 256
326ret 1
327end
328for k ulong 32
329put l k compose_word wire k
330end
331for j ulong 3840
332if ne get wire add j 256 0
333ret 1
334end
335end
336ret compose_launch b l
337end
338fn compose_launchwrite l view ulong 32 wire edit uchar 4096 to void
339for j ulong 4096
340put wire j 0
341end
342for k ulong 32
343compose_put wire k get l k
344end
345end
346fn compose_quant b view uchar 4096 q edit uchar 384 to void
347for j ulong 384
348put q j get b add j 768
349end
350end
351fn compose_setquant b edit uchar 4096 q view uchar 384 to void
352for j ulong 384
353put b add j 768 get q j
354end
355end