Archived
libxe2: quant_act_fp8 a sub-group a (row, group) -- 49.6 -> 8.0 us at n=17408
A row's work-group walked its groups sixteen at a time, ~5 us a group of dependent loads, reduction and stores. The groups are independent, so each sub-group now takes one (as gated_quant_fp8 already does); the arithmetic is unchanged. rad-kbench against libref: 45 checked, 45 passed, rel_l2 0. Greedy output identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
dad30c6b59
commit
ed8e26c2fc
1 file changed
+11
-9
+11
-9
@@ -196,19 +196,21 @@ int quant_act_fp8(const RadArgs* a, RadStream st) {
|
||||
sycl::queue* q = queue_of(st);
|
||||
if (!q) return RAD_E_DEVICE;
|
||||
constexpr int kSubs = (int)(kWg / kSub);
|
||||
/* a sub-group a (row, group): the groups are independent, and a row's work-group walking its
|
||||
* groups in turn ran ~5 us a group (48 us at n = 17408) */
|
||||
const int64_t wpr = (ngrp + kSubs - 1) / kSubs; /* work-groups a row */
|
||||
return submit([&] {
|
||||
syclex::nd_launch(*q, sycl::nd_range<1>{(size_t)rows * kWg, kWg},
|
||||
syclex::nd_launch(*q, sycl::nd_range<1>{(size_t)(rows * wpr) * kWg, kWg},
|
||||
[=](sycl::nd_item<1> it) [[sycl::reqd_sub_group_size(kSub)]] {
|
||||
const int64_t r = (int64_t)it.get_group(0);
|
||||
const int64_t r = (int64_t)it.get_group(0) / wpr;
|
||||
const sycl::sub_group sg = it.get_sub_group();
|
||||
const int sgi = (int)sg.get_group_linear_id();
|
||||
const int64_t gi = ((int64_t)it.get_group(0) % wpr) * kSubs + (int64_t)sg.get_group_linear_id();
|
||||
if (gi >= ngrp) return; /* uniform over the sub-group */
|
||||
auto v = [&](int64_t i) { return rad_load_f32(x.base, x.dtype, r * x.pitch + i); };
|
||||
for (int64_t gi = sgi; gi < ngrp; gi += kSubs) {
|
||||
const int64_t k0 = gi * g, len = sycl::min(g, n - k0);
|
||||
const float sc = quant_group(sg, v, k0, len, 448.0f, qv.base, qv.dtype, r * qv.pitch);
|
||||
if (sg.get_local_linear_id() == 0)
|
||||
rad_store_f32(sv.base, sv.dtype, r * sv.pitch + gi, sc);
|
||||
}
|
||||
const int64_t k0 = gi * g, len = sycl::min(g, n - k0);
|
||||
const float sc = quant_group(sg, v, k0, len, 448.0f, qv.base, qv.dtype, r * qv.pitch);
|
||||
if (sg.get_local_linear_id() == 0)
|
||||
rad_store_f32(sv.base, sv.dtype, r * sv.pitch + gi, sc);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user