huggingface/transformers · error · ValueError
File not found: {audio}
Error message
File not found: {audio} What it means
During `HfTrainerDeepSpeedConfig.fill_matches`/`fill_only` auto-filling, transformers resolves `auto` entries that depend on hidden size (e.g. `zero_optimization.reduce_bucket_size`, `stage3_prefetch_bucket_size`) by reading `model.config.hidden_size`, `hidden_sizes`, or the nested `text_config` equivalents. If none of these attributes exist on the model config (non-standard architecture), hidden_size stays None and auto-fill cannot proceed, so it raises with the list of affected keys.
Source
Thrown at src/transformers/audio_utils.py:342
- `str`: Base64 encoded audio data (if return_format="base64")
- `dict`: Dictionary with 'data' (base64 encoded audio data) and 'format' keys (if return_format="dict")
- `io.BytesIO`: BytesIO object containing audio data (if return_format="buffer")
"""
requires_backends(load_audio_as, ["librosa"])
if return_format not in ["base64", "dict", "buffer"]:
raise ValueError(f"Invalid return_format: {return_format}. Must be 'base64', 'dict', or 'buffer'")
try:
# Load audio bytes from URL or file
audio_bytes = None
if audio.startswith(("http://", "https://")):
audio_bytes = _fetch_audio_bytes(audio, timeout=timeout)
elif os.path.isfile(audio):
with open(audio, "rb") as audio_file:
audio_bytes = audio_file.read()
else:
raise ValueError(f"File not found: {audio}")
# Process audio data
with io.BytesIO(audio_bytes) as audio_file:
with sf.SoundFile(audio_file) as f:
audio_array = f.read(dtype="float32")
original_sr = f.samplerate
audio_format = f.format
if sampling_rate is not None and sampling_rate != original_sr:
# Resample audio to target sampling rate
audio_array = soxr.resample(audio_array, original_sr, sampling_rate, quality="HQ")
else:
sampling_rate = original_sr
# Convert to mono if needed
if force_mono and audio_array.ndim != 1:
audio_array = audio_array.mean(axis=1)
buffer = io.BytesIO()View on GitHub (pinned to a597f97485)
Solutions
- Replace the `auto` values for the listed keys with explicit integers in your DeepSpeed config (e.g. `reduce_bucket_size: 5000000`, `stage3_prefetch_bucket_size: 4500000`)
- Or expose `hidden_size`/`hidden_sizes` on your custom config class so auto-fill works
- Or route the config through a `text_config` attribute carrying `hidden_size` if the model wraps a text backbone
Example fix
// before (ds_config.json)
"zero_optimization": { "stage": 3, "reduce_bucket_size": "auto", "stage3_prefetch_bucket_size": "auto" }
// after
"zero_optimization": { "stage": 3, "reduce_bucket_size": 5000000, "stage3_prefetch_bucket_size": 4500000 } Defensive patterns
Strategy: validation
Validate before calling
cfg = model.config
hidden = getattr(cfg, "hidden_size", None) or (
max(getattr(cfg, "hidden_sizes", [])) if hasattr(cfg, "hidden_sizes") else None
) or getattr(getattr(cfg, "text_config", None), "hidden_size", None)
if hidden is None:
# replace 'auto' bucket keys with explicit ints before training
for k in ("zero_optimization.reduce_bucket_size", "zero_optimization.stage3_prefetch_bucket_size"):
if deepspeed_dict_get(ds_cfg, k) == "auto":
raise SystemExit(f"set {k} to an integer; model config has no hidden_size") Prevention
- Give custom config classes a hidden_size (or text_config.hidden_size) attribute
- Prefer explicit bucket sizes in shared DeepSpeed JSONs used across architectures
When it happens
Trigger: Training with DeepSpeed ZeRO (config containing `auto` bucket-size keys) a model whose config class lacks `hidden_size`/`hidden_sizes` (and `text_config.hidden_size[s]`) — e.g. some vision/multimodal/audio models or heavily custom configs.
Common situations: Custom model architectures; older multimodal configs without text_config; wrapper configs that hide the LM config under a different attribute name.
Related errors
- Error loading audio: {e}
- Invalid return_format: {return_format}. Must be 'base64', 'd
- out_indices must be a list, got {type(self._out_indices)}
- out_indices must be valid indices for stage_names {self.stag
- out_indices must not contain any duplicates, got {self._out_
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/e4873e7d55f8bacf.
Report an issue: GitHub.