Closed H-Simpson123 closed 1 day ago
hi, it is expected as the MoE modeling code in transformers is not optimized and finetune.py uses transformers.
currently, the optimized usecase is inference in vllm with the original model, whose base implementation is contributed by the community.
Thanks for the quick update. Any plans from your side to add an optimized implementation to HF transformers?
All MoE models in transformers
compute the results of the expert FFNs in loops, because it is simple and easier to understand, but it is less efficient for GPUs by nature. The perf is even worse when the model has a lot of experts, which is the case for Qwen MoE. To optimize that, a fused kernel implementation (as in vllm) or methods like expert parallel (as in mcore) is needed.
To be frank, I don't think it could be done in transformers
in the short term.
This issue has been automatically marked as inactive due to lack of recent activity. Should you believe it remains unresolved and warrants attention, kindly leave a comment on this thread.
The finetuning of Qwen2-57B-A14B-Instruct is extremely slow compared to finetuning of Qwen2-72B-Instruct.
Here are the runtimes:
Qwen/Qwen2-7B-Instruct: {'train_runtime': 100.8509, 'train_samples_per_second': 5.652, 'train_steps_per_second': 0.099, 'train_loss': 0.751581035554409, 'epoch': 10.0} Qwen/Qwen2-72B-Instruct: {'train_runtime': 483.8572, 'train_samples_per_second': 1.178, 'train_steps_per_second': 0.021, 'train_loss': 0.6512975960969924, 'epoch': 10.0} Qwen/Qwen2-57B-A14B-Instruct: {'train_runtime': 2713.6648, 'train_samples_per_second': 0.21, 'train_steps_per_second': 0.004, 'train_loss': 10.314393818378448, 'epoch': 10.0}
I'm using the finetune.sh /finetune.py from this repository with --use_lora True and your provided deepspeed 3 config. I've set the per_device_train_batch_size to 1
Hardware Setup is 8xH100 80GB
Environment:
cutlass is v3.5.0