From 8fced2e79f09b4d589133d317d92bda917b50204 Mon Sep 17 00:00:00 2001 From: claude Date: Mon, 2 Nov 2026 12:20:10 +0100 Subject: [PATCH] libxe2: auto large-GRF mode on the AOT backend line, so grf_size<256> kernels get 256 registers No kernel's grf_size<256> property reached the card: sycl-post-link records it on the device image (sycl-grf-size=256 in the image's properties), but only the runtime's JIT path reads that and adds the large-register option, and this build compiles AOT at link time with the -options string alone. Every kernel ran with 128 registers; prefill attention spilled 4 KiB a thread and spent 66% of its stall samples on the scoreboard. -ze-intel-enable-auto-large-GRF-mode gives a kernel the large file when it needs it: the flash attention kernels get 256 with no spill, the w4 GEMMs keep 128. Probe fa.cpp (24/4 heads, head_dim 256): 2048 tokens 7.3 -> 13.5 TFLOPS, 8192 tokens 8.3 -> 17.8, output identical. rad-kbench replay (libxe2, libref, spechub): 1410/1410. qwen3.8-27b-w4a16 (mtp4fc), fresh prompts: prefill ~2.1k tokens 1346 -> 1376 tok/s, ~6.9k tokens 1177 -> 1301; decode over 24 corpus prompts 90.2 -> 90.4; greedy 8/8 identical. Co-Authored-By: Claude Opus 5.5 --- libxe2/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libxe2/CMakeLists.txt b/libxe2/CMakeLists.txt index 4416f785..9c3aa4b6 100644 --- a/libxe2/CMakeLists.txt +++ b/libxe2/CMakeLists.txt @@ -35,10 +35,17 @@ rad_add_plugin(libxe2 kernels SOURCES ${XE2_SRC}) # add unless its own option says strict, whatever the front end's -ffp-contract (probe fmac.cpp: # t = (s * a) * b; c += t came back fused in 14062 of 65536 lanes, 0 with the option; SIMT kernels # are unaffected either way). Without it an ESIMD epilogue that copies libref's chain is not exact. +# -ze-intel-enable-auto-large-GRF-mode: a kernel's grf_size<256> property never reached the card. +# sycl-post-link records it on the device image (sycl-grf-size), but only the runtime's JIT reads that +# and adds the large-register option; this build compiles AOT at link time with the options here +# alone, so every kernel got 128 registers, and the 256-register ones spilled (prefill attention: 4 +# KiB a thread, 66% of its stall samples on the scoreboard). The auto mode gives a kernel the large +# file when it needs it: the attention kernels get 256 and no spill (probe fa.cpp at 2048 tokens 7.3 +# -> 13.5 TFLOPS, output identical), the w4 GEMMs keep 128 and their eight threads an EU. set(_xe2_sycl -fsycl "-fsycl-targets=${RAD_SYCL_TARGETS}" -ffp-model=precise -ffp-contract=off -Wno-overriding-option -foffload-fp32-prec-div -foffload-fp32-prec-sqrt "SHELL:-Xspirv-translator -spirv-ext=+SPV_INTEL_subgroup_matrix_multiply_accumulate" - "SHELL:-Xsycl-target-backend \"-options -ffp-contract=off\"") + "SHELL:-Xsycl-target-backend \"-options '-ffp-contract=off -ze-intel-enable-auto-large-GRF-mode'\"") target_compile_options(libxe2 PRIVATE ${_xe2_sycl} -fvisibility=hidden) get_filename_component(_xe2_icpx_bin "${CMAKE_CXX_COMPILER}" DIRECTORY) get_filename_component(_xe2_oneapi_lib "${_xe2_icpx_bin}/../lib" ABSOLUTE)