code wiki / (root) / nx_rvq.nx

nx_rvq.nx

buildroot/runtime/nx_rvq.nx

2074 B46 linesdepth 1pulls 1 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rvq.nx -- RESIDUAL VECTOR QUANTIZATION, moonshot rung #3 and the literal structure inside SoundStream / Lyra-v2 / Encodec: a stack of S codebooks where stage k quantises the RESIDUAL left by stages 0..k-1. Reconstruction is the sum of the chosen stage centroids; each added stage costs log2(K) bits and shrinks the residual -> a rate-distortion knob. The neural codec replaces these fixed centroids with learned ones over a learned latent; the structure is identical. Composes nx_vq (+ nx_vq_train trains each stage on its residuals). license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_vq.nx nx_rvq.nx nx_rvq_gate.nx

imports: nx_vq.nx

imported by: nx_rvq_gate.nx

structs

none

consts

none

functions

9func rvq_stage(cbs: *i64, k: i64, K: i64, D: i64) -> *i64 { return (cbs as i64 + k*K*D*8) as *i64 }
12func rvq_encode(v: *i64, D: i64, cbs: *i64, K: i64, S: i64, indices: *i64, resid: *i64) -> i64
called by 1: main calls 2: rvq_stagevq_encode
27func rvq_decode_partial(indices: *i64, cbs: *i64, K: i64, D: i64, stages: i64, out: *i64) -> i64
called by 1: main calls 1: rvq_stage
41func rvq_dist(v: *i64, out: *i64, D: i64) -> i64
called by 1: main