code wiki / _hdl_build / nx_strategy_test.nx

nx_strategy_test.nx source

↩ module page · 49 lines · 4009 B

1// nx_strategy_test.nx -- the team's two new forward/outward roles. The FUTURIST forecasts where the 2// frontier is heading (weight bits 16->8->4->2 -> 1-bit/ternary is coming, team not ready -> prepare 3// now). The MARKET RESEARCHER scores what to capitalize on (deliverable now vs build-first). The 4// honest signal they work: both converge on the SAME build -- closing the rate-distortion gap to a 5// SOTA-beating (S-class) quantizer. Exit 0 if all hold. license_tier: ORIGINAL 6 7import "nx_futurist.nx" 8import "nx_market.nx" 9import "nx_syscalls.nx" 10 11func st_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12func st_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(1,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } 13 14func main() -> i64 { 15 st_puts("=== FUTURIST + MARKET RESEARCHER: look forward, see what to capitalize on ===\n" as *u8) 16 // FUTURIST: weight bits/weight trend over time -> heading to 1-bit/ternary 17 let bits: *i64 = sys_mmap(8*8) as *i64; bits[0]=16; bits[1]=8; bits[2]=4; bits[3]=2 18 let rate: i64 = fut_rate(bits, 4) 19 let next: i64 = fut_forecast(2, rate, 1) 20 let eta1: i64 = fut_eta(2, 1, rate) 21 let team_has_1bit: i64 = 0 22 let prep: i64 = fut_prepare_now(team_has_1bit, eta1, 3) 23 st_puts(" [futurist] bits 16->8->4->2 rate=" as *u8); st_num(rate); st_puts("/step forecast(next)=" as *u8); st_num(next); st_puts(" ETA-to-1bit=" as *u8); st_num(eta1); st_puts(" steps ready=" as *u8); st_num(fut_ready(team_has_1bit,1)); st_puts(" PREPARE-NOW=" as *u8); st_num(prep); st_puts("\n" as *u8) 24 25 // MARKET RESEARCHER: opportunities (value, feasibility, our grade, required grade); floor=50 26 let val: *i64 = sys_mmap(8*8) as *i64; let fea: *i64 = sys_mmap(8*8) as *i64; let grd: *i64 = sys_mmap(8*8) as *i64; let req: *i64 = sys_mmap(8*8) as *i64 27 // O0 edge inference on 16GB consumer O1 beat-SOTA quant (IP) O2 garden-sensor energy O3 low-value 28 val[0]=90; fea[0]=70; grd[0]=SG_A_PARITY; req[0]=SG_A_PARITY 29 val[1]=95; fea[1]=40; grd[1]=SG_A_PARITY; req[1]=SG_S_EXCEED 30 val[2]=60; fea[2]=80; grd[2]=SG_A_PARITY; req[2]=SG_A_PARITY 31 val[3]=20; fea[3]=90; grd[3]=SG_A_PARITY; req[3]=SG_A_PARITY 32 let floor: i64 = 50 33 let top: i64 = mkt_top_deliverable(4, val, fea, grd, req, floor) 34 let unlock: i64 = mkt_top_unlock(4, val, grd, req, floor) 35 st_puts(" [market] capitalize NOW on opportunity #" as *u8); st_num(top); st_puts(" (edge inference, deliverable) biggest UNLOCK to build = #" as *u8); st_num(unlock); st_puts(" (beat-SOTA quant, needs S-class)\n" as *u8) 36 st_puts(" -> BOTH point to the same build: close the rate-distortion gap to a SOTA-beating quantizer.\n" as *u8) 37 38 let r: *i64 = sys_mmap(8*8) as *i64 39 r[0] = 0; if rate == 0 - 4 { r[0] = 1 } // detected the decreasing trend 40 r[1] = 0; if prep == 1 { if fut_ready(0,1) == 0 { r[1] = 1 } } // not ready -> prepare now 41 r[2] = 0; if mkt_disposition(val[0],floor,grd[0],req[0]) == MKT_CAPITALIZE { if mkt_disposition(val[1],floor,grd[1],req[1]) == MKT_BUILD_FIRST { r[2] = 1 } } // deliverable vs build-first 42 r[3] = 0; if top == 0 { r[3] = 1 } // capitalize on edge inference now 43 r[4] = 0; if unlock == 1 { r[4] = 1 } // beat-SOTA quant = the unlock 44 var pass: i64 = 0; var i: i64 = 0 45 while i < 5 { pass = pass + r[i]; i = i + 1 } 46 st_puts("----\n passed " as *u8); st_num(pass); st_puts("/5\n" as *u8) 47 if pass == 5 { st_puts(" STRATEGY LIVE: Futurist sees 1-bit coming, Market sees edge-inference to ship + beat-SOTA-quant to build -- they agree on the next build.\n" as *u8); sys_exit(0); return 0 } 48 st_puts(" FAIL\n" as *u8); sys_exit(1); return 1 49}