Skip to content

Conversation

@XChen-Zero
Copy link

What does this PR do?

This PR fixes a bug in SFT validation when use_sequence_packing is enabled.

In the current implementation, train_step wraps the loss function with
SequencePackingSFTLossWrapper, while val_step directly uses the raw
loss function. This causes validation to fail when sequence packing is enabled.

This PR applies the same loss wrapper logic in val_step to keep training and
validation behavior consistent.

Why is this needed?

When use_sequence_packing is enabled:

  • Training uses SequencePackingSFTLossWrapper to correctly handle packed sequences
  • Validation does not apply the wrapper
  • As a result, forward_step receives incompatible inputs and validation fails

This leads to runtime errors during validation and makes SFT training with
sequence packing unusable.

Changes

  • Apply SequencePackingSFTLossWrapper in val_step when use_sequence_packing is enabled
  • Align loss handling between train_step and val_step

Backward Compatibility

  • No behavior change when use_sequence_packing is disabled
  • Fully backward compatible

Related Issue

N/A

@CLAassistant
Copy link

CLAassistant commented Dec 15, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants