Add MiniMax Text model support#4662
Open
yicycyc wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 新增模型支持:MiniMax-Text-01
本 PR 新增
MiniMaxAI/MiniMax-Text-01支持。复现对齐对象为 HuggingFace/Transformers 端 MiniMax 实现以及 ModelScope 上的原始 safetensors 权重。主要改动
paddleformers/transformers/minimax/MiniMaxConfigMiniMaxModelMiniMaxForCausalLMMiniMaxForCausalLMPipepaddleformers.transformersAutoConfigAutoModelForCausalLMminimaxtemplateMiniMaxPretrainedModel._gen_aoa_config中实现 HF/ModelScope safetensors 到 PaddleFormers 权重的自动转换规则MiniMaxPretrainedModel._gen_inv_aoa_config中实现 PaddleFormers 到 safetensors 的反向映射规则tests/transformers/minimax/test_modeling.pyMiniMaxModelforward、MiniMaxForCausalLMloss/backward、AutoModelForCausalLM.from_configdocs/zh/model_capability.md能力矩阵Stage3 训练跑通方式在下方训练验证中说明,通用 Trainer / Optimizer 侧改动不纳入本 PR。
前向对齐验证
模型:
MiniMaxAI/MiniMax-Text-01验证模型为一层缩层模型:
num_hidden_layers = 1/root/claude_workspace/minimax-text-01-layer0-msbf16 eager 最终 hidden states:
(1, 4, 6144)fp32 eager :
(1, 4, 6144)5.7220459e-062.5422841e-071.9073486e-06说明:
1e-6量级误差,符合 fp32 算子执行差异预期。训练验证
使用 GSM8K 做 BF16 full-SFT,Paddle 侧使用 sharding stage3,Torch 侧使用 ms-swift ZeRO-3。
共同设置:
max_length = 512max_steps = 300per_device_train_batch_size = 1gradient_accumulation_steps = 1learning_rate = 1e-5lr_scheduler_type = constantwarmup_steps = 0weight_decay = 08,146,085,888loss 曲线如下:
结论:
27.x,没有出现异常 loss scale。Stage3 / ZeRO3 说明
MiniMax sparse MoE 会根据 token 动态选择 expert。Stage3 / ZeRO3 下,如果不同 rank 只执行本 rank 命中的 expert,不同 rank 的 expert 执行顺序可能不一致,从而导致 collective 顺序不一致、训练卡住或梯度状态异常。
本地成功验证使用:
生成对齐
使用真实文本输入做 greedy generation,对齐对象为 Transformers 4.57.6 MiniMax 实现。
输入:
输入 token:
bf16 生成前 10 个 token:
[162551, 197066, 109245, 4698, 7169, 29897, 4791, 69130, 190900, 177743][162551, 197066, 109245, 4698, 7169, 29897, 4791, 69130, 190900, 177743]