Fix cache collisions and zero-initialize decompression scratchpad in InnerProduct#314
Open
Shanmuk4622 wants to merge 1 commit into
Open
Conversation
Shanmuk4622
commented
Jun 11, 2026
Shanmuk4622
left a comment
Author
There was a problem hiding this comment.
Technical Review: oneDNN Decompression Submodule Fixes
1. Hashing, Serialization & Deserialization (primitive_attr_quant.cpp)
- Correctness: The additions of
type_,is_set_,is_set_scale,mask_scale,data_type_scale,ndims_scale,dims_scale,is_set_wei,mask_wei,data_type_wei,ndims_wei, anddims_weitoget_hash(),serialize(), anddeserialize()are symmetric and maintain exact parity. - Style & Conventions: Using
hash_combinefor scalar values andprimitive_hashing::get_array_hashfor the shape arrays is correct and aligns with oneDNN's existing hashing conventions. - Impact: This cleanly eliminates weights cache collisions between models with distinct decompression parameters.
2. Scratchpad Zero-Initialization (jit_brgemm_inner_product.cpp)
-
Design & Timing: Performing the
std::memsetcall in the master thread immediately after retrievingdecomp_buf_globalis optimal. It avoids redundant or multi-threaded initializations inside the parallel loop. -
Memory Safety: The size computation logic:
- For
weights_compressed(usingjbgp.ic * 64) - For
weights_decompressioninprepackmode (usingjbgp.ic_block * jbgp.nb_ic_blocking * jbgp.oc_block)
exactly matches the sizes allocated during configuration booking (
init_scratchpad_base). This makes thestd::memsetboundary completely safe against buffer overruns. - For
-
Impact: It successfully forces all alignment and boundary elements to
0.0f, preventing vector instructions from loading uninitialized garbage and propagating NaNs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR resolves non-deterministic NaN outputs observed in the OpenVINO CPU plugin (OpenVINO issue #36328) during weight decompression (specifically decompressing f8e8m0 weights to f32).
Problem:
quant_entry_t::get_hash(),serialize(), anddeserialize(). This led to hash collisions and incorrect weights sharing across different compiled models.decomp_buf_globalmemory fetched from the oneDNN scratchpad (key_brgemm_primitive_decomp_buf) was not zero-initialized. When the subsequent GEMM executor performed aligned vector loads, it read uninitialized padding elements containing garbage/NaN bits. Multiplying them by 0 (since they were out-of-bounds/padded) still produced NaN outputs (0.0 * NaN = NaN), propagating NaNs non-deterministically.Solution:
quant_entry_t::get_hash(),serialize(), anddeserialize().decomp_buf_globalusingstd::memsetbefore executing decompression injit_brgemm_inner_product.cpp.Fixes: Related to openvinotoolkit/openvino#36328
Checklist
General
Bug fixes