modelscope / modelscope/ms-swift

'Linear' object has no attribute 'ds_grads_remaining'

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

Nobody has claimed this yet.

bug
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 描述

训练qwen3-vl的时候,zero1是正常的,zero3会报错:AttributeError: 'Linear' object has no attribute 'ds_grads_remaining'

How to Reproduce / 如何复现

Docker:modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py311-torch2.9.0-vllm0.13.0-modelscope1.33.0-swift3.12.3

我直接用的ms-swift的docker作为环境,没用pip install改过任何包。

训练代码如下:

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
NPROC_PER_NODE=8 \
FPS_MAX_FRAMES=160 \
FPS=4 \
    swift sft \
    --model /yke/models/Qwen3-VL-32B-Instruct \
    --train_type lora \
    --dataset train_with_prompt.jsonl \
    --torch_dtype bfloat16 \
    --dataset_num_proc 8 \
    --dataloader_num_workers 4 \
    --dataset_shuffle true \
    --split_dataset_ratio 0.1 \
    --seed 42 \
    --num_train_epochs 3 \
    --per_device_train_batch_size 1 \
    --per_device_eval_batch_size 1 \
    --gradient_accumulation_steps 1 \
    --warmup_ratio 0.1 \
    --max_grad_norm 1 \
    --weight_decay 0.01 \
    --lr_scheduler_type cosine \
    --learning_rate 1e-4 \
    --target_modules all-linear \
    --lora_rank 128 \
    --lora_alpha 256 \
    --lora_dropout 0.0 \
    --eval_steps 100 \
    --save_steps 100 \
    --save_total_limit 5 \
    --logging_steps 5 \
    --max_length 40960 \
    --output_dir output \
    --attn_impl flash_attn \
    --use_liger_kernel false \
    --gradient_checkpointing true \
    --gradient_checkpointing_kwargs '{"use_reentrant": false}' \
    --num_labels 1 \
    --problem_type regression \
    --task_type seq_cls \
    --use_chat_template true \
    --deepspeed zero3
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

Run the supplied Docker image and swift sft command with Qwen3-VL, first comparing the working zero1 setup with zero3. Trace the Linear/LoRA training path around the ds_grads_remaining failure; done means zero3 training completes without this AttributeError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.