This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/sycl/CMakeLists.txt
T
claudeandClaude Opus 5.5 0e81041881 libxe2: rmsnorm, rmsnorm_quant_fp8, quant_act_fp8, gated_quant_fp8
One work-group a row; a quantisation group a sub-group. The arithmetic is libref's step for step,
and two things made it so on the card:

- Device code is generated at link time (AOT), so the flags that shape it now go to the link as
  well as the compile: -ffp-contract=off, -ffp-model=precise, and -foffload-fp32-prec-div/-sqrt.
  Without correctly rounded division a group's scale amax * (1/448) came out one ulp off, and
  bf16 inputs sit exactly on E4M3 rounding ties often enough that 1780 of 524288 codes moved
  (a standalone host/device comparison showed it; with the flags, none).
- The sum of squares is libref's ascending f32 sum, by one work-item. A tree reduction moved
  normed values across bf16 ties on MiniCPM5-2B's real weights and failed rmsnorm_quant_fp8 at
  M=1 (rel 7.7e-3 against its 4e-3 tolerance).

rad-kbench against libref: the fixture 228/228 and MiniCPM5-2B's container 140/140, worst rel_l2
1e-7, inside guarded allocations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-23 16:02:58 +02:00

69 lines
3.7 KiB
CMake

# The parts of radiance compiled by icpx: the SYCL device backend (librad_sycl.so) and, later, the
# Intel kernel library. The main project builds this directory through ExternalProject with icpx
# as the C++ compiler (top-level CMakeLists.txt, RAD_SYCL), so the engine and every host plugin
# stay on the main project's compiler (docs/SYCL_PORTING.md §4.5, docs/SYCL_PROGRESS.md D6).
cmake_minimum_required(VERSION 3.21)
project(radiance_sycl LANGUAGES CXX)
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
message(FATAL_ERROR "sycl/ is built by icpx (IntelLLVM); this configure has "
"${CMAKE_CXX_COMPILER_ID} at ${CMAKE_CXX_COMPILER}.")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
set(RAD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." CACHE PATH "the radiance checkout")
set(RAD_SYCL_TARGETS "intel_gpu_bmg_g31" CACHE STRING "AOT targets for SYCL device code")
# The same warnings as the main build. icpx defaults to -fp-model=fast; host code here is precise
# as the main build's is, and device code keeps the main build's -ffp-contract=off discipline in
# the kernels themselves.
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
-ffp-model=precise)
set(RAD_SYCL_FLAGS -fsycl "-fsycl-targets=${RAD_SYCL_TARGETS}" -foffload-fp32-prec-div
-foffload-fp32-prec-sqrt)
# The oneAPI runtime libraries sit beside the compiler; record their directory so the engine runs
# without setvars.sh in its environment.
get_filename_component(_icpx_bin "${CMAKE_CXX_COMPILER}" DIRECTORY)
get_filename_component(RAD_ONEAPI_LIBDIR "${_icpx_bin}/../lib" ABSOLUTE)
# ---------------------------------------------------------------- the device backend
# The backend, and the core's own kernels under it (the step's advance, the weight-table patches),
# each the SYCL twin of a .hip the AMD build compiles. The engine calls the kernels' launchers by
# the same names on either backend.
add_library(rad_sycl SHARED
${RAD_SOURCE_DIR}/core/device/sycl.cpp
${RAD_SOURCE_DIR}/core/device/sycl_host.cpp
${RAD_SOURCE_DIR}/core/sched/advance_sycl.cpp
${RAD_SOURCE_DIR}/core/runtime/wtab_sycl.cpp)
target_include_directories(rad_sycl PRIVATE
${RAD_SOURCE_DIR}/core/device ${RAD_SOURCE_DIR}/core ${RAD_SOURCE_DIR}/abi
${RAD_SOURCE_DIR}/vendor)
target_compile_definitions(rad_sycl PRIVATE RAD_HAVE_SYCL=1)
target_compile_options(rad_sycl PRIVATE ${RAD_SYCL_FLAGS} -fvisibility=hidden)
target_link_options(rad_sycl PRIVATE ${RAD_SYCL_FLAGS} "LINKER:-rpath,${RAD_ONEAPI_LIBDIR}"
"LINKER:--no-undefined")
set_target_properties(rad_sycl PROPERTIES OUTPUT_NAME rad_sycl)
# ---------------------------------------------------------------- the kernel library
# libxe2 is a plugin like any other: built by rad_add_plugin against the ABI headers alone, into
# the main build's $RADIANCE_HOME (RAD_PLUGIN_OUT, passed down by the main project). The variables
# cmake/RadAddPlugin.cmake expects describe a build with no HIP; libxe2 adds its SYCL flags itself.
set(RAD_PLUGIN_OUT "${CMAKE_BINARY_DIR}/radiance_home" CACHE PATH "the build tree's $RADIANCE_HOME")
set(RAD_HIP_FOUND OFF)
set(RAD_GPU_TARGETS "")
set(RAD_HIP_RUNTIME "")
# The sub-build installs nothing; the main project installs what it needs from here.
set(RAD_PLUGIN_INSTALL OFF)
add_library(rad_abi INTERFACE)
add_library(radiance::abi ALIAS rad_abi)
target_include_directories(rad_abi INTERFACE ${RAD_SOURCE_DIR}/abi)
include(GNUInstallDirs)
include(${RAD_SOURCE_DIR}/cmake/RadAddPlugin.cmake)
add_subdirectory(${RAD_SOURCE_DIR}/libxe2 ${CMAKE_BINARY_DIR}/libxe2)