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/tests/CMakeLists.txt
T
Deadcode b93b531f63 radiance 1.5.0
- Gemma 4 31B (PRs #74, #75, #81, #86; sfjes, keptn42): sliding and global attention with their
  own kernels, the assistant head as a drafter that reads the trunk's cache, the vision tower, a
  fused w4a8 decode step, bf16 and compressed-tensors int4 checkpoints, and window snapshots so a
  prefix hit on a sliding-window model resumes instead of prefilling again.
  deploy/compose/gemma4-31b-w4a8.yaml serves keptn42's container on two cards
- ParoQuant (PRs #65, #66, #67; malic): Qwen3.8-27B checkpoints with learned Givens rotations,
  as int4, int5 and MXFP4, imported without re-quantising, the prefill's rotations on the matrix
  cores. deploy/compose/qwen3.8-27b-paro.yaml serves them on one card. A ParoQuant container made
  with the PR builds is refused: convert it again with --reuse <old container>
- Gemma 4 26B-A4B with z-lab's DFlash drafter (PR #88; Perire): arch/gemma4 serves Google's bf16
  checkpoint with the routed experts in block fp8 or bf16 (data/recipes/gemma4-26b-a4b-df*.recipe),
  and libr4d gains its windowed paged attention, the fused sandwich-norm joins, expert_scale and
  the sharded draft head's pair_argmax. A prefill chunk runs as two slices with its all-reduces
  beside the compute, bit-exact with the whole step. The 31B's global layers take the windowed
  attention too: an 11.5K-token prefill on two R9700s in 3.1 s instead of 4.9
- a startup that logs nothing for two minutes says where it waits (#89): the system call (a KFD
  request by name), the library that made it, and its stack, which addr2line resolves against the
  binary
- the prefix cache is kept in VRAM and host memory only (#70): the disk tier wrote every block and
  snapshot a prompt produced, and its copies never outlived the process. --prefix-cache-host-mib
  is renamed --prefix-cache-mib; --prefix-cache-dir and --prefix-cache-disk-mib are removed, and
  startup refuses all three with what replaced them. The compose files no longer mount /data, and
  .env no longer needs RADIANCE_STATE
- --prefix-cache-ttl S (default 3600, 0 never): a conversation no request has used for that long
  leaves the cache, whichever tier holds it; radiance:prefix_cache_expired_total counts them. A
  full host tier now drops its least recently used conversations
- --vision-tower-placement vram|ram (#84): ram keeps an encoder tower in pinned host memory and
  gives its VRAM to the KV cache, read over the link once an image
- timings carry ttft_ms and total_ms (#85): the server's own time from the request body's arrival
  to the first and the last token, queueing and tokenisation included
- a KV-cache recall that found a moved expert with nowhere to go stopped halfway and leaked the
  slots it had already freed: after it every recall failed, the cache stayed short until a
  restart, and requests failed with HTTP 500. A recall now waits for the slots it is owed and
  always finishes
- a tool result or tool-call arguments that are not JSON are no longer refused as nesting past
  1024 levels for their unmatched brackets (#90): only text that parses as JSON is held to the
  bound, since nothing else is parsed into a tree
- the host-pool refusal names the limit that applies to pinned memory (RAM less 1/64 and
  1.5 GiB), not ttm.pages_limit
- --embedding-placement auto, removed in 1.3.0, is refused with what replaced it
- for out-of-tree kernel libraries: gemm_nt_q gains two operands (pb1, pb2, the part bounds), and
  the loader requires identical op schemas, so a library built against 1.4.0 must be rebuilt. For
  architecture plugins, rad_op_declared(b, op) asks whether an op is in the loaded vocabulary
  without declaring it
2026-10-13 19:35:16 +02:00

348 lines
21 KiB
CMake

# One executable per *_test.cpp, globbed, so adding a test is adding a file.
#
# arch_test is the exception and says why in its own header: "No GPU, no model file, no core." It
# supplies its OWN implementation of the declare-phase C ABI -- a recording fake -- so that a
# plugin cannot pass only against core/build/'s builder, which would be an undeclared dependency.
# Linking rad_core would put a second definition of every rad_decl_* symbol in the link, so it
# gets the two utility translation units it actually needs and nothing else.
#
# The failure mode this avoids is worth naming, because it is not obvious from the error: a static
# archive only yields an object file that resolves an undefined symbol, so the clash appears the
# moment the ABI grows a call the fake has not implemented yet. The linker pulls rad_builder.cpp.o
# to satisfy that one symbol and every other rad_decl_* in it collides. Adding the call to the fake
# is the real fix; not linking the archive is what stops the next one presenting as a wall of
# duplicate-definition errors instead of one honest "undefined reference".
set(RAD_TESTS_NO_CORE arch_test)
# fixture_test is about tools/kfixture.cpp and tools/opshapes.cpp -- the seeded draw, the
# reduction and the on-disk recording that every kernel correctness number in the project is
# relative to. Those two are compiled into each tool rather than made a library (tools/
# CMakeLists.txt says why), so a test of them compiles them too. The alternative is a test that
# shells out to rad-kbench, which can only observe the harness through whatever a kernel run says
# about it -- and the properties worth pinning here are ones a passing run is equally consistent
# with.
set(RAD_TESTS_WITH_TOOLS fixture_test)
# The tokenizer tests compare the encoder against tools/tokref, the reference encoder, which is a
# library of its own for exactly that (tools/CMakeLists.txt).
set(RAD_TESTS_WITH_TOKREF tokenizer_test tokenizer_perf_test)
# The GBNF oracle is upstream's candidate walk, which the mask engine is held to bit for bit. It is
# test code and is compiled into the tests that compare against it -- and into rad-gbnf-check,
# which runs the same comparison on a real vocabulary -- so that no serving binary contains it.
set(RAD_TESTS_WITH_GBNF_ORACLE sample_test gbnf_test)
# THE LEGACY REPLY PARSER, AS AN ORACLE. The engine reads replies with core/text/chatparse.h; a
# whole-reply path built on llama.cpp's PEG parser and a by-hand call lifter is kept in legacy/ so
# that the tests can compare the two on every input. Built as its own archive and linked into the
# tests that compare -- nothing in core/ can reach it. tools/ links it for the acceptance tool's
# side-by-side numbers.
add_library(rad_legacy_toolparse STATIC ${CMAKE_CURRENT_SOURCE_DIR}/legacy/toolparse_legacy.cpp
${CMAKE_CURRENT_SOURCE_DIR}/legacy/chatdiff.cpp)
target_link_libraries(rad_legacy_toolparse PUBLIC rad_core)
target_include_directories(rad_legacy_toolparse PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/legacy)
set(RAD_TESTS_WITH_LEGACY chatparse_test chatparse_gemma4_test)
# relayout_parity_test holds each kernel library's relayout of libquant's planes to the recorded
# hash of the bytes that library stores. libr4d needs a HIP toolchain to build and its layouts do
# not, so the test compiles their host sources in -- -ffp-contract=off, as libr4d compiles every
# unit, so a scale converted on the way through rounds here as it does in the plugin.
set(RAD_TESTS_WITH_R4D_HOST relayout_parity_test)
# The chat templates the reply-format tests render through, copied from the model repositories,
# and the media samples the decoder is held to. Passed by path so a test binary run from anywhere
# finds them.
set(RAD_CHAT_FIXTURES ${CMAKE_CURRENT_SOURCE_DIR}/data/chat)
set(RAD_MEDIA_FIXTURES ${CMAKE_CURRENT_SOURCE_DIR}/data/media)
# libstdc++ AHEAD OF rad_core ON EVERY TEST'S LINK LINE. lld extracts an archive member to resolve
# any undefined symbol, a shared library's imports included: ROCm 10.1's libamdhip64 imports
# std::string::reserve, g++-14 emits that template weak in rad_graph.cpp.o, and what that object
# needs in turn reaches dispatch.cpp.o, whose strong device calls replace the weak fakes sched_test,
# ref_test and runtime_test run on -- with no link error, only a test on the wrong backend. With
# libstdc++ first, the import resolves to it and no member is extracted for it.
set(RAD_TEST_CORE stdc++ rad_core)
file(GLOB RAD_TESTS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*_test.cpp)
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)
elseif(n IN_LIST RAD_TESTS_WITH_TOKREF)
add_executable(${n} ${t})
target_link_libraries(${n} PRIVATE rad_tokref ${RAD_TEST_CORE})
elseif(n IN_LIST RAD_TESTS_WITH_TOOLS)
add_executable(${n} ${t} ${CMAKE_SOURCE_DIR}/tools/kfixture.cpp
${CMAKE_SOURCE_DIR}/tools/opshapes.cpp)
target_link_libraries(${n} PRIVATE ${RAD_TEST_CORE})
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/tools)
elseif(n IN_LIST RAD_TESTS_WITH_R4D_HOST)
add_executable(${n} ${t} ${CMAKE_SOURCE_DIR}/libr4d/r4d_layout.cpp
${CMAKE_SOURCE_DIR}/libr4d/r4d_fp8_layout.cpp)
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)
elseif(n IN_LIST RAD_TESTS_WITH_GBNF_ORACLE)
add_executable(${n} ${t} ${CMAKE_CURRENT_SOURCE_DIR}/gbnf_oracle.cpp)
target_link_libraries(${n} PRIVATE ${RAD_TEST_CORE})
# The chat templates whose tool-call grammars the engine is held to the oracle on. Checked
# in, because a template is a few kilobytes and the tokenizer beside it is not.
target_compile_definitions(${n} PRIVATE
RAD_GBNF_TEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/data/gbnf")
else()
add_executable(${n} ${t})
target_link_libraries(${n} PRIVATE ${RAD_TEST_CORE})
endif()
if(n IN_LIST RAD_TESTS_WITH_LEGACY)
target_link_libraries(${n} PRIVATE rad_legacy_toolparse)
endif()
target_compile_definitions(${n} PRIVATE RAD_CHAT_FIXTURES="${RAD_CHAT_FIXTURES}"
RAD_MEDIA_FIXTURES="${RAD_MEDIA_FIXTURES}")
# include/ normally arrives through rad_core's PUBLIC interface; a test that does not link it
# still needs the ABI headers, since that is the whole surface it is testing against.
target_include_directories(${n} PRIVATE ${CMAKE_SOURCE_DIR}/core ${CMAKE_SOURCE_DIR}/abi
${CMAKE_BINARY_DIR}/rad_include)
set_target_properties(${n} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
# The tier transfer test loads a kernel plugin that waits on a stream through the device API, so
# the executable exports it the way the engine binary does for its plugins.
if(n STREQUAL "mem_test")
set_target_properties(${n} PROPERTIES ENABLE_EXPORTS ON)
endif()
add_test(NAME ${n} COMMAND ${n})
# AND mem_test NEEDS THE CARD TO ITSELF, which nothing about its name says. The KV pool is
# elastic on every run, so Pools::configure reserves and commits through the driver whatever
# allocators the fixture injects -- the host-allocator seam is real for the weight pool and
# dead for this one. Beside a server holding the card the pool cannot be backed and the whole
# file fails with "the card would not back it", which reads as a regression and is contention.
# The `gpu` label is how the rest of the tree already says that, and `ctest -LE gpu` still runs
# everything else on a machine that is busy.
if(${n} STREQUAL "mem_test")
set_tests_properties(${n} PROPERTIES LABELS "gpu")
endif()
# A TEST THAT SKIPPED IS NOT A TEST THAT PASSED, and a test that FAILED must not read as one
# either. Several files here guard cases on a model file, a vocabulary or a backend and print a
# " SKIP " line when it is absent; ctest swallows output on success, so without a skip signal
# those cases report Passed having asserted nothing.
#
# SKIP_REGULAR_EXPRESSION cannot be that signal. CMake evaluates it BEFORE the return code, so a
# binary that prints one skip line and then fails is reported Skipped and counted toward "100%
# tests passed" -- and a partly-skipped binary is exactly the one that prints skip lines.
#
# So the skip signal is the RETURN CODE, and rad_test.h derives it rather than declaring it:
# every CHECK increments a counter and main returns 77 only when nothing failed and nothing was
# checked at all. A file where some cases ran and others skipped passes on the ones that ran,
# which is the honest answer, and a failure anywhere is a failure.
set_tests_properties(${n} PROPERTIES SKIP_RETURN_CODE 77)
set_tests_properties(${n} PROPERTIES ENVIRONMENT
"RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home")
endforeach()
# ================================================================== the device selftest
#
# r4d_selftest IS THE ONLY THING THAT CHECKS THE FUSION CLAIMS, so it is a registered test.
#
# Sixteen rows in libr4d's registry say things like "byte-identical to the two ops it replaces",
# and that claim is what makes a fused kernel SUBSTITUTABLE rather than a second numerical path --
# it is the difference between a fusion and a fork. Six of those claims are verified, by memcmp,
# against the unfused kernels run on the same inputs. Every one of those verifications lives in
# r4d_selftest.cpp, which libr4d/CMakeLists.txt builds; a binary built and registered with nothing
# leaves `ctest` green without executing a single one of them.
#
# It needs a card, so it is guarded on the HIP backend; it forks a child per row and takes about
# two minutes, against 1.2 seconds for everything else, so it carries a `slow` label and
# `ctest -LE slow` is the fast inner loop. The default `ctest` 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
ENVIRONMENT "RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home")
endif()
# ================================================================== the device layer without SVM
#
# A KERNEL DRIVER WITHOUT THE SVM API PINS HOST MEMORY ANOTHER WAY, and a machine with it never
# takes that way. ROCr's thunk maps a locked range in place only through the KFD's SVM API; without
# it (a KVM guest whose amdgpu registered no device memory with HMM) the backend allocates a pinned
# range whole from the host pool (core/device/aql.cpp, "pinned host memory, in pieces"). HSA_USE_SVM=0
# is the thunk's own switch for that driver, so device_test runs a second time under it and the
# path is held on every machine with a card. On the host backend both runs are the same run.
if(RAD_HIP_FOUND AND TARGET device_test)
add_test(NAME device_test_nosvm COMMAND device_test)
set_tests_properties(device_test_nosvm PROPERTIES
SKIP_RETURN_CODE 77
ENVIRONMENT "RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home;HSA_USE_SVM=0")
endif()
# ================================================================== the host kernels
#
# rad-avx-check holds libavx to libref, op for op and at every ISA level the machine executes, and
# runs embed_lookup_q over a file-backed table with two ranks and the read-ahead racing: the path a
# model's host gather takes and that no geometry reaches. It writes its table beside itself, where
# the filesystem reports its direct-I/O alignment, and again in TMPDIR, where a tmpfs reports none
# and the gather aligns its reads by the block size, as it does on btrfs.
if(TARGET libavx AND TARGET rad-avx-check)
add_test(NAME avx_check
COMMAND rad-avx-check --ref ${RAD_PLUGIN_OUT}/kernels/libref.so
--avx ${RAD_PLUGIN_OUT}/kernels/libavx.so)
set_tests_properties(avx_check PROPERTIES TIMEOUT 600)
endif()
# ================================================================== libr4d's kernels, on the host
#
# libr4d builds for gfx12 only, and some of its ops (the sandwich-norm joins, expert_scale) have no
# libref oracle by design (docs/OPS.md), so neither rad-kbench nor a no-card machine would ever run
# those kernels. r4d_emu runs the SOURCE of four of libr4d's units on the host instead -- the
# windowed paged attention, pair_argmax, the joins and expert_scale, the units written against
# r4d_launch.h: emu/hip/hip_runtime.h supplies the HIP names, every GPU thread is a fiber,
# __syncthreads and every cross-lane op a barrier (one not reached uniformly is reported as a
# deadlock), and the units' launch macro is pointed at the emulator. Checked against a port of
# libref's ref_attn_paged, against the host arithmetic in ref_host.cpp, and -- for the joins --
# against the unfused chain, bit for bit.
#
# CLANG AND x86-64: the kernels use clang's ext_vector_type, and the fiber switch is x86-64 SysV
# inline assembly. Under a clang C++ compiler they are ordinary targets here, the .hip files
# compiled as C++ (`-x c++`, which is what makes them host code; the property is per directory, so
# libr4d's own HIP build is untouched). Under g++ -- the docker image's -- a build with a card
# still has a clang: its HIP compiler, ROCm's own clang++, and r4d_emu/run.sh builds and runs the
# same tests with that. So wherever libr4d is built, this runs.
set(R4D_DIR ${CMAKE_SOURCE_DIR}/libr4d)
set(R4D_EMU ${CMAKE_CURRENT_SOURCE_DIR}/r4d_emu)
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)$")
# no fiber switch for this ISA: nothing to register
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(R4D_EMU_HIP ${R4D_DIR}/r4d_attn_paged_window.hip ${R4D_DIR}/r4d_pair_argmax_f32.hip
${R4D_DIR}/r4d_norm_join_bf16.hip ${R4D_DIR}/r4d_expert_scale_bf16.hip)
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)
target_include_directories(r4d_emu_kernels PUBLIC ${R4D_EMU}/emu ${R4D_EMU} ${R4D_DIR})
target_link_libraries(r4d_emu_kernels PUBLIC rad_abi)
# As libr4d compiles every unit: the joins are held to the chain bit for bit, and a contracted
# multiply-add is a different rounding.
target_compile_options(r4d_emu_kernels PRIVATE -ffp-contract=off -Wno-psabi)
foreach(t attn pick norm escale)
add_executable(r4d_emu_${t} ${R4D_EMU}/test_${t}.cpp)
target_link_libraries(r4d_emu_${t} PRIVATE r4d_emu_kernels)
target_compile_options(r4d_emu_${t} PRIVATE -ffp-contract=off -Wno-psabi)
set_target_properties(r4d_emu_${t} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
add_test(NAME r4d_emu_${t} COMMAND r4d_emu_${t})
endforeach()
# The random sweep at a size the inner loop can afford; `r4d_emu_attn sweep 200` is the long one.
add_test(NAME r4d_emu_attn_sweep COMMAND r4d_emu_attn sweep 40)
set_tests_properties(r4d_emu_attn r4d_emu_pick r4d_emu_norm r4d_emu_escale r4d_emu_attn_sweep
PROPERTIES LABELS "r4d_emu" TIMEOUT 600)
elseif(RAD_HIP_FOUND AND CMAKE_HIP_COMPILER_ID MATCHES "Clang")
add_test(NAME r4d_emu
COMMAND sh ${R4D_EMU}/run.sh ${CMAKE_HIP_COMPILER} ${CMAKE_SOURCE_DIR}/abi ${R4D_DIR}
${CMAKE_CURRENT_BINARY_DIR}/r4d_emu 40)
set_tests_properties(r4d_emu PROPERTIES LABELS "r4d_emu" TIMEOUT 900)
endif()
# ================================================================== the document as a test
#
# docs/OPS.md calls its resolved table "THE AUTHORITY FOR THE OPS IN IT" and says of itself that
# ref's op list is the conventional vocabulary and this file is that list. A hand-maintained table
# drifts from the registries -- dropped optional operands, a missing `:inout`, parameters that
# have moved into the `params` operand, a parameter no plugin declares -- so this test holds the
# document to what the plugins dump.
#
# The cost is named in OPS.md itself: a header written against a GUESS at a schema the document
# omits gets the schema wrong. A document that is WRONG is worse than one that is missing, because
# it is read instead of the source.
#
# It is cheap (a dlopen and an awk pass) so it carries no label and runs in the default ctest.
# libref alone would catch most of it; libr4d.so is added when there is a card to load it, and
# the script reports " SKIP " rather than green when a plugin will not dump.
set(RAD_OPSDOC_PLUGINS ${RAD_PLUGIN_OUT}/kernels/libref.so)
if(RAD_HIP_FOUND AND TARGET libr4d)
list(APPEND RAD_OPSDOC_PLUGINS ${RAD_PLUGIN_OUT}/kernels/libr4d.so)
endif()
add_test(NAME ops_doc
COMMAND ${CMAKE_SOURCE_DIR}/tools/ops_doc_check.sh
${CMAKE_SOURCE_DIR}/docs/OPS.md $<TARGET_FILE:rad-schemas>
${RAD_OPSDOC_PLUGINS})
set_tests_properties(ops_doc PROPERTIES SKIP_RETURN_CODE 77)
# ================================================================== the shipped plugins, out of tree
#
# Every plugin radiance ships is a plugin like any other, and this is what holds that to be true:
# the build is installed into a prefix, every plugin directory is configured ON ITS OWN against it
# with find_package(radiance), built and installed into a home of its own, and the result has to
# hold the same plugins, declare the same vocabulary and register the same way as the tree's build
# -- then serve rad-kbench's fixture from that home through the installed tools
# (tests/oot_plugins.sh). A first-party plugin that quietly depended on being built in the tree
# fails here; so does an installed package a third party could not build against.
#
# The device library (libr4d) is included where the tree built it: the same HIP compiler, libr4d's
# targets. Labelled `oot` because it rebuilds every plugin, which is minutes, not seconds.
set(RAD_OOT_HIP "")
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}")
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})
set_tests_properties(oot_plugins PROPERTIES LABELS "oot" TIMEOUT 3600
ENVIRONMENT "CMAKE_GENERATOR=${CMAKE_GENERATOR}")
# ================================================================== the kernel library, as a test
#
# rad-kbench replaying data/kernels.rkb: every kernel every loaded library supplies, run against
# libref's recorded answers on seeded inputs, inside guarded allocations. No model, no oracle at
# run time, no network -- the fixture is checked in.
#
# r4d_selftest checks what its author wrote down and is compiled by the plugin; rad-kbench checks
# every row in every registry against an independent implementation, and the checked-in fixture
# lets it run without a model container.
#
# NOT GATED ON A CARD, because the reference library is under test in a replay too. The answers
# in the fixture were recorded by libref and checked in, so libref against them is a real
# comparison and the only regression test the oracle has -- which matters more than it sounds,
# since every correctness number this project reports about any kernel is defined relative to
# libref. It also means a build machine with no card still checks something, and a host
# implementation is exactly what regresses there.
#
# SLOW: libref is a straight-loop host implementation, so a full replay is minutes rather than the
# seconds the device libraries take. `ctest -LE slow` is the fast inner loop, as it is for
# r4d_selftest. `gpu` is added only where there is one, so `ctest -LE gpu` on a build machine
# still runs this.
#
# `--max-cases 1` because a fixture recorded at max-cases 1 has one case per point already and
# the cap is then only a guard against a future fixture that does not.
if(TARGET rad-kbench AND EXISTS ${CMAKE_SOURCE_DIR}/data/kernels.rkb)
add_test(NAME kbench
COMMAND rad-kbench --home ${RAD_PLUGIN_OUT} --max-cases 1)
set(RAD_KBENCH_LABELS "slow")
if(RAD_HIP_FOUND AND TARGET libr4d)
set(RAD_KBENCH_LABELS "slow;gpu")
endif()
# RESOURCE_LOCK, because the case budget each of these takes is a fraction of what the machine
# has FREE at the moment it starts. Two replays launched together both read the same number and
# both take their share of it, so the pair arrives at the total the budget exists to stay under.
# They also thrash a shared last-level cache against each other, which makes --bench meaningless.
set_tests_properties(kbench PROPERTIES
LABELS "${RAD_KBENCH_LABELS}"
TIMEOUT 1800
RESOURCE_LOCK kbench_memory
ENVIRONMENT "RADIANCE_HOME=${RAD_PLUGIN_OUT}")
endif()
# The same replay over the ROUTED fixture. A recording is of one container and no container in
# scope declares the whole vocabulary, so the MoE ops, the gqa 8 attention dispatch and the MTP
# head have no coverage in data/kernels.rkb at all -- see the note beside it in the root
# CMakeLists. Two tests rather than one merged fixture because a fixture names the container it
# was recorded from, and merging two would make that field a lie.
if(TARGET rad-kbench AND EXISTS ${CMAKE_SOURCE_DIR}/data/kernels_moe.rkb)
add_test(NAME kbench_moe
COMMAND rad-kbench --home ${RAD_PLUGIN_OUT} --max-cases 1
--fixture ${RAD_PLUGIN_OUT}/kernels_moe.rkb)
set_tests_properties(kbench_moe PROPERTIES
LABELS "${RAD_KBENCH_LABELS}"
TIMEOUT 1800
RESOURCE_LOCK kbench_memory
ENVIRONMENT "RADIANCE_HOME=${RAD_PLUGIN_OUT}")
endif()