Repository navigation
Commit 78a4daf
authored
Fix flaky
* Fix flaky `test_causal_lm_loss_honors_shift_labels`
The first check compared the loss for two random 0/1 `shift_labels`
tensors and required them to differ. On tiny random models with nearly
flat logits (e.g. Inkling, which divides its hidden states by its muP
width multiplier), the per-token loss changes have random signs and can
cancel out in the mean below float32 resolution, so the two losses are
bit-identical and the test wrongly reports that `shift_labels` is
ignored (~1 in 700-2000 runs for Inkling).
Use the most and the least likely token at every position as the two
`shift_labels` instead: every token loss then moves in the same
direction, by the max - min spread of its logits, so the mean is bound
to move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address review: probe logits without labels, drop skip guard
- Reuse the existing no-labels probe forward (moved out of the `else`
branch) to pick the most / least likely tokens, instead of an extra
forward with labels.
- Drop the skip on missing / misaligned logits: the loss would already
fail on misaligned targets, and a head without logits should error.
- Shorten the comment and point to #50533.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Select the logits the loss is computed on before picking `shift_labels`
Git's logits also cover the image patches placed before the text, but its
loss only uses the text positions, so `shift_labels` picked from all of
the logits had the wrong length. Add a `_logits_scored_by_loss` hook
(identity by default) and override it in `GitModelTest` to drop the image
patch positions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>test_causal_lm_loss_honors_shift_labels (#50533)1 parent a4f3627 commit 78a4daf
2 files changed
Lines changed: 33 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
394 | 400 | | |
395 | 401 | | |
396 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1925 | 1925 | | |
1926 | 1926 | | |
1927 | 1927 | | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
1928 | 1938 | | |
1929 | 1939 | | |
1930 | 1940 | | |
| |||
1966 | 1976 | | |
1967 | 1977 | | |
1968 | 1978 | | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
1969 | 1983 | | |
1970 | 1984 | | |
1971 | 1985 | | |
1972 | 1986 | | |
1973 | 1987 | | |
1974 | 1988 | | |
1975 | | - | |
1976 | | - | |
1977 | | - | |
1978 | | - | |
1979 | | - | |
1980 | 1989 | | |
1981 | 1990 | | |
1982 | 1991 | | |
| |||
1987 | 1996 | | |
1988 | 1997 | | |
1989 | 1998 | | |
1990 | | - | |
| 1999 | + | |
1991 | 2000 | | |
1992 | | - | |
1993 | | - | |
| 2001 | + | |
| 2002 | + | |
1994 | 2003 | | |
1995 | 2004 | | |
1996 | 2005 | | |
1997 | 2006 | | |
1998 | 2007 | | |
1999 | 2008 | | |
2000 | | - | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
2001 | 2017 | | |
2002 | 2018 | | |
2003 | 2019 | | |
2004 | 2020 | | |
2005 | | - | |
| 2021 | + | |
2006 | 2022 | | |
2007 | 2023 | | |
2008 | 2024 | | |
2009 | 2025 | | |
2010 | 2026 | | |
2011 | 2027 | | |
2012 | 2028 | | |
2013 | | - | |
| 2029 | + | |
2014 | 2030 | | |
2015 | 2031 | | |
2016 | 2032 | | |
| |||
0 commit comments