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 / checks / avrope.om

88 lines · 2288 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/avrope.om: av_attnrope (gpu/nvidia/om/api/attn_math.om, through av_pow, av_log, av_exp,
3note av_pow2, av_sinc, av_rrow and vc_rope) against av_ropegen of CUDApp src/omega_attn_tables.h with its pending C
4note and the C host math of src/omega_gpu_hostmath.c: the ropegen calls of tests/attn_views_cases.c, the decode
5note tables of the attention APIs and probes. attn_math.om carries om2, so it is the head of this check. Rows:
6note R pos theta dim width rows h
7note theta is the bits of the f64. The f32 array of rows*width elements starts as the bits 0x40490fdb (so an element
8note the call does not write is compared too); h is its FNV-1a digest (h = (h xor bits) * 1099511628211 from
9note 1469598103934665603). The unit must answer 0. rows*width above 1000003 (the largest local f32 array, 4 MiB) is
10note ckbad. The host math the R rows stand on is compared on its own, every value as f64 bits, so an error the f32
11note table rounds away still shows:
12note L x log(x) (av_log) E y exp(y) (av_exp)
13note P b e pow(b,e) (av_pow) S a sin(a) cos(a) (av_sinc)
14text t_name "AVROPE"
15text t_r "R"
16text t_l "L"
17text t_e "E"
18text t_p "P"
19text t_s "S"
20fn cname to void
21for i ulong len t_name bound 64
22ckoc ulong get t_name i
23end
24end
25fn ckf i ulong to f64
26ret bitcast f64 cknum i
27end
28fn arm to bool
29if ckis 0 t_l
30if ne ckcnt 3
31ckbad
32end
33ret eq bitcast ulong av_log ckf 1 cknum 2
34end
35if ckis 0 t_e
36if ne ckcnt 3
37ckbad
38end
39ret eq bitcast ulong av_exp ckf 1 cknum 2
40end
41if ckis 0 t_p
42if ne ckcnt 4
43ckbad
44end
45ret eq bitcast ulong av_pow ckf 1 ckf 2 cknum 3
46end
47if or ne ckcnt 4 not ckis 0 t_s
48ckbad
49end
50o = new ulong 2 0
51av_sinc ckf 1 o
52ret and eq get o 0 cknum 2 eq get o 1 cknum 3
53end
54fn crow to bool
55if not ckis 0 t_r
56ret arm
57end
58if ne ckcnt 7
59ckbad
60end
61w = cknum 4
62rows = cknum 5
63if gt w 0
64if gt rows div 1000003 w
65ckbad
66end
67end
68l = mul rows w
69d = new f32 1000003 f32 0
70for i ulong l bound 1000003
71put d i bitcast f32 uint 1078530011
72end
73q = new ulong 16 0
74put q 0 cknum 1
75put q 1 cknum 2
76put q 2 cknum 3
77put q 3 w
78put q 4 rows
79rc = av_attnrope d q
80if ne rc 0
81ret false
82end
83h = ulong 1469598103934665603
84for i ulong l bound 1000003
85h = mul xor h ulong bitcast uint get d i 1099511628211
86end
87ret eq h cknum 6
88end