Skip to content

Commit

Permalink
debug loss mask
Browse files Browse the repository at this point in the history
  • Loading branch information
nikil-ravi committed Jan 12, 2025
1 parent bb708c4 commit 5530adf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/levanter/data/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def pack_prompt_completions(
for sequence in sequences:
loss_mask = np.arange(len(sequence.ids)) >= sequence.prompt_length - 1
loss_mask[-1] = 0

if not np.any(loss_mask):
logger.error(f"Invalid loss_mask: all zeros for sequence with prompt_length={sequence.prompt_length} and len(ids)={len(sequence.ids)}")
raise ValueError("Loss mask has no active tokens for loss computation.")

assert np.any(loss_mask)

for packer in packers:
Expand Down

0 comments on commit 5530adf

Please sign in to comment.