unslothai/unsloth · error · ValueError

No valid examples after CSM preprocessing (skipped {skipped}

Error message

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

What it means

ValueError raised at the end of the CSM example loop when processed_examples is empty — every single example hit the per-example 'except Exception' path and was skipped. The count of skipped examples is included. It means the dataset schema passed column validation but the contents (audio decoding, feature extraction, tokenizer behavior) failed for 100% of rows, so training cannot proceed.

Source

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

                if not all(isinstance(out[k], torch.Tensor) for k in out):
                    skipped += 1
                    continue

                processed_examples.append(out)

            except Exception as e:
                logger.warning(f"Error processing CSM example {idx}: {e}")
                skipped += 1
                continue

            if (idx + 1) % 100 == 0:
                self._update_progress(
                    status_message = f"Preprocessing CSM... {idx + 1}/{len(dataset)}"
                )

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

        result_dataset = Dataset.from_list(processed_examples)
        logger.info(
            f"CSM preprocessing complete: {len(result_dataset)} examples " f"({skipped} skipped)\n"
        )
        return result_dataset

    def _format_audio_vlm_dataset(
        self,
        dataset,
        custom_format_mapping = None,
    ):
        """Format dataset as audio chat messages for multimodal models (e.g. Gemma 3N).

        Expects columns audio (Audio), text (str). Produces a messages column
        with system/user/assistant chat format.
        """
        from datasets import Audio

View on GitHub (pinned to 203007d190)

Solutions

  1. Read the preceding per-example warnings ('Error processing CSM example ...') — they contain the actual exception that skipped every row.
  2. Spot-check a few examples: open dataset[0]['audio'] and confirm it decodes (bytes/path valid, non-empty).
  3. Fix the data: restore/repair audio files, re-encode to wav/flac, or rebuild the dataset with absolute paths.
  4. If one bad file poisons the whole run, quarantine it and retry — but note this error means ALL examples were skipped.

Example fix

// before: dataset rows reference moved files
ds[0]['audio']['path']  # '/old-location/0001.wav' (gone)
// after: rebuild with current paths
from datasets import Audio
ds = ds.cast_column('audio', Audio())  # re-generate from corrected metadata
Defensive patterns

Strategy: validation

Validate before calling

def first_example_decodes(dataset, audio_col='audio') -> bool:
    try:
        sample = dataset[0][audio_col]
        return bool(sample and (sample.get('array') is not None or sample.get('bytes')))
    except Exception:
        return False

assert first_example_decodes(dataset), "audio does not decode — fix data before CSM preprocessing"

Try / catch

try:
    ds = trainer._preprocess_csm_dataset(dataset, mapping)
except ValueError as e:
    if 'No valid examples after CSM preprocessing' in str(e):
        # inspect the earlier 'Error processing CSM example' warnings for root cause
        ...

Prevention

When it happens

Trigger: All rows fail inside the loop: corrupt or unreadable audio bytes, wrong file paths in an Audio column of path type, sample-rate/channel problems the feature extractor rejects, or transcript encoding errors. Each row logs 'Error processing CSM example {idx}: {e}' — those warnings name the root cause.

Common situations: Audio files moved/deleted after the dataset was built; dataset rows store relative paths but the process runs from a different cwd; audio format not supported by the decoder (e.g. exotic codecs); upstream preprocessing produced empty or zero-length audio.

Related errors


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