protomotions.agents.common.discrete_latent module#
Reusable helpers for discrete latent targets, decoders, and GPC priors.
- class protomotions.agents.common.discrete_latent.DiscreteLatentQuantizer(*args, **kwargs)[source]#
Bases:
ProtocolInterface required by discrete latent adapters.
FSQ-style quantizers expose scalar-code dimensions with FSQ terminology so callers do not confuse them with autoregressive prior tokens.
- __init__(*args, **kwargs)#
- class protomotions.agents.common.discrete_latent.FSQTokenization(
- *,
- num_fsq_levels,
- num_fsq_scalars,
- fsq_scalars_per_prior_token,
Bases:
<Mock object at 0x7fd696f00490>[]Pack flat FSQ scalar indices into categorical prior tokens.
FSQ produces one small discrete index per latent scalar. The GPC prior consumes fewer categorical tokens by packing several FSQ scalar indices into a mixed-radix vocabulary entry.
- fsq_indices_to_prior_tokens(fsq_indices)[source]#
Pack
(batch, num_fsq_scalars)FSQ indices into prior tokens.
- class protomotions.agents.common.discrete_latent.DiscreteLatentDecoder(
- *,
- decoder,
- quantizer,
- latent_key='latent',
- decoder_out_key=None,
- freeze=True,
Bases:
<Mock object at 0x7fd696bd26d0>[]Frozen FSQ-code-to-action decoder path.
- class protomotions.agents.common.discrete_latent.DiscreteLatentTargetEncoder(*args, **kwargs)[source]#
Bases:
ProtoMotionsTensorDictModuleEncode target observations to FSQ indices, then pack prior tokens.
- protomotions.agents.common.discrete_latent.make_discrete_latent_decoder(module, *, freeze=True)[source]#
Adapt a module exposing decoder/quantizer to
DiscreteLatentDecoder.
- protomotions.agents.common.discrete_latent.load_pretrained_discrete_latent_decoder(config, device)[source]#
Load the frozen latent-index-to-action path from a pretrained module.