OSError
OSError: [Errno 2] No such file or directory (model not found)
Stack trace
Traceback (most recent call last):
File "load_model.py", line 12, in <module>
model = AutoModelForCausalLM.from_pretrained('Qwen2.5-72B-Instruct')
File "/usr/local/lib/python3.11/site-packages/transformers/models/auto/modeling_auto.py", line 541, in from_pretrained
model = cls.from_config(config, **kwargs)
FileNotFoundError: Model 'Qwen2.5-72B-Instruct' not found on HuggingFace Hub. Did you mean one of these: 'Qwen/Qwen2.5-72B-Instruct', 'Qwen/Qwen2.5-72B-Instruct-AWQ'?
OSError: [Errno 2] No such file or directory: 'Qwen2.5-72B-Instruct' Why it happens
Qwen model identifiers on HuggingFace Hub require the namespace prefix 'Qwen/' before the model name (e.g., 'Qwen/Qwen2.5-72B-Instruct' not 'Qwen2.5-72B-Instruct'). Developers often omit this namespace, especially when loading models locally or migrating from older documentation. The transformers library strictly enforces Hub naming conventions and cannot resolve partial model names without the organization prefix.
Detection
Check HuggingFace Hub directly at https://huggingface.co/Qwen to verify the exact model identifier before loading. Enable verbose logging with `logging.basicConfig(level=logging.DEBUG)` to see the full model resolution path the transformers library attempts.
Causes & fixes
Missing 'Qwen/' namespace prefix in model name string
Change 'Qwen2.5-72B-Instruct' to 'Qwen/Qwen2.5-72B-Instruct' in your from_pretrained() call or HUGGINGFACE_MODEL environment variable
Incorrect quantization suffix (e.g., using -AWQ or -GGUF variants without specifying in model name)
Verify the exact quantized model available on Hub and use full name: 'Qwen/Qwen2.5-72B-Instruct-AWQ' for AWQ quantized version, or use bnb_4bit_compute_dtype for dynamic quantization
Using old Qwen1 or Qwen1.5 naming conventions with Qwen2.5 codebase
Update model name to Qwen2.5 series: 'Qwen/Qwen2.5-7B-Instruct', 'Qwen/Qwen2.5-32B-Instruct', or 'Qwen/Qwen2.5-72B-Instruct' (available sizes only)
Loading from local filesystem but model directory name doesn't match Hub naming convention
Store local model in directory named exactly 'Qwen2.5-72B-Instruct' (no 'Qwen/' prefix for local paths), or pass full path: from_pretrained('/path/to/local/Qwen2.5-72B-Instruct')
Code: broken vs fixed
import os
from transformers import AutoModelForCausalLM, AutoTokenizer
# BROKEN: missing 'Qwen/' namespace prefix
model_name = 'Qwen2.5-72B-Instruct' # ← This will fail with OSError
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype='auto',
device_map='auto',
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name) import os
from transformers import AutoModelForCausalLM, AutoTokenizer
# FIXED: added 'Qwen/' namespace prefix (required for HuggingFace Hub)
model_name = 'Qwen/Qwen2.5-72B-Instruct' # ← Changed: added 'Qwen/' prefix
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype='auto',
device_map='auto',
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
print(f'Model loaded successfully: {model_name}') Workaround
If you cannot modify the model loading code immediately, download the model manually to local disk using `huggingface-hub` CLI (`huggingface-cli download Qwen/Qwen2.5-72B-Instruct --local-dir ./models/qwen`), then load from local path with `from_pretrained('./models/qwen')`: this bypasses Hub name resolution entirely.
Prevention
Always verify model names on HuggingFace Hub before hardcoding them in source. Use environment variables for model names (loaded from .env or config files) rather than literals, so names can be updated without code changes. Implement a model registry function that validates model names against a known-good list before instantiation.