Repository navigation
[mkldnn][16/N] Port ideep matmul (fp32 and quantized) into ATen - #205976
frost-intel wants to merge 4 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 (9): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/205976
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit e549534 with merge base 47eb5c6 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
|
Addressing bot comments:
|
There was a problem hiding this comment.
Automated review of e53bc55: nothing blocking; ready for human review.
The PR ports ideep's matmul_forward (floating-point path plus static and dynamic int8) into aten/src/ATen/native/mkldnn/detail/Matmul.{h,cpp} and moves the mkldnn matmul and quantized linear callers over to it. Recommendation: Approve. Every remaining point is non-blocking.
⚪ 9 non-blocking findings
dst_coeff is ignored on the dynamic path (non-blocking, carried over). The dynamic matmul_forward_compute overload accepts dst_coeff, but do_compute_dynamic_quant never reads it. A caller that passes something other than 1.0 gets no effect and no error. Remove the parameter or document that it does nothing.
Stale comments (non-blocking, carried over). detail/Matmul.h:118 calls matmul_forward a "Deprecated 2-in-1 compute", and detail/Matmul.cpp:1042 says "Consider fp32 only for IPEX". In ATen this is the only floating-point entry point, and its callers pass bf16/fp16 tensors. Also, quantized/cpu/qlinear.cpp:839 and qlinear_dynamic.cpp:573 still say "Use ideep::matmul_forward".
Mutable static holding a constant (non-blocking, carried over). static ideep::lowp_kind dummy_lowp_kind only ever holds u8s8. Pass ideep::u8s8 directly.
Existing lowp_kind mismatch on a touched line (non-blocking, not a regression, carried over). The cache-miss call at lines 609-612 leaves out alowp_kind, so it defaults to u8s8, while the matching prepare call at lines 597-601 passes s8s8 for signed input. The old ideep call had the same arguments, but this line is touched here, so it is cheap to fix now or in a follow-up.
Unused include (non-blocking, new). #include <utility> was needed only for the std::move calls in the removed constructors. Nothing else in the header uses it.
Unused member (non-blocking, new). matmul_forward_params::bias_attr is never written or read anywhere in aten/. The description says unused code was dropped, so either drop this member or note that it is kept to match ideep. It was not raised last time because the constructor that set it was removed only in this round.
Duplicated primitive-descriptor lookup (non-blocking). The #ifdef __aarch64__ choice between building the descriptor directly and going through create_key + computation_cache::fetch_or_create appears three times in detail/Matmul.cpp (about lines 146-177, 370-400 and 539 onward). detail/InnerProduct.cpp:23-80 and detail/Conv.cpp:333-470 put the same choice in a file-local get_primitive_desc helper. Copying ideep faithfully is a reasonable choice for this PR, so a follow-up is fine.
Static int8 cache miss has no committed test (non-blocking, carried over). No committed test reaches the static int8 cache-miss path here; only the uncommitted probe in the description shows it works. A small TestQuantizedLinear case would keep this path covered: prepack once, then call with two different input scales or shapes and compare each result against the reference.
The description overstates the coverage gap (non-blocking, carried over). It calls fp32 addmm/mm/bmm/baddbmm with fp32_precision set to bf16/tf32 "paths no existing test exercises". In fact, @ reduced_f32_on_and_off reruns those test_linalg.py tests at both precisions; the A/B filter and (bfloat16 or float16 or half) excludes exactly those runs. Re-running the A/B with the *_cpu_float32 variants included would back up the "no behavior change" claim for these paths.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
[ghstack-poisoned]
|
Addressing bot comments:
|
|
Starting merge as part of PR stack under #205977 |
[ghstack-poisoned]
|
Starting merge as part of PR stack under #205977 |
1 similar comment
|
Starting merge as part of PR stack under #205977 |
…5977) ## Linked issue or supporting maintainer Part of #154444 Supported by @albanD ## BC-breaking? No ## Summary (human written only) This PR ports oneDNN primitive cache and attr_t from ideep to ATen, as well as renames for uses within ATen. Tests verified the same number of cache-misses for a fixed workload with A/B testing. ## Agent details (if applicable) Developed with assistance from Claude Opus 5.5. > > Three parts, each line-for-line with no behavior change: > > 1. **Primitive cache.** `detail/PrimitiveCache.h` ports `ideep::utils::lru_cache`, `computation_cache` and the `to_bytes`/`create_key` key builders. Behavior is unchanged: one thread-local store per descriptor type, capacity 1024 (1 on aarch64), overridable with `LRU_CACHE_CAPACITY`, and byte-identical keys. The conv, deconv, inner-product and matmul ports, plus `clear_computation_cache`, now use it. The ideep store is no longer used by ATen. > 2. **`Attr` alias.** Mechanical rename of `ideep::attr_t` to `at::native::mkldnn::Attr` (233 uses). > 3. **`Attr` class.** `detail/Attr.h` ports `ideep::attr_t`: the constructors ATen uses, deep-copy assignment, scale/zero-point storage, `has_op_kind`, `non_negative_output` (ideep spells it `non_negitive_output`), `to_bytes`, and the 15 factory helpers ATen uses. Unused helpers and constructors are not ported. ideep's note in `to_bytes` saying scales and zero points are not encoded is out of date (they are), so it is rewritten to list what is actually left out. A conversion to `ideep::attr_t` that carries the scale and zero-point maps remains until `ideep::tensor` is ported (21/N), because its reorders still take `ideep::attr_t`. > > Testing: > - oneDNN verbose logs before vs. after are identical for `test_mkldnn`, quantized conv/deconv/linear, and the fp matmul tests. The cache-miss probes for quantized linear/deconv and the fp32 matmul probe also give bitwise-equal outputs. > - Per-op primitive-descriptor cache-miss counts are identical before vs. after, at the default capacity and with `LRU_CACHE_CAPACITY=1`. > - A standalone probe checks that `Attr` and `ideep::attr_t` produce byte-identical cache keys for every factory and constructor ATen uses, and that copying and conversion keep scales and zero points. > > Previously submitted as #204801. Pull Request resolved: #205977 Approved by: https://github.com/albanD ghstack dependencies: #205972, #205973, #205974, #205975, #205976
Stack from ghstack (oldest at bottom):
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.
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01