Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/om/qwen-native/model/generate.om # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / om / qwen-native / model / generate.om` 143 lines ยท 2096 bytes Raw Blame History 1 note Token-to-token CLI. The paired native tokenizer handles the rendered UTF-8 input and output bytes. 2 note qwen-generate MODEL MODEL_DIR CAP, decimal prompt token IDs (one per line) on stdin. 3 global qintbuf uchar 32 4 fn qnumber buf view uchar * n ulong to ulong 5 if or eq n 0 gt n 7 6 qwfail 56 7 end 8 v = ulong 0 9 for i ulong n 10 c = get buf i 11 if or lt c 48 gt c 57 12 qwfail 56 13 end 14 v = add mul v 10 sub ulong c 48 15 end 16 ret v 17 end 18 19 fn qnumericarg a ulong to ulong 20 b = new uchar 8 0 21 n = argread a b 0 8 22 if le n 0 23 qwfail 56 24 end 25 ret qnumber b ulong n 26 end 27 28 fn outid id ulong to void 29 n = get qnids 0 30 if or ge n len qids ge id len sizes 31 qwfail 56 32 end 33 put qids n uint id 34 put qnids 0 add n 1 35 end 36 37 fn qprintid id ulong to void 38 v = id 39 p = ulong 31 40 put qintbuf p 10 41 while true bound 8 42 p = sub p 1 43 put qintbuf p uchar add 48 rem v 10 44 v = div v 10 45 if eq v 0 46 break 47 end 48 end 49 while lt p 32 bound 32 50 w = write 1 qintbuf p sub 32 p 51 if le w 0 52 qwfail 57 53 end 54 p = add p ulong w 55 end 56 end 57 58 fn qgenerate count ulong cap ulong to void 59 id = ulong 0 60 for j ulong count 61 id = qtoken ulong get qids j j eq add j 1 count 62 end 63 for j ulong cap 64 put qrun 3 0 65 put qrun 4 add j 1 66 if eq get qidmode 0 1 67 qprintid id 68 else 69 if eq get qidmode 0 2 70 qsessiontoken id 71 end 72 end 73 if or eq id 248044 eq id 248046 74 put qrun 3 1 75 ret 76 end 77 if eq get qidmode 0 0 78 if ge id len sizes 79 qwfail 57 80 end 81 if eq get sizes id 0 82 qwfail 57 83 end 84 emitword id 85 tkpfl 86 end 87 if lt add j 1 cap 88 id = qtoken id add count j true 89 end 90 end 91 end 92 93 fn main to int 94 if and ne argcnt 4 ne argcnt 5 95 ret 2 96 end 97 model = qnumericarg 1 98 cap = qnumericarg 3 99 if or eq cap 0 gt cap 160 100 ret 2 101 end 102 layers = ulong 40 103 if eq model 27 104 layers = ulong 64 105 else 106 if ne model 35 107 ret 2 108 end 109 end 110 if eq argcnt 5 111 mode = qnumericarg 4 112 if not or eq mode 1 eq mode 2 113 ret 2 114 end 115 put qidmode 0 mode 116 end 117 loadmodel 118 if ne get qtidentity 0 model 119 qwfail 59 120 end 121 unicodeinit 122 qwload 2 layers 123 qprofile layers 124 put qrun 0 model 125 qgpuopen 126 if eq get qidmode 0 2 127 qsession cap 128 else 129 encodeinput inputsize 130 count = get qnids 0 131 if eq count 0 132 qwfail 56 133 end 134 if gt add count sub cap 1 8192 135 qwfail 56 136 end 137 qgenerate count cap 138 end 139 if not lqclose 140 ret 58 141 end 142 ret 0 143 end