Closed JiahaoYao closed 2 years ago
this can be simplified to the minimal codes:
import ray
ray.init()
class Trainer:
def __init__(self, state):
self.state = state
def method(self, arg):
print(arg)
print(self.state)
return self.state
@ray.remote
def wrapper(some_function, args, trainer):
print("some_fucntion.__self__", some_function.__self__)
print("type", type(some_function.__self__))
print("trainer", trainer)
return some_function(args)
t = Trainer(1234)
ray.get(wrapper.remote(t.method, 6789, t))
thanks @ckw017 !! 👍
In the current ray strategy, since the
strategy
shows in three places: two are obvious and one is hidden.one is in the ray launcher:
https://github.com/JiahaoYao/ray_lightning/blob/2727fd441a62e0e6763fd1f25ed97575dc5a6733/ray_lightning/ray_ddp.py#L38-L48
And later we use these in
_wrapped_function_
https://github.com/JiahaoYao/ray_lightning/blob/main/ray_lightning/ray_ddp.py#L241-L242
The second is an attributed in the
trainer.strategy
.The last hidden one is in the
https://github.com/JiahaoYao/ray_lightning/blob/2727fd441a62e0e6763fd1f25ed97575dc5a6733/ray_lightning/ray_ddp.py#L222-L226
ray remote functions create the copy of trainer.
Thus, the actual call of the
strategy.teardown
is the one from the copies of trainer.support of the assumption is
printing out the pid of strategy, and it turns out they are different.
Proposal: might removing the redundant use of strategy