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

[quant] Move the order of x86 engine to avoid changing the default qengine #86631

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion aten/src/ATen/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ const std::vector<at::QEngine>& Context::supportedQEngines() {

#ifdef USE_FBGEMM
if (fbgemm::fbgemmSupportedCPU()) {
engines.push_back(at::kFBGEMM);
// The X86 qengine is available if and only if FBGEMM is available
engines.push_back(at::kX86);
engines.push_back(at::kFBGEMM);
Comment on lines -327 to +329
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, order of supported engines is completely irrelevant here, isn't it?

}
#endif

Expand Down
12 changes: 6 additions & 6 deletions torch/ao/quantization/qconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ def __new__(cls, activation=torch.nn.Identity, weight=torch.nn.Identity):
Default qconfig for operators that reuse the observers from input Tensor, e.g. reshape
"""

def get_default_qconfig(backend='x86', version=0):
def get_default_qconfig(backend='fbgemm', version=0):
"""
Returns the default PTQ qconfig for the specified backend.

Args:
* `backend`: a string representing the target backend. Currently supports
`x86` (default), `fbgemm`, `qnnpack` and `onednn`.
`x86`, `fbgemm` (default), `qnnpack` and `onednn`.

Return:
qconfig
Expand Down Expand Up @@ -298,13 +298,13 @@ def get_default_qconfig(backend='x86', version=0):
default_embedding_qat_qconfig_4bit = QConfig(activation=NoopObserver.with_args(dtype=torch.float32),
weight=default_embedding_fake_quant_4bit)

def get_default_qat_qconfig(backend='x86', version=1):
def get_default_qat_qconfig(backend='fbgemm', version=1):
"""
Returns the default QAT qconfig for the specified backend.

Args:
* `backend`: a string representing the target backend. Currently supports
`x86`(default), `fbgemm`, `qnnpack` and `onednn`.
`x86`, `fbgemm` (default), `qnnpack` and `onednn`.
* `version`: version, for backwards compatibility. Can be `None` or `1`.

Return:
Expand Down Expand Up @@ -392,13 +392,13 @@ def get_default_qat_qconfig(backend='x86', version=1):
eps=2 ** -12),
weight=fused_per_channel_wt_fake_quant_range_neg_127_to_127)

def get_default_qconfig_dict(backend='x86', version=0):
def get_default_qconfig_dict(backend='fbgemm', version=0):
warnings.warn(
"torch.ao.quantization.get_default_qconfig_dict is deprecated and will be removed in "
"a future version. Please use torch.ao.quantization.get_default_qconfig_mapping instead.")
return torch.ao.quantization.get_default_qconfig_mapping(backend, version).to_dict()

def get_default_qat_qconfig_dict(backend='x86', version=1):
def get_default_qat_qconfig_dict(backend='fbgemm', version=1):
warnings.warn(
"torch.ao.quantization.get_default_qat_qconfig_dict is deprecated and will be removed in "
"a future version. Please use torch.ao.quantization.get_default_qat_qconfig_mapping instead.")
Expand Down
8 changes: 4 additions & 4 deletions torch/ao/quantization/qconfig_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,25 @@ def _get_default_qconfig_mapping(is_qat: bool, backend: str, version: int) -> QC

return qconfig_mapping

def get_default_qconfig_mapping(backend="x86", version=0) -> QConfigMapping:
def get_default_qconfig_mapping(backend="fbgemm", version=0) -> QConfigMapping:
"""
Return the default QConfigMapping for post training quantization.

Args:
* ``backend`` : the quantization backend for the default qconfig mapping, should be
one of ["x86" (default), "fbgemm", "qnnpack", "onednn"]
one of ["x86", "fbgemm" (default), "qnnpack", "onednn"]
* ``version`` : the version for the default qconfig mapping
"""
# TODO: add assert for backend choices
return _get_default_qconfig_mapping(False, backend, version)

def get_default_qat_qconfig_mapping(backend="x86", version=1) -> QConfigMapping:
def get_default_qat_qconfig_mapping(backend="fbgemm", version=1) -> QConfigMapping:
"""
Return the default QConfigMapping for quantization aware training.

Args:
* ``backend`` : the quantization backend for the default qconfig mapping, should be
one of ["x86" (default), "fbgemm", "qnnpack", "onednn"]
one of ["x86", "fbgemm" (default), "qnnpack", "onednn"]
* ``version`` : the version for the default qconfig mapping
"""
return _get_default_qconfig_mapping(True, backend, version)
Expand Down