[tune] Prefix global object registry with job ID to avoid conflicts in multi tenancy - #33095
Conversation
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <kai@anyscale.com>
Signed-off-by: Kai Fricke <coding@kaifricke.com>
| def _register_atexit(self): | ||
| if not self._atexit_handler_registered: | ||
| atexit.register(_unregister_all) | ||
| self._atexit_handler_registered = True |
There was a problem hiding this comment.
I guess we're assuming this is only ever used on the driver. Is that true?
There was a problem hiding this comment.
That's a good point. rllib registers envs/trainers on import. So if a remote process triggers an import, this may be triggered. I've added a check to only register this handler on the driver, which should be safe.
There was a problem hiding this comment.
Guarding this on the driver only sounds good to me.
|
I wonder if we should rethink this whole registry thing. Would it be possible to replace it with a named actor pinned to the head node, which would automatically get gc'ed with the job end? |
Signed-off-by: Kai Fricke <kai@anyscale.com>
|
We discuss some alternatives in this doc, including the detached actor. My main concern at the moment is the fault tolerance, i.e. recreating the actor if it fails. My feeling (maybe wrongly so) is that the global kv store has better availability guarantees - is that accurate? Since we have the registry already, I think this PR is very non-invasive to the current logic. If it's fine with you, I'd like to go ahead with the changes in the PR and track the detached actor refactor as a P2 improvement. |
| return | ||
|
|
||
| if ray._private.worker.global_worker.mode != ray.SCRIPT_MODE: | ||
| # Only cleanup on the driver |
There was a problem hiding this comment.
I think it's acceptable to not care about Ray client here. The garbage we may collect should be small in any case, and we didn't do any cleanup previously at all.
There was a problem hiding this comment.
That seems ok, though wouldn't this also work in client mode automatically, as the Tune driver is usually run on the driver in client mode too?
There was a problem hiding this comment.
The default behavior is to wrap the whole tune run/tuner object in a remote task/actor, which would then be WORKER_MODE
| return | ||
|
|
||
| if ray._private.worker.global_worker.mode != ray.SCRIPT_MODE: | ||
| # Only cleanup on the driver |
There was a problem hiding this comment.
That seems ok, though wouldn't this also work in client mode automatically, as the Tune driver is usually run on the driver in client mode too?
| self._atexit_handler_registered = False | ||
|
|
||
| @property | ||
| def prefix(self): |
There was a problem hiding this comment.
| def prefix(self): | |
| def job_id_prefix(self): |
For clarity.
There was a problem hiding this comment.
I'll leave it as prefix as it can be specified in the registry init to something other than the job id (mostly for compatibility, we can remove this later though).
β¦n multi tenancy (ray-project#33095) In ray-project#32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in ray-project#30091. This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials. To prove that it works, we modify the fix from ray-project#32560 to not require a workaround anymore. To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run. Signed-off-by: Kai Fricke <kai@anyscale.com> Signed-off-by: Kai Fricke <coding@kaifricke.com> Signed-off-by: Jack He <jackhe2345@gmail.com>
β¦n multi tenancy (ray-project#33095) In ray-project#32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in ray-project#30091. This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials. To prove that it works, we modify the fix from ray-project#32560 to not require a workaround anymore. To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run. Signed-off-by: Kai Fricke <kai@anyscale.com> Signed-off-by: Kai Fricke <coding@kaifricke.com> Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
β¦n multi tenancy (ray-project#33095) In ray-project#32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in ray-project#30091. This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials. To prove that it works, we modify the fix from ray-project#32560 to not require a workaround anymore. To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run. Signed-off-by: Kai Fricke <kai@anyscale.com> Signed-off-by: Kai Fricke <coding@kaifricke.com>
β¦n multi tenancy (ray-project#33095) In ray-project#32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in ray-project#30091. This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials. To prove that it works, we modify the fix from ray-project#32560 to not require a workaround anymore. To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run. Signed-off-by: Kai Fricke <kai@anyscale.com> Signed-off-by: Kai Fricke <coding@kaifricke.com> Signed-off-by: elliottower <elliot@elliottower.com>
β¦n multi tenancy (ray-project#33095) In ray-project#32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in ray-project#30091. This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials. To prove that it works, we modify the fix from ray-project#32560 to not require a workaround anymore. To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run. Signed-off-by: Kai Fricke <kai@anyscale.com> Signed-off-by: Kai Fricke <coding@kaifricke.com> Signed-off-by: Jack He <jackhe2345@gmail.com>
Why are these changes needed?
In #32560, we documented a workaround for the multi tenancy issues in Ray Tune, e.g. described in #30091.
This PR fixes the root issue by prefixing the global registry with the core worker job ID, which is unique per driver process. This will avoid conflicts between parallel running tune trials.
To prove that it works, we modify the fix from #32560 to not require a workaround anymore.
To avoid cluttering the global key-value store with stale objects, we also de-register objects from the global KV store after finishing a Ray Tune run.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.