Conversation
Bypass Liger CE when a context contains no valid tokens and return a differentiable FP32 zero. This avoids the 0/0 calibration NaN while preserving zero gradients for both inputs.
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.
修复 Liger all-ignore 场景下的 loss 校准除零问题
当 SP 切分等情况导致本地一次 Liger 调用没有有效 token 时,
使用 valid_count.clamp_min(1) 避免校准公式出现 0/0,
保持正常输入的缩放公式不变,且不引入额外 CPU/GPU 同步。
附带一个 CPU/mock 回归测试,验证可微零 loss 及 hidden/head
零梯度正常
单元测试显示,该改动引入中位增量约 4.58 µs/调用开销,但可处理单 rank all-ignore 问题
该结果不代表完整训练 step 的性能开销。