In the tutorial, the distributedOptimizer is necessary.

image1620×620 150 KB

On the other hand, even the rref object(self.language_model_service_rref) is only used in the model(used in model.forward() exactly), the same error occurs when the second batch begins to be handled.
# remove the rref object from optimizer
opt = DistributedOptimizer(
        optim.SGD,

        # Just get the local params and wrap it with RRef,
        # because I need no update to the remote bert params
        [RRef(prompt_embedding_policy.params)],  

        # model.parameter_rrefs(),  # get the remote params, will use self.language_model_service_rref)
        lr=0.05,
    )
...
# when the model begins to deal with the second batch, the same error occurs(the rref object does not exist).
for batch in data_loader:
    logits = model(batch)  # note just an example here