unslothai/unsloth · error · ValueError
No valid examples after SNAC preprocessing (skipped {skipped
Error message
No valid examples after SNAC preprocessing (skipped {skipped}) What it means
ValueError raised after the SNAC encoding loop when processed_examples is empty — every example failed during codec encoding and was skipped. The SNAC model is loaded, audio encoded per example, and failures counted; if all rows fail, the error reports the skipped count and aborts before Dataset.from_list. The per-example exceptions were logged as warnings during the run.
Source
Thrown at studio/backend/core/training/trainer.py:2021
except Exception as e:
logger.warning(f"Error processing SNAC example {idx}: {e}")
skipped += 1
continue
if (idx + 1) % 100 == 0:
self._update_progress(status_message = f"Encoding audio... {idx + 1}/{len(dataset)}")
logger.info("Freeing SNAC codec model from GPU...\n")
snac_model.to("cpu")
del snac_model
gc.collect()
clear_gpu_cache()
self._cuda_audio_used = True
if not processed_examples:
raise ValueError(f"No valid examples after SNAC preprocessing (skipped {skipped})")
result_dataset = Dataset.from_list(processed_examples)
logger.info(
f"SNAC preprocessing complete: {len(result_dataset)} examples " f"({skipped} skipped)\n"
)
return result_dataset
def _preprocess_bicodec_dataset(
self,
dataset,
custom_format_mapping = None,
):
"""Preprocess dataset for Spark-TTS training with BiCodec tokenizer.
Mirrors Spark_TTS_(0_5B).ipynb: encode audio with BiCodec (semantic +
global tokens), format as special-token text strings for SFTTrainer
with dataset_text_field="text".
"""View on GitHub (pinned to 203007d190)
Solutions
- Inspect the loop's logged per-example warnings to identify the recurring exception.
- Manually decode one example: check dataset[0]['audio'] yields bytes and plays back; verify its path exists.
- Repair or re-ingest the audio data, then rebuild the dataset.
- Confirm you are not feeding a metadata-only dataset (e.g. only paths, no actual files).
Example fix
// before: relative audio paths, wrong cwd ds[0]['audio']['path'] # 'wavs/0001.wav' — missing from cwd // after: absolute or verified paths import os assert os.path.exists(ds[0]['audio']['path'])
Defensive patterns
Strategy: validation
Validate before calling
def snac_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 len(a['array']) > 0 and dataset[i]['text']):
return False
return True
assert snac_examples_valid(dataset), "examples fail SNAC input requirements" Try / catch
try:
ds = trainer._preprocess_snac_dataset(dataset, mapping)
except ValueError as e:
if 'No valid examples after SNAC preprocessing' in str(e):
# read per-example warnings; repair audio/text data and retry
... Prevention
- Spot-check several examples for decodable audio and non-empty transcripts before training.
- Keep audio files at stable absolute paths, or embed audio in the dataset.
- Log skip reasons prominently during preprocessing so systemic failures are debuggable.
When it happens
Trigger: 100% of examples fail SNAC codec encoding: unreadable/zero-length audio, sample-rate decode failures, transcripts that break tokenization, or the audio column containing path strings to files that no longer exist.
Common situations: Audio files deleted or moved after dataset creation; Audio column storing relative paths resolved from the wrong cwd; corrupt audio encodings; transcripts empty for all rows.
Related errors
- No valid examples after CSM preprocessing (skipped {skipped}
- SNAC dataset needs 'audio' and 'text' columns, got: {dataset
- No valid examples after BiCodec preprocessing (skipped {skip
- No valid examples after DAC preprocessing (skipped {skipped}
- No valid examples after Whisper preprocessing
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/aeb3936ba34d52d7.
Report an issue: GitHub.