oa::VectorQuantizer
VectorQuantizer class in the OA Ml public surface.
Inheritance
public Module
Public Methods
Constructor & Destructor Documentation
Public Method Documentation
No public source comment is attached to this declaration.
Returns
const oa::Matrix &The declared return value.
No public source comment is attached to this declaration.
Returns
oa::Matrix &The declared return value.
No public source comment is attached to this declaration.
Returns
const VectorQuantizerConfig &The declared return value.
EMA codebook update + dead-code reinit. call ONCE per step AFTER the optimizer step, with this step's z_e and the idx returned by quantize(). in-place on the codebook buffer (so it stays the same checkpointed buffers() entry).
Parameters
inZeconst oa::Matrix &—
inIdxconst oa::Matrix &—
Returns
voidThe declared return value.
Module forward returns just the straight-through quantized tensor.
Parameters
inZeconst oa::Matrix &—
Returns
oa::MatrixThe declared return value.
Token → latent: gather the code vectors for the given indices ([N] Int32, the dtype VqAssign emits, or any generated ids). The inference-time inverse of the nearest-code assignment — feed generated token ids straight back through it to reconstruct z_q [N, D] for the decoder. Pure lookup, no STE.
Parameters
inIdxconst oa::Matrix &—
Returns
oa::MatrixThe declared return value.
z_e [N, D] (RMS-normalized latents recommended) → quantized (STE) + code indices + commitment loss. Records entirely on-GPU.
Parameters
inZeconst oa::Matrix &—
Returns
VqResultThe declared return value.
Data-dependent init: seed the K codes from the K HIGHEST-NORM rows of inLatents ([>= K, D] encoder outputs) — NOT the first K, which is degenerate for residual VQ (rows a shallow level used → ~zero residual → a deeper codebook seeds all zeros and dies). Highest-norm rows are never zero, so every level gets live, distinct codes. writes the codebook IN-PLACE (copyFrom) so the registered buffers() entry stays valid. Completes inLatents before reading.
Parameters
inLatentsconst oa::Matrix &—
Returns
voidThe declared return value.