Repository navigation
[mkldnn][23/N] Update comments that still describe ideep - #206278
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 - OUTDATED (earlier commit) - Ready for human review:
Findings (10): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/206278
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 ed8d0ea with merge base d54e485 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
|
Starting merge as part of PR stack under #206630 |
…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
…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)))
|
@frost-intel your PR has been reverted as part of the stack under #206276. |
There was a problem hiding this comment.
Automated review of 9b59954: nothing blocking; ready for human review.
This PR changes only comments in 10 files under mkldnn/ and quantized/cpu/, replacing mentions of ideep with the in-tree code that now does the work. Recommendation: Approve. Every point raised is non-blocking, though the review says the inaccurate comments (the int32 NOTE/TODO, "ITensors", and mkldnn::matmul_forward in the qlinear files) are worth fixing before landing.
⚪ 10 non-blocking findings are attached to the code below, collapsed.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
| Tensor new_with_itensor_mkldnn(mkldnn::MkldnnMemory&& it, std::optional<ScalarType> dtype, std::optional<Device> device) { | ||
| // NOTE: int32_t dims from ideep::tensor but sizes needs int64_t | ||
| // TODO: support int64_t dims in ideep::tensor to avoid extra conversion | ||
| // NOTE: int32_t dims from MkldnnMemory but sizes needs int64_t |
There was a problem hiding this comment.
⚪ Non-blocking: false int32 NOTE and TODO (here at 97-98 and in MKLDNNConversions.cpp:52).
The comments now say "int32_t dims from MkldnnMemory", but MkldnnMemory::get_dims() (detail/Memory.h:721-723) returns dnnl::memory::dims, a std::vector<dnnl_dim_t> of int64_t. So std::vector<int64_t>(dims.begin(), dims.end()) widens nothing, and the TODO asks for work already done. The ideep wording was already stale, and renaming it pins a false claim on an in-tree type. Delete the NOTE and TODO instead.
| "For uint8, int8, float8 mkldnn_tensor input, we should not change the data type."); | ||
| } | ||
| // NOTE: int32_t dims from ideep::tensor but sizes needs int64_t | ||
| // NOTE: int32_t dims from MkldnnMemory but sizes needs int64_t |
There was a problem hiding this comment.
⚪ Non-blocking: same false int32 NOTE as MKLDNNCommon.cpp:97-98. MkldnnMemory::get_dims() returns int64_t dims (dnnl::memory::dims), so no…
Non-blocking: same false int32 NOTE as MKLDNNCommon.cpp:97-98. MkldnnMemory::get_dims() returns int64_t dims (dnnl::memory::dims), so no conversion happens. Delete the NOTE instead of renaming it.
| const Tensor &mat2, | ||
| const Tensor &result) { | ||
| // Create ideep tensors for oneDNN computation | ||
| // Create ITensors for oneDNN computation |
There was a problem hiding this comment.
⚪ Non-blocking: "Create ITensors for oneDNN computation" names a type that doesn't exist.
The only similar names are the unrelated at::ITensorList / ITensorListRef. The code below (lines 544-558) builds mkldnn::MkldnnMemory objects. Say "Create MkldnnMemory objects", as the rest of the PR does.
| const std::vector<int32_t>& src_zero_point = std::vector<int32_t>(1, input_zero_point); | ||
| const std::vector<int32_t>& dst_zero_point = std::vector<int32_t>(1, output_zero_point); | ||
| // Compute: Use ideep::matmul_forward to support asymmetric quantization | ||
| // Compute: Use mkldnn::matmul_forward to support asymmetric quantization |
There was a problem hiding this comment.
⚪ Non-blocking: wrong function named. mkldnn::matmul_forward is the deprecated helper without bias (detail/Matmul.h:115-123).
It takes no scales or zero points, so it cannot "support asymmetric quantization". This path actually calls mkldnn::matmul_forward_prepare / matmul_forward_compute (lines 880, 891, 893). Name those two functions instead.
| const std::vector<float>& weights_scales = w.get_scale(); | ||
| // Compute -> f32 | ||
| // Use ideep::matmul_forward instead of ideep::inner_product_forward, | ||
| // Use mkldnn::matmul_forward instead of mkldnn::inner_product_forward, |
There was a problem hiding this comment.
⚪ Non-blocking: wrong function named. mkldnn::matmul_forward is the deprecated no-bias helper with no scales or zero points.
This path actually calls mkldnn::matmul_forward_prepare / matmul_forward_compute (lines 597, 607, 609). Name those instead. The mkldnn::inner_product_forward half of the comment is correct.
| // and possibly use blocked formats for weights depending shape info. | ||
| // b. All mkldnn memories are created (in plain format) as views on ATen tensor, | ||
| // the weight reorder(if any) is handed automatically inside ideep (mkldnn bridge) | ||
| // the weight reorder(if any) is handed automatically inside the oneDNN wrappers (mkldnn bridge) |
There was a problem hiding this comment.
⚪ Non-blocking: "the oneDNN wrappers" doesn't name anything.
No file, namespace or type has that name, and under mkldnn/ it is easy to confuse with the real at::native::onednn namespace in the XPU code. The leftover "(mkldnn bridge)" described ideep and no longer means anything. Name the actual code: the weight reorder is reorder_if_differ_in in detail/Lstm.cpp, reached through mkldnn::lstm_forward_* / lstm_backward.
| apply_impl<false>(q_input, /*accum*/std::nullopt, q_params.scale, q_params.zero_point); | ||
|
|
||
| // TODO: Modify ideep to allow fp32 input & output | ||
| // TODO: Modify the oneDNN wrappers to allow fp32 input & output |
There was a problem hiding this comment.
⚪ Non-blocking: "the oneDNN wrappers" doesn't name any file, namespace or type.
Name the actual code: mkldnn::convolution_forward_* in detail/Conv.cpp.
| // So, we will use default output_scale as 1.0 and output_zero_point as 0, since | ||
| // when output_scale is 1.0, we will skip invoking of op_attr.set_scales in ideep; | ||
| // when output_zero_point is 0, we will skip invoking of op_attr.set_zero_points in ideep. | ||
| // when output_scale is 1.0, we will skip invoking of op_attr.set_scales; |
There was a problem hiding this comment.
⚪ Non-blocking, optional clarity suggestion: dropping "in ideep" removes where the skip happens.
The comment is still true, just less useful. With DNNL_PREREQ(3, 1, 0), the skip is later in this function at lines 1787-1792 and 1830-1839, and that code calls set_scales_mask / set_zero_points_mask, not set_scales. With older oneDNN, the skip is in detail/Conv.cpp:159-172.
| #if DNNL_PREREQ(3, 1, 0) | ||
| // Use oneDNN's APIs instead of prepare/compute from ideep to reduce integration overhead. | ||
| // The functions from ideep are heavy because they have complex data structures for unified API | ||
| // Use oneDNN's APIs instead of the prepare/compute ported from ideep to reduce integration overhead. |
There was a problem hiding this comment.
⚪ Non-blocking, optional clarity suggestion: "the prepare/compute ported from ideep" could name mkldnn::convolution_forward_prepare /…
Non-blocking, optional clarity suggestion: "the prepare/compute ported from ideep" could name mkldnn::convolution_forward_prepare / convolution_forward_compute, which the #else branch calls (lines 1857 and 1869).
| if(c.get_data_handle() != c_data){ | ||
| // ideep will query onednn expect format of output | ||
| // if given output format is not expected, ideep will re-init an output buffer | ||
| // matmul_forward will query onednn expect format of output |
There was a problem hiding this comment.
⚪ Non-blocking (optional nit): inconsistent "oneDNN" casing.
Lines 271 and 428 keep the lowercase "onednn" from the old text, while the same copied comment at line 218 says "oneDNN". Since the PR rewrites these lines anyway, it could make them match.
|
@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)
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.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01
Differential Revision: D135688232