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

Completely Remove FutureMessage from RPC agents #50028

Closed
wants to merge 4 commits into from

Conversation

mrshenli
Copy link
Contributor

@mrshenli mrshenli commented Jan 4, 2021

Stack from ghstack:

Differential Revision: D25753887

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jan 4, 2021

💊 CI failures summary and remediations

As of commit 1de8a22 (more details on the Dr. CI page):


  • 2/2 failures possibly* introduced in this PR
    • 2/2 non-CircleCI failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

This comment has been revised 17 times.

mrshenli added a commit that referenced this pull request Jan 4, 2021
ghstack-source-id: 34cc2d66b97bd0c956e635b38277426eacd6fb24
Pull Request resolved: #50028
Comment on lines 517 to 518
auto futureResponse =
std::make_shared<JitFuture>(at::AnyClassType::get());
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines are different than the ones they're replacing: before we were creating an empty (null) shared_ptr, here we create a "full" shared_ptr that points to an uncompleted future. It also appears that immediately after we re-set this shared_ptr to a new value, hence destroying that uncompleted future. I think it makes sense to avoid creating it in the first place.

if (!error) {
if (!futureResponseMessage->hasError()) {
Message&& responseMessage =
std::move(*futureResponseMessage->value().toCustomClass<Message>());
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder: does it make sense to add a moveValue() method to ivalue::Future? For cases like this where we don't care about the future anymore and just want its content?

(Personally I think the "idiomatic" way would be to have a &&-qualified value() method but I've seen that in PyTorch that's not always the convention...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can add that. cc @wanchaol if there are concerns for adding value() &&.

const c10::optional<utils::FutureError> error =
futureResponseMessage->error();
Message&& responseMessage = std::move(*futureResponseMessage).moveValue();
responseMessage.setId(messageId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did this line go? Is it not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I don't think this is necessary as request cbs have already set the id for the response message. But let me add it back for safety.

@@ -572,12 +570,14 @@ void TensorPipeAgent::respond(std::shared_ptr<tensorpipe::Pipe>& pipe) {
<< " is running request #" << messageId << " from "
<< pipe->getRemoteName() << " in thread pool";

std::shared_ptr<FutureMessage> futureResponseMessage;
auto futureResponseMessage =
std::make_shared<JitFuture>(at::AnyClassType::get());
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above: we're allocating an uncompleted JitFuture just to immediately replacing it (and thus deallocating it). It's probably better to leave the shared_ptr unset.

@facebook-github-bot
Copy link
Contributor

@mrshenli merged this pull request in 171648e.

@facebook-github-bot facebook-github-bot deleted the gh/mrshenli/280/head branch January 11, 2021 15:17
hwangdeyu pushed a commit to hwangdeyu/pytorch that referenced this pull request Jan 14, 2021
Summary: Pull Request resolved: pytorch#50028

Test Plan: Imported from OSS

Reviewed By: lw

Differential Revision: D25753887

Pulled By: mrshenli

fbshipit-source-id: 40718349c2def262a16aaa24c167c0b540cddcb1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: distributed Add this issue/PR to distributed oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants