已合并
docs: add loss_ctx parameter docstring for DeepseekV4 and MiniMaxM2 CausalLM #4930
Rostellaria创建于 18 天前
docs: add loss_ctx parameter docstring for DeepseekV4 and MiniMaxM2 CausalLM #4930
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Rostellaria 的贡献)18 天前 创建了 pull request,commit a0c41321
18 天前 关联了issue:[Bug]: 修复脚本运行时的loss_ctx文档错误
atomgit-bot
18 天前 评论:
18 天前 评论:
变更摘要
此 PR 是一个纯文档补丁,为 DeepseekV4ForCausalLM.forward 和 MiniMaxM2ForCausalLM.forward 方法补充了此前缺失的 loss_ctx 参数文档字符串(docstring),明确了该参数的可调用签名、行为语义以及副作用——提供 loss_ctx 后主损失路径将忽略 labels 并返回 None 作为 logits,同时特别指出 DeepseekV4 的 MTP 损失路径仍会使用 labels。该变更不涉及任何运行时行为修改。
主要改动
- 为
DeepseekV4ForCausalLM.forward添加loss_ctx文档:在modeling_deepseek_v4.py中新增了loss_ctx参数的文档字符串,描述其签名为(hidden_states, weight, bias) -> loss,并说明提供后主损失路径忽略labels、返回logits为None,同时特别注明labels仍用于 MTP 损失路径。 - 为
MiniMaxM2ForCausalLM.forward添加loss_ctx文档:在modeling_minimax_m2.py中新增了loss_ctx参数的文档字符串,内容与 DeepseekV4 版本基本一致,但未包含 MTP 相关说明。


ascend-robot
18 天前 评论:
18 天前 评论:
atomgit-bot
18 天前 评论:
18 天前 评论:
此处折叠了42条消息 查看更多
tichang
18 天前 评论:
18 天前 评论:
/lgtm


18 天前 添加了label:approved
18 天前 关闭了关联的issue
18 天前 合入了pull request
#1745
What this PR does / why we need it?
This PR documents the previously undocumented loss_ctx parameter in the forward methods of DeepseekV4ForCausalLM and MiniMaxM2ForCausalLM , clarifying its callable signature, behavior, and the side-effect that labels remain active for DeepseekV4's MTP loss path. Without this, callers cannot discover the parameter from auto-generated docs and may be surprised by MTP still consuming labels.
Does this PR introduce any user-facing change?
No runtime behavior changes; this is a docstring-only patch. The added descriptions appear in the auto-generated API docstring for DeepseekV4ForCausalLM.forward at modeling_deepseek_v4.py#L1704-L1707 and MiniMaxM2ForCausalLM.forward at modeling_minimax_m2.py#L823-L826 .
How was this patch tested?
Verification is static: the rendered docstring was cross-checked against the loss_ctx branching logic in both forward methods and the LMHead.forward implementation in modules.py#L8-L32 to confirm signature, logits-behavior, and the DeepseekV4 MTP label-usage note match actual code semantics. No runtime tests are required for a doc-only change.