Skip to content

[mkldnn][10/N] Port forward FP Conv ops from ideep to ATen - #205716

Closed
frost-intel wants to merge 5 commits into
gh/frost-intel/8/basefrom
gh/frost-intel/8/head
Closed

frost-intel wants to merge 5 commits into
gh/frost-intel/8/basefrom
gh/frost-intel/8/head

Conversation

@frost-intel

@frost-intel frost-intel commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Linked issue or supporting maintainer

Part of #154444

BC-breaking?

No

Summary (human written only)

Ports floating-point conv forward operators from ideep. Only ops called within ATen are ported over. Backward and quantized ops are left for a follow-up PR

Ports are line-for-line and do not change any behavior.

Agent details (if applicable)

Developed with assistance from Claude Opus 5.5.

Ports the floating-point convolution forward operators that ATen uses from ideep (ideep::convolution_forward) into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp} (namespace at::native::mkldnn). The port is line-for-line and changes no behavior: it still takes ideep::tensor / ideep::attr_t and uses ideep's engine, stream and primitive cache.

To stay under the PR size limit, convolution is split across three PRs:

Ported

Public (detail/Conv.h), each with ideep's comment:

  • convolution_forward_compute_v3: with and without bias.
  • convolution_forward_compute_binary<reorder_src, reorder_weight>: with and without bias. Explicitly instantiated for <true, true>, the only combination ATen uses.
  • convolution_forward_expected_weights_desc: the overload that takes is_channels_last at runtime.

File-local (detail/Conv.cpp), same names as in ideep:

  • convolution_forward_params
  • conv_deconv_utils::prepare_parameters (fp32 overload)
  • get_primitive_desc: the uncached aarch64 variant and the cached x86 variant
  • expected_weights_desc<is_channels_last>
  • do_compute, do_compute_binary
  • compute_dispatch (fp32)
  • do_prepare (fp32)
  • compute_binary_dispatch

Call sites switched

  • mkldnn/Conv.cpp: compute_v3 ×2, compute_binary ×2.
  • mkldnn/ConvPrepack.cpp: expected_weights_desc.
  • mkldnn/MKLDNNConversions.cpp: expected_weights_desc ×2 (conv2d/conv3d weight reorder).
  • quantized/cpu/qconv_prepack.cpp: expected_weights_desc ×2. This is a quantized file, but the call is the same fp expected_weights_desc overload.

Still on ideep:

  • backward data and weights (backward PR)
  • ConvPrepack.cpp compute_v2 (compute_v2 PR)
  • quantized prepare / compute in qconv.cpp
  • transposed convolution
  • t_store().clear() in IDeepRegistration.cpp

Dropped (no ATen callers / unused)

  • convolution_forward::use_gemm
  • unused overloads, and the engine / lowp_kind parameters on the public functions
  • the int8 do_prepare and the param-based prepare / compute(params, ...) overloads (moving with quantized conv)

Other changes

  • IDEEP_ENFORCE becomes a debug-only dnnl::error::wrap_c_api(...) under #ifndef NDEBUG. IDEEP_CHECK becomes an unconditional wrap_c_api. Both behave as in ideep.
  • Called directly from ideep for now: ideep::utils::get_compatible_dilates, ideep::utils::group_dims, ideep::utils::create_key, ideep::utils::computation_cache.
  • The primitive cache is ideep's thread-local computation_cache<dnnl::convolution_forward::primitive_desc>, the same store ideep uses. clear_computation_cache() therefore needs no change.
  • Two loop indices in expected_weights_desc changed from int to size_t (sign-compare; ideep hides this as a system header).
  • Fixed typos in a comment copied from ideep: "workaroud", "detials", "weihgts".

Testing

oneDNN verbose logs (ONEDNN_VERBOSE=1, timings stripped, sorted counts) are identical before and after:

  • test_mkldnn.py plus test_freezing.py -k mkldnn: 6,572 distinct lines.
  • quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8": 257 distinct lines.
  • test_mkldnn_fusion.py, nn/test_convolution.py -k mkldnn, and inductor/test_mkldnn_pattern_matcher.py -k "conv and not qconv and not quant and not woq": 1,284 distinct lines, 772 of them convolution.

