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 / ng / target / fabric.om

156 lines · 3564 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/ng/target/fabric.om: Step 3 -- Live Realization Cache <-> QDI_WTBL Dispatch Fabric
3note + Heterogeneous apu-gb10 Scheduler (X925 / A725 / SM121 / Spark Ring) + Arboris Metabolic Re-Specialization.
4
5const FAB_SLOTS ulong 32
6
7note Dispatch execution modes:
8const FAB_MODE_NONE ulong 0
9const FAB_MODE_NEURAL ulong 1
10const FAB_MODE_CPU_NATIVE ulong 2
11const FAB_MODE_GPU_NATIVE ulong 3
12const FAB_MODE_CRYSTALLIZED ulong 4
13
14note Live dispatch table (software mirror of GPU QDI_WTBL + CPU indirect dispatch table)
15global fabSem ulong 32
16global fabPtr ulong 32
17global fabTid ulong 32
18global fabVer ulong 32
19global fabMode ulong 32
20global fabCostNs ulong 32
21
22note Arboris live shape trace histogram (tracks hot (semId, M, K, N) calls for A725 background specialization)
23const FAB_HIST_CAP ulong 16
24global fabHUsed ulong 16
25global fabHSem ulong 16
26global fabHM ulong 16
27global fabHK ulong 16
28global fabHN ulong 16
29global fabHHits ulong 16
30global fabHSpec ulong 16
31
32note Heterogeneous apu-gb10 task kinds:
33const TASK_CTRL_LATENCY ulong 1
34const TASK_BG_METABOLIC ulong 2
35const TASK_TENSOR_LOCAL ulong 3
36const TASK_TENSOR_MULTI_SPARK ulong 4
37
38fn fabInit to void
39for i ulong FAB_SLOTS
40put fabSem i 0
41put fabPtr i 0
42put fabTid i 0
43put fabVer i 0
44put fabMode i FAB_MODE_NONE
45put fabCostNs i 0
46end
47for j ulong FAB_HIST_CAP
48put fabHUsed j 0
49put fabHHits j 0
50put fabHSpec j 0
51end
52end
53
54note Heterogeneous apu-gb10 scheduler: routes each task kind to its optimal TargetDesc!
55fn fabScheduleApu taskKind ulong to ulong
56if eq taskKind TASK_CTRL_LATENCY
57ret TID_X925
58end
59if eq taskKind TASK_BG_METABOLIC
60ret TID_A725
61end
62if eq taskKind TASK_TENSOR_LOCAL
63ret TID_SM121
64end
65if eq taskKind TASK_TENSOR_MULTI_SPARK
66ret TID_SPARK_RING
67end
68ret TID_X925
69end
70
71note Proof-gated atomic hot-swap into fabWtbl (QDI_WTBL mirror): requires proofMask == 7!
72fn fabHotSwap slot ulong semId ulong codePtr ulong tid ulong mode ulong proofMask ulong to bool
73if ge slot FAB_SLOTS
74ret false
75end
76if ne and proofMask 7 7
77ret false
78end
79put fabSem slot semId
80put fabPtr slot codePtr
81put fabTid slot tid
82put fabMode slot mode
83put fabVer slot add get fabVer slot 1
84if eq mode FAB_MODE_NEURAL
85put fabCostNs slot 15000000
86else
87if eq mode FAB_MODE_CRYSTALLIZED
88put fabCostNs slot 500
89else
90put fabCostNs slot 20000
91end
92end
93ret true
94end
95
96fn fabMatchHist i ulong semId ulong M ulong K ulong N ulong to bool
97if ne get fabHUsed i 1
98ret false
99end
100if ne get fabHSem i semId
101ret false
102end
103if ne get fabHM i M
104ret false
105end
106if ne get fabHK i K
107ret false
108end
109ret eq get fabHN i N
110end
111
112note Record a live (semId, M, K, N) observation from Arboris traces
113fn fabObserveShape semId ulong M ulong K ulong N ulong to ulong
114for i ulong FAB_HIST_CAP
115if fabMatchHist i semId M K N
116h = add get fabHHits i 1
117put fabHHits i h
118ret h
119end
120end
121for j ulong FAB_HIST_CAP
122if eq get fabHUsed j 0
123put fabHUsed j 1
124put fabHSem j semId
125put fabHM j M
126put fabHK j K
127put fabHN j N
128put fabHHits j 1
129put fabHSpec j 0
130ret 1
131end
132end
133ret 0
134end
135
136note A725 background metabolic tick: specializes any hot shape (hits >= 4) and hot-swaps fabWtbl[wtblSlot]!
137fn fabMetabolicTick wtblSlot ulong targetTid ulong to ulong
138swaps = ulong 0
139for i ulong FAB_HIST_CAP
140if and eq get fabHUsed i 1 eq get fabHSpec i 0
141if ge get fabHHits i 4
142sem = get fabHSem i
143rc = peSpecializeW4Gemm sem targetTid get fabHM i get fabHK i get fabHN i
144if eq rc TDK_OK
145cslot = get peOut 4
146ptr = get rcPtr cslot
147if fabHotSwap wtblSlot sem ptr targetTid FAB_MODE_GPU_NATIVE 7
148put fabHSpec i 1
149swaps = add swaps 1
150end
151end
152end
153end
154end
155ret swaps
156end