ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

Loading Deepseek FP8 Model causes error during dequant

Open arvyanh opened this issue 1 year ago • 4 comments

Describe the bug When Training Deepseek FP8 model (from hugginface), ms-swift failed during dequantizer with error ValueError: Matrix dimensions (576, 7168) must be divisible by block sizes (128, 128)

Image

Probably some kind of padding logic is required instead of a assertion.

Your hardware and system info Write your system info like CUDA version/system/GPU/torch version here(在这里给出硬件信息和系统信息,如CUDA版本,系统,GPU型号和torch版本等)

CUDA 12.8 ms-swift (master) GPU H20

arvyanh avatar Dec 02 '25 07:12 arvyanh

脚本是什么

Jintao-Huang avatar Dec 02 '25 09:12 Jintao-Huang

Reduce tp_size

Jintao-Huang avatar Dec 02 '25 09:12 Jintao-Huang

减tp看起来没用

megatron sft
--train_type full
--num_workers 8
--dataset_num_proc 8
--no_save_optim true
--no_save_rng true
--sequence_parallel true
--weight-decay 0.01
--adam-beta1 0.9
--adam-beta2 0.95
--log_interval 2
--dataset xx
--save xx
--pipeline_model_parallel_size 16
--tensor_model_parallel_size 1
--expert_model_parallel_size 8
--expert_tensor_parallel_size 1
--context_parallel_size 1
--cross_entropy_loss_fusion true
--sequence_parallel true
--micro_batch_size 4
--global_batch_size 64
--streaming false
--split_dataset_ratio 0
--train_iters 7
--finetune true
--lr 1e-05
--min_lr 1e-06
--lr_warmup_iters 0
--eval_interval 50
--save_interval 2
--max_length 20480
--tensorboard_dir []
--use_flash_attn true
--recompute_granularity selective
--recompute_modules core_attn moe_act
--overlap_grad_reduce true
--overlap_param_gather true
--moe_grouped_gemm true
--moe_aux_loss_coeff 1e-3
--moe_router_dtype fp32
--moe_permute_fusion true
--attention_backend flash
--loss_scale default
--quant_method fp8
--fp8_format e4m3
--fp8_recipe blockwise
--model []/DeepSeek-R1-0528
--load_safetensors true
--save_safetensors true
--moe_enable_deepep true
--moe_token_dispatcher_type flex
--decoder-first-pipeline-num-layers 3
--decoder-last-pipeline-num-layers 2
--megatron_extra_kwargs /workdir/megatron_args.json

arvyanh avatar Dec 04 '25 03:12 arvyanh

try --fp8_param_gather true

I’ll fix this issue.

Jintao-Huang avatar Dec 05 '25 09:12 Jintao-Huang