Repository navigation
Cm u2 fc gnk native - #39044
Cm u2 fc gnk native#39044vmadananth wants to merge 32 commits into
Conversation
4cea237 to
e4285d4
Compare
e4285d4 to
9ffdf20
Compare
…ogue broadcast on CM u2 FC
…multiplying FC weight dimensions' Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…acy padded GNK shape
# Conflicts: # src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp # src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp
…gpu-fc-weights-layout # Conflicts: # src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp # src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp
# Conflicts: # src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp # src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp # src/plugins/intel_gpu/src/graph/registry/fully_connected_impls.cpp
# Conflicts: # src/plugins/intel_gpu/include/intel_gpu/op/fc_weights_layout.hpp # src/plugins/intel_gpu/include/intel_gpu/primitives/fully_connected.hpp # src/plugins/intel_gpu/src/graph/fully_connected.cpp # src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_quantization.cpp # src/plugins/intel_gpu/src/graph/impls/onednn/fully_connected_onednn.hpp # src/plugins/intel_gpu/src/plugin/transformations/op/fully_connected.cpp # src/plugins/intel_gpu/tests/unit/test_cases/fully_connected_weights_layout_test.cpp
…f the deferred scale/zp reorder
There was a problem hiding this comment.
please remove onednn change in the PR which I think is not needed
…e the CM u2 FC test scans the FC registry
…u2 FC (clang-tidy readability-braces-around-statements)
…reorder when it already has the target format
e-ddykim
left a comment
There was a problem hiding this comment.
After merging #38206, transpose_before_reshape_m precedes and shadows gnk_transpose_reshape_m. This means the native GNK path introduced by this PR is never reached, and the PR's own GNK tests would fail. The pattern overlap/order needs to be reconciled in this PR.
# Conflicts: # src/plugins/intel_gpu/tests/unit/transformations/convert_fc_to_compressed_test.cpp
…-u2-fc-gnk-native # Conflicts: # src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
| const auto G = w[0].get_length(); | ||
| const auto gs = w[2].get_length(); | ||
| return {w[1], w[0] * w[2], G, gs}; | ||
| } |
There was a problem hiding this comment.
it is possible that weights-rank = 3 not because it is per group quantization, but because it is MOE model as I described in this PR #39268.
In MOE model, it is 3D which has first dimension as experts. Please make sure the refactor of weights layout also take this case into consideration.
|
This PR is merged with #38894 |
Summary
Native GNK path for CM only. When
cm::woq_u2_accepts_gnkpasses (Xe2/Xe3 + CM JIT, u2 weights, gs = 64, N % 32 == 0, f16 per-group scale, per-group zp, f16 inference precision), the ONNXMatMulNBitsreordered-B chainu2[G,N,gs] → Convert → Subtract(zp) → Multiply(scale) → Transpose{1,0,2} → Reshape[N,K] → MatMul(transpose_b)stays compressed. It becomes a
FullyConnectedCompressedwithweights_layout=GNKon the raw[G, N, gs]u2 weights, and the CM kernel runs it withWLAYOUT=0. Otherwise the chain is constant-folded to f16 exactly as on master.The non-CM permute-to-NK fallback is #38206's scope; whichever lands second reconciles the shared pattern.
Changes
impls/cm/fully_connected_woq_u2_gnk.hpp:cm::woq_u2_accepts_gnk, the single check used by the three places below.transformations_pipeline.cpp:is_decompression_multiplykeepsMultiply → Transpose{1,0,2} → Reshape(3D→2D) → MatMulon constant weights unfolded only when the check passes. Every other chain behaves as on master.compressed_weights_pattern.hpp: new narrow branchgnk_transpose_reshape_m(order{1,0,2}, rank 3→2, output[N, G·gs]). The existing branches are unchanged.ConvertFullyConnectedToFullyConnectedCompressed:transpose_b=true,transpose_b_scale/zp=false, scale/zp squeezed to[G, N]). No Transpose or Reshape is left on the weights.validate_implaccepts GNK via the same check. N/K come fromfc_weight_dims.WLAYOUT=0for GNK. Fusion reads the epilogue N fromfc_weight_dims.Dependencies / commit structure
weights_layoutattribute) and [GPU] CM u2 weight-compressed FullyConnected (XMX/DPAS) #38894 (CM u2 FC, NK). Draft until both merge.76621478fb,69559d3cc6: from Gpu fc weights layout #39011. Dropped once it merges.35aeb25a97:[TEMP from #38894]CM u2 FC (NK), squashed. Dropped once [GPU] CM u2 weight-compressed FullyConnected (XMX/DPAS) #38894 merges.4cea2372bd: this PR.Validation (Xe2/Xe3 with CM JIT)
--gtest_filter=*woq_u2*: 130 run, 129 passed, 1 skipped (no_cm_device, which runs only on a device without CM). New tests:gnk_check.accepts_only_cm_eligible_gnk: each accept/reject condition of the check.gnk_pipeline.eligible_chain_becomes_gnk_fc:[80,5120,64]through the fullTransformationsPipelinegives one GNK FC on the raw u2 constant.gnk_fold.matches_pipeline_without_gnk(gs=32, N=5104, no zp): the graph and constants are identical to a run with the GNK path disabled; no compressed FC or u2 constant remains.gnk.selects_cm_and_matches_nk(M=5/40, f16/f32 out): CM is selected without forcing,WLAYOUT=0is used, and the output is bit-identical to the NK layout of the same weights.*fully_connected*:*FullyConnected*:*ConvertFCToCompressed*:*ConvertMatMulToFullyConnected*:*dynamic_quantize*:*fc_weights_layout*: 1417 run, 1385 passed, 0 failed, 32 skipped (31 device-specific int4 GEMV +no_cm_device).