Skip to content
Closed
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions python/monarch/gradient/_gradient_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
#include <torch/csrc/autograd/python_function.h> // @manual=//caffe2:torch_extension
#include <torch/extension.h> // @manual=//caffe2:torch_extension

#define TORCH_VERSION_NEWER_THAN(major, minor, patch) \
((TORCH_VERSION_MAJOR > (major)) || \
(TORCH_VERSION_MAJOR == (major) && TORCH_VERSION_MINOR > (minor)) || \
(TORCH_VERSION_MAJOR == (major) && TORCH_VERSION_MINOR == (minor) && \
TORCH_VERSION_PATCH > (patch)))

using torch::autograd::Edge;
using torch::autograd::InputBuffer;
using torch::autograd::Node;
Expand Down Expand Up @@ -420,12 +426,20 @@ struct GradientGenerator {
DEBUG_PRINT(
"// add: " << node->node->name()
<< ", input_nr=" << static_cast<int>(input_nr) << "\n");
#if TORCH_VERSION_NEWER_THAN(2, 8, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

@pzhan9 Shouldn't this condition have been for 2.9.1? Even the release/2.9 branch has a 4-argument version: https://github.com/pytorch/pytorch/blob/d38164a545b4a4e4e0cf73ce67173f70574890b6/torch/csrc/autograd/input_buffer.h#L31

Copy link
Contributor

Choose a reason for hiding this comment

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

Addressed by #2000

realInputBuffer(node).add(
input_nr,
check_and_reduce(node->node, input_nr, std::move(t)),
std::nullopt,
std::nullopt,
node->node);
#else
realInputBuffer(node).add(
input_nr,
check_and_reduce(node->node, input_nr, std::move(t)),
std::nullopt,
std::nullopt);
#endif
}

InputBuffer& realInputBuffer(NodeState* state) {
Expand Down