Skip to content

[WIP][JIT][Fork/Join] Stage 1: Eager fork-join#12405

Closed
jamesr66a wants to merge 2 commits intopytorch:masterfrom
jamesr66a:async_1_eager
Closed

[WIP][JIT][Fork/Join] Stage 1: Eager fork-join#12405
jamesr66a wants to merge 2 commits intopytorch:masterfrom
jamesr66a:async_1_eager

Conversation

@jamesr66a
Copy link
Copy Markdown
Collaborator

Establishing the front-end APIs for explicit fork/join parallelism. At runtime the forked sections are inlined, and wait is eliminated.

Forthcoming work is to implement lazy evaluation via coroutines. After that we can add true parallelism.

TODO: Figure out if this works in the string frontend
TODO: Remove remnants of coroutine implementation that got left in while i did a sketchy rebase

Comment thread torch/csrc/jit/type.h
friend struct Type;
template<typename ... T>
static FutureTypePtr create( T&& ... all) {
return FutureTypePtr(new FutureType( std::forward<T>(all)... )); // NOLINT(modernize-make-shared)

This comment was marked as off-topic.

// TODO schema
Operator(prim::Fork, [](Node* stack) -> Operation {
return [=](Stack& stack) -> int {
throw detail::NewCoroutine();

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Comment thread torch/csrc/jit/async.h
}
};

Future fork(script::Module &sm, std::vector<IValue> inputs) {

This comment was marked as off-topic.

Comment thread test/test_jit.py
return torch.neg(x)

x = torch.rand(3, 4)
fut = torch.jit.Fork(foo, (x,))

This comment was marked as off-topic.

};
}),
// TODO: type variable
Operator(prim::Wait, [](Node* stack) -> Operation {

This comment was marked as off-topic.

Method & m,
at::ArrayRef<NamedValue> inputs,
at::ArrayRef<NamedValue> attributes,
const std::vector<std::shared_ptr<SugaredValue>> &blocks,

This comment was marked as off-topic.

->setSourceLocation(std::make_shared<SourceRange>(loc));
auto body_block = n->addBlock();

std::vector<NamedValue> block_inputs;

This comment was marked as off-topic.

tree->range(), emitExpr(Expr(tree))));
auto sugared_expr = emitSugaredExpr(Expr(tree), 1);
// TODO: non-sketchy check
if (collect_blocks && sugared_expr->kind() == "module") {

This comment was marked as off-topic.

Comment thread test/test_jit.py
if not (TEST_WITH_UBSAN and test_name in UBSAN_BLACKLISTED_TESTS):
setattr(TestJitGenerated, test_name, do_test)

class TestAsync(JitTestCase):

This comment was marked as off-topic.

// TODO schema
Operator(prim::Fork, [](Node* stack) -> Operation {
return [=](Stack& stack) -> int {
throw detail::NewCoroutine();

This comment was marked as off-topic.

}
}
JIT_ASSERT(body_block->outputs().size() == 1);
n->output()->replaceAllUsesWith(value_remap[body_block->outputs()[0]]);

This comment was marked as off-topic.

Method& m,
at::ArrayRef<NamedValue> inputs_,
at::ArrayRef<NamedValue> attributes,
const std::vector<std::shared_ptr<SugaredValue>> &blocks,

This comment was marked as off-topic.

@jamesr66a
Copy link
Copy Markdown
Collaborator Author

Superseded by #12925

@jamesr66a jamesr66a closed this Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants