Archived
Merge upstream main (v1.12 -> v1.15.1, 408 commits) into the SYCL port
Conflicts from the old m2xfp branch take upstream's version. Two libxe2 fixes the merge needs:
- rad_plugin_abi_layout: the plugin now exports the ABI layout hash the loader checks.
- gemm_nt_q_w4a16: upstream 492d33c sends bf16 activations to the w4a16 GEMM (the separate cast
is gone); the fast kernel took only f16, so every call fell back to the exact path (decode
~2.5 tok/s). A bf16 activation is narrowed to f16 (round to nearest even) into a workspace first,
the dropped cast bit for bit; decode back to ~57 tok/s on one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
7580ec3d17
937 files changed
+285776
-8914
No files matched your search
+309
-26
@@ -15,7 +15,7 @@
|
||||
# builder. With the archive linked, a new ABI call missing from the fake would pull in
|
||||
# rad_builder.cpp.o and collide on every rad_decl_* symbol; without it the error is a single
|
||||
# undefined reference.
|
||||
set(RAD_TESTS_NO_CORE arch_test glm5next_test)
|
||||
set(RAD_TESTS_NO_CORE arch_test glm5next_test nemotron35_test)
|
||||
|
||||
# fixture_test tests tools/kfixture.cpp and tools/opshapes.cpp (the seeded draw, the reduction and
|
||||
# the on-disk recording) directly, kbench_test tools/kbench_core.cpp (rad-kbench's rules), and
|
||||
@@ -49,6 +49,17 @@ set(RAD_TESTS_WITH_LEGACY chatparse_test chatparse_gemma4_test)
|
||||
# r4d_ar_links_test checks libr4d's header-only link reader, so it needs only the include path.
|
||||
set(RAD_TESTS_WITH_R4D_HOST relayout_parity_test r4d_ar_links_test)
|
||||
|
||||
# ref2va_pack_test checks the Ref2VA sequence packing (arch/minimaxh3/rad_ref2va_pack.cpp, a
|
||||
# device-free TU of the plugin) against golden vectors generated from the reference implementation
|
||||
# by tests/data/ref2va/gen_golden.py. It is pure host arithmetic, so like arch_test it links no
|
||||
# core; nlohmann comes straight from vendor/, which core reaches the same way.
|
||||
set(RAD_TESTS_WITH_PACK ref2va_pack_test)
|
||||
|
||||
# vae_geom_test checks the encode geometry (arch/minimaxh3/rad_vae_geom.cpp) the same way: golden
|
||||
# vectors generated by running the reference VAEs' own encoders on CPU
|
||||
# (tests/data/vae_geom/gen_golden.py). Also device-free, also links no core.
|
||||
set(RAD_TESTS_WITH_VAE_GEOM vae_geom_test)
|
||||
|
||||
# Chat templates (copied from the model repositories) and media samples, passed by absolute path so
|
||||
# test binaries can run from anywhere.
|
||||
set(RAD_CHAT_FIXTURES ${CMAKE_CURRENT_SOURCE_DIR}/data/chat)
|
||||
@@ -121,6 +132,7 @@ set(RAD_TEST_ENV ${RAD_TEST_CARD_ENV} ${RAD_TEST_HIDE_ENV})
|
||||
set(RAD_TEST_CPU_BUDGET_quant_ggml_test 25) # llama.cpp's iq1_s and iq2_* grid searches, ~13 s
|
||||
set(RAD_TEST_CPU_BUDGET_tokenizer_test 20) # the reference encoder over every corpus: ~3 s built by GCC 16, ~10.5 s by GCC 14 (the image's Ubuntu)
|
||||
set(RAD_TEST_CPU_BUDGET_arch_test 15) # every plugin's graph declared; ~10.8 s with the batched-tower case
|
||||
set(RAD_TEST_CPU_BUDGET_glm5next_test 20) # GLM-5.3-Flash's graphs and op schemas: ~4.8 s built by GCC 16, ~10.1 s by GCC 14 (the image's Ubuntu)
|
||||
|
||||
# Binaries whose OpenMP team is busy for most of their run, so a parallel ctest counts them as a
|
||||
# team's worth of slots rather than one.
|
||||
@@ -158,6 +170,28 @@ foreach(t ${RAD_TESTS})
|
||||
get_filename_component(n ${t} NAME_WE)
|
||||
if(n IN_LIST RAD_TESTS_NO_CORE)
|
||||
add_executable(${n} ${t} ${CMAKE_SOURCE_DIR}/core/util/rad_util.cpp)
|
||||
if(n STREQUAL "nemotron35_test")
|
||||
target_sources(${n} PRIVATE ${CMAKE_SOURCE_DIR}/core/mm/processor.cpp
|
||||
${CMAKE_SOURCE_DIR}/core/mm/item.cpp
|
||||
${CMAKE_SOURCE_DIR}/core/mm/media.cpp
|
||||
${CMAKE_SOURCE_DIR}/core/server/nemotron35.cpp
|
||||
${CMAKE_SOURCE_DIR}/core/server/oai.cpp)
|
||||
# Exercise the actual request parser without pulling the unrelated core runtime into the
|
||||
# recording-builder test. Unused completion/response helpers are discarded at link time.
|
||||
target_compile_options(${n} PRIVATE -ffunction-sections -fdata-sections)
|
||||
target_link_options(${n} PRIVATE -Wl,--gc-sections)
|
||||
file(GLOB NEMOTRON_TEST_TOKENIZER CONFIGURE_DEPENDS
|
||||
${CMAKE_SOURCE_DIR}/core/text/tokenizer*.cpp ${CMAKE_SOURCE_DIR}/core/text/unicode_norm*.cpp)
|
||||
target_sources(${n} PRIVATE ${NEMOTRON_TEST_TOKENIZER})
|
||||
target_link_libraries(${n} PRIVATE rad_vendor_llama)
|
||||
target_link_libraries(${n} PRIVATE ${CMAKE_DL_LIBS})
|
||||
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/vendor)
|
||||
add_dependencies(${n} libref)
|
||||
if(TARGET libavx)
|
||||
add_dependencies(${n} libavx)
|
||||
target_compile_definitions(${n} PRIVATE RAD_NEMOTRON_TEST_AVX=1)
|
||||
endif()
|
||||
endif()
|
||||
elseif(n IN_LIST RAD_TESTS_HARNESS)
|
||||
add_executable(${n} ${t})
|
||||
add_dependencies(${n} harness_fixture)
|
||||
@@ -181,6 +215,24 @@ foreach(t ${RAD_TESTS})
|
||||
target_link_libraries(${n} PRIVATE ${RAD_TEST_CORE} ${CMAKE_DL_LIBS})
|
||||
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/libr4d)
|
||||
target_compile_options(${n} PRIVATE -ffp-contract=off)
|
||||
# relayout_parity_test also holds tools/opshapes.cpp's fallback table to these hooks' byte
|
||||
# totals, so it needs the table's source too.
|
||||
if(n STREQUAL relayout_parity_test)
|
||||
target_sources(${n} PRIVATE ${CMAKE_SOURCE_DIR}/tools/opshapes.cpp)
|
||||
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/tools)
|
||||
endif()
|
||||
elseif(n IN_LIST RAD_TESTS_WITH_PACK)
|
||||
add_executable(${n} ${t} ${CMAKE_SOURCE_DIR}/arch/minimaxh3/rad_ref2va_pack.cpp)
|
||||
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/arch/minimaxh3
|
||||
${CMAKE_SOURCE_DIR}/vendor)
|
||||
target_compile_definitions(${n} PRIVATE
|
||||
RAD_REF2VA_GOLDEN="${CMAKE_CURRENT_SOURCE_DIR}/data/ref2va")
|
||||
elseif(n IN_LIST RAD_TESTS_WITH_VAE_GEOM)
|
||||
add_executable(${n} ${t} ${CMAKE_SOURCE_DIR}/arch/minimaxh3/rad_vae_geom.cpp)
|
||||
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/arch/minimaxh3
|
||||
${CMAKE_SOURCE_DIR}/vendor)
|
||||
target_compile_definitions(${n} PRIVATE
|
||||
RAD_VAE_GOLDEN="${CMAKE_CURRENT_SOURCE_DIR}/data/vae_geom")
|
||||
elseif(n IN_LIST RAD_TESTS_WHOLE_CORE)
|
||||
add_executable(${n} ${t})
|
||||
target_link_libraries(${n} PRIVATE stdc++ "$<LINK_LIBRARY:WHOLE_ARCHIVE,rad_core>")
|
||||
@@ -236,10 +288,11 @@ set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
|
||||
# ================================================================== the device tests on a card
|
||||
#
|
||||
# The unit entries run on the host backend. These run the tests whose code differs on a card (the
|
||||
# AQL backend, the driver's elastic commit, the mover's copies) on the card, one at a time: a test
|
||||
# that commits device memory fails beside another holding it, or beside a server.
|
||||
# AQL backend, the driver's elastic commit, the mover's copies, libquant's trellis GPTQ) on the
|
||||
# card, one at a time: a test that commits device memory fails beside another holding it, or beside
|
||||
# a server.
|
||||
if(RAD_HIP_FOUND)
|
||||
foreach(n device_test mem_test place_test runtime_test)
|
||||
foreach(n device_test mem_test place_test runtime_test quant_tcq_gpu_test)
|
||||
add_test(NAME ${n}_card COMMAND ${n} -perf_)
|
||||
set_tests_properties(${n}_card PROPERTIES
|
||||
LABELS gpu
|
||||
@@ -264,23 +317,51 @@ if(RAD_SYCL_FOUND)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# spechub_wiring_test dlopens the built spechub plugin and checks how its rows are classified: the
|
||||
# device rows must be production kernels and the host oracle rows must stay reference. It needs the
|
||||
# library path and the same RAD_SPECHUB_WITH_DEVICE answer the plugin was built with.
|
||||
if(TARGET spechub)
|
||||
target_link_libraries(spechub_wiring_test PRIVATE ${CMAKE_DL_LIBS})
|
||||
target_compile_definitions(spechub_wiring_test PRIVATE
|
||||
RAD_SPECHUB_LIB="${RAD_PLUGIN_OUT}/kernels/spechub.so")
|
||||
if(RAD_HIP_FOUND)
|
||||
target_compile_definitions(spechub_wiring_test PRIVATE RAD_SPECHUB_WITH_DEVICE=1)
|
||||
endif()
|
||||
add_dependencies(spechub_wiring_test spechub)
|
||||
# sample_test's coupling case declares a Sampler with draft_coupling set and needs the verify
|
||||
# op the spechub plugin carries (its host row); it skips when the library is absent.
|
||||
add_dependencies(sample_test spechub)
|
||||
endif()
|
||||
|
||||
# ================================================================== whole models on the CPU
|
||||
#
|
||||
# engine_e2e_test runs the radiance binary on tiny synthetic checkpoints (tests/tiny_model.h) on
|
||||
# the host backend; convert_test runs rad-convert on the same checkpoints. Both start the built
|
||||
# binaries as children, so they depend on them and on every plugin the checkpoints select
|
||||
# (llama_fp8 for convert_test's --set of an fp8 quantization_config).
|
||||
set(RAD_E2E_DEPS radiance rad-convert libref libquant qwen35_bf16 lfm2_bf16 gemma4 llama_dense_fp8
|
||||
llama_fp8 qwenimage21)
|
||||
set(RAD_E2E_DEPS radiance rad-convert libref libquant nemotron35_embed qwen35_bf16 lfm2_bf16 gemma4 gemma4_bf16
|
||||
llama_dense_fp8 llama_fp8 qwenimage21)
|
||||
if(TARGET libavx)
|
||||
list(APPEND RAD_E2E_DEPS libavx)
|
||||
endif()
|
||||
foreach(t engine_e2e_test convert_test)
|
||||
foreach(t engine_e2e_test convert_test clef_decision_test laya_decision_test)
|
||||
if(TARGET ${t})
|
||||
target_compile_definitions(${t} PRIVATE
|
||||
RAD_E2E_SERVER="$<TARGET_FILE:radiance>" RAD_E2E_CONVERT="$<TARGET_FILE:rad-convert>"
|
||||
RAD_E2E_HOME="${RAD_PLUGIN_OUT}")
|
||||
add_dependencies(${t} ${RAD_E2E_DEPS})
|
||||
RAD_E2E_HOME="${RAD_PLUGIN_OUT}" RAD_E2E_RECIPES="${CMAKE_SOURCE_DIR}/data/recipes")
|
||||
if(t STREQUAL "clef_decision_test")
|
||||
# The tiny clef's golden (tests/mkclefgolden.py) and the one plugin a clef container selects.
|
||||
target_compile_definitions(${t} PRIVATE
|
||||
RAD_CLEF_GOLDEN="${CMAKE_CURRENT_SOURCE_DIR}/data/golden/clef_tiny.json")
|
||||
add_dependencies(${t} radiance rad-convert libref libquant clef_bf16)
|
||||
elseif(t STREQUAL "laya_decision_test")
|
||||
# The tiny Laya's golden (tests/mklayagolden.py) and the plugin a Laya container selects.
|
||||
target_compile_definitions(${t} PRIVATE
|
||||
RAD_LAYA_GOLDEN="${CMAKE_CURRENT_SOURCE_DIR}/data/golden/laya_tiny.json")
|
||||
add_dependencies(${t} radiance rad-convert libref libquant laya)
|
||||
else()
|
||||
add_dependencies(${t} ${RAD_E2E_DEPS})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
# 6 to 17 s by build type and load, mostly libref's GEMMs and decode steps and the engine's own
|
||||
@@ -288,6 +369,12 @@ endforeach()
|
||||
if(TARGET engine_e2e_test)
|
||||
set_tests_properties(engine_e2e_test PROPERTIES LABELS "e2e" TIMEOUT 300)
|
||||
endif()
|
||||
if(TARGET clef_decision_test)
|
||||
set_tests_properties(clef_decision_test PROPERTIES LABELS "e2e" TIMEOUT 300)
|
||||
endif()
|
||||
if(TARGET laya_decision_test)
|
||||
set_tests_properties(laya_decision_test PROPERTIES LABELS "e2e" TIMEOUT 300)
|
||||
endif()
|
||||
|
||||
# abi_layout_test compares the ABI's struct layouts with a C translation unit's: abi_c_test.c
|
||||
# includes every abi/ header as strict C11, so a header only C++ accepts fails the build.
|
||||
@@ -328,17 +415,28 @@ endif()
|
||||
#
|
||||
# r4d_selftest is the only check of libr4d's fusion claims: rows declaring a fused kernel
|
||||
# byte-identical to the ops it replaces, verified by memcmp against the unfused kernels on the same
|
||||
# inputs. It needs a card and forks a child per row (about six minutes), so it is labelled `slow`;
|
||||
# the default `ctest` still runs it.
|
||||
# inputs. It needs a card and forks a child per row (about fifteen minutes on an R9700), so it is
|
||||
# labelled `slow`; the default `ctest` still runs it.
|
||||
if(RAD_HIP_FOUND AND TARGET r4d_selftest)
|
||||
add_test(NAME r4d_selftest
|
||||
COMMAND r4d_selftest ${RAD_PLUGIN_OUT}/kernels/libr4d.so)
|
||||
set_tests_properties(r4d_selftest PROPERTIES
|
||||
LABELS "slow;gpu"
|
||||
TIMEOUT 900
|
||||
TIMEOUT 2400
|
||||
ENVIRONMENT "RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home")
|
||||
endif()
|
||||
|
||||
# ================================================================== libhalo's interface parity
|
||||
#
|
||||
# libhalo serves gfx1151 behind libr4d's exact interface (libhalo/halo_parity.cpp): the same op
|
||||
# schemas and rows, so every model plugin runs on either. Host-only (the tables, no device calls);
|
||||
# present when one build produces both plugins.
|
||||
if(TARGET halo_parity)
|
||||
add_test(NAME halo_parity
|
||||
COMMAND halo_parity ${RAD_PLUGIN_OUT}/kernels/libr4d.so ${RAD_PLUGIN_OUT}/kernels/libhalo.so)
|
||||
set_tests_properties(halo_parity PROPERTIES LABELS "fast" TIMEOUT 60)
|
||||
endif()
|
||||
|
||||
# ================================================================== the device layer without SVM
|
||||
#
|
||||
# Without the KFD SVM API (e.g. a KVM guest whose amdgpu registered no device memory with HMM), ROCr
|
||||
@@ -400,10 +498,16 @@ if(TARGET rad-avx-check AND TARGET libref)
|
||||
set_tests_properties(avx_check_general PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT} ENVIRONMENT "${env}")
|
||||
endif()
|
||||
|
||||
# The ISA instruments' parsers, on fixtures in the script: no build tree, no card, no ROCm. The
|
||||
# wave counts at the 24-VGPR boundaries and the waterfall back-edge detection are the parts that
|
||||
# can be wrong without anything else noticing.
|
||||
add_test(NAME isa_tools COMMAND sh ${CMAKE_SOURCE_DIR}/libr4d/isa/selftest.sh)
|
||||
set_tests_properties(isa_tools PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
|
||||
# ================================================================== libr4d's kernels, on the host
|
||||
#
|
||||
# Some libr4d ops (the sandwich-norm joins, expert_scale) have no libref oracle by design
|
||||
# (docs/OPS.md), so rad-kbench never checks them. r4d_emu runs the source of fourteen units
|
||||
# (docs/OPS.md), so rad-kbench never checks them. r4d_emu runs the source of sixteen units
|
||||
# written against r4d_launch.h on the host: the windowed paged attention, pair_argmax, the joins,
|
||||
# expert_scale, the QSA block selection, the runtime-LoRA pair, the F32 routing projection's tile
|
||||
# forms, GLM's mHC read with its chunk split, the F32-scale E4M3 GEMM's forms, GLM's KDA
|
||||
@@ -414,7 +518,8 @@ endif()
|
||||
# deadlock). Checked against ports of libref's ref_attn_paged and ref_qsa_select, the host
|
||||
# arithmetic in ref_host.cpp, for the joins the unfused chain bit for bit, for the LoRA pair libref
|
||||
# itself when the test can load it, for KDA libref itself, and for the DSA split the unsplit
|
||||
# kernels.
|
||||
# kernels. The other two, the M2XFP4 decode and tiled GEMMs, are checked against an f64 decode of
|
||||
# the weight.
|
||||
#
|
||||
# Requires clang (ext_vector_type) and x86-64 (SysV fiber switch in inline assembly). With a clang
|
||||
# C++ compiler the .hip files build here as C++ (`-x c++`; the property is per directory, so
|
||||
@@ -429,17 +534,19 @@ set(R4D_EMU_HIP ${R4D_DIR}/r4d_attn_paged_window.hip ${R4D_DIR}/r4d_pair_argmax_
|
||||
${R4D_DIR}/r4d_qsa_select_bf16.hip ${R4D_DIR}/r4d_lora_bf16.hip ${R4D_DIR}/r4d_glm.hip
|
||||
${R4D_DIR}/r4d_mhc.hip ${R4D_DIR}/r4d_fp8_f32scale.hip ${R4D_DIR}/r4d_kda.hip
|
||||
${R4D_DIR}/r4d_moe_mxfp4.hip ${R4D_DIR}/r4d_mla.hip ${R4D_DIR}/r4d_quant_act_fp8.hip
|
||||
${R4D_DIR}/r4d_dsa.hip
|
||||
# The M2XFP4 GEMMs: their cfg readers are inline in r4d_args.h, so the units link
|
||||
# without the declaration side and the test runs what an untuned install runs.
|
||||
${R4D_DIR}/r4d_kv_resolve.hip ${R4D_DIR}/r4d_dsa.hip
|
||||
${R4D_DIR}/r4d_gemm_m2xfp4a8_decode.hip ${R4D_DIR}/r4d_gemm_m2xfp4a8_tiled.hip)
|
||||
set(R4D_EMU_TESTS attn pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse dsa m2xfp4)
|
||||
# The M2XFP4 units' plugin entries call two cfg readers that r4d_rows.cpp defines, which is not in
|
||||
# this build: cfg_stub.cpp defines them at their axis defaults, in both arms below.
|
||||
set(R4D_EMU_TESTS attn pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres
|
||||
dsa m2xfp4)
|
||||
set(R4D_EMU_BUILT OFF)
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
|
||||
# No fiber switch for this ISA.
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT RAD_ASAN AND NOT RAD_TSAN)
|
||||
set_source_files_properties(${R4D_EMU_HIP} PROPERTIES LANGUAGE CXX COMPILE_OPTIONS "-x;c++")
|
||||
add_library(r4d_emu_kernels OBJECT ${R4D_EMU_HIP} ${R4D_EMU}/ref_host.cpp ${R4D_EMU}/emu/emu.cpp)
|
||||
add_library(r4d_emu_kernels OBJECT ${R4D_EMU_HIP} ${R4D_EMU}/ref_host.cpp ${R4D_EMU}/cfg_stub.cpp
|
||||
${R4D_EMU}/emu/emu.cpp)
|
||||
target_include_directories(r4d_emu_kernels PUBLIC ${R4D_EMU}/emu ${R4D_EMU} ${R4D_DIR})
|
||||
target_link_libraries(r4d_emu_kernels PUBLIC rad_abi)
|
||||
# As in libr4d: the joins must match the unfused chain bit for bit, so no FMA contraction.
|
||||
@@ -472,7 +579,8 @@ else()
|
||||
${R4D_EMU}/test_escale.cpp ${R4D_EMU}/test_qsa.cpp ${R4D_EMU}/test_lora.cpp
|
||||
${R4D_EMU}/test_f32.cpp ${R4D_EMU}/test_mhc.cpp ${R4D_EMU}/test_fp8f32.cpp
|
||||
${R4D_EMU}/test_kda.cpp ${R4D_EMU}/test_moemx.cpp ${R4D_EMU}/test_mla.cpp
|
||||
${R4D_EMU}/test_moefuse.cpp ${R4D_EMU}/test_dsa.cpp ${R4D_EMU}/test_m2xfp4.cpp)
|
||||
${R4D_EMU}/test_moefuse.cpp ${R4D_EMU}/test_kvres.cpp
|
||||
${R4D_EMU}/test_dsa.cpp ${R4D_EMU}/test_m2xfp4.cpp ${R4D_EMU}/cfg_stub.cpp)
|
||||
get_filename_component(stem ${src} NAME_WE)
|
||||
set(lang "")
|
||||
if(src MATCHES "\\.hip$")
|
||||
@@ -509,7 +617,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
if(R4D_EMU_BUILT)
|
||||
foreach(t pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse dsa m2xfp4)
|
||||
foreach(t pick norm escale qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres dsa m2xfp4)
|
||||
add_test(NAME r4d_emu_${t} COMMAND ${CMAKE_BINARY_DIR}/tests/r4d_emu_${t})
|
||||
endforeach()
|
||||
# The attention cases take about 11 s, 7 of them in the two long prefills on the WMMA kernel,
|
||||
@@ -520,8 +628,7 @@ if(R4D_EMU_BUILT)
|
||||
endforeach()
|
||||
set_tests_properties(r4d_emu_attn_shard0 r4d_emu_attn_shard1 r4d_emu_attn_shard2 r4d_emu_pick
|
||||
r4d_emu_norm r4d_emu_escale r4d_emu_qsa r4d_emu_lora r4d_emu_mla r4d_emu_moefuse
|
||||
r4d_emu_dsa
|
||||
r4d_emu_m2xfp4
|
||||
r4d_emu_dsa r4d_emu_m2xfp4
|
||||
PROPERTIES LABELS "r4d_emu" TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
# The LoRA pair has a libref oracle, and the test holds the emulated kernels to it when it can
|
||||
# load one -- expand bit for bit, shrink to its bound. kda_update is held to libref's within
|
||||
@@ -537,6 +644,131 @@ if(R4D_EMU_BUILT)
|
||||
set_tests_properties(r4d_emu_qsa_sweep PROPERTIES LABELS "r4d_emu;slow" TIMEOUT 900)
|
||||
endif()
|
||||
|
||||
# ================================================================== libhalo on the emulator
|
||||
#
|
||||
# tests/halo_emu runs libhalo units (gfx1151) on the same SIMT emulator through its gfx11 WMMA
|
||||
# forms: the LDS-tiled prefill GEMMs against the narrow rows whose bytes they promise, and the
|
||||
# MXFP4 decode's activation plane against its in-kernel decode (test_gemm.cpp says which). The
|
||||
# units are the plugin's own sources, compiled as C++ the way r4d_emu compiles libr4d's, so a
|
||||
# card-less build checks them on every run. Same toolchain rules as r4d_emu above.
|
||||
set(HALO_DIR ${CMAKE_SOURCE_DIR}/libhalo)
|
||||
set(HALO_EMU ${CMAKE_CURRENT_SOURCE_DIR}/halo_emu)
|
||||
set(HALO_EMU_HIP ${HALO_DIR}/halo_gemm_fp8a8.hip ${HALO_DIR}/halo_gemm_mxfp4a8_tiled.hip
|
||||
${HALO_DIR}/halo_gemm_mxfp4a8_nt_m64.hip ${HALO_DIR}/halo_gemm_mxfp4a8_decode.hip
|
||||
${HALO_DIR}/halo_norm_join_bf16.hip ${HALO_DIR}/halo_expert_scale_bf16.hip
|
||||
${HALO_DIR}/halo_pair_argmax_f32.hip ${HALO_DIR}/halo_attn_paged_window.hip
|
||||
${HALO_DIR}/halo_qsa_select_bf16.hip ${HALO_DIR}/halo_lora_bf16.hip
|
||||
${HALO_DIR}/halo_glm.hip ${HALO_DIR}/halo_mhc.hip
|
||||
${HALO_DIR}/halo_gemm_fp8_f32scale.hip ${HALO_DIR}/halo_kda.hip
|
||||
${HALO_DIR}/halo_moe_mxfp4.hip ${HALO_DIR}/halo_mla.hip
|
||||
${HALO_DIR}/halo_quant_act_fp8.hip ${HALO_DIR}/halo_kv_resolve.hip
|
||||
${HALO_DIR}/halo_dsa.hip ${HALO_DIR}/halo_gemm_nt_f32.hip
|
||||
${HALO_DIR}/halo_router_sigmoid_topk_f32.hip ${HALO_DIR}/halo_router_scatter.hip
|
||||
${HALO_DIR}/halo_gen.hip ${HALO_DIR}/halo_audio.hip ${HALO_DIR}/halo_encoder_bf16.hip
|
||||
${HALO_DIR}/halo_model_bf16.hip ${HALO_DIR}/halo_hc_bf16.hip
|
||||
${HALO_DIR}/halo_p2p_copy2d.hip
|
||||
${HALO_DIR}/halo_attn_paged_gqa8.hip ${HALO_DIR}/halo_attn_paged_h128_gqa1.hip
|
||||
${HALO_DIR}/halo_attn_paged_h128_gqa2.hip ${HALO_DIR}/halo_attn_paged_h128_gqa2w.hip
|
||||
${HALO_DIR}/halo_attn_paged_h128_gqa4.hip ${HALO_DIR}/halo_attn_paged_h256_gqa2.hip
|
||||
${HALO_DIR}/halo_attn_paged_h256_gqa4.hip ${HALO_DIR}/halo_attn_paged_h256_gqa6.hip
|
||||
${HALO_DIR}/halo_gemm_bf16_nt_tiled.hip ${HALO_DIR}/halo_gemm_bf16_nt_m64.hip)
|
||||
# gemm: test_gemm.cpp above. norm, escale, pick: r4d_emu's tests of the same three ops, renamed --
|
||||
# the sandwich-norm joins, expert_scale and pair_argmax have no libref oracle by design (Gemma 4's
|
||||
# trunk runs the joins every layer), so the unfused chain bit for bit is the only check they get.
|
||||
# attn: r4d_emu's windowed paged attention test against its port of libref's ref_attn_paged --
|
||||
# the h128/h256/h512 window rows Gemma 4 runs, prefill and decode, plus a seeded shape sweep.
|
||||
# The rest are r4d_emu's other tests by the rename transform, over the libhalo ports of the same
|
||||
# units: QSA selection, the LoRA pair, GLM's F32 routing projection and MoE decode fusions, mHC,
|
||||
# the F32-scale E4M3 GEMM, KDA, the MXFP4 expert GEMM, MLA, kv_resolve and DSA's split.
|
||||
# ref: the elementwise and data-movement rows no model fixture reaches and halo_selftest has no
|
||||
# case for, each held to libref's row on operands drawn from libref's own descriptions.
|
||||
# paged: every block-size-16 attn_paged decode and prefill row (the decode and prefill bodies through
|
||||
# the units that own each geometry) against test_attn's reference.
|
||||
set(HALO_EMU_TESTS gemm norm escale pick attn qsa lora f32 mhc fp8f32 kda moemx mla moefuse kvres
|
||||
dsa ref paged)
|
||||
set(HALO_EMU_BUILT OFF)
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
|
||||
# No fiber switch for this ISA.
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT RAD_ASAN AND NOT RAD_TSAN)
|
||||
set_source_files_properties(${HALO_EMU_HIP} PROPERTIES LANGUAGE CXX COMPILE_OPTIONS "-x;c++")
|
||||
add_library(halo_emu_kernels OBJECT ${HALO_EMU_HIP} ${HALO_EMU}/cfg_host.cpp ${R4D_EMU}/ref_host.cpp
|
||||
${R4D_EMU}/emu/emu.cpp)
|
||||
target_include_directories(halo_emu_kernels PUBLIC ${R4D_EMU}/emu ${R4D_EMU} ${HALO_DIR})
|
||||
target_link_libraries(halo_emu_kernels PUBLIC rad_abi)
|
||||
target_compile_options(halo_emu_kernels PRIVATE -ffp-contract=off -Wno-psabi)
|
||||
foreach(t ${HALO_EMU_TESTS})
|
||||
add_executable(halo_emu_${t} ${HALO_EMU}/test_${t}.cpp)
|
||||
target_link_libraries(halo_emu_${t} PRIVATE halo_emu_kernels ${CMAKE_DL_LIBS})
|
||||
target_compile_options(halo_emu_${t} PRIVATE -ffp-contract=off -Wno-psabi)
|
||||
set_target_properties(halo_emu_${t} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
|
||||
endforeach()
|
||||
set(HALO_EMU_BUILT ON)
|
||||
elseif(R4D_EMU_CXX)
|
||||
set(dir ${CMAKE_CURRENT_BINARY_DIR}/halo_emu)
|
||||
file(MAKE_DIRECTORY ${dir})
|
||||
set(flags -std=c++20 -O2 -ffp-contract=off -Wno-psabi -I${R4D_EMU}/emu -I${R4D_EMU} -I${HALO_DIR}
|
||||
-I${CMAKE_SOURCE_DIR}/abi)
|
||||
set(objs "")
|
||||
set(srcs ${HALO_EMU_HIP} ${HALO_EMU}/cfg_host.cpp ${R4D_EMU}/ref_host.cpp ${R4D_EMU}/emu/emu.cpp)
|
||||
foreach(t ${HALO_EMU_TESTS})
|
||||
list(APPEND srcs ${HALO_EMU}/test_${t}.cpp)
|
||||
endforeach()
|
||||
foreach(src ${srcs})
|
||||
get_filename_component(stem ${src} NAME_WE)
|
||||
set(lang "")
|
||||
if(src MATCHES "\\.hip$")
|
||||
set(lang -x c++)
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${dir}/${stem}.o
|
||||
COMMAND ${R4D_EMU_CXX} ${flags} -MD -MF ${dir}/${stem}.o.d ${lang} -c ${src}
|
||||
-o ${dir}/${stem}.o
|
||||
DEPENDS ${src}
|
||||
DEPFILE ${dir}/${stem}.o.d
|
||||
COMMENT "Building halo_emu ${stem}.o with ${R4D_EMU_CXX}"
|
||||
VERBATIM)
|
||||
if(NOT stem MATCHES "^test_")
|
||||
list(APPEND objs ${dir}/${stem}.o)
|
||||
endif()
|
||||
endforeach()
|
||||
# test_lora, test_kda and test_ref open libref with dlopen.
|
||||
set(dl "")
|
||||
foreach(l ${CMAKE_DL_LIBS})
|
||||
list(APPEND dl -l${l})
|
||||
endforeach()
|
||||
set(exes "")
|
||||
foreach(t ${HALO_EMU_TESTS})
|
||||
set(exe ${CMAKE_BINARY_DIR}/tests/halo_emu_${t})
|
||||
add_custom_command(OUTPUT ${exe}
|
||||
COMMAND ${R4D_EMU_CXX} ${dir}/test_${t}.o ${objs} ${dl} -o ${exe}
|
||||
DEPENDS ${dir}/test_${t}.o ${objs}
|
||||
COMMENT "Linking halo_emu_${t}"
|
||||
VERBATIM)
|
||||
list(APPEND exes ${exe})
|
||||
endforeach()
|
||||
add_custom_target(halo_emu ALL DEPENDS ${exes})
|
||||
set(HALO_EMU_BUILT ON)
|
||||
endif()
|
||||
if(HALO_EMU_BUILT)
|
||||
foreach(t gemm norm escale pick qsa lora f32 mhc fp8f32 kda mla moefuse kvres dsa ref paged)
|
||||
add_test(NAME halo_emu_${t} COMMAND ${CMAKE_BINARY_DIR}/tests/halo_emu_${t})
|
||||
set_tests_properties(halo_emu_${t} PROPERTIES LABELS "halo_emu;fast" TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
endforeach()
|
||||
# As r4d_emu: the LoRA pair and KDA are held to libref itself when the test can load it.
|
||||
set_tests_properties(halo_emu_lora halo_emu_kda halo_emu_ref PROPERTIES
|
||||
ENVIRONMENT "RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home")
|
||||
# As r4d_emu_attn: three shards of the fixed cases, and the seeded sweep as `slow`.
|
||||
foreach(k 0 1 2)
|
||||
add_test(NAME halo_emu_attn_shard${k} COMMAND ${CMAKE_BINARY_DIR}/tests/halo_emu_attn --shard ${k}/3)
|
||||
set_tests_properties(halo_emu_attn_shard${k} PROPERTIES LABELS "halo_emu;fast"
|
||||
TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
endforeach()
|
||||
# libhalo's one MXFP4 expert kernel takes about 160 s here (libr4d's shape-specialised forms 30 s).
|
||||
add_test(NAME halo_emu_moemx COMMAND ${CMAKE_BINARY_DIR}/tests/halo_emu_moemx)
|
||||
set_tests_properties(halo_emu_moemx PROPERTIES LABELS "halo_emu;slow" TIMEOUT 900)
|
||||
add_test(NAME halo_emu_attn_sweep COMMAND ${CMAKE_BINARY_DIR}/tests/halo_emu_attn sweep 40)
|
||||
set_tests_properties(halo_emu_attn_sweep PROPERTIES LABELS "halo_emu;slow" TIMEOUT 900)
|
||||
endif()
|
||||
|
||||
# ================================================================== the document as a test
|
||||
#
|
||||
# docs/OPS.md is the authoritative op table, so this test checks it against what the plugins dump
|
||||
@@ -544,6 +776,9 @@ endif()
|
||||
# parameters). Cheap, so in the fast tier. libr4d.so is added when built; the script reports
|
||||
# " SKIP " rather than passing when a plugin will not dump.
|
||||
set(RAD_OPSDOC_PLUGINS ${RAD_PLUGIN_OUT}/kernels/libref.so)
|
||||
if(TARGET spechub)
|
||||
list(APPEND RAD_OPSDOC_PLUGINS ${RAD_PLUGIN_OUT}/kernels/spechub.so)
|
||||
endif()
|
||||
if(RAD_HIP_FOUND AND TARGET libr4d)
|
||||
list(APPEND RAD_OPSDOC_PLUGINS ${RAD_PLUGIN_OUT}/kernels/libr4d.so)
|
||||
endif()
|
||||
@@ -556,6 +791,19 @@ set_tests_properties(ops_doc PROPERTIES
|
||||
TIMEOUT ${RAD_TEST_TIMEOUT}
|
||||
ENVIRONMENT "${RAD_TEST_HIDE_ENV}")
|
||||
|
||||
# docs/KERNELS.md is generated by rad-kbench and merged by hand; a partial merge can leave a
|
||||
# library's "rows not reached" header from one run above a table from another. The counts must
|
||||
# agree with each other and with the headline; cheap.
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/docs/KERNELS.md)
|
||||
add_test(NAME kernel_report_check
|
||||
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/kernel_report_check.sh
|
||||
${CMAKE_SOURCE_DIR}/docs/KERNELS.md)
|
||||
set_tests_properties(kernel_report_check PROPERTIES
|
||||
LABELS "fast;unit"
|
||||
SKIP_RETURN_CODE 77
|
||||
TIMEOUT ${RAD_TEST_TIMEOUT})
|
||||
endif()
|
||||
|
||||
# tools/rad-export. Its standard-library checks always run; the merge arithmetic runs where torch
|
||||
# and safetensors import, and the PEFT comparison where peft and transformers do too.
|
||||
find_program(RAD_PYTHON3 NAMES python3)
|
||||
@@ -571,15 +819,18 @@ endif()
|
||||
# vocabulary and registration, and serve rad-kbench's fixture through the installed tools
|
||||
# (tests/oot_plugins.sh). libr4d is included when the tree built it, with the same HIP compiler,
|
||||
# targets and RAD_HIP_VOPD_REPEATABLE. Labelled `oot`: it rebuilds every plugin and takes minutes.
|
||||
set(RAD_OOT_HIP "")
|
||||
set(RAD_OOT_COMPILER "")
|
||||
set(RAD_OOT_TARGETS "")
|
||||
if(RAD_HIP_FOUND AND TARGET libr4d)
|
||||
get_target_property(RAD_OOT_R4D_ARCH libr4d HIP_ARCHITECTURES)
|
||||
string(REPLACE ";" "\\;" RAD_OOT_R4D_ARCH "${RAD_OOT_R4D_ARCH}")
|
||||
set(RAD_OOT_HIP ${CMAKE_HIP_COMPILER} "${RAD_OOT_R4D_ARCH}" ${RAD_HIP_VOPD_REPEATABLE})
|
||||
set(RAD_OOT_COMPILER "${CMAKE_HIP_COMPILER}")
|
||||
set(RAD_OOT_TARGETS "${RAD_OOT_R4D_ARCH}")
|
||||
endif()
|
||||
add_test(NAME oot_plugins
|
||||
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/oot_plugins.sh
|
||||
${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/oot ${RAD_OOT_HIP})
|
||||
${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/oot "${RAD_OOT_COMPILER}" "${RAD_OOT_TARGETS}"
|
||||
"${RAD_HIP_VOPD_REPEATABLE}" "${CMAKE_CXX_COMPILER}")
|
||||
# RESOURCE_LOCK kbench_memory: its replay holds operands in host memory as the kbench entries do.
|
||||
# A SYCL build passes its icpx so libxe2 is rebuilt out of tree too.
|
||||
set(RAD_OOT_ENV "CMAKE_GENERATOR=${CMAKE_GENERATOR}" ${RAD_TEST_OMP_ENV})
|
||||
@@ -713,3 +964,35 @@ foreach(cost IN ITEMS kbench_ref:500 r4d_selftest:350 r4d_emu_attn_sweep:80 kben
|
||||
set_tests_properties(${t} PROPERTIES COST ${c})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Model-local device kernels are checked on the actual engine queue against libref.
|
||||
if(TARGET nemotron35_device_test)
|
||||
set_target_properties(nemotron35_device_test PROPERTIES ENABLE_EXPORTS ON)
|
||||
add_dependencies(nemotron35_device_test libref)
|
||||
if(TARGET libr4d)
|
||||
add_dependencies(nemotron35_device_test libr4d)
|
||||
add_test(NAME nemotron35_device_test_card COMMAND nemotron35_device_test)
|
||||
set_tests_properties(nemotron35_device_test_card PROPERTIES LABELS "gpu" RUN_SERIAL TRUE
|
||||
ENVIRONMENT "RADIANCE_HOME=${RAD_PLUGIN_OUT};RAD_TEST_CPU_BUDGET=0" TIMEOUT 180)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Large BF16 GEMMs require real device memory; ordinary host entries skip them.
|
||||
if(TARGET r4d_bf16_capacity_test)
|
||||
set_target_properties(r4d_bf16_capacity_test PROPERTIES ENABLE_EXPORTS ON)
|
||||
if(TARGET libr4d)
|
||||
add_dependencies(r4d_bf16_capacity_test libr4d)
|
||||
add_test(NAME r4d_bf16_capacity_test_card COMMAND r4d_bf16_capacity_test)
|
||||
set_tests_properties(r4d_bf16_capacity_test_card PROPERTIES LABELS "gpu" RUN_SERIAL TRUE
|
||||
ENVIRONMENT "RADIANCE_HOME=${RAD_PLUGIN_OUT};RAD_TEST_CPU_BUDGET=0" TIMEOUT 300)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The vendor record, verified: every file under vendor/ -- the lifts, the patch series, the record
|
||||
# itself -- hashed against vendor/SHA256SUMS. A changed file the record does not carry, or one that
|
||||
# arrived unrecorded, is an unrecorded change to a lifted dependency, which is the thing UPSTREAM
|
||||
# exists to prevent and nothing else notices. It reads the source tree only: no build inputs, no
|
||||
# machine state, so it runs wherever the suite runs.
|
||||
add_test(NAME vendor_sums
|
||||
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/vendor_sums.sh ${CMAKE_SOURCE_DIR})
|
||||
set_tests_properties(vendor_sums PROPERTIES LABELS "fast;unit" TIMEOUT 120)
|
||||
Reference in new issue
Block a user