KEMBAR78
Remove LazyStreamContext (2 out of 2) by lw · Pull Request #59299 · pytorch/pytorch · GitHub
Skip to content

Conversation

@lw
Copy link
Contributor

@lw lw commented Jun 2, 2021

Stack from ghstack:

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: D28789174

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot added oncall: distributed Add this issue/PR to distributed oncall triage queue cla signed labels Jun 2, 2021
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 2, 2021

💊 CI failures summary and remediations

As of commit 8a1dfce (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_linux_bionic_py3_8_gcc9_coverage_test1 Run tests 🔁 rerun

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.

Click here to manually regenerate this comment.

lw added a commit that referenced this pull request Jun 2, 2021
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

ghstack-source-id: 130359961
Pull Request resolved: #59299
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
lw added a commit that referenced this pull request Jun 3, 2021
Pull Request resolved: #59299

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.
ghstack-source-id: 130473860

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
lw added a commit that referenced this pull request Jun 3, 2021
Pull Request resolved: #59299

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.
ghstack-source-id: 130478940

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)
const std::vector<torch::Tensor>& tensors) {
c10::optional<c10::impl::VirtualGuardImpl> impl;
size_t deviceCount = 0;
std::vector<bool> indexBitSet;
Copy link
Contributor

Choose a reason for hiding this comment

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

curious about this var name. It seems to be neither bit nor set? Or is it possible to use a real std::bitset here?

Copy link
Contributor Author

@lw lw Jun 3, 2021

Choose a reason for hiding this comment

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

This is probably not the best capitalization, but the name was meant to be "a bitset of indices". It is conceptually identical to std::bitset, but if you notice std::bitset requires a compile-time size. The doc for std::bitset says:

If the size of the bitset is not known at compile time, std::vector<bool> may be used.

Hope this clarifies. I'll fix the capitalization.

}
std::vector<c10::Device> devices;
devices.reserve(deviceCount);
for (c10::DeviceIndex idx = 0; idx < indexBitSet.size(); idx++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

lint failures look real.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter is correct "in principle" but here we know that the size of the vector will fit in a DeviceIndex because we used a DeviceIndex to resize the vector.

I'm starting to think that perhaps we should create a dedicated DeviceVector class, that can provide properly-typed accessors, can perhaps use small-vector optimizations, ...

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
lw added 3 commits June 3, 2021 08:04
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
Copy link
Contributor

@mrshenli mrshenli left a comment

Choose a reason for hiding this comment

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

LGTM. Stamp to unblock.

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.

Differential Revision: [D28789174](https://our.internmc.facebook.com/intern/diff/D28789174/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in c09beaa.

@facebook-github-bot facebook-github-bot deleted the gh/lw/204/head branch June 7, 2021 14:17
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this pull request Jun 9, 2021
Summary:
Pull Request resolved: pytorch#59299

After recent changes, LazyStreamContext had in fact always become eager, and was in fact equivalent to a vector of streams. So it makes more sense now to remove this abstraction and use a more self-descriptive type.

This PR migrates the TensorPipe agent. The previous PR migrated the RequestCallback internals.
ghstack-source-id: 130583773

Test Plan: CI

Reviewed By: mrshenli

Differential Revision: D28789174

fbshipit-source-id: a27d2b1f40ab3cf2ac0dd946232fd0eecda6d450
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