-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
[tracing] Fix issue where actor/task is defined before ray.init
is called
#38323
Conversation
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
ray.init
is called
@@ -163,6 +163,7 @@ def remote(self, *args, **kwargs): | |||
|
|||
return FuncWrapper() | |||
|
|||
@wrap_auto_init |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto-init needs to happen before the tracing decorator runs because it calls get_runtime_context
if not _is_tracing_enabled(): | ||
return function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change: if ray.init
hasn't been called then _is_tracing_enabled
isn't set properly yet.
Need to always inject this kwarg
optimistically. This shouldn't affect anything unless users have a kwarg called _ray_trace_ctx
in their function.
Note that this is already how it worked for actor methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need an unit test, or is it already covered?
@rkooo567 it's covered by removing the |
…called (ray-project#38323) Fixes an issue where the `_ray_trace_ctx` kwarg isn't injected to the function signature if `ray.init` is called w/ a tracing hook _after_ defining the function (see issue for repro). The issue was we were checking `_is_tracing_enabled` at function definition time and selectively injecting the kwarg, but this variable isn't set until `ray.init` is called. I modified it to always inject the kwarg (matching the existing behavior for actor methods). I've updated the tests to not explicitly call `ray.init` before defining the task. Signed-off-by: harborn <gangsheng.wu@intel.com>
…called (ray-project#38323) Fixes an issue where the `_ray_trace_ctx` kwarg isn't injected to the function signature if `ray.init` is called w/ a tracing hook _after_ defining the function (see issue for repro). The issue was we were checking `_is_tracing_enabled` at function definition time and selectively injecting the kwarg, but this variable isn't set until `ray.init` is called. I modified it to always inject the kwarg (matching the existing behavior for actor methods). I've updated the tests to not explicitly call `ray.init` before defining the task.
…called (ray-project#38323) Fixes an issue where the `_ray_trace_ctx` kwarg isn't injected to the function signature if `ray.init` is called w/ a tracing hook _after_ defining the function (see issue for repro). The issue was we were checking `_is_tracing_enabled` at function definition time and selectively injecting the kwarg, but this variable isn't set until `ray.init` is called. I modified it to always inject the kwarg (matching the existing behavior for actor methods). I've updated the tests to not explicitly call `ray.init` before defining the task. Signed-off-by: e428265 <arvind.chandramouli@lmco.com>
#39362) The single_client_tasks_and_get_batch benchmark saw a ~0.5-1k tasks/s average regression (2k tasks/s on a local machine) due to #38323, which changed some tracing logic to unconditionally change the signature of every remote function to accomodate tracing during _inject_tracing_into_function. Make the signature change conditional again, but move it to the execution portion of RemoteFunction rather than the definition. Also make sure the injection only happens once even when the remote function is executed multiple times.
ray-project#39362) The single_client_tasks_and_get_batch benchmark saw a ~0.5-1k tasks/s average regression (2k tasks/s on a local machine) due to ray-project#38323, which changed some tracing logic to unconditionally change the signature of every remote function to accomodate tracing during _inject_tracing_into_function. Make the signature change conditional again, but move it to the execution portion of RemoteFunction rather than the definition. Also make sure the injection only happens once even when the remote function is executed multiple times.
#39362) (#39429) The single_client_tasks_and_get_batch benchmark saw a ~0.5-1k tasks/s average regression (2k tasks/s on a local machine) due to #38323, which changed some tracing logic to unconditionally change the signature of every remote function to accomodate tracing during _inject_tracing_into_function. Make the signature change conditional again, but move it to the execution portion of RemoteFunction rather than the definition. Also make sure the injection only happens once even when the remote function is executed multiple times.
ray-project#39362) The single_client_tasks_and_get_batch benchmark saw a ~0.5-1k tasks/s average regression (2k tasks/s on a local machine) due to ray-project#38323, which changed some tracing logic to unconditionally change the signature of every remote function to accomodate tracing during _inject_tracing_into_function. Make the signature change conditional again, but move it to the execution portion of RemoteFunction rather than the definition. Also make sure the injection only happens once even when the remote function is executed multiple times. Signed-off-by: Jim Thompson <jimthompson5802@gmail.com>
…called (ray-project#38323) Fixes an issue where the `_ray_trace_ctx` kwarg isn't injected to the function signature if `ray.init` is called w/ a tracing hook _after_ defining the function (see issue for repro). The issue was we were checking `_is_tracing_enabled` at function definition time and selectively injecting the kwarg, but this variable isn't set until `ray.init` is called. I modified it to always inject the kwarg (matching the existing behavior for actor methods). I've updated the tests to not explicitly call `ray.init` before defining the task. Signed-off-by: Victor <vctr.y.m@example.com>
ray-project#39362) The single_client_tasks_and_get_batch benchmark saw a ~0.5-1k tasks/s average regression (2k tasks/s on a local machine) due to ray-project#38323, which changed some tracing logic to unconditionally change the signature of every remote function to accomodate tracing during _inject_tracing_into_function. Make the signature change conditional again, but move it to the execution portion of RemoteFunction rather than the definition. Also make sure the injection only happens once even when the remote function is executed multiple times. Signed-off-by: Victor <vctr.y.m@example.com>
Why are these changes needed?
Fixes an issue where the
_ray_trace_ctx
kwarg isn't injected to the function signature ifray.init
is called w/ a tracing hook after defining the function (see issue for repro).The issue was we were checking
_is_tracing_enabled
at function definition time and selectively injecting the kwarg, but this variable isn't set untilray.init
is called. I modified it to always inject the kwarg (matching the existing behavior for actor methods).I've updated the tests to not explicitly call
ray.init
before defining the task.Related issue number
Closes #26019
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.