oa::ResidualVectorQuantizer

ResidualVectorQuantizer class in the OA Ml public surface.

Inheritance

public Module

Public Methods

void oa::ResidualVectorQuantizer::emaUpdate(const ResidualVqResult & inResult)
oa::Matrix oa::ResidualVectorQuantizer::forward(const oa::Matrix & inZe)
VectorQuantizer & oa::ResidualVectorQuantizer::level(oa::I32 q)
oa::Matrix oa::ResidualVectorQuantizer::lookup(const oa::Vector<oa::Matrix> & inIdx)
oa::I32 oa::ResidualVectorQuantizer::numLevels()
ResidualVqResult oa::ResidualVectorQuantizer::quantize(const oa::Matrix & inZe)
void oa::ResidualVectorQuantizer::seed(const oa::Matrix & inLatents)

Constructor & Destructor Documentation

oa::ResidualVectorQuantizer::ResidualVectorQuantizer( const VectorQuantizerConfig & inConfig, oa::I32 inNumLevels )
No public source comment is attached to this declaration.

Parameters

inConfig
const VectorQuantizerConfig &

inNumLevels
oa::I32

void oa::ResidualVectorQuantizer::~ResidualVectorQuantizer()
No public source comment is attached to this declaration.

Public Method Documentation

void oa::ResidualVectorQuantizer::emaUpdate( const ResidualVqResult & inResult )
Per-level EMA codebook update; call once per step AFTER the optimizer step with the result returned by this step's quantize().

Parameters

inResult
const ResidualVqResult &

Returns

void

The declared return value.

oa::Matrix oa::ResidualVectorQuantizer::forward( const oa::Matrix & inZe )
No public source comment is attached to this declaration.

Parameters

inZe
const oa::Matrix &

Returns

oa::Matrix

The declared return value.

VectorQuantizer & oa::ResidualVectorQuantizer::level( oa::I32 q )
No public source comment is attached to this declaration.

Parameters

q
oa::I32

Returns

VectorQuantizer &

The declared return value.

oa::Matrix oa::ResidualVectorQuantizer::lookup( const oa::Vector<oa::Matrix> & inIdx )
Token → latent: sum each level's gathered code vectors. The inference-time inverse of quantize for the SUMMED RVQ output — pass per-level generated token ids (one [N] Int32 per level, shallow→deep) → z_q [N, D] for the decoder. inIdx may carry fewer than numLevels() levels (e.g. a model that only generates level 0); only the supplied levels are summed.

Parameters

inIdx
const oa::Vector<oa::Matrix> &

Returns

oa::Matrix

The declared return value.

oa::I32 oa::ResidualVectorQuantizer::numLevels()
No public source comment is attached to this declaration.

Returns

oa::I32

The declared return value.

ResidualVqResult oa::ResidualVectorQuantizer::quantize( const oa::Matrix & inZe )
z_e [N, D] → straight-through total quantization + per-level tokens + per-level residuals (kept for emaUpdate) + commitment loss. Records entirely on-GPU.

Parameters

inZe
const oa::Matrix &

Returns

ResidualVqResult

The declared return value.

void oa::ResidualVectorQuantizer::seed( const oa::Matrix & inLatents )
Greedy data-dependent seed: seed level 0 from the latents, then each deeper level from the running residual under the already-seeded shallower levels.

Parameters

inLatents
const oa::Matrix &

Returns

void

The declared return value.