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

disable autograd in lazy mode #7070

Merged
merged 19 commits into from
Dec 26, 2021
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5c39829
disable autograd in lazy mode
hjchen2 Dec 21, 2021
263f25e
refine
hjchen2 Dec 21, 2021
76bcf2d
Merge branch 'master' into dev_fix_lazy_autograd
hjchen2 Dec 22, 2021
515fb89
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 22, 2021
bfd4234
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 22, 2021
c5c17f6
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 22, 2021
d0ad90d
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 22, 2021
53c35d0
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 23, 2021
84d8979
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 23, 2021
8c02c7e
Merge branch 'master' into dev_fix_lazy_autograd
hjchen2 Dec 23, 2021
506be97
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 23, 2021
1eb9660
Merge branch 'master' into dev_fix_lazy_autograd
hjchen2 Dec 24, 2021
09b3160
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 24, 2021
dd5847a
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 24, 2021
21d88d1
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 24, 2021
199ae1e
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 24, 2021
e9bccd2
Merge branch 'master' into dev_fix_lazy_autograd
hjchen2 Dec 25, 2021
09a769f
Merge branch 'master' into dev_fix_lazy_autograd
oneflow-ci-bot Dec 25, 2021
d147539
Merge branch 'master' into dev_fix_lazy_autograd
hjchen2 Dec 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion oneflow/core/framework/op_interpreter/op_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
#include "oneflow/core/framework/op_expr_grad_function.h"
#include "oneflow/core/framework/tensor.h"
#include "oneflow/core/framework/tensor_tuple.h"
#include "oneflow/core/job/lazy_mode.h"

namespace oneflow {
namespace one {
Expand Down Expand Up @@ -94,7 +95,8 @@ Maybe<void> AutogradInterpreter::Apply(const OpExpr& op_expr, const TensorTuple&
autograd::AutoGradMode mode(false);
JUST(internal_->Apply(op_expr, inputs, outputs, ctx));
}
if (requires_grad) {
// Lazy mode will construct backward compute graph in passes, so disable autograd if lazy mode.
if (requires_grad && !LazyMode::is_enabled()) {
const auto& grad_closure = JUST(op_expr.GetOrCreateOpGradClosure());
JUST(grad_closure->Capture(inputs, *outputs, ctx));

Expand Down