Add option to skip first token during logits comparison#2953
Add option to skip first token during logits comparison#2953copybara-service[bot] merged 1 commit intomainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Wondering if the 1st token doesn't match, will this affect following tokens? |
at first token entropy is quite high (a lot of plausible options), so large (and MoE) models can be sensitive to numerical accuracy issues (e.g. routing to different expert). 2nd, 3rd, and upcoming tokens are all conditioned on the previous tokens (including first), and have smaller entropy, (less sensitive to numerical issues). |
shuningjin
left a comment
There was a problem hiding this comment.
Thanks for identifying the noise in the initial token prediction and adding the option to skip! LGTM.
Thanks for the explanation! Potentially you have some data points for Kimi large model in logits verification. My mental model is: the first token is the most volatile due to high entropy. However, because each token depends on the previous one, that initial "tweak" usually causes the 2nd and 3rd tokens to diverge further from the original path, not settle back down. Right? |
Discussed offline with @gagika! It makes more sense now. This could be an issue for large MoE models (like Kimi-K2), potentially related with numerics, even the tokens IDs and weights are fixed. |
Description
Adds
--skip_first_tokenflag totests/forward_pass_logit_checker.py. This ignores the first token during logit comparison, preventing logit comparison failures due to high entropy at the first token which is sensitivity to numeric accuracy especially for MoE models with many experts.Tests
Verified locally on CPU. The script successfully ignored the initial token mismatch and passed the test criteria for the subsequent tokens using the new flag.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.