Skip to content

Commit 0cf4a17

Browse files
authored
Fix: score final partial window in sliding window eval (openai#124)
The window_starts filter dropped windows shorter than stride, silently skipping up to (stride-1) tokens at the end of the validation set. Now includes all windows with >= 1 scoreable token, and clamps the score start for short final windows.
1 parent 608a57d commit 0cf4a17

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • records/track_10min_16mb/2026-03-19_SlidingWindowEval

records/track_10min_16mb/2026-03-19_SlidingWindowEval/train_gpt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,9 @@ def eval_val_sliding(
856856
seq_len = args.train_seq_len
857857
total_tokens = val_tokens.numel() - 1
858858

859-
# Build windows; skip any too short to score a full stride
859+
# Build windows; include final partial window if it has at least 1 token
860860
window_starts = [ws for ws in range(0, total_tokens, stride)
861-
if min(ws + seq_len, total_tokens) - ws >= stride]
861+
if min(ws + seq_len, total_tokens) - ws >= 1]
862862
total_windows = len(window_starts)
863863

864864
# Distribute across ranks
@@ -899,7 +899,7 @@ def eval_val_sliding(
899899

900900
for i, ws in enumerate(batch_ws):
901901
wlen = wlens[i]
902-
s = 0 if ws == 0 else wlen - stride
902+
s = 0 if ws == 0 else max(wlen - stride, 0)
903903
scored_nll = nll[i, s:wlen].to(torch.float64)
904904
loss_sum += scored_nll.sum()
905905
token_count += float(wlen - s)

0 commit comments

Comments
 (0)