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/core/CMakeLists.txt
T
Deadcode b068190326 radiance 1.6.0
- Qwen-Image 2.1 and 2.1 Turbo: text to image and image edits over OpenAI's images API,
  /v1/images/generations and /v1/images/edits. An edit takes up to ten pictures and an optional
  mask, outside which the picture comes back exactly as it was; `background: transparent`, png,
  jpeg and webp output, `n` pictures from one prompt, streamed previews (`partial_images`), and
  vLLM-Omni's seed, negative_prompt with true_cfg_scale, num_inference_steps, width and height.
  arch/qwenimage21 serves the diffusers pipeline directory, converted with
  data/recipes/qwen-image-2.1-fp8.recipe (block fp8) or qwen-image-2.1-bf16.recipe.
  deploy/compose/qwen-image-2.1.yaml and qwen-image-2.1-turbo.yaml serve the fp8 containers on
  two cards. Two R9700s make a 2048x2048 picture in 61 s at the base model's 40 steps and in
  13 s with Turbo (56 and 12 s with --tp-wire wht6), a 1024x1024 one in 6.0 and 2.6 s. The
  models are under Qwen's research license, which is non-commercial
- an image generator is a program kind of its own (core/gen): an architecture declares its
  conditioning, denoising and decoding passes, and the driver runs the schedule, the pictures of
  a batch and the conditioning cache. An image model's /v1/models entry is its generator's name
  (qwen-image-2.1, qwen-image-2.1-turbo), and its capabilities and startup banner list only the
  images endpoints
- the tiled prefill GEMMs run their tiles in groups of activation bands, 16 for fp8 and 8 for
  bf16, so an operand larger than the 64 MB cache is read once a group instead of once a band. A
  bf16 GEMM with more than 64 MB of weight runs up to twice as fast
- fixed: a second lane opened in the middle of a step started beside work lane 0 had not
  finished. Gemma 4 26B-A4B opens its lane that way, so its first step after startup could read
  rows not yet written
- startup no longer warns about --checkpoint-slots when it was not passed, nor about an expert
  floor on a model with no experts
- the image's FFmpeg writes png, jpeg and webp (libwebp)
- for out-of-tree plugins: RAD_ABI_VERSION is 16. The op vocabulary gains the image generator's
  ops (conv2d_nhwc, ln_mod, ln_mod_quant_fp8, flow_euler, attn_prefix_self and others; docs/OPS.md,
  "Image generation"), and all_reduce takes an optional `overlap`. Plugins built against 1.5.0
  must be rebuilt
2026-10-14 14:03:59 +02:00

117 lines
7.4 KiB
CMake

