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

[Train] Report only once in SklearnTrainer #30593

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

Yard1
Copy link
Member

@Yard1 Yard1 commented Nov 22, 2022

Signed-off-by: Antoni Baum antoni.baum@protonmail.com

Why are these changes needed?

Sets "done": True in the SklearnTrainer report so that it only print the results only once.

Related issue number

Closes #29226

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 :(

Signed-off-by: Antoni Baum <antoni.baum@protonmail.com>
@amogkam
Copy link
Contributor

amogkam commented Nov 22, 2022

@Yard1 is this a bug in Tune? Report is only being called once right?

@Yard1
Copy link
Member Author

Yard1 commented Nov 22, 2022

@amogkam It's more a quirk of Tune - obviously, Tune doesn't know ahead of time if the report its getting will be the last one (unless "done" is explicitly passed in there) - in which case, the functional trainable does the following:

        If the RunnerThread finishes without reporting "done",
        Tune will automatically provide a magic keyword __duplicate__
        along with a result with "done=True". The TrialRunner will handle the
        result accordingly (see tune/trial_runner.py).

I suppose a more generic fix to this issue would be to not print the duplicate result, as duplicate printing is the main issue here. Logic should be otherwise correct in all cases.

@amogkam
Copy link
Contributor

amogkam commented Nov 22, 2022

Yeah I guess my main question is does this duplicate printing apply to function trainables as well? Since I've never seen any of our function trainable examples report with "done": True.

If that's the case, then I think we should avoid the duplicate printing on the Tune side.

@Yard1
Copy link
Member Author

Yard1 commented Nov 22, 2022

Yeah the duplicate printing with functional trainable is the exact issue here. It's not unique to SklearnTrainer, but it's easy to miss it with trainers that report multiple times (because it's just one more result printout out of dozens or hundreds). Also, we print out a result only if n seconds have passed since last printout OR if this is a result with "done": True, so it's not uncommon for the last result with "done": False to not be printed.

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.

Sounds good. Can we also fix the duplicate printing on the Tune side as well?

@Yard1
Copy link
Member Author

Yard1 commented Nov 22, 2022

@amogkam followup in tune #30597

@amogkam amogkam merged commit c0f86f4 into ray-project:master Nov 22, 2022
@Yard1 Yard1 deleted the fix_sklearn_trainer_double_report branch November 22, 2022 22:18
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
Sets "done": True in the SklearnTrainer report so that it only print the results only once.

Signed-off-by: Antoni Baum <antoni.baum@protonmail.com>
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
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.

[AIR] SklearnTrainer prints results 2x
3 participants