nx_model_port_registry.nx source
↩ module page · 89 lines · 4829 B
1// nx_model_port_registry.nx -- the STANDARD sovereign MODEL-PORT registry: ONE data-driven place that maps every
2// ported (or target) external model -> {family, source URL path, container format, loader organ, status}. Today the
3// ecosystem ports models by COPY-PASTE (nx_hifigan_*, nx_apertus_*, nx_qwen_*/gguf each hardcode their URL, shards,
4// shas, format inline) -- there is no queryable "what have we ported + how" backbone and no format->driver dispatch.
5// This organ is that backbone: a reusable LIBRARY (no main) the team + the generic port-driver query, so porting a
6// NEW model becomes "add a registry row + reuse the fetch/verify/parse/dequant/load organs", not a new copy-paste.
7// Provenance is LIAR-KILLED downstream (nx_model_port_registry_gate opens every entry's loader organ). Data-as-data
8// (rule 11/6): all model facts are table rows, no logic hardcodes a URL. license_tier: ORIGINAL
9import "nx_syscalls.nx"
10
11const MPR_N: i64 = 4 // registry entries
12const MPR_FIELDS: i64 = 6 // name, family, source, format, loader, status
13// field ids
14const MPR_NAME: i64 = 0
15const MPR_FAMILY: i64 = 1
16const MPR_SOURCE: i64 = 2
17const MPR_FORMAT: i64 = 3
18const MPR_LOADER: i64 = 4
19const MPR_STATUS: i64 = 5
20
21func mpr_streq(a: *u8, b: *u8) -> i64 {
22 var i: i64 = 0
23 while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 }
24 if b[i] != (0 as u8) { return 0 }
25 return 1
26}
27
28func mpr_count() -> i64 { return MPR_N }
29
30// fill the caller-allocated table (MPR_N*MPR_FIELDS i64 slots, each an *u8 as i64). Seeded with the REAL existing
31// ports (verified by the reconnaissance: HiFiGAN pytorch-bin, Apertus safetensors shards, Qwen GGUF) + the pose
32// benchmark TARGET (forward already built = nx_pose_cnn; weights pending -> status candidate).
33func mpr_init(tbl: *i64) -> i64 {
34 // 0: SpeechT5 HiFiGAN vocoder -- the non-LLM conv-net port precedent
35 tbl[0*6+0] = ("speecht5-hifigan" as *u8) as i64
36 tbl[0*6+1] = ("vocoder" as *u8) as i64
37 tbl[0*6+2] = ("microsoft/speecht5_hifigan/resolve/main/pytorch_model.bin" as *u8) as i64
38 tbl[0*6+3] = ("pytorch-bin" as *u8) as i64
39 tbl[0*6+4] = ("runtime/nx_hifigan_load.nx" as *u8) as i64
40 tbl[0*6+5] = ("LIVE" as *u8) as i64
41 // 1: Apertus-8B -- safetensors sharded mirror
42 tbl[1*6+0] = ("apertus-8b" as *u8) as i64
43 tbl[1*6+1] = ("llm" as *u8) as i64
44 tbl[1*6+2] = ("adamo1139/Apertus-8B-Instruct-2509-ungated/resolve/main" as *u8) as i64
45 tbl[1*6+3] = ("safetensors" as *u8) as i64
46 tbl[1*6+4] = ("runtime/nx_apertus_shards_pull.nx" as *u8) as i64
47 tbl[1*6+5] = ("mirrored" as *u8) as i64
48 // 2: Qwen2.5-0.5B -- the no-float GGUF port (LIVE serving)
49 tbl[2*6+0] = ("qwen2.5-0.5b-nf" as *u8) as i64
50 tbl[2*6+1] = ("llm" as *u8) as i64
51 tbl[2*6+2] = ("qwen2.5-0.5b (GGUF quant)" as *u8) as i64
52 tbl[2*6+3] = ("gguf" as *u8) as i64
53 tbl[2*6+4] = ("runtime/nx_gguf_load_f32.nx" as *u8) as i64
54 tbl[2*6+5] = ("LIVE" as *u8) as i64
55 // 3: POSE BENCHMARK -- RESOLVED live (nx_model_enumerate, status 200 ungated): ViTPose-base-simple, single
56 // model.safetensors 343673076 B, sha256 85375373893ddd3641f3912821073e53f5435f9e966e1dca59d004454bfe4fdf.
57 tbl[3*6+0] = ("pose-benchmark" as *u8) as i64
58 tbl[3*6+1] = ("pose" as *u8) as i64
59 tbl[3*6+2] = ("usyd-community/vitpose-base-simple/resolve/main/model.safetensors" as *u8) as i64
60 tbl[3*6+3] = ("safetensors" as *u8) as i64
61 tbl[3*6+4] = ("runtime/nx_pose_cnn.nx" as *u8) as i64
62 tbl[3*6+5] = ("DOWNLOADED+sha256-VERIFIED (models/vitpose-base-simple.safetensors, 343673076B)" as *u8) as i64
63 return 0
64}
65
66func mpr_get(tbl: *i64, idx: i64, field: i64) -> *u8 {
67 return (tbl[idx * MPR_FIELDS + field]) as *u8
68}
69
70// find an entry index by name, or -1.
71func mpr_lookup(tbl: *i64, name: *u8) -> i64 {
72 var i: i64 = 0
73 while i < MPR_N {
74 if mpr_streq((tbl[i * MPR_FIELDS + MPR_NAME]) as *u8, name) == 1 { return i }
75 i = i + 1
76 }
77 return 0 - 1
78}
79
80// the STANDARD driver dispatch: given a container format, name the sovereign parse+load organ chain the generic
81// driver composes. This is what makes porting repeatable -- the format decides the loader, not a copy-paste.
82func mpr_driver_for(fmt: *u8) -> *u8 {
83 if mpr_streq(fmt, "gguf" as *u8) == 1 { return "nx_gguf_load_f32 (meta -> per-type dequant -> f32)" as *u8 }
84 if mpr_streq(fmt, "safetensors" as *u8) == 1 { return "nx_safetensors st_tensor -> F32 direct / F16|BF16 convert -> f32" as *u8 }
85 if mpr_streq(fmt, "pytorch-bin" as *u8) == 1 { return "nx_hifigan_load-style ZIP/pickle parse -> stored f32" as *u8 }
86 return 0 as *u8 // unknown format -> no driver (null); caller must add a parser
87}
88
89func mpr_open(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }