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/rllib] Add checkpoint eraser #4490

Merged
merged 13 commits into from
Apr 7, 2019

Conversation

jodusan
Copy link
Contributor

@jodusan jodusan commented Mar 27, 2019

What do these changes do?

Adds checkpoint eraser so disk doesn't get filled up.

Arguments introduced are

  • --keep-checkpoints-num - specifies up to how many checkpoints to keep
  • --checkpoint-score-attr - specifies by which parameter will the "best" checkpoints be ranked. (example episode_reward_mean). It can be specified with min- in front of the param name to rank by decreasing order (by default it is increasing example min-classification_loss).

Related issue number

#4381
#4287

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13298/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13358/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13409/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13408/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13407/
Test FAILed.

@ericl ericl self-assigned this Apr 3, 2019
self.best_checkpoint_attr_value = -float("inf") \
if self._cmp_greater else float("inf")
self.checkpoint_score_attr = checkpoint_score_attr \
if self._cmp_greater else checkpoint_score_attr[4:]
Copy link
Contributor

Choose a reason for hiding this comment

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

could add a comment that this strips off the "min-" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

Copy link
Contributor

@ericl ericl left a comment

Choose a reason for hiding this comment

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

Looks good to me! One minor comment.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13515/
Test FAILed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13516/
Test FAILed.

@ericl
Copy link
Contributor

ericl commented Apr 4, 2019

python/ray/tune/trial_runner.py:205: in restore
    new_trial = Trial(trial_cp["trainable_name"])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'Trial' object has no attribute 'custom_trial_name'") raised in repr()] SafeRepr object at 0x7f1b9ee50c68>
trainable_name = '_Mock', config = None, trial_id = None
local_dir = '/root/ray_results', experiment_tag = '', resources = None
stopping_criterion = None, checkpoint_freq = 0, checkpoint_at_end = False
keep_checkpoints_num = None, checkpoint_score_attr = None, export_formats = None
restore_path = None, upload_dir = None, trial_name_creator = None
loggers = None, sync_function = None, max_failures = 0

    def __init__(self,
                 trainable_name,
                 config=None,
                 trial_id=None,
                 local_dir=DEFAULT_RESULTS_DIR,
                 experiment_tag="",
                 resources=None,
                 stopping_criterion=None,
                 checkpoint_freq=0,
                 checkpoint_at_end=False,
                 keep_checkpoints_num=None,
                 checkpoint_score_attr=None,
                 export_formats=None,
                 restore_path=None,
                 upload_dir=None,
                 trial_name_creator=None,
                 loggers=None,
                 sync_function=None,
                 max_failures=0):
        """Initialize a new trial.
    
        The args here take the same meaning as the command line flags defined
        in ray.tune.config_parser.
        """
    
        Trial._registration_check(trainable_name)
        # Trial config
        self.trainable_name = trainable_name
        self.config = config or {}
        self.local_dir = os.path.expanduser(local_dir)
        self.experiment_tag = experiment_tag
        self.resources = (
            resources
            or self._get_trainable_cls().default_resource_request(self.config))
        self.stopping_criterion = stopping_criterion or {}
        self.upload_dir = upload_dir
        self.loggers = loggers
        self.sync_function = sync_function
        validate_sync_function(sync_function)
        self.verbose = True
        self.max_failures = max_failures
    
        # Local trial state that is updated during the run
        self.last_result = {}
        self.last_update_time = -float("inf")
        self.checkpoint_freq = checkpoint_freq
        self.checkpoint_at_end = checkpoint_at_end
    
        self.history = []
        self.keep_checkpoints_num = keep_checkpoints_num
>       self._cmp_greater = not checkpoint_score_attr.startswith("min-")
E       AttributeError: 'NoneType' object has no attribute 'startswith'

@jodusan
Copy link
Contributor Author

jodusan commented Apr 5, 2019

@ericl Updated!

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13588/
Test FAILed.

@@ -495,6 +505,27 @@ def update_last_result(self, result, terminate=False):
self.last_update_time = time.time()
self.result_logger.on_result(self.last_result)

def compare_checkpoints(self, attr_mean):
"""Compares two checkpoints based on the attribute attr_mean param.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you change this to match the Google Style for docstrings? https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html

@richardliaw richardliaw changed the title Add checkpoint eraser [tune/rllib] Add checkpoint eraser Apr 5, 2019
@richardliaw
Copy link
Contributor

jenkins retest this please

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-Perf-Integration-PRB/384/
Test PASSed.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13590/
Test FAILed.

@ericl
Copy link
Contributor

ericl commented Apr 6, 2019

jenkins retest this please

Also some lint errors.

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/Ray-PRB/13607/
Test FAILed.

@ericl ericl merged commit 820c71b into ray-project:master Apr 7, 2019
@ericl
Copy link
Contributor

ericl commented Apr 7, 2019

Tests look good, merging. Thanks!

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