Archived
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
This commit is contained in:
1 parent
41a3c32a65
commit
b2cdcb4420
5 files changed
+332
-5
No files matched your search
@@ -24,10 +24,14 @@ rad_add_plugin(libxe2 kernels SOURCES ${XE2_SRC})
|
||||
|
||||
# -ffp-contract=off is a correctness flag here as in libref: kernels are checked against it, so
|
||||
# `a*b + c` rounds twice on both sides. It follows -ffp-model=precise, which would otherwise set
|
||||
# contraction back on.
|
||||
set(_xe2_sycl -fsycl "-fsycl-targets=${RAD_SYCL_TARGETS}")
|
||||
target_compile_options(libxe2 PRIVATE ${_xe2_sycl} -ffp-model=precise -ffp-contract=off -Wno-overriding-option
|
||||
-fvisibility=hidden)
|
||||
# contraction back on. -foffload-fp32-prec-div and -sqrt make device division and sqrt correctly
|
||||
# rounded, as libref's are: a quantiser's scale is amax * (1/top), and a 1/top one ulp off moves
|
||||
# codes that sit exactly on an E4M3 rounding tie, which bf16 inputs hit often.
|
||||
# Device code is generated at link time (AOT), so every flag that shapes it goes to the link too;
|
||||
# on the compile line alone it changes nothing on the card.
|
||||
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)
|
||||
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)
|
||||
target_link_options(libxe2 PRIVATE ${_xe2_sycl} "LINKER:-rpath,${_xe2_oneapi_lib}"
|
||||
|
||||
Reference in new issue
Block a user