libxe2: the fused gdn epilogue's output gate on a float exp, libref's chain near a bf16 tie

63.0 us a call from 71.4 (unitrace, decode at depth 5); greedy 8/8 and the 2234-token
continuation identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-11-02 04:51:07 +01:00
1 parent 9d6eb9fba1
commit bfb1ebd1dd
1 file changed
+8 -1
+8 -1
View File
@@ -1187,6 +1187,7 @@ Anchor anchor_layout(int64_t K, int64_t V) {
struct RecIO {
DT q, k, v, av, bv, state, o, alog, dtb, sidx, z, nw, oq, osc;
bool exact = false; /* XE2_EXACT: libref's double chains only */
V3 qv, kv, vv, ov, zv;
V2 a2, b2, si;
V4 stv;
@@ -1397,6 +1398,7 @@ int rec_io(const RadArgs* a, const RadTensor* t, int nt, RecIO* r, int64_t* n_se
r->has_z = z != nullptr;
r->has_nw = nw != nullptr;
r->has_q8 = oq && osc;
r->exact = exact_only();
if (r->has_q8) {
Rows qr, sr;
if (int rc = rows_view(oq, Hv * V, &qr, "gdn o_q"); rc < 0) return rc;
@@ -1913,6 +1915,7 @@ int launch_recurrent_reg_t(sycl::queue& qu, const RecIO& r, int64_t n_seq, float
if (so >= 0) store_rows(so); /* uniform */
}
if constexpr (FUSED) {
const bool fast_o = r.o.dt == RAD_BF16 && !r.exact;
/* kernel B's epilogue, a sub-group a token, from the outputs in local memory */
sycl::group_barrier(it.get_group());
for (int64_t t = blk; t < q_len; t += nblk) {
@@ -1936,7 +1939,11 @@ int launch_recurrent_reg_t(sycl::queue& qu, const RecIO& r, int64_t n_seq, float
if (r.has_nw) x *= r.nw.ld(ee * r.nw_s);
if (r.has_z) {
const float zz = r.z.ld(at3(r.zv, tok, h, ee));
x *= (r.nact == 1 ? sigm(zz) : silu(zz));
/* a bf16 o from a float exp, libref's double chain again only
* near a rounding tie (near_bf16_tie): the same bf16 */
const float sf = sigmoid_fexp(zz);
const float xf = x * (r.nact == 1 ? sf : zz * sf);
x = fast_o && !near_bf16_tie(xf) ? xf : x * (r.nact == 1 ? sigm(zz) : silu(zz));
}
r.o.st(at3(r.ov, tok, h, ee), x);
if (r.has_q8) {