modelscope / modelscope/ms-swift

Qwen/Qwen3-VL-4B-Instruct-FP8 AssertionError: Attempted to load weight (torch.Size([4096, 2560])) into parameter (torch.Size([6144, 2560]))

Open
#8,086 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug stale
Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

Checklist / 检查清单
  • I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述

[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/qwen3_vl.py", line 1602, in load_weights
[rank5]: return loader.load_weights(weights, mapper=self.hf_to_vllm_mapper)
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 294, in load_weights
[rank5]: autoloaded_weights = set(self._load_module("", self.module, weights))
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 252, in _load_module
[rank5]: yield from self._load_module(prefix,
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 225, in _load_module
[rank5]: loaded_params = module_load_weights(weights)
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/qwen3.py", line 341, in load_weights
[rank5]: return loader.load_weights(weights)
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 294, in load_weights
[rank5]: autoloaded_weights = set(self._load_module("", self.module, weights))
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 252, in _load_module
[rank5]: yield from self._load_module(prefix,
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/utils.py", line 225, in _load_module
[rank5]: loaded_params = module_load_weights(weights)
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/models/qwen2.py", line 423, in load_weights
[rank5]: weight_loader(param, loaded_weight)
[rank5]: File "/home/team_cv/miniconda3/envs/megatron/lib/python3.11/site-packages/vllm/model_executor/model_loader/weight_utils.py", line 810, in default_weight_loader
[rank5]: assert param.size() == loaded_weight.size(), (
[rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]: AssertionError: Attempted to load weight (torch.Size([4096, 2560])) into parameter (torch.Size([6144, 2560]))

How to Reproduce / 如何复现

Reproduce:
export NVTE_CUDA_INCLUDE_DIR=/usr/local/cuda/include
PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True,garbage_collection_threshold:0.8'
OMP_NUM_THREADS=14
NPROC_PER_NODE=4
CUDA_VISIBLE_DEVICES=4,5,6,7
IMAGE_MAX_TOKEN_NUM=1024
VIDEO_MAX_TOKEN_NUM=128
FPS_MAX_FRAMES=16
MAX_PIXELS=602112
MASTER_PORT=29600
megatron rlhf
--rlhf_type grpo
--model Qwen/Qwen3-VL-4B-Instruct-FP8
--ref_load Qwen/Qwen3-VL-4B-Instruct-FP8
--load_safetensors true
--save_safetensors true
--fp8_recipe delayed
--fp8_format e4m3
--fp8_param_gather true
--context_parallel_size 1
--tensor_model_parallel_size 2
--pipeline_model_parallel_size 2
--dataset /home/team_cv/tdkien/kms-agentic-vtv/test_local/data_train_ocr.jsonl
--max_epochs 1
--global_batch_size 64
--micro_batch_size 1
--steps_per_generation 1
--num_generations 4
--external_plugins /home/team_cv/tdkien/ocr-training-model-vdu/rewards/plugin_glm.py
--reward_funcs external_ocr_classification_tag_reward
--use_vllm true
--vllm_mode colocate
--vllm_gpu_memory_utilization 0.3
--vllm_max_model_len 4096
--max_length 2048
--max_completion_length 2048
--lr 1e-6
--beta 0.001
--importance_sampling_level token
--epsilon 0.2
--epsilon_high 0.2
--dynamic_sample false
--overlong_filter true
--loss_type grpo
--sleep_level 2
--offload_model true
--offload_bridge false
--offload_optimizer true
--log_interval 1
--recompute_granularity selective
--finetune
--num_workers 8
--dataset_num_proc 8
--no_save_optim true
--no_save_rng true
--attention_backend flash
--temperature 1.0
--padding_free true
--log_completions true
--report_to wandb
--train_iters 100
--eval_interval 1000
--save_interval 1000
--use_hf true

Additional Information / 补充信息

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the command with Qwen/Qwen3-VL-4B-Instruct-FP8, then inspect model_executor/models/qwen3_vl.py, qwen3.py, qwen2.py, and model_loader/weight_utils.py around load_weights and the reported assertion. Determine why the checkpoint shape differs from the parameter shape; done means the model loads successfully without this mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.