Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
michaelsuo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
5cffb33 to
c271b03
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
michaelsuo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@pytorchbot retest this please |
zdevito
left a comment
There was a problem hiding this comment.
Nice! See comments for where I think there is a fixable bug. I also think it may be possible to remove the MoveSide thing by phrasing everything as moveBefore.
| // Move 'this' (already in the graph) after 'n' in the topological order. | ||
| // | ||
| // Tries to preserve value dependencies, so other nodes might be moved. The | ||
| // only guarantee is that in the new ordering, `this` is after `n`. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| } | ||
|
|
||
| // Does `this` output any values used by `nodes`? | ||
| template <typename T> |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
|
||
| // Does the working set consume any values produced by `n`? | ||
| bool consumesFrom(Node* n) const { | ||
| const auto& users = getUsersSameBlock(n); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| bool Node::tryMove(Node* movePoint, MoveSide moveSide) { | ||
| JIT_ASSERT(this->inBlockList() && movePoint->inBlockList()); | ||
| JIT_ASSERT(this->owningBlock() == movePoint->owningBlock()); | ||
| JIT_ASSERT(this != movePoint); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
facebook-github-bot
left a comment
There was a problem hiding this comment.
michaelsuo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
michaelsuo has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
How does this relate to the DynamicDAG data structure that @zou3519 added for autodiff subgraph search? Is this meant to be faster/easier to maintain? |
|
There's a lot of overlap; I think the main difference is that the topological index is located directly in the graph and so it stays updated/correct by construction. This makes things simpler for pass authors, who only have to deal with the graph and its canonical topological ordering. As it is currently implemented it seems impractical to embed DynamicDAG into the graph, because common operations like node insertion would become quite expensive. I think a good path to converging would be to optimize DynamicDAG a bit around some of the performance cliffs, and then embed it into the IR so that passes don't have to construct their own copy every time. |
|
Hmmm could you please comment a bit more on the performance characteristics of this solution that are lacking from the DynamicDAG? The algorithm generally is pretty solid, and generally it’s not necessarily true that insertions would become expensive. It’s also fundamentally an online solution with proofs of correctness, so it’s an appealing solution. |
|
@apaszke This solution solves a different problem from DynamicDAG There is one main difference:
edit: Sorry, I realized from reading the code that I don't know how |
This is not true. We can modify DynamicDAG to have "gaps" between nodes in topological index, just like what you implemented last week, @michaelsuo, to make node insertions fast. |
|
|
||
| // Test that moveAfter(n) and moveBefore(n->next()) are not necessarily | ||
| // equivalent. Here, the dependency ordering is n -> o -> p. So we can't | ||
| // move `n` after `o`, but we can move `n` before `p` (which pushes `o` after |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
|
The main performance concern was that My other concerns were around maintainability. I don't think pass authors should have to construct a separate data structure every time they want to do reordering, and having But like I originally said, I think all these problems are fixable by modifying DynamicDAG (adding "gaps" like @zou3519 describes) and then making it part of the graph interface. I think the ideal end state is we basically merge the topological index stuff and DynamicDAG together to implement |
|
I think it is also important to keep in mind that the reason for making these queries about valid moves centralized is because mutability is going to make a bunch of moves that appear to be topologically valid become invalid. We can to limit the number of places that have to interact with the metadata about mutating operators. |
Summary: Add new methods to move a node before/after another node while preserving data data dependencies. Any suggestions for a pithier name for the methods would be appreciated 😃 Pull Request resolved: pytorch#13026 Differential Revision: D10854574 Pulled By: QueryConnectionException fbshipit-source-id: b42751cac18d1e23940e35903c8e6a54a395292e
Add new methods to move a node before/after another node while preserving data data dependencies.
Any suggestions for a pithier name for the methods would be appreciated 😃