Archived
libxe2, arch/common: silu_mul for 4-bit down projections, float exp at the tie rule; head-row norms vectorized; attention SLM by gqa
- Under Geom::plain_norm a down projection that reads the bf16 plane and no codes (w4a16 / w4a8i8 quantise their own activation) takes `silu_mul` instead of gated_quant_fp8 (the E4M3 pass nobody read: 17 us a call, 64 a round). - silu_mul: float exp, libref's double chain again only near a bf16 tie (near_bf16_tie, as the gdn activations): op oracle 300/300 bit-identical at tolerance 0. - rmsnorm's bf16 head rows (n = 128..512): a lane its contiguous slice by 16-byte loads (16 us -> a few us a q / k norm call). rad-kbench rmsnorm 240/240. - the flash kernel's staged queries sized for gqa <= 8 (24 of 64 KiB a work-group). Greedy decode proxy (depth 5, mtp4, draft vocab 131072): 74.3 -> 81.2 tok/s. KL against the exact reference 0.00231 (was 0.00239), top-1 96.70%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2d2356ad4b
commit
f26eec2633
4 files changed
+63
-7
No files matched your search
@@ -289,6 +289,7 @@ int silu_mul(const RadArgs* a, RadStream st) {
|
||||
sycl::queue* q = queue_of(st);
|
||||
if (!q) return RAD_E_DEVICE;
|
||||
const int64_t total = rows * n;
|
||||
const bool bf16_out = y.dtype == RAD_BF16 && !exact_only();
|
||||
const size_t wg = 256, groups = (size_t)((total + 255) / 256);
|
||||
return submit([&] {
|
||||
syclex::nd_launch(*q, sycl::nd_range<1>{groups * wg, wg}, [=](sycl::nd_item<1> it) {
|
||||
@@ -297,8 +298,11 @@ int silu_mul(const RadArgs* a, RadStream st) {
|
||||
const int64_t r = g / n, i = g % n;
|
||||
const float x = rad_load_f32(gu.base, gu.dtype, r * gu.pitch + i);
|
||||
const float up = rad_load_f32(gu.base, gu.dtype, r * gu.pitch + n + i);
|
||||
const float sg = 1.0f / (1.0f + (float)sycl::exp((double)-x));
|
||||
rad_store_f32(y.base, y.dtype, r * y.pitch + i, x * sg * up);
|
||||
/* a bf16 result from a float exp, libref's double chain again only near a rounding
|
||||
* tie (near_bf16_tie): the same bf16 */
|
||||
float v = x * sigmoid_fexp(x) * up;
|
||||
if (!bf16_out || near_bf16_tie(v)) v = x * (1.0f / (1.0f + (float)sycl::exp((double)-x))) * up;
|
||||
rad_store_f32(y.base, y.dtype, r * y.pitch + i, v);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user