Repository navigation
Commit fcd9d03
committed
Return f32 from apply_frequency_presence_penalty, don't round back down
Codex review: the function computed the penalty in f32 but cast the
result back to the caller's original dtype before returning. For
f16/bf16 logits this could round a small penalty away outright (or
noticeably distort it) before LogitsProcessor::sample converts back to
f32 anyway for softmax. utils::apply_repeat_penalty already avoids this
by always returning f32; do the same here for consistency, including
in the zero-penalty no-op path so the function's return dtype is
uniform regardless of whether a penalty was actually applied.
Adds a regression test with a f16 logit large enough (1000.0, ULP
~0.98) that a 0.5 penalty would be rounded away by a cast back to f16.1 parent 88facc3 commit fcd9d03
2 files changed
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
| |||
0 commit comments