huggingface/transformers · error · ValueError
Error loading audio: {e}
Error message
Error loading audio: {e} What it means
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.
Source
Thrown at src/transformers/audio_utils.py:375
if force_mono and audio_array.ndim != 1:
audio_array = audio_array.mean(axis=1)
buffer = io.BytesIO()
sf.write(buffer, audio_array, sampling_rate, format=audio_format.upper())
buffer.seek(0)
if return_format == "buffer":
return buffer
elif return_format == "base64":
return base64.b64encode(buffer.read()).decode("utf-8")
elif return_format == "dict":
return {
"data": base64.b64encode(buffer.read()).decode("utf-8"),
"format": audio_format.lower(),
}
except Exception as e:
raise ValueError(f"Error loading audio: {e}")
def conv1d_output_length(module: "torch.nn.Conv1d", input_length: int) -> int:
"""
Computes the output length of a 1D convolution layer according to torch's documentation:
https://docs.pytorch.org/docs/stable/generated/torch.nn.Conv1d.html
"""
return int(
(input_length + 2 * module.padding[0] - module.dilation[0] * (module.kernel_size[0] - 1) - 1)
/ module.stride[0]
+ 1
)
def is_valid_audio(audio):
return (
is_numpy_array(audio)
or is_torch_tensor(audio)View on GitHub (pinned to a597f97485)
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
Example fix
// before (ds_config.json vs TrainingArguments(batch_size=16))
"train_micro_batch_size_per_gpu": 8,
"scheduler": { "params": { "total_num_steps": 100, "warmup_num_steps": 10 } }
// after
"train_micro_batch_size_per_gpu": "auto",
"scheduler": { "params": { "total_num_steps": "auto", "warmup_num_steps": "auto" } } Defensive patterns
Strategy: validation
Validate before calling
# mirror the trainer's check before launching
mismatches = []
if ds.get("train_micro_batch_size_per_gpu") not in ("auto", args.per_device_train_batch_size):
mismatches.append("train_micro_batch_size_per_gpu")
if ds.get("gradient_accumulation_steps") not in ("auto", args.gradient_accumulation_steps):
mismatches.append("gradient_accumulation_steps")
assert not mismatches, f"fix or set 'auto': {mismatches}" Try / catch
try:
trainer.train()
except ValueError as e:
if "mismatch TrainingArguments values" in str(e):
# set the listed keys to "auto" in ds_config.json and retry
raise SystemExit("edit ds_config.json: set listed keys to 'auto'")
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid return_format: {return_format}. Must be 'base64', 'd
- File not found: {audio}
- This tokenizer does not have a mask token which is necessary
- mlm_probability should be between 0 and 1.
- batched_mm experts dispatch does not support activation_sche
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/6db113e103f88d23.
Report an issue: GitHub.