interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / om / qwen-native / model / project.om

160 lines · 2771 bytes Raw Blame History
1note GB10 matrix layer. Preserve weight residency across tokens, one read-only host fd per shard.
2global qgpu long 66
3global qxy long 2
4global qbuf uchar 1048576
5fn qtransfer fd int origin ulong n ulong dev long to void
6off = ulong 0
7while lt off n bound 65536
8w = sub n off
9if gt w len qbuf
10w = len qbuf
11end
12if ne pread fd qbuf 0 w long add origin off long w
13qwfail 48
14end
15if ne mapwrite dev off qbuf 0 w long w
16qwfail 48
17end
18off = add off w
19end
20end
21
22fn qresident id ulong to long
23s = ulong get qwfile id
24h = get qgpu s
25if gt h 0
26ret h
27end
28origin = ulong 0
29n = get qwsize s
30if eq s 64
31if ne id ulong get qrole 1021
32qwfail 49
33end
34origin = get qwoff id
35n = mul get qwcount id 2
36end
37h = nvalloc n true
38if le h 0
39qwfail 50
40end
41qrestat s
42qtransfer int get qwfd s origin n h
43qrestat s
44put qgpu s h
45ret h
46end
47
48fn qgpuopen to void
49if not lqopen
50qwfail 50
51end
52x = nvalloc 1048576 true
53if le x 0
54qwfail 50
55end
56put qxy 0 x
57y = nvalloc 1048576 true
58if le y 0
59qwfail 50
60end
61put qxy 1 y
62end
63
64fn qbf j ulong to f32
65a = mul j 2
66bits = or uint get qbuf a shl uint get qbuf add a 1 8
67ret bitcast f32 shl bits 16
68end
69
70fn qreadrow id ulong first ulong buf edit f32 * pos ulong n ulong to void
71if ne get qwdtype id 2
72qwfail 51
73end
74if or gt first get qwcount id gt pos len buf
75qwfail 51
76end
77if or gt n sub get qwcount id first gt n sub len buf pos
78qwfail 51
79end
80h = qwhandle id
81bytes = mul n 2
82if gt bytes len qbuf
83qwfail 51
84end
85if ne mapread h add get qwoff id mul first 2 qbuf 0 bytes long bytes
86qwfail 51
87end
88for j ulong n
89put buf add pos j qbf j
90end
91end
92
93fn qfillinput x view f32 * n ulong to void
94if gt n len x
95qwfail 52
96end
97for j ulong n
98bits = bitcast uint get x j
99if ne mapset get qxy 0 mul j 4 4 ulong bits 0
100qwfail 52
101end
102end
103end
104
105fn qbindmatrix id ulong to void
106h = qresident id
107put lqmap 0 h
108off = get qwoff id
109if eq get qwfile id 64
110off = ulong 0
111end
112put lqoff 0 off
113put lqlen 0 mul get qwcount id ulong get qwdtype id
114put lqlen 1 0
115s = ulong get qscale id
116if ne s 0
117if ne get qwfile s get qwfile id
118qwfail 52
119end
120put lqmap 1 h
121put lqoff 1 get qwoff s
122put lqlen 1 mul get qwcount s 2
123end
124end
125
126fn qdispatch id ulong m uint k uint to void
127s = ulong get qscale id
128ok = false
129if eq s 0
130ok = lqrun 0 m k 0 0
131else
132a = mul s 4
133ok = lqrun 1 m k uint get qwshape a uint get qwshape add a 1
134end
135if not ok
136qwfail 53
137end
138end
139
140fn qproject id ulong x view f32 * y edit f32 * pos ulong to void
141a = mul id 4
142m = uint get qwshape a
143k = uint get qwshape add a 1
144if or gt pos len y gt ulong m sub len y pos
145qwfail 52
146end
147qfillinput x ulong k
148qbindmatrix id
149put lqmap 2 get qxy 0
150put lqmap 3 get qxy 1
151put lqoff 2 0
152put lqoff 3 0
153put lqlen 2 mul ulong k 4
154put lqlen 3 mul ulong m 4
155qdispatch id m k
156for j ulong ulong m
157bits = uint mapget get qxy 1 mul j 4 4
158put y add pos j bitcast f32 bits
159end
160end