mstar.model.cosmos3.components.sound_tokenizer#
Cosmos3 AVAE sound tokenizer (decoder-only), ported from the diffusers-format
sound_tokenizer/ checkpoint component that ships with the Cosmos3 models.
The checkpoint is an Oobleck-style 1D decoder (Snake activations, weight-normed
convs) that turns joint-denoised sound latents [B, C=64, T] into a waveform
[B, channels=2, T * hop_size] at 48 kHz. The safetensors decoder.* keys
use the classic weight_g/weight_v weight-norm naming, which this module
reproduces one-to-one so loading is a plain name-matching stream with a
completeness check (same design as the transformer loader).
Classes
|
Decoder-only AVAE for Cosmos3 sound latents. |
|
Latent [B, C_latent, T] -> waveform [B, audio_channels, T * prod(strides)]. |
|
Upsampling block: snake -> transposed conv (stride upsample) -> 3 residual units. |
|
Dilated residual unit (snake -> conv k7 -> snake -> conv k1). |
|
1D Snake activation ( |
- class mstar.model.cosmos3.components.sound_tokenizer.Cosmos3SoundTokenizer(config)[source]#
Bases:
ModuleDecoder-only AVAE for Cosmos3 sound latents.
Built from the checkpoint’s
sound_tokenizer/config.json(Oobleck decoder geometry, sample rate, channel count, hop size) and loaded strictly fromsound_tokenizer/diffusion_pytorch_model.safetensors— every decoder parameter must be filled, so a layout drift surfaces as a load error rather than silently wrong audio.- CONFIG_NAME = 'config.json'#
- WEIGHTS_NAME = 'diffusion_pytorch_model.safetensors'#
- decode(latents)[source]#
Sound latents
[B, C, T]or[C, T]-> waveform in [-1, 1] ([B, audio_channels, T * hop_size], squeezed for unbatched input).
- classmethod from_pretrained(checkpoint_dir, device='cpu', dtype=torch.bfloat16)[source]#
- Parameters:
- Return type:
- class mstar.model.cosmos3.components.sound_tokenizer.OobleckDecoder(channels, input_channels, audio_channels, upsampling_ratios, channel_multiples)[source]#
Bases:
ModuleLatent [B, C_latent, T] -> waveform [B, audio_channels, T * prod(strides)].
- Parameters:
- forward(hidden_state)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.cosmos3.components.sound_tokenizer.OobleckDecoderBlock(input_dim, output_dim, stride=1, output_padding=0)[source]#
Bases:
ModuleUpsampling block: snake -> transposed conv (stride upsample) -> 3 residual units.
- forward(hidden_state)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.cosmos3.components.sound_tokenizer.OobleckResidualUnit(dimension=16, dilation=1)[source]#
Bases:
ModuleDilated residual unit (snake -> conv k7 -> snake -> conv k1).
- forward(hidden_state)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class mstar.model.cosmos3.components.sound_tokenizer.Snake1d(hidden_dim, logscale=True)[source]#
Bases:
Module1D Snake activation (
x + 1/b * sin^2(a x)) with log-scale parameters.- forward(hidden_states)[source]#
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.