{"record":{"id":"aaf024ed9fb9fde8","repo":"hiyouga/LlamaFactory","slug":"all-dcp-path-hf-path-and-config-path-are-r","errorCode":null,"errorMessage":"All 'dcp_path', 'hf_path', and 'config_path' are required.","messagePattern":"All 'dcp_path', 'hf_path', and 'config_path' are required\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/dcp2hf.py","lineNumber":46,"sourceCode":"import torch.distributed.checkpoint as dcp\nimport transformers\nfrom transformers import AutoConfig\n\n\ndef convert(dcp_path: str, hf_path: str, config_path: str) -> None:\n    \"\"\"Convert DCP model weights to HF.\n\n    Note: this script is used to convert a DCP checkpoint to HuggingFace model format,\n    it will just convert the DCP checkpoint to a HuggingFace model format, for the tokenizer,\n    you may need to copy from the original model.\n\n    Args:\n        dcp_path: DCP checkpoint directory.\n        hf_path: Output path (directory) for HuggingFace model.\n        config_path: Path to the HuggingFace model directory containing config.json.\n    \"\"\"\n    if not dcp_path or not hf_path or not config_path:\n        raise ValueError(\"All 'dcp_path', 'hf_path', and 'config_path' are required.\")\n\n    print(f\"Loading config from {config_path}...\")\n    config = AutoConfig.from_pretrained(config_path)\n    architectures = getattr(config, \"architectures\", [])\n    if architectures:\n        model_cls = getattr(transformers, architectures[0], transformers.AutoModelForCausalLM)\n    else:\n        model_cls = transformers.AutoModelForCausalLM\n\n    print(\"Initializing model on CPU...\")\n    model = model_cls(config).to(torch.bfloat16)\n\n    print(f\"Loading DCP from {dcp_path}...\")\n    state_dict = model.state_dict()\n    dcp.load(state_dict, checkpoint_id=dcp_path)\n    model.load_state_dict(state_dict)\n\n    print(f\"Saving to HF format at {hf_path}...\")","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/scripts/dcp2hf.py#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\npip list | grep transformers  # 4.46.x\nmodel_name_or_path: internlm/internlm3-8b  # -> RuntimeError\n\n# after\npip install -U 'transformers>=4.47.1'","handlingStrategy":"validation","validationCode":"from transformers import AutoConfig\nfrom llamafactory.extras.packages import is_transformers_version_greater_than\nif AutoConfig.from_pretrained(model_path).model_type == 'internlm3':\n    assert is_transformers_version_greater_than('4.47.1'), 'pip install -U \\'transformers>=4.47.1\\''","typeGuard":"def internlm3_supported() -> bool:\n    from llamafactory.extras.packages import is_transformers_version_greater_than\n    return is_transformers_version_greater_than('4.47.1')","tryCatchPattern":"try:\n    run_sft(train_args)\nexcept RuntimeError as e:\n    if 'InternLM3' in str(e):\n        raise SystemExit('Upgrade: pip install -U \\'transformers>=4.47.1\\'') from e\n    raise","preventionTips":["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"],"tags":["version","transformers","internlm3","dependency"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}