Archived
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>
51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
/* abi_c_test.c -- abi/ as a C plugin sees it.
|
|
*
|
|
* Every header is included in one translation unit compiled as strict C11 (-pedantic-errors, see
|
|
* tests/CMakeLists.txt), so a header that only C++ accepts fails the build. The struct layouts a
|
|
* C compiler gives them, and rad_yarn.h's C definitions, are handed to abi_layout_test.cpp, which
|
|
* compares them with its own. */
|
|
#include "rad_abi.h"
|
|
#include "rad_builder.h"
|
|
#include "rad_device.h"
|
|
#include "rad_encoding.h"
|
|
#include "rad_format.h"
|
|
#include "rad_philox.h"
|
|
#include "rad_planes.h"
|
|
#include "rad_plugin.h"
|
|
#include "rad_quant.h"
|
|
#include "rad_runtime.h"
|
|
#include "rad_sample.h"
|
|
#include "rad_sycl.h"
|
|
#include "rad_spechub.h"
|
|
#include "rad_types.h"
|
|
#include "rad_yarn.h"
|
|
|
|
#include "abi_layout.h"
|
|
|
|
const AbiRow abi_c_rows[] = {
|
|
#define ABI_STRUCT(T) { #T, "", 0, sizeof(T) },
|
|
#define ABI_FIELD(T, f) { #T, #f, offsetof(T, f), sizeof(((T*)0)->f) },
|
|
#include "rad_abi_layout_rows.h"
|
|
#undef ABI_STRUCT
|
|
#undef ABI_FIELD
|
|
};
|
|
const size_t abi_c_n_rows = sizeof abi_c_rows / sizeof abi_c_rows[0];
|
|
|
|
float abi_c_yarn_frequency(float factor, float low, float high, float magnitude, float inv, int i) {
|
|
RadYarn y;
|
|
y.factor = factor;
|
|
y.low = low;
|
|
y.high = high;
|
|
y.magnitude = magnitude;
|
|
return rad_yarn_frequency(&y, inv, i);
|
|
}
|
|
|
|
int abi_c_yarn_valid(float factor, float low, float high, float magnitude) {
|
|
RadYarn y;
|
|
y.factor = factor;
|
|
y.low = low;
|
|
y.high = high;
|
|
y.magnitude = magnitude;
|
|
return rad_yarn_valid(&y);
|
|
}
|