# One static library. The engine is monolithic on purpose (spec §head): the plugin boundary is
# where substitution happens, and inside it there is nothing to gain from .so seams.
#
# Sources are globbed per subdirectory with CONFIGURE_DEPENDS so that adding a file to a component
# does not mean editing a file another component owns. Re-run cmake if a new file does not appear.
set(RAD_CORE_DIRS util device plugin build runtime mem sched place sample text server format mm diag gen)
set(RAD_CORE_SRC "")
foreach(d ${RAD_CORE_DIRS})
file(GLOB_RECURSE _s CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/${d}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/${d}/*.c)
list(APPEND RAD_CORE_SRC ${_s})
endforeach()
# The top level, MINUS main.cpp. main() belongs to the `radiance` executable and not to the
# library: with the archive linked whole -- which every host of an architecture plugin must do, see
# tools/CMakeLists.txt -- a main() inside it collides with each tool's own. A plain archive link
# hides this, because the tools reference nothing in main.cpp.o and the linker skips it.
file(GLOB _top CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
list(REMOVE_ITEM _top ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
list(APPEND RAD_CORE_SRC ${_top})
add_library(rad_core STATIC ${RAD_CORE_SRC})
target_link_libraries(rad_core PUBLIC rad_abi ${CMAKE_DL_LIBS} Threads::Threads)
target_compile_definitions(rad_core PUBLIC RAD_VERSION="${PROJECT_VERSION}")
target_include_directories(rad_core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/abi
${CMAKE_SOURCE_DIR}/vendor)
if(TARGET rad_vendor)
target_link_libraries(rad_core PUBLIC rad_vendor)
endif()
if(RAD_FFMPEG_FOUND)
target_compile_definitions(rad_core PRIVATE RAD_HAVE_FFMPEG=1)
target_link_libraries(rad_core PUBLIC PkgConfig::RAD_FFMPEG)
endif()
if(RAD_HIP_FOUND)
target_compile_definitions(rad_core PUBLIC RAD_HAVE_HIP=1)
target_link_libraries(rad_core PUBLIC ${RAD_HIP_RUNTIME} ${RAD_HSA_RUNTIME})
# AN EXECUTABLE RUNS THE ROCm IT WAS BUILT AGAINST. The runtime is linked by its full path, but the
# HIP driver reports that directory among its implicit link directories, so CMake writes no RPATH
# for it: the engine, the tools and the tests loaded whichever libamdhip64.so.7 the system's loader
# cache names, and a tree built against a second ROCm beside /opt/rocm ran /opt/rocm's runtime
# under its own kernels. A linker flag and not CMake's RPATH, because install rewrites CMake's, and
# rewriting it beside the entry ROCm 10's clang gives a shared library left an empty element -- the
# current directory -- in the installed plugin.
get_filename_component(RAD_HIP_LIBDIR "${RAD_HIP_RUNTIME}" DIRECTORY)
target_link_options(rad_core INTERFACE "LINKER:-rpath,${RAD_HIP_LIBDIR}")
# THE AQL BACKEND'S OWN KERNELS: the copies and fills it dispatches for rad_memcpy_async and
# rad_memset_async.
target_sources(rad_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/device/aql_blit.hip)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/device/aql_blit.hip PROPERTIES LANGUAGE HIP)
# THE STEP'S OWN BOOKKEEPING ON THE CARD: acceptance and the next pass's positions (sched/advance.h).
target_sources(rad_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/sched/advance.hip)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/sched/advance.hip PROPERTIES LANGUAGE HIP)
# WEIGHT-TABLE ENTRIES WRITTEN IN STREAM ORDER, their values carried in the arguments (runtime/wtab.h).
target_sources(rad_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/wtab.hip)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/runtime/wtab.hip PROPERTIES LANGUAGE HIP)
# THE NEXT-LAYER EXPERT PREFETCH's prediction, plan and table patches (runtime/xprefetch.h).
target_sources(rad_core PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime/xprefetch.hip)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/runtime/xprefetch.hip PROPERTIES LANGUAGE HIP)
# THE CORE'S OWN KERNELS ARE BUILT FOR EVERY AMD GPU FAMILY, not only for the cards this build
# targets. They are what every copy and fill on a card runs, so an engine without a code object
# for a card cannot start on it -- whatever kernel plugin is installed for that card, and a plugin
# for a card the build machine does not have is exactly what a third party ships. The generic
# targets cost three small files a family; the loader prefers the exact chip where both exist
# (core/device/aql_code.cpp), so a targeted card still runs code built for it.
set(RAD_CORE_GPU_TARGETS ${RAD_GPU_TARGETS}
gfx9-generic gfx9-4-generic gfx10-1-generic gfx10-3-generic gfx11-generic gfx12-generic)
list(REMOVE_DUPLICATES RAD_CORE_GPU_TARGETS)
set_target_properties(rad_core PROPERTIES HIP_ARCHITECTURES "${RAD_CORE_GPU_TARGETS}")
rad_hip_repeatable(rad_core)
# EVERY EXECUTABLE THAT LINKS THE CORE EXPORTS THE HIP ENTRY POINTS THE BACKEND DEFINES. A kernel
# plugin is dlopen'ed and its hipLaunchKernel binds to the first definition in the global scope,
# which is the executable's only if the executable exports it. Without this a plugin would launch
# through HIP onto a queue HIP does not own; aql.cpp checks at startup and refuses to run.
foreach(sym hipLaunchKernel hipMemcpy2DAsync hipMemcpyAsync hipMemsetAsync hipMemset hipStreamSynchronize
hipEventRecord hipStreamWaitEvent hipGetLastError hipPeekAtLastError
__hipRegisterFatBinary __hipRegisterFunction __hipUnregisterFatBinary)
target_link_options(rad_core INTERFACE "LINKER:--export-dynamic-symbol=${sym}")
endforeach()
endif()
# The engine binary. core/main.cpp is owned by the engine component.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
add_executable(radiance main.cpp)
target_link_libraries(radiance PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,rad_core>")
# ENABLE_EXPORTS: the architecture plugin binds the declare-phase C ABI back to this binary at
# dlopen. See the same note in tools/CMakeLists.txt.
set_target_properties(radiance PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
ENABLE_EXPORTS ON)
# Installed beside the tools, so a prefix that holds rad-convert and rad-kbench also holds the
# binary they exist to feed. RUNTIME and not a bare DESTINATION so that ENABLE_EXPORTS -- which
# is what lets an architecture plugin bind the declare-phase C ABI back to this binary at
# dlopen, see the note above -- is carried by the same rule that carries the executable.
install(TARGETS radiance RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
# The plugin layer's test plugins. They are .so files rather than part of rad_core, so they need a
# CMakeLists of their own -- and it needs to be reached. (Owned by core/plugin/.)
#
# RAD_PLUGIN_INSTALL=OFF for that whole subtree, and this is the one place in the build that turns
# it off. rad_add_plugin installs what it builds, because a plugin that is built and not installed
# leaves $RADIANCE_HOME working only when it points at a build directory. But the .so files under
# core/plugin/testplugin exist only for tests -- to be refused, to conflict with each other, to
# report a stale ABI, or to stand in for a card in one test -- and none is a kernel a real run may
# select. Shipping those into a real prefix is the same mistake testplugin/CMakeLists.txt already
# refuses to make in the build tree -- "a test plugin that a real run could select is a fallback
# nobody knows about" -- so the opt-out is set here, where the subtree is reached, rather than in a
# file that component owns.
set(RAD_PLUGIN_INSTALL OFF)
add_subdirectory(plugin)