dnn: optimize int4 LLM decode models and support Gemma-3 quantized models (#30258)

MatMulNBits kernel. The op was compiling at the SSE3 baseline, so 128 bits on a 512-bit machine. It now has dispatched SIMD kernels (AVX2, AVX-512, NEON) that unpack the int4 weights straight into the dot product instead of dequantising a whole column into a buffer first, and the parallel stripes follow onnxruntime's 16-column policy rather than issuing 269k dispatches per token. Layer_MatMulNBits in perf_layer.cpp covers M=1/16/128 for 4-bit, 4-bit with zero points and 8-bit.
This commit is contained in:
Prasad Ayush Kumar
2026-12-01 17:06:51 +05:30
committed by GitHub
parent dbe66b4214
commit 14790c2faa
26 changed files with 1535 additions and 239 deletions

View File

@@ -230,6 +230,7 @@ void initializeLayerFactory()
CV_DNN_REGISTER_LAYER_CLASS(Reciprocal, ReciprocalLayer);
CV_DNN_REGISTER_LAYER_CLASS(Gather, GatherLayer);
CV_DNN_REGISTER_LAYER_CLASS(Gather2, Gather2Layer);
CV_DNN_REGISTER_LAYER_CLASS(GatherBlockQuantized, GatherBlockQuantizedLayer);
CV_DNN_REGISTER_LAYER_CLASS(GatherElements, GatherElementsLayer);
CV_DNN_REGISTER_LAYER_CLASS(LayerNormalization, LayerNormLayer);
CV_DNN_REGISTER_LAYER_CLASS(RMSNormalization, RMSNormLayer);