Repository navigation
[mkldnn][21/N] Port ideep::tensor, engine and stream into ATen - #206276
frost-intel wants to merge 5 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/206276
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4515474 with merge base d54e485 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
|
Starting merge as part of PR stack under #206630 |
## 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
## Linked issue or supporting maintainer Part of #154444 ## BC-breaking? No ## Summary (human written only) Replaces any references to ideep in comments with mkldnn references reflecting the current code. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > Part of #154444 (remove the ideep submodule). > > Comment-only. After ideep is removed, comments in `aten/src/ATen/native/mkldnn/` and `aten/src/ATen/native/quantized/cpu/` still describe ideep doing the work. They now name what does it: `MkldnnMemory` for ideep tensors, `matmul_forward` / `mkldnn::inner_product_forward` for ideep operators, the oneDNN wrappers for "ideep (mkldnn bridge)", and oneDNN where the comment means the library. > > Left as-is on purpose: "Ported from ideep" provenance notes, ideep comments that were ported with the code in `detail/`, and identifiers that still say ideep (`DeviceType::IDEEP`, `IDeepRegistration.cpp`, `make_ideep_tensor`). > > What changed: 10 files, +33/−33, all comment lines. Pull Request resolved: #206278 Approved by: https://github.com/albanD ghstack dependencies: #205978, #205979, #205980, #206276, #206277
…n Attr (#206279) ## Linked issue or supporting maintainer Part of #154444 ## BC-breaking? No ## Summary (human written only) Changing `inner_product_forward_expected_weights_desc` to take an `Attr` parameter as its last argument, allowing the packed weight layout to depend on primitive attributes. This was requested by @mriganks-amd for upcoming ZenDNN fp16 accumulation support. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > Part of #154444. Requested by AMD for ZenDNN fp16 accumulation (#204794). > > `inner_product_forward_expected_weights_desc` now takes `const Attr& attr = Attr()` as its last parameter and passes it to the `dnnl::inner_product_forward::primitive_desc`, as `matmul_forward_expected_weights_desc` already does. The packed weight layout can depend on primitive attributes. For example, with ZenDNN's fp16 "any" accumulation mode, a weight packed with default attributes runs on brgemm even with the mode set. Callers can now pack with the attributes they compute with. > > No behavior change: the only caller, `mkldnn_reorder_linear_weight` in `MKLDNNConversions.cpp`, does not pass `attr`, and a default `Attr` is an empty `dnnl::primitive_attr`, which is what oneDNN uses when no attributes are given. This is an API addition on top of the port; ideep's version takes no attributes. > > Testing: compiles with `-Wall -Wextra -Wsign-compare -Werror` in release and debug builds; `test_mkldnn`, the mkldnn conv tests and the quantized conv/linear tests pass at the tip. Pull Request resolved: #206279 Approved by: https://github.com/albanD ghstack dependencies: #205978, #205979, #205980, #206276, #206277, #206278
## Linked issue or supporting maintainer Part of #154444 ## BC-breaking? No ## Summary (human written only) Rename all itensor functions to `memory_*` to eliminate all itensor references in ideep port. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > Part of #154444 (remove the ideep submodule). > > Follows the `ITensor` -> `MkldnnMemory` rename. The helpers that convert between `at::Tensor` and `MkldnnMemory` drop their `itensor` prefix. This is a mechanical rename with no behavior change: > - `itensor_from_mkldnn` -> `memory_from_mkldnn` > - `itensor_from_tensor` -> `memory_from_tensor` > - `itensor_from_const_tensor` -> `memory_from_const_tensor` > - `itensor_view_from_dense` -> `memory_view_from_dense` > - `itensor_view_from_const_dense` -> `memory_view_from_const_dense` > - `itensor_view_from_dense_impl` -> `memory_view_from_dense_impl` (file-local) > - `new_with_itensor_mkldnn` -> `new_with_mkldnn_memory` > - `typed_itensor_view_from_dense` -> `typed_mkldnn_memory_view_from_dense` (file-local) > > These are internal ATen helpers declared in `MKLDNNCommon.h`, so their exported symbol names change, as with the helpers in 21/N. Pull Request resolved: #206630 Approved by: https://github.com/albanD ghstack dependencies: #205978, #205979, #205980, #206276, #206277, #206278, #206279
|
✴️ iz2: Reverting this PR because it breaks Meta-internal tests that OSS CI does not run. @frost-intel, to reland it, please reach out to @albanD, who reviewed it, about the fix it needs. |
|
@pytorchbot successfully started a revert job. Check the current status here. |
…206630)" This reverts commit bcfd834. Reverted #206630 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
…c take an Attr (#206279)" This reverts commit c067e37. Reverted #206279 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
…6278)" This reverts commit d9216ae. Reverted #206278 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
This reverts commit 7dad426. Reverted #206277 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
#206276)" This reverts commit 3fcdfc9. Reverted #206276 on behalf of https://github.com/izaitsevfb due to Breaks Meta-internal tests that OSS CI does not run ([comment](#206276 (comment)))
|
@frost-intel your PR has been successfully reverted. |
|
@soulitzer has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Stack from ghstack (oldest at bottom):
Linked issue or supporting maintainer
Part of #154444
BC-breaking?
No
Summary (human written only)
Ports
tensor,engine, andstreamfrom ideep to ATen, as well as replacing aliases.After this PR, ATen no longer calls any ideep code.
Agent details (if applicable)
Developed with assistance from Claude Opus 5.5.
Differential Revision: D135688229