code wiki / _hdl_build / nx_ng_hashenc.nx
nx_ng_hashenc.nx
buildroot/runtime/_hdl_build/nx_ng_hashenc.nx
about
nx_ng_hashenc.nx -- CAP-HASH-ENCODING, generation 9: the core contribution of Instant-NGP (Mueller et al.
2022, arxiv 2201.05989, the repo the operator linked). The measured CLAIM that justifies the method: a
LEARNABLE interpolated FEATURE-GRID encoding represents high-frequency detail that a model of the RAW
coordinate cannot -- cheap, fast, "seconds not hours".
Honest measured-exceed, isolated on the ENCODING (operator: capability is the exceed, measured, no wave).
Two models trained on the SAME maximally-high-frequency target, differing ONLY in how the input coordinate
is represented:
PLAIN out_i = a*x_i + b -- the raw coordinate (affine). Provably can only draw a LINE, so it
cannot fit an oscillating signal. (convex -> trains robustly to its
best-line plateau = an honest, non-fragile failure.)
HASH out_i = interp(feat[i],feat[i+1]) -- a learnable interpolated feature grid (the encoding core).
Linear in the features -> convex -> fits the high-freq field.
Gate: T1 HASH FITS (SSE collapses >=95%), T2 PLAIN FAILS (its SSE stays high), T3 MEASURED EXCEED
(loss_plain >= 4x loss_hash), T4 BIT-EXACT (train twice -> identical integer features). HONEST: this isolates
the encoding; composing it with a trainable MLP readout (proven in nx_ng_radiance) + the MULTI-resolution
levels + spatial hashing (3D/high-dim scaling) are the follow-on rungs. Sovereign: nx_nofloat_autograd +
syscalls, no float. license_tier: ORIGINAL expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_nofloat_autograd.nxnx_itoa_lib.nxnx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 22 | const LR_MAGIC_32768: i64 = 32768 |
| 23 | const LR_MAGIC_6553: i64 = 6553 |
| 24 | const LR_MAGIC_1234: i64 = 1234 |
| 25 | const LR_MAGIC_26000: i64 = 26000 |
| 26 | const LR_MAGIC_1024: i64 = 1024 |
| 27 | const LR_MAGIC_16384: i64 = 16384 |
| 28 | const LR_MAGIC_58982: i64 = 58982 |
| 30 | const HLOG: *u8 = "knowledge/status/ng_hashenc.log" |
| 31 | const Q16: i64 = 65536 |
| 32 | const NC: i64 = 8 // sample coords (high-frequency target) |
| 33 | const NG: i64 = 9 // grid vertices (NC+1) for the feature encoding |
| 34 | const EPOCHS: i64 = 6000 |
| 35 | const LR_PLAIN: i64 = 1024 // raw-coord affine: small lr (it diverges/overflows at high lr) -> stable plateau |
| 36 | const LR_HASH: i64 = 8192 // convex feature grid: fast. Per-model lr = each trained to its representational best. |
functions
| 38 | func hp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 43 | func hpn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 44 | func hl_ws(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 49 | func hl_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 52 | func plain_build(tape: *i64, vals: *i64, st: *i64, coords: *i64, targ: *i64, p: *i64, wn: *i64) -> i64 |
| 70 | func hash_build(tape: *i64, vals: *i64, st: *i64, featp: *i64, targ: *i64, fn: *i64) -> i64 |
| 87 | func train_plain(tape: *i64, vals: *i64, grads: *i64, st: *i64, coords: *i64, targ: *i64, lf: *i64, ll: *i64) -> i64 |
| 102 | func train_hash(tape: *i64, vals: *i64, grads: *i64, st: *i64, targ: *i64, featout: *i64, lf: *i64, ll: *i64) -> i64 |
| 120 | func main() -> i64 |