modelscope / modelscope/ms-swift
DeepSeek-v4-flash-0731 sft
Open
Nobody has claimed this yet.
question
- 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 question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
Question Description / 问题描述
example from https://swift.readthedocs.io/zh-cn/v4.4/BestPractices/deepseek-v4.html
PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
NPROC_PER_NODE=4 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
megatron sft \
--model /code/hewangsh/models/DeepSeek-V4-Flash-0731 \
--save_safetensors true \
--dataset 'AI-ModelScope/alpaca-gpt4-data-zh#1000' \
--model_author swift \
--model_name swift-robot \
--merge_lora true \
--load_from_cache_file true \
--add_non_thinking_prefix true \
--loss_scale ignore_empty_think \
--split_dataset_ratio 0.01 \
--tuner_type lora \
--lora_rank 16 \
--lora_alpha 32 \
--tensor_model_parallel_size 1 \
--expert_model_parallel_size 4 \
--micro_batch_size 1 \
--global_batch_size 32 \
--padding_free false \
--group_by_length true \
--recompute_granularity full \
--recompute_method uniform \
--recompute_num_layers 1 \
--moe_permute_fusion true \
--moe_grouped_gemm true \
--moe_shared_expert_overlap true \
--moe_aux_loss_coeff 1e-3 \
--num_train_epochs 1 \
--finetune true \
--cross_entropy_loss_fusion true \
--lr 1e-4 \
--lr_warmup_fraction 0.05 \
--min_lr 1e-5 \
--output_dir megatron_output/DeepSeek-V4-Flash \
--eval_steps 200 \
--save_steps 200 \
--max_length 4096 \
--dataloader_num_workers 8 \
--dataset_num_proc 8 \
--no_save_optim true \
--no_save_rng true \
--sequence_parallel true \
--mtp_num_layers 1 \
--attention_backend flash
Error:
[rank3]: Traceback (most recent call last):
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/cli/_megatron/sft.py", line 7, in <module>
[rank3]: megatron_sft_main()
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/pipelines/train/sft.py", line 99, in megatron_sft_main
[rank3]: return MegatronSft(args).main()
[rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/pipelines/base.py", line 52, in main
[rank3]: result = self.run()
[rank3]: ^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/pipelines/train/sft.py", line 72, in run
[rank3]: trainer = self.prepare_trainer()
[rank3]: ^^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/pipelines/train/sft.py", line 38, in prepare_trainer
[rank3]: return MegatronTrainer(self.args, self.template)
[rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/trainers/base.py", line 68, in __init__
[rank3]: self.prepare_model()
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/trainers/base.py", line 188, in prepare_model
[rank3]: self.unwrapped_models = get_mcore_model(args, self.template.config)
[rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/model/utils.py", line 82, in get_mcore_model
[rank3]: config = get_mcore_model_config(args, hf_config)
[rank3]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "/usr/local/lib/python3.12/site-packages/swift/megatron/model/utils.py", line 73, in get_mcore_model_config
[rank3]: config = ModelConfig(**kwargs)
[rank3]: ^^^^^^^^^^^^^^^^^^^^^
[rank3]: File "<string>", line 305, in __init__
[rank3]: File "/usr/local/lib/python3.12/site-packages/mcore_bridge/config/model_config.py", line 342, in __post_init__
[rank3]: super().__post_init__()
[rank3]: File "/usr/local/lib/python3.12/site-packages/megatron/core/transformer/transformer_config.py", line 1836, in __post_init__
[rank3]: raise ValueError(
[rank3]: ValueError: Expert bias for aux-loss-free routing only supports sigmoid score function.Please set --moe-router-score-function sigmoid for sigmoid score function.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at swift/megatron/model/utils.py, especially get_mcore_model_config, and trace how MegatronSft.prepare_model constructs ModelConfig. Reproduce the supplied four-GPU command and compare its generated configuration with the validation in mcore_bridge/config/model_config.py and megatron/core/transformer/transformer_config.py. Done when the example's configuration and the reported validation error are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100