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

[2.5.0][air] Store unflattened metrics in _TrackedCheckpoint #35706

Merged

Conversation

krfricke
Copy link
Contributor

Why are these changes needed?

Pick of 5acf41e

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 added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • 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 :(

)

We currently store metrics associated with a tracked AIR checkpoint in flattened format. This was done so we can specify nested keys in e.g. `checkpoint_score_attr`, which determines which checkpoints to keep.

However, we also rely on these stored metrics to restore the `trial.last_result` property when restoring from a checkpoint. Since ray-project#35000, we unflatten the dict there to resolve issues where we relied on the original structure in `trial.last_result`.

This again leads to issues with metrics in e.g. pytorch lightning, where some metrics are reported with a `/` (our default flatten separator). Or in a nutshell, `dict != unflatten(flatten(dict))` when the separator can be contained in the dict keys.

Some users may prefer to report with `/`, since it shows up nicely as nested metrics in wandb.

The proper resolution here is to not flatten the metrics at all. Instead, we should use `unflattened_lookup` to lookup the `checkpoint_score_attr` from the original metrics dict. 

This PR updates the `_TrackedCheckpoint` to retain the unflattened metrics.

Signed-off-by: Kai Fricke <[email protected]>
@zhe-thoughts
Copy link
Collaborator

Thanks for the work @krfricke

@matthewdeng and @gjoliver : is this critical enough to warrant a cherry pick vs. having it in 2.6?

Copy link
Contributor

@matthewdeng matthewdeng left a comment

Choose a reason for hiding this comment

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

@zhe-thoughts yes without this some basic workflows break

Copy link
Collaborator

@zhe-thoughts zhe-thoughts left a comment

Choose a reason for hiding this comment

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

Let's pick

@krfricke krfricke merged commit b5a775a into ray-project:releases/2.5.0 May 25, 2023
@krfricke krfricke deleted the pick/2.5.0/checkpoint-metrics branch May 25, 2023 10:08
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.

5 participants