libxe2: prefill GEMMs on oneMKL -- 27B prefill 208 -> 305 tok/s

oneMKL's SYCL GEMM (part of oneAPI; libxe2 links it when CMake finds it, RAD_XE2_MKL=OFF or
XE2_NO_MKL=1 keep the hand-written kernels) runs the fp16 prefill GEMMs at 85-91 TFLOPS on random
data at the 27B's shapes, deterministic run to run, against ~23-30 for the hand-tiled XMX kernel:
xmx_f16_scaled (the m2xfp4 prefill) and xmx_f16_batched (the rotation's) go to its gemm and
gemm_batch, and bf16 gemm_nt at M >= 17 to its bf16 GEMM (N = 96 had fallen to the exact kernel,
5 ms a call). The m2xfp4 weight decode to fp16 now takes a (column, 32-group) a work-item. fp16 or
bf16 products with f32 accumulation, as before: the 27B's cases 133/133 (rel_l2 <= 1.42e-3), the
fixture 1410/1410. Prefill GEMMs over a 1882-token prompt 4.06 -> 1.66 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
pascallinxweilerandClaude Opus 5.5 committed 2026-10-24 17:49:44 +02:00
1 parent 3f782b935c
commit c81aa869a0
4 files changed
+123 -11

No files matched your search

+21
View File
@@ -39,3 +39,24 @@ get_filename_component(_xe2_icpx_bin "${CMAKE_CXX_COMPILER}" DIRECTORY)
get_filename_component(_xe2_oneapi_lib "${_xe2_icpx_bin}/../lib" ABSOLUTE)
target_link_options(libxe2 PRIVATE ${_xe2_sycl} "LINKER:-rpath,${_xe2_oneapi_lib}"
"LINKER:--no-undefined")
# oneMKL's SYCL BLAS for the prefill-sized fp16 GEMMs (xe2_gemm_xmx.cpp, xmx_f16_scaled): ~85-90
# TFLOPS at the 27B's shapes against ~25 for the hand-tiled kernel, deterministic run to run. Part
# of oneAPI, found beside icpx; without it the hand-tiled kernel serves (RAD_XE2_MKL=OFF forces that).
option(RAD_XE2_MKL "libxe2: oneMKL's SYCL GEMM for the prefill fp16 GEMMs" ON)
get_filename_component(_xe2_oneapi_root "${_xe2_icpx_bin}/../../.." ABSOLUTE)
find_library(_xe2_mkl_sycl_blas mkl_sycl_blas
HINTS "$ENV{MKLROOT}/lib" "${_xe2_oneapi_root}/mkl/latest/lib" NO_DEFAULT_PATH)
find_path(_xe2_mkl_inc oneapi/mkl/blas.hpp
HINTS "$ENV{MKLROOT}/include" "${_xe2_oneapi_root}/mkl/latest/include" NO_DEFAULT_PATH)
if(RAD_XE2_MKL AND _xe2_mkl_sycl_blas AND _xe2_mkl_inc)
get_filename_component(_xe2_mkl_lib "${_xe2_mkl_sycl_blas}" DIRECTORY)
message(STATUS "libxe2: oneMKL SYCL BLAS from ${_xe2_mkl_lib}")
target_compile_definitions(libxe2 PRIVATE XE2_HAVE_MKL=1 MKL_ILP64)
target_include_directories(libxe2 SYSTEM PRIVATE "${_xe2_mkl_inc}")
target_link_libraries(libxe2 PRIVATE "${_xe2_mkl_sycl_blas}" "${_xe2_mkl_lib}/libmkl_intel_ilp64.so"
"${_xe2_mkl_lib}/libmkl_sequential.so" "${_xe2_mkl_lib}/libmkl_core.so")
target_link_options(libxe2 PRIVATE "LINKER:-rpath,${_xe2_mkl_lib}")
else()
message(STATUS "libxe2: no oneMKL SYCL BLAS; the prefill GEMMs use the hand-tiled XMX kernel")
endif()