@@ -1338,6 +1338,66 @@ static void mul_mat_vec_ptq1_0_q8_1_sycl_switch_ncols(
13381338 }
13391339}
13401340
1341+ static void mul_mat_vec_pq2_0_q8_1_sycl (const void * vx, const void * vy,
1342+ float * dst, const int ncols,
1343+ const int nrows,
1344+ dpct::queue_ptr stream) {
1345+ GGML_ASSERT (ncols % QK_PQ2_0 == 0 );
1346+ const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1 ) / GGML_SYCL_MMV_Y ;
1347+ const sycl::range<3 > block_nums (1 , 1 , block_num_y);
1348+ const sycl::range<3 > block_dims (1 , GGML_SYCL_MMV_Y , WARP_SIZE );
1349+
1350+ stream->submit ([&](sycl::handler & cgh) {
1351+ cgh.parallel_for (
1352+ sycl::nd_range<3 >(block_nums * block_dims, block_dims),
1353+ [=](sycl::nd_item<3 > item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1354+ mul_mat_vec_q<QK_PQ2_0 , QI_PQ2_0 , block_pq2_0,
1355+ VDR_PQ2_0_Q8_1_MMVQ , vec_dot_pq2_0_q8_1>(
1356+ vx, vy, dst, ncols, nrows, item_ct1);
1357+ });
1358+ });
1359+ }
1360+
1361+ template <int ncols_dst>
1362+ static void mul_mat_vec_pq2_0_q8_1_sycl_ncols (
1363+ const void * vx, const void * vy, float * dst,
1364+ const int ncols, const int nrows,
1365+ const int stride_col_y, const int stride_col_dst,
1366+ dpct::queue_ptr stream) {
1367+ GGML_ASSERT (ncols % QK_PQ2_0 == 0 );
1368+ const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1 ) / GGML_SYCL_MMV_Y ;
1369+ const sycl::range<3 > block_nums (1 , 1 , block_num_y);
1370+ const sycl::range<3 > block_dims (1 , GGML_SYCL_MMV_Y , WARP_SIZE );
1371+
1372+ stream->submit ([&](sycl::handler & cgh) {
1373+ cgh.parallel_for (
1374+ sycl::nd_range<3 >(block_nums * block_dims, block_dims),
1375+ [=](sycl::nd_item<3 > item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1376+ mul_mat_vec_q_ncols<QK_PQ2_0 , QI_PQ2_0 , block_pq2_0,
1377+ VDR_PQ2_0_Q8_1_MMVQ , vec_dot_pq2_0_q8_1, ncols_dst>(
1378+ vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, item_ct1);
1379+ });
1380+ });
1381+ }
1382+
1383+ static void mul_mat_vec_pq2_0_q8_1_sycl_switch_ncols (
1384+ const void * vx, const void * vy, float * dst,
1385+ const int ncols, const int nrows, const int ncols_dst,
1386+ const int stride_col_y, const int stride_col_dst,
1387+ dpct::queue_ptr stream) {
1388+ switch (ncols_dst) {
1389+ case 1 : mul_mat_vec_pq2_0_q8_1_sycl (vx, vy, dst, ncols, nrows, stream); break ;
1390+ case 2 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<2 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1391+ case 3 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<3 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1392+ case 4 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<4 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1393+ case 5 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<5 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1394+ case 6 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<6 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1395+ case 7 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<7 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1396+ case 8 : mul_mat_vec_pq2_0_q8_1_sycl_ncols<8 >(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break ;
1397+ default : GGML_ABORT (" unsupported ncols_dst=%d for PQ2_0 multi-col MMVQ" , ncols_dst);
1398+ }
1399+ }
1400+
13411401static void mul_mat_vec_q2_0_q8_1_sycl (const void * vx, const void * vy,
13421402 float * dst, const int ncols,
13431403 const int nrows,
@@ -2415,6 +2475,20 @@ void ggml_sycl_op_mul_mat_vec_q(ggml_backend_sycl_context & ctx, const ggml_tens
24152475 mul_mat_vec_ptq1_0_q8_1_sycl (src0_dd_i, src1_ddq_i_bs, dst_dd_i_bs, ne00, row_diff, stream);
24162476 }
24172477 break ;
2478+ case GGML_TYPE_PQ2_0 :
2479+ if (i == 0 && src1_ncols > 1 && src1_ncols <= 8 ) {
2480+ const int stride_col_y = src1_padded_col_size / QK8_1 ;
2481+ const int stride_col_dst = dst->ne [0 ];
2482+ GGML_SYCL_DEBUG (" Calling mul_mat_vec_pq2_0_q8_1_sycl_switch_ncols ncols=%d\n " , (int )src1_ncols);
2483+ mul_mat_vec_pq2_0_q8_1_sycl_switch_ncols (
2484+ src0_dd_i, src1_ddq_i, dst_dd_i, ne00, row_diff,
2485+ src1_ncols, stride_col_y, stride_col_dst, stream);
2486+ return ;
2487+ } else if (i == 0 || src1_ncols == 1 ) {
2488+ GGML_SYCL_DEBUG (" Calling mul_mat_vec_pq2_0_q8_1_sycl\n " );
2489+ mul_mat_vec_pq2_0_q8_1_sycl (src0_dd_i, src1_ddq_i_bs, dst_dd_i_bs, ne00, row_diff, stream);
2490+ }
2491+ break ;
24182492 case GGML_TYPE_Q2_0 :
24192493 if (i == 0 && src1_ncols > 1 && src1_ncols <= 8 ) {
24202494 const int stride_col_y = src1_padded_col_size / QK8_1 ;
0 commit comments