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
omega-mv / om / gpu / dsv41 / arboris / prefetch.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Adapter for the layer-zero pack replay ABI. Scores are the settled |
| 3 | note logical FP32 score plane; a node maps to one expert or 0xffffffff. |
| 4 | note Aggregate duplicate mappings by maximum score. Zero scores never issue |
| 5 | note I/O. Lower expert ID breaks exact ties. A caller controls its I/O budget |
| 6 | note via the number of 2-word records in outbuf. -1 rejects invalid input. |
| 7 | fn ar_select_experts peak edit uint 384 outbuf edit uint * to long |
| 8 | for slot ulong div len outbuf 2 bound 384 |
| 9 | best = ulong 0 |
| 10 | for id ulong 384 |
| 11 | if gt get peak id get peak best |
| 12 | best = id |
| 13 | end |
| 14 | end |
| 15 | if eq get peak best 0 |
| 16 | ret long slot |
| 17 | end |
| 18 | put outbuf mul slot 2 3 |
| 19 | put outbuf add 1 mul slot 2 uint best |
| 20 | put peak best 0 |
| 21 | end |
| 22 | ret long div len outbuf 2 |
| 23 | end |
| 24 | |
| 25 | fn ar_vote_expert peak edit uint 384 id uint score uint to bool |
| 26 | if gt score 0x3f800000 |
| 27 | ret false |
| 28 | end |
| 29 | if ne id 0xffffffff |
| 30 | if ge id 384 |
| 31 | ret false |
| 32 | end |
| 33 | if gt score get peak ulong id |
| 34 | put peak ulong id score |
| 35 | end |
| 36 | end |
| 37 | ret true |
| 38 | end |
| 39 | |
| 40 | fn arboris_expert_hints scores view uint * experts view uint * outbuf edit uint * to long |
| 41 | if or ne len scores len experts ne and len outbuf 1 0 |
| 42 | ret long -1 |
| 43 | end |
| 44 | if or gt len scores 0xffffffff gt len outbuf 768 |
| 45 | ret long -1 |
| 46 | end |
| 47 | peak = new uint 384 0 |
| 48 | for i ulong len scores bound 0xffffffff |
| 49 | id = get experts i |
| 50 | score = get scores i |
| 51 | if not ar_vote_expert peak id score |
| 52 | ret long -1 |
| 53 | end |
| 54 | end |
| 55 | ret ar_select_experts peak outbuf |
| 56 | end |
| 57 | |
| 58 | note Send advisory records to the existing read-ring consumer. The demand |
| 59 | note path retains its authority over the actual experts used for inference. |
| 60 | fn arboris_send_hints fd int records view uint * count ulong to bool |
| 61 | if or gt count 384 gt count div len records 2 |
| 62 | ret false |
| 63 | end |
| 64 | b = new uchar 8 0 |
| 65 | for i ulong count bound 384 |
| 66 | pos = mul i 2 |
| 67 | if or ne get records pos 3 ge get records add pos 1 384 |
| 68 | ret false |
| 69 | end |
| 70 | end |
| 71 | for i ulong count bound 384 |
| 72 | expert = get records add 1 mul i 2 |
| 73 | put b 0 3 |
| 74 | put b 4 uchar and expert 255 |
| 75 | put b 5 uchar shr expert 8 |
| 76 | sent = ulong 0 |
| 77 | while lt sent 8 bound 8 |
| 78 | n = write fd b sent sub 8 sent |
| 79 | if le n 0 |
| 80 | ret false |
| 81 | end |
| 82 | sent = add sent ulong n |
| 83 | end |
| 84 | end |
| 85 | ret true |
| 86 | end |