Archived
At K = 21504 (a dense 27B's down projection) the single-threaded Cholesky and inverse took hours a layer; dpotrf / dpotri take 13.5 s for all three on 24 cores, identical to 1e-14. Without OpenBLAS nothing changes. The factor cache kept every layer's factor, 3.7 GB each at that width, which OOM-killed a 62-layer conversion at layer 25; it now keeps one at a time (a layer's experts arrive together and still share it). RAD_LQ_FACTOR_CACHE_ALL keeps the old behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.7 KiB
CMake
38 lines
1.7 KiB
CMake
# libquant -- the built-in quantisers (spec §4.5). Host C++ only.
|
|
#
|
|
# Links rad_abi and nothing else, like every plugin: abi/rad_quant.h is the whole contract, which
|
|
# keeps it substitutable by a third-party quantiser.
|
|
# Built in radiance's tree, or standalone against an installed radiance
|
|
# (`cmake -S libquant -B build -DCMAKE_PREFIX_PATH=<radiance prefix>`); see cmake/RadAddPlugin.cmake.
|
|
if(NOT COMMAND rad_add_plugin)
|
|
cmake_minimum_required(VERSION 3.21)
|
|
project(libquant LANGUAGES CXX)
|
|
find_package(radiance REQUIRED)
|
|
rad_plugin_defaults()
|
|
endif()
|
|
|
|
file(GLOB LQ_SRC CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
|
|
|
rad_add_plugin(libquant quantizers SOURCES ${LQ_SRC} INCLUDES ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# -ffp-contract=off: quantiser output is a stored file, so two builds must produce the same bytes. A
|
|
# compiler-chosen FMA can move a value on a rounding boundary into the next code.
|
|
target_compile_options(libquant PRIVATE -ffp-contract=off)
|
|
|
|
# Optional OpenMP over rows (GPTQ and round-to-nearest over large tables are long serial loops).
|
|
# Rows are independent, so the result does not depend on the thread count.
|
|
find_package(OpenMP QUIET)
|
|
if(OpenMP_CXX_FOUND)
|
|
target_link_libraries(libquant PRIVATE OpenMP::OpenMP_CXX)
|
|
else()
|
|
message(STATUS "libquant: no OpenMP -- quantisers will run single-threaded")
|
|
endif()
|
|
|
|
# GPTQ's Hessian factorisations through LAPACK where OpenBLAS is installed (lq_gptq.cpp): the
|
|
# built-in loops are single-threaded and take hours on a 21504-wide down projection.
|
|
find_library(LQ_OPENBLAS openblas)
|
|
if(LQ_OPENBLAS)
|
|
target_compile_definitions(libquant PRIVATE RAD_LQ_LAPACK=1)
|
|
target_link_libraries(libquant PRIVATE ${LQ_OPENBLAS})
|
|
endif()
|