Skip to content

Setting num_sanity_val_steps = -1 Disables Sanity Check Instead of Running All Batches #20586

@RaphaelLilt

Description

@RaphaelLilt

📚 Documentation

Description:
The documentation indicates that setting num_sanity_val_steps to -1 a sanity check is run on all validation batches. However, in Trainer._run_sanity_check, the sanity check only runs if self.num_sanity_val_steps > 0. As a result, when num_sanity_val_steps is set to -1, no sanity check is run.

Steps to Reproduce:

  1. Instantiate Trainer with num_sanity_val_steps = -1.
  2. Add validation dataloader.
  3. Call trainer.fit(). Notice that no sanity check is run.

Expected Behavior:
When num_sanity_val_steps is -1, the sanity check should iterate over all validation batches.

Actual Behavior:
The condition (self.num_sanity_val_steps > 0) prevents any sanity checking when num_sanity_val_steps is -1.

Proposed Fix:
Update _run_sanity_check to treat -1 as a special value that means “run all validation batches”, or update the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation relatedneeds triageWaiting to be triaged by maintainers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions