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

Checkpoint refactoring - recognize checkpoints by operator instance name. #5503

Merged
merged 7 commits into from
Jun 13, 2024

Conversation

mzient
Copy link
Contributor

@mzient mzient commented Jun 5, 2024

Category:

Refactoring (Redesign of existing code that doesn't affect functionality)

Description:

Use operator names rather than incidental order in checkpoints.
Get operator instances from executor (by name) rather than from lowered graph (by index).
Rationale:

  • new graph doesn't store operator instances - that's the job of the executor
  • order of operators in the graph is incidental and brittle

Additionally, OpCheckpoint is now only forward-declared in operator.h, because most operators are stateless and don't need to depend on OpCheckpoint definition.

Additional information:

Affected modules and functionalities:

Key points relevant for the review:

Tests:

Tests adjusted (not added)

  • Existing tests apply
  • New tests added
    • Python tests
    • 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-3979

@mzient mzient requested a review from szkarpinski June 5, 2024 16:35
@mzient mzient requested a review from stiepan June 5, 2024 16:36
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15594081]: BUILD STARTED

@mzient mzient force-pushed the checkpoint_by_name branch 2 times, most recently from 557bc05 to 1188880 Compare June 5, 2024 17:02
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15594721]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15594721]: BUILD FAILED

Comment on lines +34 to +53
OpCheckpoint &Checkpoint::GetOpCheckpoint(int idx) {
DALI_ENFORCE_VALID_INDEX(idx, cpts_.size());
return cpts_[idx];
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you still rely on the order of the operators, right? The exectuor accesses the checkpoints by opnode's ordinal (opnode.id), not operator instance name. It feels like it becomes more brittle now.

Previously, when deserializing checkpoint we checked, one by one, that the op's name in the serialized checkpoint matches the name in the deserialized checkpoint (and thus in the graph, because the deserialized checkpoints were built first to match the graph ordering). Now, if the order somehow changes in the restored pipeline, we may succeed when deserializing (because we fetch the ops by name from the executor ignoring the order), but later we access the op checkpoints by the ordinal of the operator.

It seems like there should be one step further, either hiding the order whatsoever and accessing the op checkpoints by name (another map) or at least validate when deserializing that the order of op checkpoints matches the operators' ordinals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, here the executor is expected to remember the order in which the operators were added to the checkpoint. Still, there was a bug elsewhere and I've already posted a fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a question of practicality - current executor uses indices. I could add a name->index map and a lookup by name function, but I can still do it later, if it's necessary. Note that when restoring the checkpoint, I reversed the old logic and now restore the operators' state in the order in which they appear in the checkpoint, getting operators from the executor by name.

@mzient mzient force-pushed the checkpoint_by_name branch from 1188880 to 5cbffaf Compare June 11, 2024 14:39
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15740861]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15740861]: BUILD PASSED

mzient added 5 commits June 12, 2024 11:23
Use operator names rather than incidental order in checkpoints.
Get operator instances from executor (by name) rather than from lowered graph (by index).

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
…stateless.

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@mzient mzient force-pushed the checkpoint_by_name branch from c82b7e9 to b7d21b0 Compare June 12, 2024 10:23
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15766148]: BUILD STARTED

Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15768135]: BUILD STARTED

@NVIDIA NVIDIA deleted a comment from dali-automaton Jun 13, 2024
@dali-automaton
Copy link
Collaborator

CI MESSAGE: [15768135]: BUILD PASSED

@mzient mzient merged commit 927c93b into NVIDIA:main Jun 13, 2024
6 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.

4 participants