-
Notifications
You must be signed in to change notification settings - Fork 241
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
[TorchFX] Export to torch.export.export_for_training
#3075
[TorchFX] Export to torch.export.export_for_training
#3075
Conversation
a33ce2e
to
78f8588
Compare
2d8f400
to
707d4cd
Compare
84d4039
to
68bb7b6
Compare
tests/torch/conftest.py
Outdated
@@ -120,6 +128,10 @@ def pytest_configure(config: Config): | |||
if regen_dot: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I would like to update json files only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regen_dot
was added there by mistake, I have updated the suggestion. https://github.com/openvinotoolkit/nncf/pull/3075/files/68bb7b6f09bba89935ae44a7aff6e8f3bee237ea#r1841827740
@@ -384,17 +380,53 @@ def count_constants(model: torch.fx.GraphModule) -> int: | |||
return num_constant_nodes | |||
|
|||
|
|||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="capture_pre_autograd_graph is not supported on Windows") | |||
def test_create_shared_constant_transformation(): | |||
model = MultiBranchesConnectedModel() | |||
ex_inputs = torch.ones((1, 3, 3, 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you suggest we remove this transformation completely? Since, the shared nodes are taken care of now that we are using torch.export.export_for_training
and we do not necessarily need to support torch._export.capture_pre_autograd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove support for capture_pre_autograd
form the tests.
@@ -384,17 +380,53 @@ def count_constants(model: torch.fx.GraphModule) -> int: | |||
return num_constant_nodes | |||
|
|||
|
|||
@pytest.mark.skipif(sys.platform.startswith("win"), reason="capture_pre_autograd_graph is not supported on Windows") | |||
def test_create_shared_constant_transformation(): | |||
model = MultiBranchesConnectedModel() | |||
ex_inputs = torch.ones((1, 3, 3, 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tests/torch/conftest.py
Outdated
@@ -120,6 +128,10 @@ def pytest_configure(config: Config): | |||
if regen_dot: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I would like to update json files only?
|
tests/torch/conftest.py
Outdated
if regen_dot: | ||
os.environ["NNCF_TEST_REGEN_DOT"] = "1" | ||
|
||
regen_json = config.getoption("--regen-json", False) | ||
if regen_json: | ||
os.environ["NNCF_TEST_REGEN_JSON"] = "1" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if regen_dot: | |
os.environ["NNCF_TEST_REGEN_DOT"] = "1" | |
regen_json = config.getoption("--regen-json", False) | |
if regen_json: | |
os.environ["NNCF_TEST_REGEN_JSON"] = "1" | |
for option, var in [("--regen-dot", "NNCF_TEST_REGEN_DOT"), ("--regen-json", "NNCF_TEST_REGEN_JSON")]: | |
regen = config.getoption(option, False) | |
if regen: | |
os.environ[env_var] = "1" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please check
9e946ee
to
29f15e0
Compare
…it#3075) ### Changes * TorchFX Unit tests are moved from `torch._export.capture_pre_autograd_graph` to `torch.export.export_for_training` ALL REFERENCE GRAPHS WERE VALIDATED MANUALLY * BC types for `fuse_bn_node` are updated * NNCFGraphBuilder is updated to support a batch-norm type with only one output node (instead of three) * Model extractor does not traverse down from constans to prevent redundant nodes in the extracted model when the constant is shared * `shared_constants_unification_transformation` is removed * Tests which require `capture_pre_autograd_graph` are removed ### Reason for changes * To migrate to the lates and recommended export method for TorchFX backend ### Related tickets openvinotoolkit#2766 ### Tests test_shared_constants_unification_not_connected_const post_training_quantization/540/ is finished successfully
PR #3075 to the release branch: ### Changes * TorchFX Unit tests are moved from `torch._export.capture_pre_autograd_graph` to `torch.export.export_for_training` ALL REFERENCE GRAPHS WERE VALIDATED MANUALLY * BC types for `fuse_bn_node` are updated * NNCFGraphBuilder is updated to support a batch-norm type with only one output node (instead of three) * Model extractor does not traverse down from constans to prevent redundant nodes in the extracted model when the constant is shared * `shared_constants_unification_transformation` is removed * Tests which require `capture_pre_autograd_graph` are removed ### Reason for changes * To migrate to the lates and recommended export method for TorchFX backend ### Related tickets #2766 ### Tests test_shared_constants_unification_not_connected_const post_training_quantization/540/ is finished successfully
…it#3075) ### Changes * TorchFX Unit tests are moved from `torch._export.capture_pre_autograd_graph` to `torch.export.export_for_training` ALL REFERENCE GRAPHS WERE VALIDATED MANUALLY * BC types for `fuse_bn_node` are updated * NNCFGraphBuilder is updated to support a batch-norm type with only one output node (instead of three) * Model extractor does not traverse down from constans to prevent redundant nodes in the extracted model when the constant is shared * `shared_constants_unification_transformation` is removed * Tests which require `capture_pre_autograd_graph` are removed ### Reason for changes * To migrate to the lates and recommended export method for TorchFX backend ### Related tickets openvinotoolkit#2766 ### Tests test_shared_constants_unification_not_connected_const post_training_quantization/540/ is finished successfully
Changes
torch._export.capture_pre_autograd_graph
totorch.export.export_for_training
ALL REFERENCE GRAPHS WERE VALIDATED MANUALLY
fuse_bn_node
are updatedshared_constants_unification_transformation
is removedcapture_pre_autograd_graph
are removedReason for changes
Related tickets
#2766
#2987
Tests
test_shared_constants_unification_not_connected_const
post_training_quantization/540/ is finished successfully