{"record":{"id":"6db113e103f88d23","repo":"huggingface/transformers","slug":"error-loading-audio-e","errorCode":null,"errorMessage":"Error loading audio: {e}","messagePattern":"Error loading audio: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/transformers/audio_utils.py","lineNumber":375,"sourceCode":"        if force_mono and audio_array.ndim != 1:\n            audio_array = audio_array.mean(axis=1)\n\n        buffer = io.BytesIO()\n        sf.write(buffer, audio_array, sampling_rate, format=audio_format.upper())\n        buffer.seek(0)\n\n        if return_format == \"buffer\":\n            return buffer\n        elif return_format == \"base64\":\n            return base64.b64encode(buffer.read()).decode(\"utf-8\")\n        elif return_format == \"dict\":\n            return {\n                \"data\": base64.b64encode(buffer.read()).decode(\"utf-8\"),\n                \"format\": audio_format.lower(),\n            }\n\n    except Exception as e:\n        raise ValueError(f\"Error loading audio: {e}\")\n\n\ndef conv1d_output_length(module: \"torch.nn.Conv1d\", input_length: int) -> int:\n    \"\"\"\n    Computes the output length of a 1D convolution layer according to torch's documentation:\n    https://docs.pytorch.org/docs/stable/generated/torch.nn.Conv1d.html\n    \"\"\"\n    return int(\n        (input_length + 2 * module.padding[0] - module.dilation[0] * (module.kernel_size[0] - 1) - 1)\n        / module.stride[0]\n        + 1\n    )\n\n\ndef is_valid_audio(audio):\n    return (\n        is_numpy_array(audio)\n        or is_torch_tensor(audio)","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/audio_utils.py#L357-L393","documentation":"After massaging the DeepSpeed config against TrainingArguments, `fill_match` recorded every key where the user's DeepSpeed config value conflicts with the Trainer-computed value (batch size, gradient accumulation, optimizer/scheduler params like `total_num_steps`, `warmup_num_steps`, learning rate, etc.). Non-empty `mismatches` abort training with this aggregated ValueError; the recommended remedy baked into the message is to set those DeepSpeed entries to `'auto'` so transformers fills them.","triggerScenarios":"Passing a DeepSpeed config with hardcoded `train_micro_batch_size_per_gpu`, `gradient_accumulation_steps`, `scheduler.params.total_num_steps`, or `warmup_num_steps` that disagree with `TrainingArguments` (per_device_train_batch_size, gradient_accumulation_steps, computed num_training_steps from dataset length/epochs), or vice versa — changing TrainingArguments after writing the JSON.","commonSituations":"Reusing one ds_config.json across experiments while changing batch size/epochs in TrainingArguments; tutorials with fixed scheduler values; scripts where dataloader length changed (different dataset or max_steps) invalidating a previously correct total_num_steps.","solutions":["Set the mismatched DeepSpeed keys (listed in the error text) to `\"auto\"` so they are derived from TrainingArguments","Or make the DeepSpeed JSON agree exactly with TrainingArguments values","Re-check `num_training_steps` inputs (dataset size, epochs, max_steps) if scheduler params were hardcoded"],"exampleFix":"// before (ds_config.json vs TrainingArguments(batch_size=16))\n\"train_micro_batch_size_per_gpu\": 8,\n\"scheduler\": { \"params\": { \"total_num_steps\": 100, \"warmup_num_steps\": 10 } }\n\n// after\n\"train_micro_batch_size_per_gpu\": \"auto\",\n\"scheduler\": { \"params\": { \"total_num_steps\": \"auto\", \"warmup_num_steps\": \"auto\" } }","handlingStrategy":"validation","validationCode":"# mirror the trainer's check before launching\nmismatches = []\nif ds.get(\"train_micro_batch_size_per_gpu\") not in (\"auto\", args.per_device_train_batch_size):\n    mismatches.append(\"train_micro_batch_size_per_gpu\")\nif ds.get(\"gradient_accumulation_steps\") not in (\"auto\", args.gradient_accumulation_steps):\n    mismatches.append(\"gradient_accumulation_steps\")\nassert not mismatches, f\"fix or set 'auto': {mismatches}\"","typeGuard":null,"tryCatchPattern":"try:\n    trainer.train()\nexcept ValueError as e:\n    if \"mismatch TrainingArguments values\" in str(e):\n        # set the listed keys to \"auto\" in ds_config.json and retry\n        raise SystemExit(\"edit ds_config.json: set listed keys to 'auto'\")\n    raise","preventionTips":["Use 'auto' for train_micro_batch_size_per_gpu, gradient_accumulation_steps and scheduler params in DeepSpeed JSONs","Regenerate or re-review the DeepSpeed config whenever TrainingArguments or dataset size changes","Never hardcode total_num_steps when epochs/dataset can vary"],"tags":["deepspeed","training","config-mismatch","trainer"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}