已合并
docs: add loss_ctx parameter docstring for DeepseekV4 and MiniMaxM2 CausalLM #4930
docs: add loss_ctx parameter docstring for DeepseekV4 and MiniMaxM2 CausalLM #4930
已合并
Rostellaria创建于 18 天前
Rostellaria
Rostellaria成员
18 天前

#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.

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Rostellaria 的贡献)
RostellariaRostellaria成员
18 天前 创建了 pull request,commit a0c41321
RostellariaRostellaria成员
18 天前 关联了issue:[Bug]: 修复脚本运行时的loss_ctx文档错误
atomgit-bot
atomgit-bot
18 天前 评论:

变更摘要

此 PR 是一个纯文档补丁,为 DeepseekV4ForCausalLM.forwardMiniMaxM2ForCausalLM.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、返回 logitsNone,同时特别注明 labels 仍用于 MTP 损失路径。
  • MiniMaxM2ForCausalLM.forward 添加 loss_ctx 文档:在 modeling_minimax_m2.py 中新增了 loss_ctx 参数的文档字符串,内容与 DeepseekV4 版本基本一致,但未包含 MTP 相关说明。
likedislike
atomgit-bot
atomgit-bot
18 天前 评论:

代码审查

✅ 未发现问题

likedislike
此处折叠了42条消息 查看更多
tichang
tichang成员
18 天前 评论:

/lgtm

likedislike
LinShua成员
18 天前 评论:

/approve

likedislike
ascend-robotascend-robot成员
18 天前 添加了label:approved
ascend-robotascend-robot成员
18 天前 关闭了关联的issue
ascend-robotascend-robot成员
18 天前 合入了pull request