unslothai/unsloth · error · ValueError

No valid examples after BiCodec preprocessing (skipped {skip

Error message

No valid examples after BiCodec preprocessing (skipped {skipped})

What it means

ValueError raised at the end of BiCodec preprocessing when every example failed and was skipped, leaving processed_examples empty. During the loop each failure was caught and logged as a warning; after freeing the tokenizer from GPU the function checks the result and aborts with the skipped count. It indicates a systemic data problem (schema passed, contents failed), not a single bad row.

Source

Thrown at studio/backend/core/training/trainer.py:2212

                continue

            if (idx + 1) % 100 == 0:
                self._update_progress(
                    status_message = f"Encoding audio with BiCodec... {idx + 1}/{len(dataset)}"
                )

        logger.info("Freeing BiCodec tokenizer from GPU...\n")
        audio_tokenizer.model.cpu()
        audio_tokenizer.feature_extractor.cpu()
        del audio_tokenizer

        gc.collect()

        clear_gpu_cache()
        self._cuda_audio_used = True

        if not processed_examples:
            raise ValueError(f"No valid examples after BiCodec preprocessing (skipped {skipped})")

        result_dataset = Dataset.from_list(processed_examples)
        logger.info(
            f"BiCodec preprocessing complete: {len(result_dataset)} examples "
            f"({skipped} skipped)\n"
        )
        sample = result_dataset[0]["text"]
        logger.info(f"Sample text (first 200 chars): {sample[:200]}...\n")
        logger.info(f"Sample text length: {len(sample)} chars\n")
        return result_dataset

    def _preprocess_dac_dataset(
        self,
        dataset,
        custom_format_mapping = None,
    ):
        """Preprocess dataset for OuteTTS training with DAC codec.

View on GitHub (pinned to 203007d190)

Solutions

  1. Review the per-example warning logs from the loop for the underlying exception class and message.
  2. Test one example manually: load its audio, run audio_volume_normalize, and confirm it succeeds.
  3. Re-encode the audio to standard wav (e.g. 44.1kHz mono) and rebuild the dataset.
  4. Verify transcript strings are non-empty and validly encoded.

Example fix

// before: dataset has empty transcripts for all rows
// after: filter/repair rows with empty text before training
rows = [r for r in rows if r['text'].strip() and os.path.exists(r['audio'])]
Defensive patterns

Strategy: validation

Validate before calling

import numpy as np

def bicodec_examples_valid(dataset, n=3) -> bool:
    for i in range(min(n, len(dataset))):
        a = dataset[i]['audio']
        if not (a.get('array') is not None and np.asarray(a['array']).size > 0
                and isinstance(dataset[i]['text'], str) and dataset[i]['text'].strip()):
            return False
    return True

assert bicodec_examples_valid(dataset), "examples fail BiCodec preprocessing"

Try / catch

try:
    ds = trainer._preprocess_bicodec_dataset(dataset, mapping)
except ValueError as e:
    if 'No valid examples after BiCodec preprocessing' in str(e):
        # inspect warnings; fix audio decoding / empty transcripts, then retry
        ...

Prevention

When it happens

Trigger: All examples fail BiCodec tokenization/audio-volume-normalization: unreadable audio, wrong sample rates the loop's resampling rejects, empty transcripts, or audio paths that do not resolve.

Common situations: Audio files unavailable at their recorded paths; audio in a format the decoder cannot read; transcripts with encoding issues; dataset built on another machine with different absolute paths.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/adae86ed607fd3e8. Report an issue: GitHub.