-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Register fake grad to subgraph and quantized operators #14275
Conversation
MI, this is a temp solution to enable GluonCV INT8 flow and we will revert it after the improvement of CachedOP is 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.
LGTM. One suggestion, please add TODO(owner's name): some statement
in the code as a reminder for future maintenance.
Is it possible to merge this PR into #14276 ? @xinyu-intel @ZhennanQin @pengzhao-intel |
@ZhennanQin I'm afraid this PR has side effect if it's merged before #14276 . Reverting should not be a big deal as it only changes 9 lines. We always need a PR to revert changes. |
Avoiding side effect and keeping master branch healthy is the benefit. |
Merge with correct order can have same benefit:) |
@xinyu-intel Please collect #14276 into this PR as @TaoLv suggests. |
@mxnet-label-bot add [pr-awaiting-review] |
@TaoLv please help review again :) |
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.
LGTM. Just minor comment.
@@ -107,7 +107,11 @@ class SgMKLDNNConvPostQuantizeProperty : public SubgraphProperty { | |||
} | |||
} | |||
static SubgraphPropertyPtr Create() { | |||
return std::make_shared<SgMKLDNNConvPostQuantizeProperty>(); | |||
auto property = std::make_shared<SgMKLDNNConvPostQuantizeProperty>(); | |||
property->SetAttr<std::string>("prop_name", |
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.
Nit: can we use "property_name" or just "name" here? Because "prop" also stands for "propagation" somewhere.
@reminisce Can you take a look at the changes for subgraph? |
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.
LGTM
@reminisce please help confirm the subgraph related changes :)
@@ -82,6 +82,9 @@ where | |||
.set_attr<mxnet::FInferShape>("FInferShape", QuantizeShape) | |||
.set_attr<nnvm::FInferType>("FInferType", QuantizeType) | |||
.set_attr<FInferStorageType>("FInferStorageType", QuantizeStorageType) | |||
// TODO(Xinyu): a temp solution to enable GluonCV INT8 flow, | |||
// will be reverted after the improvement of CachedOP is 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.
is this currently WIP ? can you open an issue for this
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.
#14331 added:)
LOG(INFO) << "Skip subgraph " << full_name << " as it requires `grad_req=null`."; | ||
return src; | ||
} | ||
} |
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.
can we add a test for this case: module bound with for_training=True, and the symbol reused to invoke graph partitioning with MKLDNN. The returned symbol shouldn't contain mkldnn subgraph ops.
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 problem is, we can't get the symbol after module bound. So we can't check if MKLDNN graph partitioning happens or not.
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.
Why can't we use mod._sym and call get_backend_symbol("MKLDNN") on it?
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.
Because there's no python API can return the partitioned symbol after bind, even mod._sym holds the original symbol. And get_backend_symbol("MKLDNN")
will apply partition and won't skip inference_only
pass. inference_only
only works for bind.
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.
makes sense.
* add fake grad * Skip inference only subgraph pass when gradient is needed. * add fake grad to quantizev2 * add TODO * modify prop_name to property_name * add test case
* add fake grad * Skip inference only subgraph pass when gradient is needed. * add fake grad to quantizev2 * add TODO * modify prop_name to property_name * add test case
* add fake grad * Skip inference only subgraph pass when gradient is needed. * add fake grad to quantizev2 * add TODO * modify prop_name to property_name * add test case
Description
Motivation:
Register fake grad to subgraph and quantized operators to support loading back JSON files which contain inference_only operators as symbolblock to run gluon inference.
@pengzhao-intel @TaoLv @ZhennanQin @reminisce
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments