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
+25
-3
@@ -286,8 +286,8 @@ static int gemm_nt_impl(const RadArgs* a, bool bias_operand, const char* nkey, c
|
||||
* acc += (sub * a_scale[m]) * scale
|
||||
* ZP_I8_GROUP sub = sum(a * (code - zero)) exact
|
||||
* acc += (sub * a_scale[m][g]) * scale
|
||||
* ZP_F16 sub = sum over ascending k of a * (code - zero), each product exact in f32
|
||||
* acc += sub * scale
|
||||
* ZP_F16 BF16 inputs are first narrowed to F16 (the cast kernel's rounding); sub is
|
||||
* the sum over ascending k of a * (code - zero), then acc += sub * scale
|
||||
*
|
||||
* `a` is already in column order (the caller undoes the step order). `a_sum` is quant_act_i8's,
|
||||
* group-major [K/group][Mpad], Mpad = ceil(M/16)*16; the grid's zero is removed through it, as
|
||||
@@ -319,7 +319,29 @@ static int gemm_zp(const ZpGrid& zg, const RadTensor* A, const RadTensor* as_,
|
||||
const int64_t acols = parts * K;
|
||||
if (numel(A) < M * acols) return RAD_E_SHAPE;
|
||||
if (A->rank >= 2 && A->shape[A->rank - 1] != acols) return RAD_E_SHAPE;
|
||||
const int64_t ars = row_stride(A, acols), acs = laststride(A);
|
||||
int64_t ars = row_stride(A, acols), acs = laststride(A);
|
||||
|
||||
/* A BF16 activation (the W4 decode graph's, which the card narrows on load) is narrowed to F16
|
||||
* first, with the cast kernel's rounding, so the F16 grid sees what the card's GEMM sees. */
|
||||
std::vector<uint16_t> narrowed;
|
||||
RadTensor a_f16{};
|
||||
if (zg.act == ZP_F16 && A->dtype == RAD_BF16) {
|
||||
narrowed.resize((size_t)(M * acols));
|
||||
for (int64_t m = 0; m < M; ++m)
|
||||
for (int64_t k = 0; k < acols; ++k)
|
||||
narrowed[(size_t)(m * acols + k)] = f32_to_f16(ldt(A, m * ars + k * acs));
|
||||
a_f16 = *A;
|
||||
a_f16.data = narrowed.data();
|
||||
a_f16.dtype = RAD_F16;
|
||||
a_f16.rank = 2;
|
||||
a_f16.shape[0] = M;
|
||||
a_f16.shape[1] = acols;
|
||||
a_f16.stride[0] = acols;
|
||||
a_f16.stride[1] = 1;
|
||||
A = &a_f16;
|
||||
ars = acols;
|
||||
acs = 1;
|
||||
}
|
||||
|
||||
const bool i8 = zg.act != ZP_F16;
|
||||
if (i8 && A->dtype != RAD_I8) return RAD_E_DTYPE;
|
||||
|
||||
Reference in new issue
Block a user