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

[AIR] Fix Checkpoint.to_dict metadata serialization #28895

Merged
merged 2 commits into from
Sep 29, 2022

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Sep 29, 2022

Signed-off-by: Balaji Veeramani [email protected]

Why are these changes needed?

Checkpoints returned from session.report don't contain metadata because session.report converts _CheckpointDict objects to dict.

    def report(self, metrics: Dict, checkpoint: Optional[Checkpoint] = None) -> None:
        ...
        if checkpoint:
            checkpoint_dict = checkpoint.to_dict()
            self.checkpoint(**checkpoint_dict)
        ...

I've changed to_dict to store metadata directly in the dictionary as opposed to in an object attribute. The downside with this approach is that we now leak implementation details.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@xwjiang2010
Copy link
Contributor

The contract around _SERIALIZED_ATTRS is not dependent on what kind of conversion that the checkpoint goes through right?
I don't think we can just assume that it has to be go through TrainSession.report(), or it doesn't work.

@bveeramani
Copy link
Member Author

The contract around _SERIALIZED_ATTRS is not dependent on what kind of conversion that the checkpoint goes through right?

That's correct.

I don't think we can just assume that it has to be go through TrainSession.report(), or it doesn't work.

We're not assuming that checkpoints go through report. It already works for all of the other conversions; it only fails for report.

Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@xwjiang2010
Copy link
Contributor

Seems there is a relevant CI failure..

@bveeramani
Copy link
Member Author

Seems there is a relevant CI failure..

Addressed

@amogkam amogkam merged commit 1321882 into ray-project:master Sep 29, 2022
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
)

Signed-off-by: Balaji Veeramani [email protected]

Checkpoints returned from `session.report` don't contain metadata because `session.report` converts `_CheckpointDict` objects to `dict`.

I've changed `to_dict` to store metadata directly in the dictionary as opposed to in an object attribute. The downside with this approach is that we now leak implementation details.

Signed-off-by: Weichen Xu <[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.

3 participants