{"record":{"id":"aeb3936ba34d52d7","repo":"unslothai/unsloth","slug":"no-valid-examples-after-snac-preprocessing-skippe","errorCode":null,"errorMessage":"No valid examples after SNAC preprocessing (skipped {skipped})","messagePattern":"No valid examples after SNAC preprocessing \\(skipped (.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/training/trainer.py","lineNumber":2021,"sourceCode":"            except Exception as e:\n                logger.warning(f\"Error processing SNAC example {idx}: {e}\")\n                skipped += 1\n                continue\n\n            if (idx + 1) % 100 == 0:\n                self._update_progress(status_message = f\"Encoding audio... {idx + 1}/{len(dataset)}\")\n\n        logger.info(\"Freeing SNAC codec model from GPU...\\n\")\n        snac_model.to(\"cpu\")\n        del snac_model\n\n        gc.collect()\n\n        clear_gpu_cache()\n        self._cuda_audio_used = True\n\n        if not processed_examples:\n            raise ValueError(f\"No valid examples after SNAC preprocessing (skipped {skipped})\")\n\n        result_dataset = Dataset.from_list(processed_examples)\n        logger.info(\n            f\"SNAC preprocessing complete: {len(result_dataset)} examples \" f\"({skipped} skipped)\\n\"\n        )\n        return result_dataset\n\n    def _preprocess_bicodec_dataset(\n        self,\n        dataset,\n        custom_format_mapping = None,\n    ):\n        \"\"\"Preprocess dataset for Spark-TTS training with BiCodec tokenizer.\n\n        Mirrors Spark_TTS_(0_5B).ipynb: encode audio with BiCodec (semantic +\n        global tokens), format as special-token text strings for SFTTrainer\n        with dataset_text_field=\"text\".\n        \"\"\"","sourceCodeStart":2003,"sourceCodeEnd":2039,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/training/trainer.py#L2003-L2039","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before: relative audio paths, wrong cwd\nds[0]['audio']['path']  # 'wavs/0001.wav' — missing from cwd\n// after: absolute or verified paths\nimport os\nassert os.path.exists(ds[0]['audio']['path'])","handlingStrategy":"validation","validationCode":"def snac_examples_valid(dataset, n=3) -> bool:\n    for i in range(min(n, len(dataset))):\n        a = dataset[i]['audio']\n        if not (a.get('array') is not None and len(a['array']) > 0 and dataset[i]['text']):\n            return False\n    return True\n\nassert snac_examples_valid(dataset), \"examples fail SNAC input requirements\"","typeGuard":null,"tryCatchPattern":"try:\n    ds = trainer._preprocess_snac_dataset(dataset, mapping)\nexcept ValueError as e:\n    if 'No valid examples after SNAC preprocessing' in str(e):\n        # read per-example warnings; repair audio/text data and retry\n        ...","preventionTips":["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."],"tags":["audio","snac","dataset","data-quality"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}