Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DALI FW iterator reset for DROP last batch policy #4881

Merged
merged 2 commits into from
Jun 1, 2023

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented May 30, 2023

  • when the DALI FW iterator follows the DROP last batch policy,
    and the user iterates over it using its length, the last batch
    that is supposed to be dropped remains in the pipeline
    and is dropped in the next iteration. This PR makes sure that
    reset of the DALI pipeline can drop this redundant batch, so
    next iteration won't raise StopIteration

Category:

Bug fix (non-breaking change which fixes an issue)

Description:

  • when the DALI FW iterator follows the DROP last batch policy,
    and the user iterates over it using its length, the last batch
    that is supposed to be dropped remains in the pipeline
    and is dropped in the next iteration. This PR makes sure that
    reset of the DALI pipeline can drop this redundant batch, so
    next iteration won't raise StopIteration
  • related to Epochs terminating early incorrectly Lightning-AI/pytorch-lightning#12956 (comment)

Additional information:

Affected modules and functionalities:

  • dali/python/nvidia/dali/plugin/base_iterator.py

Key points relevant for the review:

  • NA

Tests:

  • Existing tests apply
  • New tests added
    • Python tests
      • test_fw_iterators.py:test_*_autoreset_iter
    • GTests
    • Benchmark
    • Other
  • N/A

Checklist

Documentation

  • Existing documentation applies
  • Documentation updated
    • Docstring
    • Doxygen
    • RST
    • Jupyter
    • Other
  • N/A

DALI team only

Requirements

  • Implements new requirements
  • Affects existing requirements
  • N/A

REQ IDs: N/A

JIRA TASK: N/A

- when the DALI FW iterator follows the DROP last batch policy,
  and the user iterates over it using its length, the last batch
  that is supposed to be dropped remains in the pipeline
  and is dropped in the next iteration. This PR makes sure that
  reset of the DALI pipeline can drop this redundant batch, so
  next iteration won't raise StopIteration

Signed-off-by: Janusz Lisiecki <[email protected]>
@JanuszL
Copy link
Contributor Author

JanuszL commented May 30, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8461064]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8461064]: BUILD PASSED

Signed-off-by: Janusz Lisiecki <[email protected]>
# incomplete batch, we need to extract from the pipeline and drop before rising
# StopIteration indicating the pipeline is depleted. Here we first check if that
# is the case, and if so we run the pipeline and drop the last batch
if self._last_batch_policy == LastBatchPolicy.DROP and not ():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self._last_batch_policy == LastBatchPolicy.DROP and not ():
if self._last_batch_policy == LastBatchPolicy.DROP:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@JanuszL
Copy link
Contributor Author

JanuszL commented Jun 1, 2023

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8490353]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8490387]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [8490353]: BUILD PASSED

@JanuszL JanuszL merged commit fec2122 into NVIDIA:main Jun 1, 2023
@JanuszL JanuszL deleted the improve_reset_drop branch June 1, 2023 16:57
JanuszL added a commit to JanuszL/DALI that referenced this pull request Oct 13, 2023
- when the DALI FW iterator follows the DROP last batch policy,
  and the user iterates over it using its length, the last batch
  that is supposed to be dropped remains in the pipeline
  and is dropped in the next iteration. This PR makes sure that
  reset of the DALI pipeline can drop this redundant batch, so
  next iteration won't raise StopIteration

Signed-off-by: Janusz Lisiecki <[email protected]>
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.

4 participants