Repository navigation
[mkldnn][22/22] Remove the ideep submodule - #204808
Closed
frost-intel wants to merge 55 commits into
Closed
frost-intel wants to merge 55 commits into
frost-intel wants to merge 55 commits into
Conversation
Part of pytorch#154444. Replace ideep type aliases with the oneDNN (or std) types they name. Each is a plain `using` in ideep, so this is a pure spelling change with no effect on generated code. It removes about a third of the remaining ideep references from ATen CPU code.
Part of pytorch#154444. Move ideep::eltwise_forward/backward into aten. Switch all CPU callers (relu, sigmoid, tanh, gelu, scalar mul, dense GELU, JIT frozen scalar mul). Line-for-line port.
Part of pytorch#154444. Depends on pytorch#201055. Move ideep::softmax_forward, ideep::prelu_forward and ideep::prelu_backward into aten/src/ATen/native/mkldnn/detail/ {Softmax,Prelu}.{h,cpp} and switch the callers in SoftMax.cpp and Prelu.cpp. The port is line-for-line; prelu_backward drops ideep's unused prop_kind parameter. ideep::softmax_backward has no ATen callers and is not ported. Verified with ONEDNN_VERBOSE=1 over test_mkldnn.py and the mkldnn freezing tests: all 6572 distinct primitive create/exec lines are identical before and after.
Replace the weight_with_src_rank helper with ideep's inline code in prelu_forward and prelu_backward so the port reads line-for-line against ideep's prelu.hpp. No behavior change; ONEDNN_VERBOSE logs are unchanged.
Part of pytorch#154444. Depends on pytorch#201055. Move ideep::pooling_forward and ideep::pooling_backward into aten/src/ATen/native/mkldnn/detail/Pooling.{h,cpp} and switch the callers in Pooling.cpp. The port is line-for-line, including storing max-pool indices as a workspace on the output tensor for use by the backward pass. ideep::pooling_v2_* (dilated pooling) has no ATen callers and is not ported. Verified with ONEDNN_VERBOSE=1 over test_mkldnn.py and the mkldnn freezing tests: all 6572 distinct primitive create/exec lines are identical before and after.
Part of pytorch#154444. Depends on pytorch#201055 Move ideep::sum, ideep::binary and ideep::direct_copy into aten/src/ATen/native/mkldnn/detail/{Binary,DirectCopy}.{h,cpp} and switch all CPU callers (add/add_/add_out, mul_out, copy_, clone, batch_norm running-stat update). The port is line-for-line, including destination reinit when the destination layout differs. It still operates on ideep::tensor. Verified with ONEDNN_VERBOSE=1 over test_mkldnn.py and the mkldnn freezing tests: all 6572 distinct primitive create/exec lines are identical before and after.
Part of pytorch#154444. Depends on pytorch#201055. Move the ideep batch_normalization_forward_inference/forward_training/ backward and layer_normalization_forward operators used by ATen into aten/src/ATen/native/mkldnn/detail/{BatchNorm,LayerNorm}.{h,cpp} and switch the callers in Normalization.cpp. The port is line-for-line for the code paths ATen uses; flags are fixed to ideep's defaults (the only values ATen ever passed), so ideep's unused fused-relu/workspace branches and the ignored momentum parameter are dropped. Verified with ONEDNN_VERBOSE=1: the primitive create/exec log of test_mkldnn.py and the mkldnn freezing tests is identical before and after. A new test_mkldnn_layer_norm in test_freezing.py is added, since not previously covered by tests.
Replace the kScaleShift constant with ideep's per-function pd_flags in the batchnorm forward inference, forward training and backward ports so they read line-for-line against ideep's batchnorm.hpp. No behavior change; ONEDNN_VERBOSE logs are unchanged.
Part of pytorch#154444. Depends on pytorch#201055. Move the ideep lstm_forward_inference (compute and expected_weights_desc), lstm_forward_training (prepare and compute) and lstm_backward operators used by ATen into aten/src/ATen/native/mkldnn/detail/Lstm.{h,cpp} and switch the callers in RNN.cpp and MKLDNNConversions.cpp. The port is line-for-line for the code paths ATen uses, including ideep's u8 branch; parameters that ATen never passed or ideep ignored are dropped. Verified with ONEDNN_VERBOSE=1 over test_mkldnn.py and the mkldnn freezing tests (all primitive create/exec lines identical before and after), and by comparing the output of mkldnn._reorder_mkldnn_rnn_layer_weight across 24 configurations (byte-identical packed layouts and values).
Part of pytorch#154444. Depends on pytorch#201055 (only the top commit is new). Move the ideep inner_product_forward (compute, compute_binary, expected_weights_desc), inner_product_backward_data and inner_product_backward_weights code paths used by ATen into aten/src/ATen/native/mkldnn/detail/InnerProduct.{h,cpp} and switch the callers in Linear.cpp and MKLDNNConversions.cpp. The port is line-for-line; ideep's private helpers keep their names. Primitive descriptors still come from ideep's computation_cache with the same keys, so the cache is shared with ideep until it is ported separately. Verified with ONEDNN_VERBOSE=1: the primitive create/exec logs of test_mkldnn.py, the mkldnn freezing tests, test_mkldnn_fusion.py and the Inductor mkldnn linear pattern tests are identical before and after.
Cast weights.ndims() to size_t when comparing with diff_src_dims.size(). The comparison is copied from ideep, where it is hidden by the system-header include; WERROR builds reject it here.
Part of pytorch#154444. Depends on pytorch#201055. Port the floating-point convolution forward, backward-data and backward-weights operators ATen uses from ideep into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}. The port is line-for-line, still takes ideep::tensor/attr_t, and shares ideep's primitive cache, so behavior is unchanged. Switch the call sites in mkldnn/Conv.cpp, ConvPrepack.cpp, MKLDNNConversions.cpp and quantized/cpu/qconv_prepack.cpp (expected_weights_desc only). Quantized prepare/compute and transposed convolution remain on ideep for now. Drop code ATen never reaches: use_gemm, unused overloads/parameters, backward_weights' diff_weight_type, and the fixed algorithm parameter on backward. Remove an unused variable and fix sign-compare loop indices that surface outside ideep's system-header include.
Keep only the fp32 forward port (compute_v3, compute_binary, expected_weights_desc and their helpers) to stay under the PR size limit. Backward data/weights and compute_v2 with its int8 prepare_parameters / compute_dispatch path move to separate PRs; their call sites in mkldnn/Conv.cpp and ConvPrepack.cpp go back to ideep until those land.
Part of pytorch#154444. Depends on pytorch#201055. Port the floating-point matmul path ATen uses (ideep's deprecated no-bias matmul_forward::compute) into aten/src/ATen/native/mkldnn/detail/Matmul.{h,cpp}. The port is line-for-line, still takes ideep::tensor/attr_t, and shares ideep's primitive cache, so behavior is unchanged. Switch the three call sites in mkldnn/Matmul.cpp. Quantized linear remains on ideep for now. Drop code ATen never reaches: compute_impl's int8 branches (callers always pass empty scales and unscaled weights), the scale, bin_post_params, dst_type, lowp_kind and engine parameters, and the unused zero-point, bias-attr and dynamic-quant fields.
Part of pytorch#154444. Depends on pytorch#201055. Port convolution_backward_data::compute_v2 and convolution_backward_weights::compute_v2 (with its compute_impl) into aten/src/ATen/native/mkldnn/detail/ConvBackward.{h,cpp}. The port is line-for-line and still takes ideep::tensor/attr_t. As in ideep, the forward hint comes from ideep::convolution_forward::get_primitive_desc. Switch the backward call sites in mkldnn/Conv.cpp. Drop the fixed algorithm parameter, the engine parameters, and backward_weights' unused diff_weight_type branch.
…rimitive_desc Base this PR on the conv forward port (pytorch#201224) instead of PR 3. The backward data/weights port now lives in detail/Conv.{h,cpp} next to the forward code, as in ideep's conv.hpp, and its forward hint calls the ported get_primitive_desc instead of ideep::convolution_forward:: get_primitive_desc. detail/ConvBackward.{h,cpp} are removed.
Part of pytorch#154444. Depends on pytorch#201224. Port ideep's deprecated convolution_forward::compute_v2 (with and without bias) and the code it routes through, the scale/zero-point compute_dispatch and the int8 conv_deconv_utils::prepare_parameters, into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp}. The port is line-for-line, still takes ideep::tensor/attr_t, and shares ideep's primitive cache, so behavior is unchanged. Switch the two compute_v2 calls in mkldnn/ConvPrepack.cpp. Drop the algorithm, prop_kind, lowp_kind and engine parameters ATen never passes, and an unused weights_zero_point local.
Port the int8 paths of ideep::matmul_forward used by quantized linear into
detail/Matmul.{h,cpp}. Part of pytorch#154444.
- TensorFactories: drop the int32_t-dims note; dnnl::memory::dims is int64_t. - qconv: the dst-scale comments named a nonexistent `scale_size`; describe what the code actually passes (1/output_scale and dst_zero_points).
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/204808
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 9387471 with merge base 30c5b5d ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
This was referenced Nov 13, 2026
This was referenced Nov 19, 2026
frost-intel
added a commit
that referenced
this pull request
Nov 19, 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. Depends on #201224 ## 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 builds on the forward PR, #201224, and adds the backward functions to the same `detail/Conv.{h,cpp}`. > > ### 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. cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01 ghstack-source-id: 1b60cfc Pull-Request: #205717
frost-intel
added a commit
that referenced
this pull request
Nov 19, 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. Depends on #201224 ## 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 builds on the forward PR, #201224, and adds the backward functions to the same `detail/Conv.{h,cpp}`. > > ### 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. cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01 ghstack-source-id: 179ae13 Pull-Request: #205717
frost-intel
added a commit
that referenced
this pull request
Nov 19, 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. cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01 ghstack-source-id: e46f8da Pull-Request: #205717
frost-intel
added a commit
that referenced
this pull request
Nov 19, 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. cc jgong5 mingfeima XiaobingSuper sanchitintel ashokei jingxu10 aditew01 ghstack-source-id: 1ec1529 Pull-Request: #205717
pytorchmergebot
pushed a commit
that referenced
this pull request
Nov 20, 2026
…into ATen (#205710) ## Linked issue or supporting maintainer Part of #154444 ## BC-breaking? No ## Summary (human written only) Ports `sum` and `binary` operators from ideep to `at::native::mkldnn::sum/binary`. Port is line-for-line. I also copy the `direct_copy` function in a new file. When we port `ideep::tensor` into ATen, the direct copy function will be moved into that file, so this is temporary. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (11 files, +167/−8): > > - **`detail/Sum.{h,cpp}` and `detail/Binary.{h,cpp}`:** `at::native::mkldnn::sum` and `binary`, ported line for line from ideep's `sum.hpp` and `binary.hpp`, one file each as in ideep. They keep the user-managed scratchpad, the output layout choice (from the inputs for `sum`, "any" for `binary`), input reorders for `binary`, and the in-place buffer replacement on `dst`. > - **`detail/DirectCopy.{h,cpp}`:** `direct_copy`, ported from ideep's `direct_copy.hpp`. It keeps the buffer replacement, the reorder and the scale propagation. > - **Call sites:** all 8 switched. > > | File | Ops | Calls | > |---|---|---| > | `BinaryOps.cpp` | `add_out` (×2), `add`, `mul_out` | 4 | > | `Copy.cpp` | `copy_` | 1 | > | `TensorShape.cpp` | `clone` | 1 | > | `Normalization.cpp` | batchnorm running-stats update | 2 | > > No `ideep::sum`, `ideep::binary` or `ideep::direct_copy` calls remain outside XPU, and `BinaryOps.cpp` and `Copy.cpp` no longer call any ideep operator. > - **`build_variables.bzl`:** 3 entries. CMake and Buck pick up headers from the `detail/` setup added in PR 3. > > **Checks:** > > - **Same oneDNN calls before and after.** I ran all of `test_mkldnn.py` plus `test_freezing.py -k mkldnn` with `ONEDNN_VERBOSE=1` and compared the logged primitive creations and executions, with timings stripped. I ran the baseline twice first, and it repeats exactly, so any difference would be real. > - All 6,572 distinct primitive log lines are identical. > - Those tests exercise the ported code: `sum` runs 40 times (13 distinct), `binary` 4 times, and `reorder` runs 130,755 times, which includes the copies. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - Freezing tests: 4 passed, 5 skipped. > - `test_mkldnn_fusion.py`: OK. > - `test_nn.py -k "batchnorm and cpu"`: 9 passed. > - **Lint:** clean. > > (`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 #201059. Pull Request resolved: #205710 Approved by: https://github.com/albanD ghstack dependencies: #205709
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) Softmax is ported line-for-line from ideep. Since the backward pass is never called in ATen, that is not ported. As part of this process, any ideep code that is not called in ATen is not being ported. A softmax backend for mkldnn tensors doesn't currently exist, but adding it is outside the scope of this PR. Generally loss has been computed on regular tensors, making mkldnn softmax backward unnecessary. Prelu forward and backward are ported line-for-line. An unused arg is dropped from `prelu_backward` (`prop_kind`). Any calls to the ideep operators are removed from ATen. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (7 files, +209/−4): > > - **`detail/Softmax.{h,cpp}`:** `softmax_forward`, ported line for line, including the in-place buffer replacement on `dst`. Only the forward pass is ported, because ATen never calls ideep's `softmax_backward`. > - **`detail/Prelu.{h,cpp}`:** `prelu_forward` and `prelu_backward`, ported line for line. > - Kept: the weight reshape to match the input's rank, the input reorders, buffer replacement on the outputs, the avx2_vnni_2 bf16/f16 check (using `is_avx2_vnni_2` from `mkldnn/Utils.h`), and reshaping the weight gradient back at the end. > - Dropped two things ideep never used: an unused variable, and the `prop_kind` argument of `prelu_backward`. The call site no longer passes `dnnl::prop_kind::backward`. > - **Call sites:** `SoftMax.cpp` (1) and `Prelu.cpp` (2). Neither file calls ideep operators anymore. > - **`build_variables.bzl`:** 2 entries. > > **Checks:** > > - **Same oneDNN calls before and after.** I ran all of `test_mkldnn.py` plus `test_freezing.py -k mkldnn` with `ONEDNN_VERBOSE=1` and compared the logged primitive creations and executions, with timings stripped. All 6,572 distinct primitive log lines are identical. > - `prelu` runs 64 times in those tests, 13 of the distinct lines being backward. > - `softmax` runs only 3 times. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - Freezing tests: 4 passed, 5 skipped. > - `test_nn.py -k "prelu or softmax"`: 36 passed. > - **Lint:** clean. > > (`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 #201062. Pull Request resolved: #205711 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710
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 `pooling_forward/backward` from ideep. Ported line-for-line. A few details that might be seen in review: * The dilation variants (pooling_v2) in ideep are never called in ATen, so they are left out of the port here. * A workaround for an existing layout issue (`src._get_unblocked_desc_if_4c_blocked`) is left as-is. Fixing/verification is outside the scope of this porting PR. Pooling calls are now to aten operators, not ideep. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (4 files, +189/−2): > > - **`detail/Pooling.{h,cpp}`:** `pooling_forward` and `pooling_backward`, ported line for line from ideep's `pool.hpp`. > - Kept: the workaround that reads `src`'s layout through `_get_unblocked_desc_if_4c_blocked()` (for oneDNN issue uxlfoundation/oneDNN#588), output layout `any`, the input reorder, buffer replacement on the outputs, scale propagation, and the avx2_vnni_2 bf16/f16 check on backward. > - **Max-pool indices:** in training mode, forward stores the indices on `dst` (`init_workspace`), and backward reads them back from `dst` and reorders them if needed. This is unchanged from ideep, so tensors created before and after this change behave the same. > - Only the variants ATen calls are ported. ideep's `pooling_v2_forward/backward` (the dilation variants) have no ATen callers. > - **Call sites:** `Pooling.cpp` (2). It no longer calls ideep operators. > - **`build_variables.bzl`:** 1 entry. > > **Checks:** > > - **Same oneDNN calls before and after.** Same comparison as above. All 6,572 distinct primitive log lines are identical. > - Pooling runs 227 times, with 216 distinct lines. Of those, 48 are max-pool forward in training mode and 48 are max-pool backward. > - The max-pool backward lines include the workspace argument (`ws:s32::blocked:...`), so the stored indices reach the backward pass. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - Freezing tests: 4 passed, 5 skipped. > - `test_nn.py -k "pool and cpu"`: 1 passed, 6 skipped. > - **Lint:** clean. > > (`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 #201080. Pull Request resolved: #205712 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710, #205711
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) Line-for-line ports of layernorm and batchnorm from ideep to ATen. Layernorm drops an empty stub that wasn't ported from ideep. Batchnorm includes the inference, training, and backward versions. Some args that had no effect were removed. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (7 files, +318/−5): > > - **`detail/BatchNorm.{h,cpp}`:** the three batchnorm functions ATen calls, ported line for line from ideep's `batchnorm.hpp`: > - `batch_normalization_forward_inference`: the version that takes the running mean and variance. > - `batch_normalization_forward_training`: the version without running stats. ATen updates the running stats itself. > - `batch_normalization_backward`. > - Kept: the workaround that reads `src`'s layout through `_get_unblocked_desc_if_4c_blocked()` (for oneDNN issue uxlfoundation/oneDNN#588), the input/mean/variance reorders, buffer replacement on the outputs, the user-managed scratchpad, and the avx2_vnni_2 bf16/f16 check on backward. > - The flags are fixed to `use_scale | use_shift` (plus `use_global_stats` for inference). ATen always used ideep's default flags, so ideep's fused-relu path and its workspace never ran. I also removed the parameters ideep took but ATen never set or ideep never used: `flags`, `dst` on backward, and `momentum` on training. In ideep's training function `momentum` had no effect. > - Not ported because ATen never calls them: the inference version without stats, and the training version that updates running stats with `ideep::sum`. > - **`detail/LayerNorm.{h,cpp}`:** `layer_normalization_forward`, ported line for line. ideep's `layer_normalization_backward` is an empty stub and isn't ported. > - **Call sites:** `Normalization.cpp` (4). The two `ideep::sum` calls for the running stats are ported separately in the sum/binary PR. > - **`build_variables.bzl`:** 2 entries. > > **Checks:** > > - **Same oneDNN calls before and after.** I ran all of `test_mkldnn.py` plus `test_freezing.py -k mkldnn` with `ONEDNN_VERBOSE=1` and compared the logged primitive creations and executions, with timings stripped. All 6,572 distinct primitive log lines are identical. > - Batchnorm runs 87 times: 17 distinct lines for inference, 1 for training forward and 1 for backward. > - The oneDNN logs are identical, including the `layer_normalization` call. > - The outputs are bitwise identical. > - The output matches eager mode to within 2.4e-7. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - Freezing tests: 4 passed, 5 skipped. > - `test_mkldnn_fusion.py`: OK. > - `test_nn.py -k "batchnorm or layer_norm or layernorm"`: 24 passed. > - **Lint:** clean. > > **Update:** `test_mkldnn_layer_norm` was originally added to `test/jit/test_freezing.py`. Upstream > #203621 deleted that file along with the public `torch.jit.script` / `torch.jit.freeze`, so the test now > lives in `test/test_mkldnn.py`. It drives the frozen-graph pass through `torch.jit._script.script`, > `torch.jit._freeze.freeze` and `torch._C._jit_pass_convert_frozen_ops_to_mkldnn`, checks for > `prim::MKLDNNLayerNorm`, and compares against eager with a random LayerNorm weight and bias. It passes before and after this PR and executes the > oneDNN `layer_normalization` primitive. > > (`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 #201083. Pull Request resolved: #205713 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710, #205711, #205712
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) Line-for-line ports of LSTM from ideep. Not all of ideep functionality is included, only what is used in ATen currently. Note that we continue to use `ideep::tensor` until all ops are ported over, then we will transition to the ported class. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (5 files, +464/−7): > > - **`detail/Lstm.{h,cpp}`:** the five LSTM functions ATen calls, ported line for line from ideep's `lstm.hpp`: > - `lstm_forward_inference` > - `lstm_forward_inference_expected_weights_desc`: the packed weight layout used when weights are prepacked > - `lstm_forward_training_prepare` and `lstm_forward_training` > - `lstm_backward` > - **Kept as in ideep:** > - "any" layouts for the weights, the weight reorders, buffer replacement on the outputs, the workspace argument, and the user-managed scratchpad. The packed-layout lookup keeps ideep's default scratchpad mode. > - Backward computes gradients in f32, zero-initializes the weight and bias gradients before running (oneDNN adds into them), and copies the results back into the caller's tensors. > - The avx2_vnni_2 bf16/f16 check on backward. > - ideep's 8-bit-input branch (s8 weights plus the RNN quantization attributes), kept line for line. ATen cannot reach it today: every LSTM entry point builds its input with `itensor_view_from_const_dense`, which accepts only float, bfloat16 and half. ATen never passes quantization parameters, so it would keep ideep's defaults (all −1). > - **Simplified:** > - Removed parameters ATen never sets or ideep never reads: the attribute and quantization parameters, and `reverse`/`prop_kind` on training `compute`, where ideep ignored them. > - ideep's `lstm_forward_training::expected_weights_desc` has no ATen callers and is not ported. > - **Call sites:** `RNN.cpp` (5) and `MKLDNNConversions.cpp` (1, the LSTM weight prepack). No `ideep::lstm_*` calls remain. > - **`build_variables.bzl`:** 1 entry. > > **Checks:** > > - **Same oneDNN calls before and after.** I ran all of `test_mkldnn.py` plus `test_freezing.py -k mkldnn` with `ONEDNN_VERBOSE=1` and compared the logged primitive creations and executions, with timings stripped. All 6,572 distinct primitive log lines are identical. > - LSTM runs 36,864 times there, in f32 and bf16: 156 distinct lines for inference, 104 for training forward and 104 for backward. > - **Weight prepack (`mkldnn._reorder_mkldnn_rnn_layer_weight`).** Inductor's freezing pass uses this op, and it's the only caller of `expected_weights_desc`. I called it for 24 configurations (f32/bf16, two sizes, both directions, three input-size settings) on builds from before and after this change: > - The oneDNN logs are identical. > - The serialized layout of all 48 packed weights is byte-identical. > - Their values are bitwise identical. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - `test_nn.py -k "lstm and cpu"`: 8 passed. > - `test/inductor/test_cpu_repro.py -k lstm`: 514 passed. This exercises the prepacked-weight path end to end. > - **Lint:** clean. > > (`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 #201126. Pull Request resolved: #205714 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710, #205711, #205712, #205713
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) Ports inner-product operators from ideep to ATen. A few unused parameters are removed. One non-impactful code change: previously, calls within `mkldnn_linear` calls a function marked "DEPRECATED" in ideep. These deprecated functions were superseded by a templatized version, but the `mkldnn_linear` calls hadn't been updated to match those in `mkldnn_linear_pointwise` which do use the templateized version. I did not port the deprecated calls over, so the calls in `mlkdnn_linear` now fallback to the templatized version. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > **What changed** (5 files, +838/−10): > - **`detail/InnerProduct.{h,cpp}`:** the inner-product code ATen calls, ported line for line from ideep's `inner_product.hpp`: > - `inner_product_forward` (with and without bias) and `inner_product_forward_binary` (with and without bias), keeping ideep's `reorder_src`/`reorder_weight` template parameters. Only the combinations ATen uses are compiled: `<true, true>` and `<false, false>` for forward, `<false, false>` for binary. > - `inner_product_forward_expected_weights_desc`, `inner_product_backward_data`, and `inner_product_backward_weights` (with and without bias). > - ideep's private functions and its `inner_product_forward_params` struct are ported under their ideep names, local to the `.cpp`. ideep's backward-weights `compute_impl` becomes `backward_weights_compute_impl`, because it would otherwise collide with the forward `compute_impl`. > - **Primitive cache:** on x86, primitive descriptors are still fetched from ideep's cache (`ideep::utils::computation_cache<dnnl::inner_product_forward::primitive_desc>` with `ideep::utils::create_key`). This is the same cache ideep's own operators use, with the same key fields, capacity, and `LRU_CACHE_CAPACITY` handling. Porting the cache itself is a later PR. The aarch64 path, which bypasses the cache, is kept under `#ifdef __aarch64__` as in ideep. > - **Kept as in ideep:** input/weight/bias reorders, the dst-buffer reuse and copy-back logic, the sum post-op copy in `do_compute_`, the Caffe2 int8 source-scale handling, the src/weights reshape workaround, the avx2_vnni_2 bf16/f16 check on both backward functions, and ideep's debug-only argument checks. Those are written out as `#ifndef NDEBUG dnnl::error::wrap_c_api(...)`, so they still only run in debug builds and throw the same error. > - **Not ported, because ATen never calls them:** the `prepare`/`compute`/`compute_binary` overloads that take a precomputed `params` object, plus `do_prepare` and `do_compute`, which only those overloads use. > - **Removed, because ATen never set them or they did nothing:** > - The unused scale and `lowp_kind` parameters of ideep's deprecated `compute` overloads. These were the overloads ATen's plain linear actually resolved to; they called the same `compute_impl` as the templated overloads. > - The `attr` parameters on both backward functions (ATen always used the default). > - `diff_weight_type` on backward weights (always the default, so the gradient type is `diff_dst`'s), along with the type-conversion branch that only ran for other values. > - An unused `op_attr` local in `do_compute_binary`. > - **Call sites:** `Linear.cpp` (9) and `MKLDNNConversions.cpp` (1, the linear weight prepack). The only remaining `ideep::inner_product_forward` text is a comment in `qlinear_dynamic.cpp`. > - **`build_variables.bzl`:** 1 entry. > > **Checks:** > > - **Same oneDNN calls before and after**, with `ONEDNN_VERBOSE=1` and timings stripped: > - `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: all 6,572 distinct primitive log lines are identical. These include 32 inner-product executions, some of them backward. > - `test_mkldnn_fusion.py` plus `test/inductor/test_mkldnn_pattern_matcher.py -k "linear and not qlinear and not quant and not woq and not da8w8"`: all 892 distinct primitive log lines are identical. These cover 254 distinct inner-product lines (the fused linear and binary-fusion paths with prepacked weights) and 61 distinct reorder lines, including the weight-prepack reorders. > - **Tests:** > - `test_mkldnn.py`: 92 passed, 1 skipped. > - Freezing tests: 4 passed, 5 skipped. > - `test_mkldnn_fusion.py`: 9 passed. > - `test_mkldnn_pattern_matcher.py` (linear subset): 12 passed. > - **Lint:** clean. > > (`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 #201194. Pull Request resolved: #205715 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710, #205711, #205712, #205713, #205714
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) 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: > - **This PR:** fp32 forward. > - **#201229, backward:** `convolution_backward_data` / `convolution_backward_weights`, in `detail/Conv.{h,cpp}`. > - **#202611, `compute_v2`:** ideep's deprecated `compute_v2` and the int8 `prepare_parameters` / `compute_dispatch` it routes through. Used only by `ConvPrepack.cpp`. Stacked on this PR. > > ### 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. Pull Request resolved: #205716 Approved by: https://github.com/albanD ghstack dependencies: #205709, #205710, #205711, #205712, #205713, #205714, #205715
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
This was referenced Nov 21, 2026
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
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 transposed convolution ops from ideep to ATen. Verbose logs form ONEDNN_VERBOSE were used to verify exact matching behavior before/after this change. We dropped unused params and an unused overload. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > > Ports the fp32 transposed-convolution operators that ATen uses from ideep's `deconv.hpp` into `aten/src/ATen/native/mkldnn/detail/Deconv.{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/Deconv.h`), with ideep's comments and default arguments. Comments that no longer describe the code are rewritten: the backward-data weights layout (`{o, i, ...}`, as the caller passes), what `is_channels_last` controls in `expected_weights_desc` (src/dst format only), the `transposed` default, and which template arguments are instantiated: > - `convolution_transpose_forward_compute_v3<reorder_src, reorder_weight>`: with and without bias. Explicitly instantiated for `<true, true>`. > - `convolution_transpose_forward_expected_weights_desc<is_channels_last, transposed>`: instantiated for `<true, true>`, `<false, true>` and `<true, false>`, the combinations ATen uses. > - `convolution_transpose_backward_data_compute_v3` > - `convolution_transpose_backward_weights_compute_v3`: with and without bias. > > File-local (`detail/Deconv.cpp`), same names as in ideep: > - `deconv_forward_params`, default constructor only (ideep's member-wise constructors are unused) > - `get_primitive_desc<with_bias>` > - `do_prepare` (fp32) > - `do_compute` > - `compute_impl` (fp32) > - `backward_weights_compute_impl`: ideep's `convolution_transpose_backward_weights::compute_impl`, renamed to avoid clashing with the forward `compute_impl`, as in the conv port. > > ideep's deconvolution has no aarch64-specific code. > > `get_primitive_desc` uses ideep's thread-local `computation_cache<dnnl::deconvolution_forward::primitive_desc>`, the same store ideep's own `convolution_transpose_forward` uses (still used by quantized deconvolution). The cache key fields and their order are unchanged. > > ### Shared with conv > - The fp32 `conv_deconv_utils::prepare_parameters` is shared with the conv port through `Conv.h` (declared there in 12/N). ideep shares it the same way between `conv.hpp` and `deconv.hpp`. This PR does not edit `detail/Conv.{h,cpp}`. > > ### Call sites switched > - `mkldnn/Conv.cpp`: forward ×2, backward data, backward weights ×2. > - `mkldnn/MKLDNNConversions.cpp`: `expected_weights_desc<true>` / `<false>` (`_reorder_convolution_transpose_weight`). > - `quantized/cpu/qconv_prepack.cpp`: `expected_weights_desc<true, false>`, for the quantized transposed-conv weight prepack. It uses the same fp weight-descriptor function. > > Still on ideep: quantized deconvolution in `quantized/cpu/qconv.cpp` (`prepare` / `compute`), ported in 15/N. > > ### Dropped / changed > - The `engine` parameters, as in the earlier ports. > - The unused non-`_v3` `compute` overloads and all int8 overloads (no fp callers). > - `expected_weights_desc`: two loop indices changed from `int` to `size_t` (sign-compare; ideep hides this as a system header). > - `do_prepare`: `std::move(super(pd))` becomes `dnnl::deconvolution_forward(pd)`; moving a temporary is a no-op. > - The commented-out `is_nhwc` block in backward data is removed. > - Four `// May replace ...` comments are added at the `reinit_if_possible` calls, following the convention of the earlier ports. They are new, not from ideep. > > ### 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,598 of them deconvolution. Calls to the ported entry points from these tests and the quantized tests below: > > | Entry point | Calls | > |---|---| > | forward, with bias | 432 | > | forward, without bias | 436 | > | backward data | 392 | > | backward weights, with bias | 196 | > | backward weights, without bias | 196 | > | `expected_weights_desc` | 11 | > > (Counted with temporary instrumentation, not included in the PR.) > - `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): 675 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. > > 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 #203645. Pull Request resolved: #205974 Approved by: https://github.com/albanD ghstack dependencies: #205972, #205973
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) Port of the matmul op 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. Ports int8 matmul_forward used by quantized linear into ATen. This is a line-by-line copy, no behavioral change. Functionality not used in ATen was dropped, along with unused params. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > > Ports the matmul paths that ATen uses from ideep (`ideep::matmul_forward`) into `aten/src/ATen/native/mkldnn/detail/Matmul.{h,cpp}` (namespace `at::native::mkldnn`): the floating-point path used by `mkldnn/Matmul.cpp` and the int8 paths used by quantized linear. 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 combines two earlier PRs, the fp32 port (#202547) and the quantized port (#204617). Code that #202547 had removed as unused on the fp path (`do_prepare`'s `dst_type` override, `do_compute`'s zero-point arguments, `compute_impl`'s int8 branches) is kept, because the quantized paths reach it. > > ### Ported > Public (`detail/Matmul.h`), each with ideep's comments: > - `matmul_forward_params` and `matmul_forward_dyn_quant_params`, with their default constructors only. ideep's member-wise constructors are unused and are dropped (the `matmul_forward_params` one also read `pd` after moving from it), as is the `bias_attr` member, which only that constructor set. `LinearParams` in `OnednnUtils.h` now points at the ported struct. > - `matmul_forward(src, weights, dst, dst_coeff, sum_coeff, attr)`: ideep's **deprecated** no-bias 2-in-1 `compute`, which all three fp calls in ATen resolve to. ideep's deprecation comment is kept. > - `matmul_forward_prepare<is_dynamic>`: static and dynamic int8 `prepare`. > - `matmul_forward_compute`: with pre-prepared params (fp32 and static int8), with pre-prepared params (dynamic int8), and the int8 2-in-1 compute. > - Both `matmul_forward_expected_weights_desc` overloads. > > File-local (`detail/Matmul.cpp`), same names as in ideep: > - `do_prepare<with_bias>` (fp32) > - `do_prepare_static_quant`, `do_prepare_dynamic_quant` > - `do_compute<with_bias, reorder_src, reorder_weight>`, `do_compute_dynamic_quant` > - `compute_impl<with_bias, reorder_src, reorder_weight>`: all three branches (fp32, static and dynamic int8) > > The call chains are the same as ideep's. The fp path is `compute_impl<false, true, true>` with ideep's empty scales and zero points, so only its fp32 branch runs. The aarch64 path (uncached primitive descriptor, `format_tag::any` weights) is kept. > > ### Call sites switched > - `mkldnn/Matmul.cpp`: all three `ideep::matmul_forward::compute` calls: the bf16/fp16/bf32/tf32 `mkldnn_gemm`, bf16→fp32 `mkldnn_gemm`, and `mkldnn_matmul`. The three empty `std::vector<float>()` scale arguments are dropped. `alpha` and `beta` map to `dst_coeff` and `sum_coeff` as before. > - `quantized/cpu/qlinear.cpp`, `qlinear_dynamic.cpp` and `qlinear_prepack.cpp`: `prepare`, `compute` and `expected_weights_desc`. > > ### Not ported, because ATen never reaches them > - `compute_binary` and its helpers > - `compute_v2` > - `compute_dynamic` > - the deprecated `compute`/`prepare` overloads that take `bin_post_params` or put `dst_coeff` first, and the deprecated with-bias fp overload > - the fp32 with-bias `prepare`/`compute` overloads > - the no-bias int8 overloads > > ### Deviations from ideep > - The `engine` parameters are dropped; ATen only ever passes `ideep::engine::cpu_engine()`, which the ported code uses directly. > - The deprecated fp `matmul_forward` drops the three scale parameters, `bin_post_params` (always `{}`), `dst_type` (always `undef`) and `lowp_kind`; it passes ideep's defaults to `compute_impl`. > - Unused local references are dropped (`bias_attr`, `wei_zero_point`, and `dst_scales_in` in the dynamic compute) because they fail `-Werror`. > - In `do_prepare_static_quant`, the zero-point size variables are declared inside `#ifndef NDEBUG`, since only that check uses them, and the unused `src_strides` vector is dropped (the src descriptor uses `format_tag::any`). > - `IDEEP_ENFORCE` becomes a debug-only `dnnl::error::wrap_c_api(...)` under `#ifndef NDEBUG`, as in ideep. The weights/bias dtype `||` chains are written with `one_of` from `mkldnn/Utils.h`, which computes the same thing. > > ### Other changes > - Called directly from ideep for now: `ideep::utils::create_key`, `ideep::utils::computation_cache`, `ideep::utils::op_scale_mask`, `ideep::utils::tensor_scale_mask`, `ideep::utils::tensor_zp_mask`, and the `IDEEP_DEF_SCALE` / `IDEEP_DEF_ZP` / `IDEEP_EMPTY_SCALE` / `IDEEP_EMPTY_ZP` constants. > - The primitive cache is ideep's thread-local `computation_cache<dnnl::matmul::primitive_desc>`. The key fields and their order are unchanged. > > ### Testing > oneDNN verbose logs (`ONEDNN_VERBOSE=1`, timings stripped, sorted counts) are identical before and after: > - `test_mkldnn.py -k "matmul or mm or bmm or dot or mv or bf32 or tf32 or reduced"` plus `test_linalg.py -k "cpu and (addmm or bmm or matmul or addmv or mv or dot or _mm_ or linear) and (bfloat16 or float16 or half)"`: 524 distinct lines, 521 of them matmul (bf16/fp16, `alpha` source scales, `beta` sum post-op). > - A probe of fp32 `addmm`/`mm`/`bmm`/`baddbmm`/`mv` with `torch.backends.mkldnn.matmul.fp32_precision` set to `bf16` and `tf32`: logs identical, outputs bitwise equal. On bf16/AMX hardware these paths are also covered by the `@reduced_f32_on_and_off` float32 tests in `test_linalg.py` (`addmm`, `mm`, `bmm`, `addbmm`, `baddbmm`, `inner`, `tensordot`), which the A/B filter above leaves out; `mv` has no such test. > - `test_quantized_op -k linear` (fixed test seeds). > - Full `test_mkldnn.py` plus `test_freezing.py -k mkldnn`: 6,572 distinct lines. > - Re-run against `main` including the `test_linalg.py` `*_cpu_float32` tests (`addmm`, `mm`, `bmm`, `baddbmm`, `addbmm`, `inner`, `tensordot`) that `@reduced_f32_on_and_off` runs with bf16 and tf32 fp32-precision: oneDNN logs identical (1,015 distinct lines, 237 matmul each with `fpmath:bf16` and `fpmath:tf32`). > > A probe that reuses packed quantized weights with new input scales and shapes, to reach the cache-miss paths, gives identical logs and bitwise-equal outputs. > > (`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 #202547 and #204617. Pull Request resolved: #205976 Approved by: https://github.com/albanD ghstack dependencies: #205972, #205973, #205974, #205975
pytorchmergebot
pushed a commit
that referenced
this pull request
Nov 25, 2026
## Linked issue or supporting maintainer Part of #154444 ## BC-breaking? No ## Summary (human written only) Removes the ideep submodule, including `#include` statements, references in comments, build setup, and related files. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > Part of #154444 (remove the ideep submodule). > > ATen no longer calls into ideep: its operators, tensor, engine, stream, attributes, primitive cache and utilities now live in `aten/src/ATen/native/mkldnn/detail/`. This PR pins oneDNN as a direct submodule, `third_party/oneDNN`, drops the last ideep includes, and deletes `third_party/ideep`. The pin was #201052; maintainers asked for it to land last, so it is part of this PR. > > ### oneDNN pin > - `third_party/oneDNN` is added at `a190d4ab` (v3.14.1), the same commit ideep's nested `mkl-dnn` pins today, so the compiled oneDNN is unchanged. `FindMKLDNN.cmake` builds the CPU library and oneDNN Graph from it. The XPU build is unchanged. > - `FindMKLDNN.cmake` drops a cached `MKLDNN_INCLUDE_DIR` / `LLGA_INCLUDE_DIR` only when it points into `third_party/ideep`, which older build directories cached. A value passed with `-D` is kept. Its submodule-init fallback is removed; `cmake/PreBuildSteps.cmake` already initializes every `.gitmodules` path. > - oneDNN's licenses ship from `third_party/oneDNN` (`pyproject.toml`, license audit manifest). OWNERSHIP/CODEOWNERS list `/third_party/oneDNN`; `labeler.yml` and `merge_rules.yaml` drop the nonexistent `third_party/mkl-dnn.BUILD`; comments in `jit/codegen/onednn` point at `third_party/oneDNN`. > > ### Changes > - The 10 remaining `#include <ideep...>` lines are removed. > - ideep's version gates become oneDNN version gates: `IDEEP_VERSION_*` -> `DNNL_VERSION_*`, and `IDEEP_PREREQ(a, b, c, r)` -> `DNNL_PREREQ(a, b, c)`. `IDEEP_PREREQ` also checked ideep's own API revision, which is 4, and every call site asked for revision 4 or lower. So that check was always true, and each gate takes the same branch as before. > - `detail/IdeepUtils.h` takes over ideep's `<omp.h>` include and its `omp_get_max_threads()` fallback for builds without OpenMP. The primitive cache keys use it. > - `FindMKLDNN.cmake` no longer looks for ideep headers, and no longer defines `IDEEP_USE_MKL`, which only ideep read. > - ideep is removed from `.gitmodules`, the `pyproject.toml` license-files list, the license audit manifest, `labeler.yml`, `merge_rules.yaml` and OWNERSHIP/CODEOWNERS; `third_party/oneDNN` takes its place. > - `DNNL_PREREQ` moves from `MKLDNNCommon.h` to a new `detail/Version.h` that includes only `<oneapi/dnnl/dnnl_version.h>`. `CPUBlas.cpp` uses it for its oneDNN version gates without pulling the mkldnn headers into the core BLAS code. > > - Keeps ideep's MIT license next to the ported code as `aten/src/ATen/native/mkldnn/detail/LICENSE.ideep`, listed in `pyproject.toml` license-files and the license audit manifest, and adds that directory to the audit's discovery globs. > > ### Deviation > - In `qconv.cpp` and `qconv_prepack.cpp`, the `#elif IDEEP_PREREQ(3, 1, 0, 0)` branches are removed. They targeted ideep API revision 0, which used reciprocal weight scales (`1 / scale`). That revision was replaced by revision 1, and these branches could not be compiled in with the bundled ideep (revision 4). Keeping them under a plain oneDNN version check would be wrong: if one were ever selected, every int8 conv would get inverted weight scales. The gates that depend only on the oneDNN version (< 3.1, 3.5 vs 3.6+, 3.9+, 3.13+) are kept as `DNNL_PREREQ` checks. The removed revision-0 branch in `qconv.cpp` carried a TODO (leslie) about removing the weight-scale reciprocal and two copies of the scales; it goes with that branch. The revision-1 branch that remains already passes the scales without the reciprocal. > - The unreachable `TORCH_CHECK(false, "Unexpected IDeep version ...")` messages now say "oneDNN". > - `test_mkldnn.py::test_mkldnn_layer_norm` and its `FileCheck` import are removed. It only exercised the TorchScript frozen-graph pass, and TorchScript is being deleted. > - Leftover ideep mentions are updated: the unsupported-dtype error and two comments in `MKLDNNConversions.cpp`, the `rnn_kind` reference in `torch/_decomp/decompositions.py` (now `detail/IdeepUtils.h`), and an outdated ideep-version comment in `Version.cpp`. > > ### Notes for reviewers > - PyTorch has no system-oneDNN build path: `FindMKLDNN.cmake` always builds `third_party/oneDNN`, so there is no separate minimum-version check to enforce. > - Existing checkouts keep an untracked `third_party/ideep` directory after updating. It is ignored by the build and the license audit; to remove it: `rm -rf third_party/ideep`, plus `.git/modules/third_party/ideep` in the git directory. > > ### Testing > This PR: > - Builds from a fresh CMake configure with `third_party/ideep` absent. No compile command references ideep, and `libtorch_cpu.so` defines no `ideep::` symbols. > - 21/N, the PR before this one, builds from scratch with oneDNN still taken from ideep's nested copy and passes `test_mkldnn.py`, so nothing earlier in the series needs the pin. > - Compiles cleanly with `-Wall -Wextra -Wsign-compare -Werror` in release and debug builds. The license audit and lintrunner are clean. > - Upstream wheels never shipped ideep headers in `torch/include`, so C++ extensions are not affected. > > Whole series, compared with the `main` commit it is based on: both builds were made with identical settings (only the commit differs) and tested on an Intel Xeon 6960P. > - **Numerics:** 202 fixed-seed outputs of oneDNN-backed ops are bitwise identical. They cover mkldnn tensors; fp32/bf16/fp16 convolution and backward; LSTM; matmul with bf16/tf32 fp32-math modes; the Inductor `mkldnn::*_pointwise` and `onednn::q*_pointwise` ops; quantized linear, conv and conv-transpose; and `torch.compile` with freezing. The oneDNN primitives they run are identical too. > - **Primitive cache:** the number of oneDNN primitive creations is identical (465 vs 465) for a workload that changes shapes, scales and thread counts, at the default `LRU_CACHE_CAPACITY` and at `LRU_CACHE_CAPACITY=1`. > - **Tests:** per-test outcomes and executed oneDNN primitives are identical across 13 suite runs (about 1,250 tests). The suites are `test_mkldnn`, `nn/test_convolution -k mkldnn`, `quantization/core/test_quantized_op`, bf16/fp16 `test_linalg`, the CPU LSTM tests in `test_nn`, `inductor/test_mkldnn_pattern_matcher`, `inductor/test_cpu_repro` (conv/linear) and the mkldnn tests in `test_aot_inductor`. `test_mkldnn` and `test_quantized_op` were also run with `ONEDNN_MAX_CPU_ISA` set to `AVX2` and to `AVX512_CORE`. The failures that do occur happen identically on `main` and are tracked separately. > - **Performance:** all 16 op microbenchmarks are within ±3%, both with primitives cached and when a new primitive is created on every call. Measured over 7 alternating rounds, pinned to 16 cores on one NUMA node. > - **Binary size:** `libtorch_cpu.so` `.text` +2.9 KB. The exported-symbol changes are listed in 21/N. > > These measurements were taken when this PR was first submitted. Since then the series has only had review changes (rewritten comments, removed dead code and unused includes, a typo rename); none change behavior. The rebuilt stack passes `-Wall -Wextra -Wsign-compare -Werror` per commit, and `test_mkldnn`, the mkldnn conv tests and the quantized conv/linear tests were rerun at the tip. > > Previously submitted as #204808. Pull Request resolved: #206277 Approved by: https://github.com/albanD ghstack dependencies: #205978, #205979, #205980, #206276
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue or supporting maintainer
Part of #154444
BC-breaking?
No
Summary (human written only)
Removes the ideep submodule, including
#includestatements, references in comments, build setup,Fake stack
sum,binary, anddirect_copyops from ideep into ATen #201059compute_v2op into ATen #202611Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01 @gujinghui @PenghuiCheng @jianyuh @min-jean-cho @yanbing-j @Guobing-Chen @Xia-Weiwen @snadampal