hiyouga/LlamaFactory · error · ValueError
All 'dcp_path', 'hf_path', and 'config_path' are required.
Error message
All 'dcp_path', 'hf_path', and 'config_path' are required.
What it means
Config patching checks config.model_type == 'internlm3' and verifies the installed transformers is newer than 4.47.1 (patcher.py:413); InternLM3 architecture support only landed in transformers 4.47.1+, so older versions cannot instantiate the model class and the loader fails fast with RuntimeError instead of a confusing AutoModel error.
Source
Thrown at scripts/dcp2hf.py:46
import torch.distributed.checkpoint as dcp
import transformers
from transformers import AutoConfig
def convert(dcp_path: str, hf_path: str, config_path: str) -> None:
"""Convert DCP model weights to HF.
Note: this script is used to convert a DCP checkpoint to HuggingFace model format,
it will just convert the DCP checkpoint to a HuggingFace model format, for the tokenizer,
you may need to copy from the original model.
Args:
dcp_path: DCP checkpoint directory.
hf_path: Output path (directory) for HuggingFace model.
config_path: Path to the HuggingFace model directory containing config.json.
"""
if not dcp_path or not hf_path or not config_path:
raise ValueError("All 'dcp_path', 'hf_path', and 'config_path' are required.")
print(f"Loading config from {config_path}...")
config = AutoConfig.from_pretrained(config_path)
architectures = getattr(config, "architectures", [])
if architectures:
model_cls = getattr(transformers, architectures[0], transformers.AutoModelForCausalLM)
else:
model_cls = transformers.AutoModelForCausalLM
print("Initializing model on CPU...")
model = model_cls(config).to(torch.bfloat16)
print(f"Loading DCP from {dcp_path}...")
state_dict = model.state_dict()
dcp.load(state_dict, checkpoint_id=dcp_path)
model.load_state_dict(state_dict)
print(f"Saving to HF format at {hf_path}...")View on GitHub (pinned to f28afaf635)
Solutions
- pip install -U 'transformers>=4.47.1'
- If you must stay on old transformers, use a different model family; InternLM3 cannot be trained on <= 4.47.0
Example fix
# before pip list | grep transformers # 4.46.x model_name_or_path: internlm/internlm3-8b # -> RuntimeError # after pip install -U 'transformers>=4.47.1'
Defensive patterns
Strategy: validation
Validate before calling
from transformers import AutoConfig
from llamafactory.extras.packages import is_transformers_version_greater_than
if AutoConfig.from_pretrained(model_path).model_type == 'internlm3':
assert is_transformers_version_greater_than('4.47.1'), 'pip install -U \'transformers>=4.47.1\'' Type guard
def internlm3_supported() -> bool:
from llamafactory.extras.packages import is_transformers_version_greater_than
return is_transformers_version_greater_than('4.47.1') Try / catch
try:
run_sft(train_args)
except RuntimeError as e:
if 'InternLM3' in str(e):
raise SystemExit('Upgrade: pip install -U \'transformers>=4.47.1\'') from e
raise Prevention
- Run `python -c "import transformers; print(transformers.__version__)"` in launch scripts and compare against model requirements
- Keep one requirements file per model family when version needs conflict
When it happens
Trigger: model_name_or_path is an InternLM3 checkpoint (model_type internlm3) and the environment has transformers <= 4.47.0; is_transformers_version_greater_than('4.47.1') returns False during model load.
Common situations: Reusing an older pinned environment (e.g. created for a Qwen2 run) to train internlm/internlm3-8b; CI images with transformers pinned below 4.47.
Related errors
- Both 'hf_path' and 'dcp_path' are required.
- `num_layers` {num_layers} should be divisible by `num_expand
- Device not supported: {device_name}.
- Qwen2VL requires 3D position ids for mrope.
- Stage does not supported: {stage}.
AI-assisted analysis of hiyouga/LlamaFactory@f28afaf635 (2026-08-14).
Data as JSON: /api/errors/aaf024ed9fb9fde8.
Report an issue: GitHub.