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

Improve iterator checkpointing #5371

Merged
merged 13 commits into from
Mar 19, 2024
Merged

Conversation

szkarpinski
Copy link
Collaborator

Category:

New feature (non-breaking change which adds functionality)
Refactoring (Redesign of existing code that doesn't affect functionality)

Description:

In this PR I explicitly save iterator data to the checkpoint and then use it to restore. Previously, I attempted to calculate iterator state based on pipeline state, which turned out to be a bad idea.

Iterator checkpointing now works as follows:

  1. User calls it.checkpoints()
  2. (!) The iterator creates a dict with values of its internal counters, pickles it and saves it to pipe._iterator_data in each of its pipelines.
  3. Iterator calls pipe.checkpoint() for each of its pipelines (pipe._iterator_data is now saved in a checkpoint as well)
  4. Later, user restores the pipelines and creates a new iterator.
  5. (!) The iterator notices that the pipelines are restored, so it grabs pipe._iterator_data and restores its counters

This approach enables the following new features, which were problematic before:

  • Checkpointing for FILL + pad_last_batch=False, which was not supported
  • Reflecting .reset() in the checkpoint. Before, the fact that user has called it.reset() was not reflected in a checkpoint in any way, resulting in ambiguous restore.

Additional information:

Affected modules and functionalities:

ExternalContext, Base iterator, C API

Key points relevant for the review:

Tests:

  • Existing tests apply
  • New tests added
    • Python tests (test_reset to check if it.reset() is now checkpointed correctly)
    • 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: DALI-3870

Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
restored_external_context.iterator_data.data,
mock_external_context.iterator_data.data,
mock_external_context.iterator_data.size), 0);
daliDestroyExternalContextCheckpoint(&mock_external_context);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adding

daliDestroyExternalContextCheckpoint(&mock_external_context);

fixes a leak which was there before, introduced with #5356

szkarpinski and others added 3 commits March 15, 2024 18:26
Co-authored-by: Kamil Tokarski <kamiltokarski04@gmail.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
Signed-off-by: Szymon Karpiński <skarpinski@nvidia.com>
@szkarpinski
Copy link
Collaborator Author

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [13612650]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [13612650]: BUILD PASSED

@szkarpinski szkarpinski merged commit 0e06487 into NVIDIA:main Mar 19, 2024
6 of 7 checks passed
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.

None yet

4 participants