{"record":{"id":"8c07def07222f8e6","repo":"microsoft/VibeVoice","slug":"unsupported-dist-type-dist-type-expected-fix","errorCode":null,"errorMessage":"Unsupported dist_type: {dist_type}, expected 'fix' or 'gaussian'","messagePattern":"Unsupported dist_type: (.+?), expected 'fix' or 'gaussian'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"vibevoice/modular/modular_vibevoice_tokenizer.py","lineNumber":1109,"sourceCode":"                nn.init.zeros_(module.bias)\n    \n    @torch.no_grad()\n    def encode(self, audio, cache=None, sample_indices=None, use_cache=False, debug=False, is_final_chunk=False):\n        \"\"\"Convert audio to latent representations\"\"\"\n        latents = self.encoder(audio, cache=cache, sample_indices=sample_indices, use_cache=use_cache, debug=debug, is_final_chunk=is_final_chunk)\n        return VibeVoiceTokenizerEncoderOutput(mean=latents.permute(0, 2, 1), std=self.fix_std)\n    \n    @torch.no_grad()\n    def sampling(self, encoder_output, dist_type=None):\n        \"\"\"Sample from the encoder output distribution\"\"\"\n        dist_type = dist_type or self.std_dist_type\n    \n        if dist_type == 'fix':\n            return encoder_output.sample(dist_type='fix')\n        elif dist_type == 'gaussian':\n            return encoder_output.sample(dist_type='gaussian')\n        else:\n            raise ValueError(f\"Unsupported dist_type: {dist_type}, expected 'fix' or 'gaussian'\")\n    \n    @torch.no_grad()\n    def decode(self, latents, cache=None, sample_indices=None, use_cache=False, debug=False):\n        \"\"\"Convert latent representations back to audio\"\"\"\n        if latents.shape[1] == self.config.vae_dim:\n            pass\n        else:\n            latents = latents.permute(0, 2, 1)\n\n        audio = self.decoder(latents, cache=cache, sample_indices=sample_indices, use_cache=use_cache, debug=debug)\n        return audio\n\n    def forward(self, audio, cache=None, sample_indices=None, use_cache=False, debug=False):\n        \"\"\"Full forward pass: encode audio to latents, then decode back to audio\"\"\"\n        encoder_output = self.encode(audio, cache=cache, sample_indices=sample_indices, use_cache=use_cache, debug=debug)\n        sampled_latents, _ = self.sampling(encoder_output)\n        reconstructed = self.decode(sampled_latents, cache=cache, sample_indices=sample_indices, use_cache=use_cache, debug=debug)\n        return reconstructed, sampled_latents","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/microsoft/VibeVoice/blob/94da20d98b2fa7688e9cbfaf7692ddb4954f7600/vibevoice/modular/modular_vibevoice_tokenizer.py#L1091-L1127","documentation":"The tokenizer's `sampling()` method draws latents from the encoder output distribution. The distribution type must be 'fix' (deterministic, using the stored fixed std) or 'gaussian' (sample from N(mean, std)). The value comes from the `dist_type` argument or, when omitted, from the model's `std_dist_type` attribute; anything else raises this ValueError.","triggerScenarios":"Calling model.sampling(encoder_output, dist_type='fixed'), dist_type='' or any string other than 'fix'/'gaussian'; or configuring the model with a std_dist_type default that is None or misspelled and then calling sampling() with no explicit dist_type.","commonSituations":"Users migrating from another VAE codebase that uses 'deterministic'/'stochastic' terminology, or setting std_dist_type in a config file with the wrong casing ('Fix', 'GAUSSIAN'). Also occurs when dist_type is left unset on a config that never defined std_dist_type.","solutions":["Pass dist_type='fix' or dist_type='gaussian' explicitly to sampling().","If omitting the argument, set the model's std_dist_type (or the corresponding config field) to 'fix' or 'gaussian' at construction time.","Check for leading/trailing whitespace or casing mistakes in config-driven values (matching is exact)."],"exampleFix":"# before\nlatents = model.sampling(encoder_output)  # std_dist_type unset -> ValueError\n\n# after\nlatents = model.sampling(encoder_output, dist_type='gaussian')","handlingStrategy":"validation","validationCode":"SUPPORTED_DIST = {'fix', 'gaussian'}\ndist = dist_type or model.std_dist_type\nassert dist in SUPPORTED_DIST, f'dist_type must be {SUPPORTED_DIST}, got {dist!r}'\nlatents = model.sampling(encoder_output, dist_type=dist)","typeGuard":"def is_supported_dist_type(value) -> bool:\n    return isinstance(value, str) and value in ('fix', 'gaussian')","tryCatchPattern":"try:\n    latents = model.sampling(encoder_output, dist_type=dist_type)\nexcept ValueError as e:\n    if 'Unsupported dist_type' in str(e):\n        latents = model.sampling(encoder_output, dist_type='fix')  # explicit safe default\n    else:\n        raise","preventionTips":["Always pass dist_type explicitly instead of relying on std_dist_type defaults.","Whitelist config-sourced strings through {'fix','gaussian'} before use.","Normalize case and strip whitespace on config values at load time."],"tags":["sampling","config","tokenizer","vae"],"backgroundTag":null,"analyzedSha":"94da20d98b2fa7688e9cbfaf7692ddb4954f7600","analyzedAt":"2026-08-15T04:12:07.418Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}