2
Qwen
使用LLaMA-Factory微调Qwen3遇到问题
2025-08-04 14:46:46
238

基础环境:麒麟系统+DTK2504

LLaMA-Factory从 http://developer.sourcefind.cn/codes/OpenDAS/llama-factory.git 下载,使用v0.9.3版本;
docker 镜像使用  docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04-py3.10 

docker 启动参数:

docker run -it
--shm-size 200g
--name llamafactory
--privileged
--device=/dev/kfd
--device=/dev/dri --device=/dev/mkfd
--group-add video
--cap-add=SYS_PTRACE
--security-opt seccomp=unconfined
-u root
-p 7860:7860
-v /code/:/mnt/data/code/
-v /opt/hyhal/:/opt/hyhal/:ro
image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.4.1-ubuntu22.04-dtk25.04-py3.10

按照,git上所提供的运行方式,正常运行;
使用Qwen3-0.6B-Instruct模型,加载模型时,报错:

Downloading Model from https://www.modelscope.cn to directory: /root/.cache/modelscope/hub/models/Qwen/Qwen3-0.6B
2025-08-04 14:39:12,720 - modelscope - INFO - Target directory already exists, skipping creation.
[INFO|configuration_utils.py:670] 2025-08-04 14:39:12,722 >> loading configuration file /root/.cache/modelscope/hub/models/Qwen/Qwen3-0___6B/config.json
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1023, in from_pretrained
config_class = CONFIG_MAPPING[config_dict["model_type"]]
File "/usr/local/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 725, in getitem
raise KeyError(key)
KeyError: 'qwen3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 715, in process_events
response = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 322, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 2191, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1714, in call_function
prediction = await utils.async_iteration(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 739, in async_iteration
return await anext(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 733, in anext
return await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2461, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 962, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 716, in run_sync_iterator_async
return next(iterator)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 877, in gen_wrapper
response = next(iterator)
File "/mnt/data/code/llama-factory/src/llamafactory/webui/chatter.py", line 158, in load_model
super().init(args)
File "/mnt/data/code/llama-factory/src/llamafactory/chat/chat_model.py", line 55, in init
self.engine: BaseEngine = VllmEngine(model_args, data_args, finetuning_args, generating_args)
File "/mnt/data/code/llama-factory/src/llamafactory/chat/vllm_engine.py", line 55, in init
config = load_config(model_args) # may download model from ms hub
File "/mnt/data/code/llama-factory/src/llamafactory/model/loader.py", line 130, in load_config
return AutoConfig.from_pretrained(model_args.model_name_or_path, **init_kwargs)
File "/usr/local/lib/python3.10/site-packages/transformers/models/auto/configuration_auto.py", line 1025, in from_pretrained
raise ValueError(
ValueError: The checkpoint you are trying to load has model type qwen3  but Transformers does not recognize this architecture. This could be because of an issue with the checkpoint, or because your version of Transformers is out of date.
Transformers 的版本问题,应该使用哪个版本,vllm + Transformers的版本分别是什么,才能正常微调;

全部评论(3)
只看楼主
R
renzhc
1楼
模型微调与vllm无关,transormers需要使用4.51.0以上版本
2025/8/4
网
网友tscL0p
回复 @renzhc
使用llama-Factory 做微调时,vllm中 要求Transformers的版本为4.45.0,否则启动不成功,但是降低Transformers的版本,就会报上面的错误
2025/8/5
R
renzhc
回复 @renzhc
https://image.sourcefind.cn/#/image/dcu/vllm?activeName=overview 可能是vllm版本较低,可以从这里获取最新的vllm镜像
2025/8/5
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据