nx_live_fire_gguf.nx source
↩ module page · 72 lines · 3454 B
1// nx_live_fire_gguf.nx -- live-fire end-to-end GGUF round-trip on real disk.
2//
3// This is NOT a synthetic in-memory smoke. It exercises:
4// 1. Build a Llama-shape GGUF in a buffer (3 top-level tensors)
5// 2. WRITE the buffer to /tmp/nx_live_fire.gguf via sys_write
6// 3. CLOSE the file
7// 4. READ it back via sys_read_file (re-opens, sys_read into mmap)
8// 5. Parse the header via nx_gguf_parse
9// 6. LAZY-load every tensor handle via nx_gguf_load_tensor_lazy
10// (Phase B of the conductor arc; zero-RAM tensor handles)
11// 7. MATERIALIZE on demand via nx_placed_tensor_get
12// 8. VERIFY the dequantized values bit-exactly match the source
13// we wrote 4 syscalls ago (proves disk round-trip + dequant
14// pipeline is end-to-end correct)
15// 9. MEASURE elapsed monotonic time via sys_clock_gettime_mono +
16// assert each phase is under generous budget
17//
18// Why this matters (live-fire vs synthetic-smoke discipline):
19// * Synthetic in-memory smokes (all 9 bricks shipped so far this
20// session) prove ALGORITHMIC correctness on hand-built buffers.
21// * THIS smoke proves the same primitives survive a kernel-mediated
22// file-system round-trip (write(2) -> close(2) -> openat(2) ->
23// read(2)) which is the actual deployment path for real-model
24// loading.
25// * If any of: file-descriptor leakage, buffered-write inversion,
26// mmap-vs-read alignment, byte-order on RV64 host -- bit-exact
27// comparison after disk round-trip catches it.
28// * Per the honest-perf-verdict cardinal: timing assertions in the
29// smoke are SIGNAL-ONLY, not the verdict. The verdict is
30// correctness; timing is recorded for trend visibility.
31//
32// Bits-up composition:
33// nx_syscalls.nx -- sys_openat_wr / sys_write / sys_close
34// / sys_read_file / sys_clock_gettime_mono
35// nx_le.nx -- header byte writers
36// nx_gguf.nx + nx_gguf_load.nx
37// -- parse + per-tensor dequant
38// nx_placement.nx -- lazy placement
39// nx_gguf_load_lazy.nx -- Phase B lazy loader
40//
41// genealogy_id: posix_file_round_trip + ggml_format_canon
42// lineage_id: substrate_live_fire_v1_disk_round_trip
43
44// nx_safety_envelope:
45// intended_use: "Live-fire end-to-end disk-backed GGUF
46// round-trip + lazy load + materialize +
47// bit-exact value verification + timing
48// budget assertion"
49// sil_target: SIL2
50// evidence: [real_file_system_io_exercised,
51// bit_exact_disk_round_trip_verified,
52// timing_budget_signal_only_per_honest_perf]
53// verdict: NOT_YET_EVALUATED
54
55import "nx_syscalls.nx"
56import "nx_tier.nx"
57import "nx_le.nx"
58import "nx_tensor.nx"
59import "nx_gguf.nx"
60import "nx_gguf_load.nx"
61import "nx_placement.nx"
62import "nx_gguf_load_lazy.nx"
63
64// Generous timing budgets (signal-only per the honest-perf cardinal).
65// On qemu-riscv64 these are pessimistic; on native they'll be much
66// faster. If we ever exceed them something has gone structurally
67// wrong (sync-write to network FS, swap thrashing, etc.).
68const NX_LF_WRITE_BUDGET_MS: i64 = 2000
69const NX_LF_READ_BUDGET_MS: i64 = 2000
70const NX_LF_PARSE_BUDGET_MS: i64 = 500
71const NX_LF_LAZY_LOAD_BUDGET_MS: i64 = 500
72const NX_LF_MATERIALIZE_BUDGET_MS: i64 = 500