Four Inductor tests fail identically with and without this change: test_conv{2,3}d_binary_broadcast_shapes_cpu and test_conv_transpose{2,3}d_unary_cpu, all with bf16 tolerance errors. test_conv2d_unary_cpu is flaky at its fp32 tolerance.

Convolution is split across PRs for size: forward (#201224), backward (#201229), compute_v2 (#202611), quantized (#202622) and transposed (#203645). Backward lives in detail/Conv.{h,cpp} alongside forward.

(test/jit/test_freezing.py and test/test_mkldnn_fusion.py were later deleted upstream by #203621. The final A/B comparison of the whole series against main, described in #204808, re-checks these paths without it.)

Previously submitted as #201224.

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01

[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added module: cpu CPU specific problem (e.g., perf, algorithm) release notes: quantization release notes category labels Nov 19, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

This PR ports ideep's floating-point convolution_forward forward path
(compute_v3, compute_binary, expected_weights_desc and helpers) into
aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp} and switches the ATen call sites
to use it. Recommendation: Approve. None of the points raised blocks merging;
the review names the Security bounds check as the one most worth adding.

Findings (4):

[minor] aten/src/ATen/native/mkldnn/detail/Conv.cpp:373
Non-blocking, already in ideep: the file-local `expected_weights_desc` (lines
372-375) reads `weights_dims.size()` elements of `src_dims` without checking its
length. `mkldnn_reorder_conv2d_weight` and `mkldnn_reorder_conv3d_weight`
(MKLDNNConversions.cpp:168-169, 225-226) pass the user's `input_size` through
unchanged, and `input_size` is an unbounded `SymInt[]?` in
native_functions.yaml. So a 4-D mkldnn weight with `input_size=[1]` reads past
the end of the vector. ConvPrepack.cpp:56-57 is safe because
`expand_param_if_needed` enforces the length. The PR only renames the callee, so
this is not a regression. Now that ATen owns this code, a
`TORCH_CHECK(src_dims.empty() || src_dims.size() == weights_dims.size(), ...)`
would be cheap to add here or in the two reorder ops.

[minor] aten/src/ATen/native/mkldnn/detail/Conv.h:12
Non-blocking: the public names in detail/Conv.h:12,30,49,70 break the convention
of the other detail/*.h ports, which map ideep's `X::compute` to `X` and
`X::compute_binary` to `X_binary` (inner_product_forward,
inner_product_forward_binary, softmax_forward, pooling_forward, eltwise_forward)
and use the parameter names `prop_kind` and `algorithm`. This header keeps
`convolution_forward_compute_v3` / `convolution_forward_compute_binary` and
ideep's `aalgorithm` / `aprop_kind`. If `_v3` is kept on purpose to distinguish
it from the compute_v2 port in # 202611, consider `convolution_forward` /
`convolution_forward_binary` here and a `_v2` suffix on the deprecated one.
Otherwise the series ends up with two naming schemes.

[minor] aten/src/ATen/native/mkldnn/detail/Conv.h:11
Non-blocking: the "for fp32" comments copied from ideep are misleading in an
ATen header (detail/Conv.h:11,29,46,67 and detail/Conv.cpp:585,657,727). These
paths also handle bf16 and f16 (`prepare_parameters`, Conv.cpp:92-122). ideep
meant "non-quantized", and Conv.cpp:61 already says "non-quantization version",
which reads better. The comment for `convolution_forward_expected_weights_desc`
(Conv.h:86-87) should say it is also used for quantized prepack:
qconv_prepack.cpp:438-442 and :599-605 pass s8 or f8_e4m3 weights, u8 or f8_e4m3
activations, and scale/zero-point op_attrs, and the function has int8-specific
logic (`y_dtype = s32` for s8 at Conv.cpp:390-392). The description's claim that
quantized ops are left for later, and that this is "the same fp overload",
understates this.

[minor] aten/src/ATen/native/mkldnn/detail/Conv.cpp:29
Non-blocking: detail/Conv.cpp carries over ideep state that nothing in ATen
uses. `convolution_forward_params::pd_use_threads` (lines 29, 42, 51) is never
read, and its comment ("only used outside ideep Set in do_prepare()") is wrong
here because the constructors set it. The 5-argument constructor (31-42) and the
`bias_attr` member are unused. `all_scales` / `all_zero_points` are never
assigned, so the loops in `do_compute` (476-489) and `do_compute_binary`
(564-577) never run. The `src_attr` / `weights_attr` / `bias_attr` outputs of
`prepare_parameters` (76-78) are never written or read. `op_attr(op_attr)`
(lines 26, 39) copies from an `ideep::attr_t&&` parameter where it should use
`std::move`. The InnerProduct port trimmed its params struct to the fields it
uses (InnerProduct.cpp:14-21). Doing the same here, and adding fields back in #
202611 if the int8 path needs them, would keep the two ports consistent.

Reviewed commit: b3f19c4 (NOT the current head 1bfef38)

Review run

🐛 Report a bad review

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205716

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 1bfef38 with merge base 4004f7e (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of b3f19c4: nothing blocking; ready for human review.

This PR ports ideep's floating-point convolution_forward forward path (compute_v3, compute_binary, expected_weights_desc and helpers) into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp} and switches the ATen call sites to use it. Recommendation: Approve. None of the points raised blocks merging; the review names the Security bounds check as the one most worth adding.

⚪ 4 non-blocking findings

x_dims.push_back(src_dims[i]);

Non-blocking, already in ideep: the file-local expected_weights_desc (lines 372-375) reads weights_dims.size() elements of src_dims without checking its length. mkldnn_reorder_conv2d_weight and mkldnn_reorder_conv3d_weight (MKLDNNConversions.cpp:168-169, 225-226) pass the user's input_size through unchanged, and input_size is an unbounded SymInt\[\]? in native_functions.yaml. So a 4-D mkldnn weight with input_size=\[1\] reads past the end of the vector. ConvPrepack.cpp:56-57 is safe because expand_param_if_needed enforces the length. The PR only renames the callee, so this is not a regression. Now that ATen owns this code, a TORCH_CHECK(src_dims.empty() || src_dims.size() == weights_dims.size(), ...) would be cheap to add here or in the two reorder ops.


void convolution_forward_compute_v3(

Non-blocking: the public names in detail/Conv.h:12,30,49,70 break the convention of the other detail/*.h ports, which map ideep's X::compute to X and X::compute_binary to X_binary (inner_product_forward, inner_product_forward_binary, softmax_forward, pooling_forward, eltwise_forward) and use the parameter names prop_kind and algorithm. This header keeps convolution_forward_compute_v3 / convolution_forward_compute_binary and ideep's aalgorithm / aprop_kind. If _v3 is kept on purpose to distinguish it from the compute_v2 port in # 202611, consider convolution_forward / convolution_forward_binary here and a _v2 suffix on the deprecated one. Otherwise the series ends up with two naming schemes.


// 2-in-1 Conv computation with bias for fp32

Non-blocking: the "for fp32" comments copied from ideep are misleading in an ATen header (detail/Conv.h:11,29,46,67 and detail/Conv.cpp:585,657,727). These paths also handle bf16 and f16 (prepare_parameters, Conv.cpp:92-122). ideep meant "non-quantized", and Conv.cpp:61 already says "non-quantization version", which reads better. The comment for convolution_forward_expected_weights_desc (Conv.h:86-87) should say it is also used for quantized prepack: qconv_prepack.cpp:438-442 and :599-605 pass s8 or f8_e4m3 weights, u8 or f8_e4m3 activations, and scale/zero-point op_attrs, and the function has int8-specific logic (y_dtype = s32 for s8 at Conv.cpp:390-392). The description's claim that quantized ops are left for later, and that this is "the same fp overload", understates this.


pd_use_threads(omp_get_max_threads()) {}

Non-blocking: detail/Conv.cpp carries over ideep state that nothing in ATen uses. convolution_forward_params::pd_use_threads (lines 29, 42, 51) is never read, and its comment ("only used outside ideep Set in do_prepare()") is wrong here because the constructors set it. The 5-argument constructor (31-42) and the bias_attr member are unused. all_scales / all_zero_points are never assigned, so the loops in do_compute (476-489) and do_compute_binary (564-577) never run. The src_attr / weights_attr / bias_attr outputs of prepare_parameters (76-78) are never written or read. op_attr(op_attr) (lines 26, 39) copies from an ideep::attr_t&amp;&amp; parameter where it should use std::move. The InnerProduct port trimmed its params struct to the fields it uses (InnerProduct.cpp:14-21). Doing the same here, and adding fields back in # 202611 if the int8 path needs them, would keep the two ports consistent.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@frost-intel frost-intel added topic: not user facing topic category and removed release notes: quantization release notes category labels Nov 19, 2026
@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 19, 2026
[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the release notes: quantization release notes category label Nov 19, 2026
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok ok

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #205717

pytorchmergebot pushed a commit that referenced this pull request Nov 20, 2026
## Linked issue or supporting maintainer
Part of #154444

## BC-breaking?
No

## Summary (human written only)
Port of the convolution backward ops from ideep to ATen. Unused params and functions were dropped, but otherwise this is a line-for-line port with identical functionality, verified by tests and onednn_verbose log checking.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the floating-point convolution **backward** operators that ATen uses from ideep (`ideep::convolution_backward_data`, `ideep::convolution_backward_weights`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`), based on #201224 (conv forward). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine and stream.
>
> This is one of the convolution PRs (split for size). It adds the backward functions to the same `detail/Conv.{h,cpp}` as the forward port.
>
> ### Ported
> Public (`detail/Conv.h`):
> - `convolution_backward_data_compute_v2` (`ideep::attr_t op_attr` by value, as in ideep)
> - `convolution_backward_weights_compute_v2`: with and without bias
>
> File-local (`detail/Conv.cpp`):
> - `backward_weights_compute_impl<with_diff_bias>`: ideep's `convolution_backward_weights::compute_impl`, renamed to avoid clashing with the forward helpers.
>
> Both functions keep ideep's aarch64 and x86 primitive-descriptor variants.
>
> The forward primitive descriptor used as a hint comes from the ported `get_primitive_desc`, exactly as ideep's backward does. On x86 that lookup goes through ideep's forward primitive cache, as before.
>
> ### Call sites switched
> - `mkldnn/Conv.cpp`: `mkldnn_convolution_backward_input` (backward data) and `mkldnn_convolution_backward_weights` (with and without bias).
>
> ### Dropped (no ATen callers / unused)
> - The `algorithm` parameter of both functions; it was always `convolution_direct`, which is now fixed locally.
> - The `engine` parameters.
> - Backward weights: `diff_weight_type` and the branch that only ran with a non-default value.
>
> ### Other changes
> - `IDEEP_CHECK` (bf16/f16 on avx2_vnni_2) becomes an unconditional `dnnl::error::wrap_c_api`, as in ideep. ideep's backward functions have no `IDEEP_ENFORCE`, so there is no debug-only check here.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines, 1,494 of them convolution backward.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `nn/test_convolution.py -k mkldnn` and the Inductor mkldnn pattern tests: covered by the whole-series A/B comparison against `main` in #204808, with identical per-test outcomes and identical oneDNN primitive logs. (`test_mkldnn_fusion.py` no longer exists upstream.)
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #201229.

Pull Request resolved: #205717
Approved by: https://github.com/albanD
ghstack dependencies: #205709, #205710, #205711, #205712, #205713, #205714, #205715, #205716
pytorchmergebot pushed a commit that referenced this pull request Nov 25, 2026
## Linked issue or supporting maintainer
Part of #154444
Supported by @albanD

## BC-breaking?
No

## Summary (human written only)
Third of convolution PRs split for size, along #205716 (forward) and #205717 (backward). In ideep, this op is marked as `DEPRECATED`, but current code in ATen still calls this, so I'm porting without changes for now. I expect that we could switch to the v3 version, but the goal of this stack is no behavior change on a line-to-line level, so that's left for a follow-up.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports ideep's **deprecated** `convolution_forward::compute_v2` into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`). Its only caller is `ConvPrepack.cpp`, which backs the `mkldnn_prepacked::conv2d_*` ops used by the TorchScript TensorExpr fuser. The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine, stream and primitive cache.
>
> This is the third of the convolution PRs (split for size), after #205716 (forward) and #205717 (backward). It adds to the forward port's `detail/Conv.{h,cpp}`.
>
> ### Ported
> Public (`detail/Conv.h`), each with ideep's `// DEPRECATED` comment:
> - `convolution_forward_compute_v2`: with and without bias.
>
> File-local (`detail/Conv.cpp`), same names as in ideep:
> - `compute_dispatch`: the scales/zero-points overload.
>
> Shared (`detail/Conv.h`, defined at namespace scope in `detail/Conv.cpp`):
> - `conv_deconv_utils::prepare_parameters`: the quantization overload (scales and zero points), ported here. The fp32 overload from #205716 moves out of `Conv.cpp`'s anonymous namespace unchanged. Both are declared in `Conv.h` so that the transposed-convolution ports (14/N, 15/N) can share them, as ideep shares them between `conv.hpp` and `deconv.hpp`.
>
> ideep routes `compute_v2` through these int8-capable functions even for fp32. `ConvPrepack` always passes empty scales and zero points, so only their fp32 branches run today. They are kept line-for-line and will be reused by the quantized-conv port (13/N). The call chain is the same as ideep's: `compute_v2` → scales/zero-points `compute_dispatch<with_bias, true, true>` → int8 `prepare_parameters` → `get_primitive_desc` / `do_compute`. The last two come from #205716.
>
> ### Call sites switched
> - `mkldnn/ConvPrepack.cpp`: `compute_v2` with and without bias.
>
> ### Dropped (no ATen callers / unused)
> - `compute_v2`'s `algorithm`, `prop_kind`, `lowp_kind` and `engine` parameters. ATen never passes them; the internal `compute_dispatch` defaults, identical to ideep's, apply.
> - The unused local `weights_zero_point` in the int8 `prepare_parameters`. ideep has it unused too; it is hidden there because ideep's headers are included as system headers, but here it fails `WERROR` builds.
>
> ### Other changes
> - `IDEEP_ENFORCE` becomes a debug-only `dnnl::error::wrap_c_api(...)` under `#ifndef NDEBUG`, as in ideep.
> - Called directly from ideep for now: `ideep::utils::get_compatible_dilates`, `ideep::utils::tensor_scale_mask`, `ideep::utils::tensor_zp_mask`, `ideep::utils::conv_weight_scale_mask`, `ideep::IDEEP_DEF_SCALE`.
>
> ### Testing
> - **Coverage:** no test in CI reaches `compute_v2` today. Its only callers are the `mkldnn_prepacked::conv2d_*` ops, which only the TorchScript TensorExpr fuser inserts, and the tests that reached them (`test_mkldnn_fusion.py`, `test_freezing.py`) no longer exist upstream. Before their removal they called the ported `compute_v2` 40 times (20 with bias, 20 without), which I checked with temporary instrumentation. I'm not adding a new test, since TorchScript is being removed.
> - **oneDNN verbose logs** (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
>   - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines.
>   - `test_mkldnn_fusion.py`, `nn/test_convolution.py -k mkldnn`, and `inductor/test_mkldnn_pattern_matcher.py -k "conv and not qconv and not quant and not woq"`: 1,284 distinct lines.
>   - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
>
> Four Inductor tests fail identically with and without this change: `test_conv{2,3}d_binary_broadcast_shapes_cpu` and `test_conv_transpose{2,3}d_unary_cpu`, all with bf16 tolerance errors.
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621, and `test_mkldnn_fusion.py` no longer exists upstream. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without them.)
>
> Previously submitted as #202611.

Pull Request resolved: #205972
Approved by: https://github.com/albanD
pytorchmergebot pushed a commit that referenced this pull request Nov 25, 2026
## Linked issue or supporting maintainer
Part of #154444
Supported by @albanD

## BC-breaking?
No

## Summary (human written only)
Ports quantized convolution ops from ideep to ATen. Verbose logs form ONEDNN_VERBOSE were used to verify exact matching behavior before/after this change.

## Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.

>
> Ports the int8 convolution entry points that `quantized/cpu/qconv.cpp` uses from ideep (`ideep::convolution_forward`) into `aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}` (namespace `at::native::mkldnn`). The port is line-for-line and changes no behavior: it still takes `ideep::tensor` / `ideep::attr_t` and uses ideep's engine, stream and primitive cache.
>
> ### Ported
> Public (`detail/Conv.h`), with ideep's comments. Where ideep's comments no longer describe the code, they are rewritten:
> - `convolution_forward_prepare`: ideep's int8 `prepare` (with bias, without the `is_channels_last` argument).
> - `convolution_forward_compute<reorder_src, reorder_weight>(const convolution_forward_params&, ...)`: compute with pre-prepared params. Explicitly instantiated for `<false, false>` only, so its default template arguments are dropped; a call relying on them would fail to link.
> - `convolution_forward_compute<reorder_src, reorder_weight>(src, weights, bias, ..., scales, zero points, ...)`: ideep's int8 2-in-1 compute. qconv uses it when its primitive cache misses. Explicitly instantiated for `<true, true>`. ideep's comment says "without bias", but the function takes a bias and uses it if non-empty. The comment now says that, and notes that this path always passes `is_channels_last = true`, while `prepare` infers it from src and weights (as in ideep).
>
> File-local (`detail/Conv.cpp`):
> - `do_prepare<with_bias>`: ideep's int8 overload.
>
> These reuse the int8 `prepare_parameters` and the scales/zero-points `compute_dispatch` from 12/N, and `get_primitive_desc` / `do_compute` from #205716.
>
> ### Type change
> - `convolution_forward_params`, already ported, moves unchanged from `Conv.cpp`'s anonymous namespace into `Conv.h`. `OnednnUtils.h` now defines `using ConvParams = at::native::mkldnn::convolution_forward_params;`. qconv only reads `params.pd`, and stores and copies the struct in `ConvPrimitiveCache`, which works the same with the moved struct.
>
> ### Call sites switched
> - `quantized/cpu/qconv.cpp`, in `PackedConvWeightsOnednn::apply_impl`:
>   - `prepare` on the cache fill
>   - `compute<false, false>(params, ...)` on a cache hit
>   - the int8 2-in-1 `compute` on a cache miss
> - `quantized/cpu/qconv.cpp`, in `_quantized_convolution_onednn`: `prepare` / `compute<false, false>`. These sit in the `#else` of `IDEEP_PREREQ(3, 1, 0, 0)`, which is never compiled with oneDNN 3.x; they are switched for consistency.
>
> The `ideep::engine::cpu_engine()` argument is dropped from each call; it equals the default.
>
> Still on ideep: quantized deconvolution in `qconv.cpp` (15/N), and `t_store().clear()` in `IDeepRegistration.cpp`.
>
> ### Dropped
> - The `engine` parameters, as in the earlier ports. ATen only ever passes `ideep::engine::cpu_engine()`, which the ported code uses directly.
> - In the 2-in-1 compute: ideep computes a local `is_channels_last` and never uses it (it passes `true` to `compute_dispatch`). The unused local is removed; it fails `-Werror=unused-variable` builds outside ideep's system-header include.
>
> ### Testing
> oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after:
> - `quantization/core/test_quantized_op.py -k "(qconv or conv_transpose or qconvtranspose) and not fp8 and not cudnn"` with `PYTORCH_HYPOTHESIS_PROFILE=pytorch_ci` (derandomized; identical across repeated baseline runs): 675 distinct lines. These tests call `prepare` and `compute(params)` 232 times each.
> - A probe that reuses one prepacked weight with new input scales and shapes, to exercise the cache-miss 2-in-1 compute: logs identical, outputs bitwise equal.
> - `quantization/core/test_quantized_op.py -k "qconv and pt2e and not fp8"`: 257 distinct lines.
> - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines.
>
> (`test/jit/test_freezing.py` was later deleted upstream by #203621. The final A/B comparison of the whole series against `main`, described in #204808, re-checks these paths without it.)
>
> Previously submitted as #202622.

Pull Request resolved: #205973
Approved by: https://github.com/albanD
ghstack dependencies: #205972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source ready for review Automated review passed, ready for a final review by a maintainer. release notes: quantization release notes category topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants