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

[tune] Exception raised when there is no more trials #3069

Closed
old-bear opened this issue Oct 16, 2018 · 4 comments
Closed

[tune] Exception raised when there is no more trials #3069

old-bear opened this issue Oct 16, 2018 · 4 comments
Labels
bug Something that is supposed to be working; but isn't

Comments

@old-bear
Copy link
Contributor

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS 10.11
  • Ray installed from (source or binary): binary
  • Ray version: 0.5.3
  • Python version: 2.7
  • Exact command to reproduce:

Describe the problem

For SeachAlgorithm, if next_trials returns empty and is_finished yields True. The following happens in TrialRunner:

   def step(self):
        ...
        next_trial = self._get_next_trial()      <----- no more trial, which yields None here
        if next_trial is not None:
            self.trial_executor.start_trial(next_trial)
        elif self.trial_executor.get_running_trials():      <--- all trials completes, so no more running trials
            self._process_events()
        else:
            ....
            raise TuneError("Called step when all trials finished?")    <--- reach here

Source code / logs

See above

For the solution, I think we can add

if not self._search_alg.is_finished():
    raise(...)
@richardliaw
Copy link
Contributor

richardliaw commented Oct 16, 2018 via email

@ericl
Copy link
Contributor

ericl commented Oct 16, 2018

We already check search_alg.is_finished() in runner.is_finished(), so I don't think we should even be entering step() if the search algo is finished.

@old-bear
Copy link
Contributor Author

The situation may be a little tricky:

class MySearchAlgorithm(SearchAlgorithm):
    def next_trials(self):
        # doing some calcuation
        # here is_finished is still False
        ... 
        # and decide we should stop here
        self._is_finished = true
        return []

    def is_finished(self):
        return self._is_finished 

When using this algorithm, the check in tune.py before will pass:

    while not runner.is_finished():
        runner.step()     <-- run step here

, and thus trigger this problem.

As for the search algorithm, although we can move all the calculation into on_trial_result and just return the calculated ones in next_trials to avoid this problem, I think that would be quite unnatural

@ericl
Copy link
Contributor

ericl commented Oct 17, 2018

I see, that makes sense!

@ericl ericl added the bug Something that is supposed to be working; but isn't label Oct 17, 2018
@richardliaw richardliaw reopened this Nov 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't
Projects
None yet
Development

No branches or pull requests

3 participants