High severity beginner · Fix: 2-5 min

OSError

OSError: [Errno 2] No such file or directory (model not found)

What this error means
Qwen model name format mismatch between local paths, HuggingFace Hub naming conventions, and inference engine expectations causes model loading to fail with 'file not found' or 'model not found' errors.

Stack trace

traceback
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'
QUICK FIX
Replace 'Qwen2.5-72B-Instruct' with 'Qwen/Qwen2.5-72B-Instruct' in from_pretrained(): the namespace prefix is required for HuggingFace Hub resolution.

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

1

Missing 'Qwen/' namespace prefix in model name string

✓ Fix

Change 'Qwen2.5-72B-Instruct' to 'Qwen/Qwen2.5-72B-Instruct' in your from_pretrained() call or HUGGINGFACE_MODEL environment variable

2

Incorrect quantization suffix (e.g., using -AWQ or -GGUF variants without specifying in model name)

✓ Fix

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

3

Using old Qwen1 or Qwen1.5 naming conventions with Qwen2.5 codebase

✓ Fix

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)

4

Loading from local filesystem but model directory name doesn't match Hub naming convention

✓ Fix

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

Broken - triggers the error
python
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)
Fixed - works correctly
python
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}')
Added the required 'Qwen/' organization namespace prefix so transformers library can resolve the model on HuggingFace Hub. Without this prefix, the library cannot find the model in the remote registry.

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.

Python 3.9+ · transformers >=4.40.0 · tested on 4.45.x
Verified 2026-04 · Qwen/Qwen2.5-7B-Instruct, Qwen/Qwen2.5-32B-Instruct, Qwen/Qwen2.5-72B-Instruct
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.