Repository navigation
[mkldnn][11/N] Port ideep convolution backward ops into ATen - #205717
frost-intel wants to merge 5 commits into
Conversation
[ghstack-poisoned]
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205717
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 9b8fb6d with merge base 4004f7e ( NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
## 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
[ghstack-poisoned]
## 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
[ghstack-poisoned]
## 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
[ghstack-poisoned]
## 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
|
Addressing bot comments:
|
|
@pytorchbot review |
There was a problem hiding this comment.
Automated review of 9b8fb6d: nothing blocking; ready for human review.
The PR moves ideep's convolution_backward_data::compute_v2 and convolution_backward_weights::compute_v2 (with and without bias) into aten/src/ATen/native/mkldnn/detail/Conv.{h,cpp} and switches the three call sites in mkldnn/Conv.cpp to the new functions. Recommendation: Approve. Nothing blocks it, and all earlier non-blocking points have been answered.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
## 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
Stack from ghstack (oldest at bottom):
sum,binary, anddirect_copyops from ideep into ATen #205710Linked 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.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01