Skip to content

[mkldnn][23/N] Update comments that still describe ideep - #206278

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

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

Conversation

@frost-intel

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

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Linked issue or supporting maintainer

Part of #154444

BC-breaking?

No

Summary (human written only)

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.

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

Differential Revision: D135688232

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

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

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

This PR 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.

Findings (10):

[minor] aten/src/ATen/native/mkldnn/MKLDNNCommon.cpp:97
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.

[minor] aten/src/ATen/native/mkldnn/MKLDNNConversions.cpp:52
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.

[minor] aten/src/ATen/native/mkldnn/Matmul.cpp:537
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.

[minor] aten/src/ATen/native/quantized/cpu/qlinear.cpp:839
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.

[minor] aten/src/ATen/native/quantized/cpu/qlinear_dynamic.cpp:573
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.

[minor] aten/src/ATen/native/mkldnn/RNN.cpp:442
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`.

[minor] aten/src/ATen/native/quantized/cpu/qconv_dynamic.cpp:168
Non-blocking: "the oneDNN wrappers" doesn't name any file, namespace or type.
Name the actual code: `mkldnn::convolution_forward_*` in detail/Conv.cpp.

[info] aten/src/ATen/native/quantized/cpu/qconv.cpp:1551
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.

[info] aten/src/ATen/native/quantized/cpu/qconv.cpp:1766
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).

(1 more not shown, see the review run)

Reviewed commit: 9b59954 (NOT the current head ed8d0ea)

Review run

🐛 Report a bad review

🔗 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 (image):

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

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

[ghstack-poisoned]
[ghstack-poisoned]
@frost-intel
frost-intel marked this pull request as ready for review November 25, 2026 14:09
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 25, 2026
@pytorch-bot pytorch-bot Bot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 25, 2026
[ghstack-poisoned]
@frost-intel frost-intel added topic: not user facing topic category and removed release notes: quantization release notes category labels Nov 25, 2026
github-actions[bot]

This comment was marked as outdated.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thx

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #206630

pytorchmergebot pushed a commit that referenced this pull request Nov 25, 2026
…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
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)
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
pytorchmergebot added a commit that referenced this pull request Nov 27, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@frost-intel your PR has been reverted as part of the stack under #206276.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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&lt;dnnl_dim_t&gt; of int64_t. So std::vector&lt;int64_t&gt;(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.

Report this finding

"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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

const Tensor &mat2,
const Tensor &result) {
// Create ideep tensors for oneDNN computation
// Create ITensors for oneDNN computation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

// 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ Non-blocking: "the oneDNN wrappers" doesn't name any file, namespace or type.

Name the actual code: mkldnn::convolution_forward_* in detail/Conv.cpp.

Report this finding

// 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

#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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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).

Report this finding

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚪ 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.

Report this finding

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 27, 2026
[ghstack-poisoned]
@soulitzer

Copy link
Copy Markdown
Contributor

@soulitzer has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@pytorch-bot pytorch-bot Bot added release notes: quantization release notes category ciflow/trunk Trigger trunk jobs on your pull request labels Dec 2, 2026

This branch was previously deployed

1 inactive (outdated) deployment
bedrock — 9b59954c Deployed Nov 27, 2026 by pytorchmergebot via analyze #43231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged module: cpu CPU specific problem (e.g., perf, algorithm) open source ready for review Automated review passed, ready for a final review by a maintainer. release notes: quantization release notes category Reverted topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants