okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-q4-sycl (41717f29c): the Intel Arc (SYCL) engine follows the compiled geometry, so q4_lite/q4_mid/q4_big build; default build unchanged (CUDA SASS 3573/3573, HIP gfx1201 3920/3920, gfx1151 string offsets only, Metal 85/85 objects, SYCL 22/22 checksums); A750 gate 2 q4_lite 0.00021 vs floor 0.00017; one conflict with f-clean-6-0 in sycl/src/prefill/prefill.cpp resolved as tested by Q4-SYMERGE (Qwen4 prep)db137d917

main
24.0 KiB519 linesraw
1// Arithmetic adapted from llama.cpp 3cf03257f219afbe7334045ff7c6a06ac68c627d:
2// src/models/qwen4exp.cpp and ggml-cuda/{reduce_rows.cuh,sumrows.cu,unary.cu}.
3// MIT License
4// Copyright (c) 2023-2026 The ggml authors
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11// The above copyright notice and this permission notice shall be included in all
12// copies or substantial portions of the Software.
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21#define DPCT_PROFILING_ENABLED
22#include <sycl/sycl.hpp>
23#include "strata/kprof.hpp"
24#include "strata/core/geometry.hpp"
25#include <dpct/dpct.hpp>
26#include "strata/sycl_queue.hpp"
27#include "strata/kernels/native_ple_postops.hpp"
28#include "strata/kernels/native_gr_norm.hpp"
29#include "strata/kernels/ngram.hpp"
30#include <cmath>
31#include <cstddef>
32#include <cstdint>
33#include <limits>
34#include <stdexcept>
35#include <string>
36
37namespace strata::kernels {
38namespace {
39constexpr int N = strata::core::kCompiledGeometry.n_embd, H = strata::core::kCompiledGeometry.hc, D = N * H, HISTORY = 9;
40static_assert(N == strata::core::kCompiledGeometry.n_embd && H == strata::core::kCompiledGeometry.hc, "native_ple_postops is compiled for core/geometry.hpp");
41inline float warp_sum(float x) {
42    /*
43DPCT1108: '__shfl_xor_sync' was migrated with the experimental feature masked
44sub_group function which may not be supported by all compilers or runtimes. You
45may need to adjust the code.
46*/
47#pragma unroll
48    for (int offset = 16; offset; offset >>= 1) x +=
49        dpct::experimental::permute_sub_group_by_xor(
50            0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(), x,
51            offset);
52    return x;
53}
54__dpct_inline__ void gate_kernel(const float *key, const float *query,
55                                 float *gate, float scale) {
56    // SUM_ROWS selects 512 threads for four rows on the target GPU. Preserve
57    // its eight partial lanes and materialized MUL rounding (never a dot FMA).
58    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
59    float sums[8] = {};
60#pragma unroll
61    for (int j = 0; j < 8; ++j) {
62        const int d = item_ct1.get_local_id(2) + j * 512;
63        /*
64        DPCT1013: The rounding mode could not be specified and the generated
65        code may have different accuracy than the original code. Verify the
66        correctness. SYCL math built-in function rounding mode is aligned with
67        OpenCL C 1.2 standard.
68        */
69        const float p = d < N ? key[item_ct1.get_group(2) * N + d] *
70                                    query[item_ct1.get_group(2) * N + d]
71                              : 0.0f;
72        sums[j] += p;
73    }
74    float sum = 0;
75#pragma unroll
76    for (int j = 0; j < 8; ++j) sum += sums[j];
77    auto &partials =
78        *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(
79            sycl::ext::oneapi::this_work_item::get_work_group<3>());
80    sum = warp_sum(sum);
81    const int lane = item_ct1.get_local_id(2) % 32;
82    if (!lane) partials[item_ct1.get_local_id(2) / 32] = sum;
83    item_ct1.barrier(sycl::access::fence_space::local_space);
84    sum = lane < 16 ? partials[lane] : 0.0f;
85    sum = warp_sum(sum);
86    if (item_ct1.get_local_id(2) == 0) {
87        /*
88        DPCT1013: The rounding mode could not be specified and the generated
89        code may have different accuracy than the original code. Verify the
90        correctness. SYCL math built-in function rounding mode is aligned with
91        OpenCL C 1.2 standard.
92        */
93        const float s = sycl::fma(scale, sum, 0.0f); // ggml SCALE's zero bias
94        const float mag = sycl::sqrt(sycl::fmax(sycl::fabs(s), 1e-6f));
95        const float sign = float((s > 0.0f) - (s < 0.0f));
96        /*
97        DPCT1013: The rounding mode could not be specified and the generated
98        code may have different accuracy than the original code. Verify the
99        correctness. SYCL math built-in function rounding mode is aligned with
100        OpenCL C 1.2 standard.
101        */
102        gate[item_ct1.get_group(2)] =
103            1.0f / (1.0f + sycl::native::exp(-sign * mag));
104    }
105}
106__dpct_inline__ void broadcast_kernel(const float *value, const float *gate,
107                                      float *gated) {
108    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
109    const int i = item_ct1.get_group(2) * item_ct1.get_local_range(2) +
110                  item_ct1.get_local_id(2);
111    /*
112    DPCT1013: The rounding mode could not be specified and the generated
113    code may have different accuracy than the original code. Verify the
114    correctness. SYCL math built-in function rounding mode is aligned with
115    OpenCL C 1.2 standard.
116    */
117    if (i < D) gated[i] = value[i % N] * gate[i / N];
118}
119__dpct_inline__ void
120conv_residual_kernel(const float *history, const float *normalized,
121                     const uint16_t *weights, const float *hidden,
122                     const float *gated, float *conv, float *result) {
123    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
124    const int c = item_ct1.get_group(2) * item_ct1.get_local_range(2) +
125                  item_ct1.get_local_id(2);
126    if (c >= D) return;
127    float sum = 0;
128#pragma unroll
129    for (int k = 0; k < 4; ++k) {
130        const float x = k == 3 ? normalized[c] : history[c * HISTORY + 3 * k];
131        const float w =
132            sycl::vec<sycl::half, 1>(
133                sycl::bit_cast<sycl::half, unsigned short>(weights[c * 4 + k]))
134                .convert<float, sycl::rounding_mode::automatic>()[0];
135        /*
136        DPCT1013: The rounding mode could not be specified and the generated
137        code may have different accuracy than the original code. Verify the
138        correctness. SYCL math built-in function rounding mode is aligned with
139        OpenCL C 1.2 standard.
140        */
141        const float term = x * w;
142        /*
143        DPCT1013: The rounding mode could not be specified and the generated
144        code may have different accuracy than the original code. Verify the
145        correctness. SYCL math built-in function rounding mode is aligned with
146        OpenCL C 1.2 standard.
147        */
148        sum = k == 0 ? term : sum + term;
149    }
150    const float activation = sum / (1.0f + sycl::native::exp(-sum));
151    conv[c] = activation;
152    // Exact hidden/result alias is safe: each thread owns one element.
153    /*
154    DPCT1013: The rounding mode could not be specified and the generated
155    code may have different accuracy than the original code. Verify the
156    correctness. SYCL math built-in function rounding mode is aligned with
157    OpenCL C 1.2 standard.
158    */
159    result[c] = hidden[c] + gated[c] + activation;
160}
161// ---- the batch: T tokens, the same arithmetic per element as the kernels above
162// weighted_rms_norm (native_gr_norm.cu) with the gamma row repeating every H rows (one token's H groups)
163inline float norm_warp_sum(float value) {
164#pragma unroll
165    /*
166    DPCT1108: '__shfl_xor_sync' was migrated with the experimental feature
167    masked sub_group function which may not be supported by all compilers or
168    runtimes. You may need to adjust the code.
169    */
170    for (int offset = 16; offset > 0; offset >>= 1) value +=
171        dpct::experimental::permute_sub_group_by_xor(
172            0xffffffffu, sycl::ext::oneapi::this_work_item::get_sub_group(),
173            value, offset);
174    return value;
175}
176__dpct_inline__ void rms_rep_kernel(const float *__restrict__ input,
177                                    const float *__restrict__ gamma,
178                                    float *__restrict__ output) {
179    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
180    constexpr int BlockSize =
181        1024; // native_gr_rms_norm_weighted's choice for 2560 columns
182    const int tid = item_ct1.get_local_id(2);
183    const size_t row_offset = size_t(item_ct1.get_group(2)) * N;
184    input += row_offset;
185    output += row_offset;
186    gamma += size_t(item_ct1.get_group(2) % H) * N;
187    float partial = 0.0f;
188    for (int col = tid; col < N; col += BlockSize) {
189        const float value = input[col];
190        partial += value * value;
191    }
192    auto &sums =
193        *sycl::ext::oneapi::group_local_memory_for_overwrite<float[32]>(
194            sycl::ext::oneapi::this_work_item::get_work_group<3>());
195    partial = norm_warp_sum(partial);
196    const int lane = tid % 32;
197    if (lane == 0) sums[tid / 32] = partial;
198    item_ct1.barrier(sycl::access::fence_space::local_space);
199    partial = 0.0f;
200    if (lane < BlockSize / 32) partial = sums[lane];
201    partial = norm_warp_sum(partial);
202    const float mean = partial / N;
203    const float scale = sycl::rsqrt(mean + NG_RMS_EPS);
204#pragma unroll
205    for (int col = tid; col < N; col += BlockSize)
206        output[col] = scale * input[col] * gamma[col];
207}
208__dpct_inline__ void broadcast_batch_kernel(const float *value,
209                                            const float *gate, float *gated,
210                                            int T) {
211    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
212    const size_t i =
213        size_t(item_ct1.get_group(2)) * item_ct1.get_local_range(2) +
214        item_ct1.get_local_id(2);
215    if (i >= size_t(T) * D) return;
216    const size_t t = i / D, d = i % D;
217    /*
218    DPCT1013: The rounding mode could not be specified and the generated
219    code may have different accuracy than the original code. Verify the
220    correctness. SYCL math built-in function rounding mode is aligned with
221    OpenCL C 1.2 standard.
222    */
223    gated[i] = value[t * N + d % N] * gate[t * H + d / N];
224}
225// the dilated conv (taps 9, 6, 3 tokens back and this one) and the residual; a tap before the chunk reads the history
226__dpct_inline__ void conv_residual_batch_kernel(const float *history,
227                                                const float *normalized,
228                                                const uint16_t *weights,
229                                                float *hidden,
230                                                const float *gated, int T) {
231    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
232    const size_t i =
233        size_t(item_ct1.get_group(2)) * item_ct1.get_local_range(2) +
234        item_ct1.get_local_id(2);
235    if (i >= size_t(T) * D) return;
236    const int t = int(i / D), c = int(i % D);
237    float sum = 0;
238#pragma unroll
239    for (int k = 0; k < 4; ++k) {
240        const int p = t - 9 + 3 * k;             // the token this tap reads (k == 3: this one)
241        const float x = p >= 0 ? normalized[size_t(p) * D + c] : history[size_t(c) * HISTORY + (9 + p)];
242        const float wk =
243            sycl::vec<sycl::half, 1>(
244                sycl::bit_cast<sycl::half, unsigned short>(weights[c * 4 + k]))
245                .convert<float, sycl::rounding_mode::automatic>()[0];
246        /*
247        DPCT1013: The rounding mode could not be specified and the generated
248        code may have different accuracy than the original code. Verify the
249        correctness. SYCL math built-in function rounding mode is aligned with
250        OpenCL C 1.2 standard.
251        */
252        const float term = x * wk;
253        /*
254        DPCT1013: The rounding mode could not be specified and the generated
255        code may have different accuracy than the original code. Verify the
256        correctness. SYCL math built-in function rounding mode is aligned with
257        OpenCL C 1.2 standard.
258        */
259        sum = k == 0 ? term : sum + term;
260    }
261    const float activation = sum / (1.0f + sycl::native::exp(-sum));
262    /*
263    DPCT1013: The rounding mode could not be specified and the generated
264    code may have different accuracy than the original code. Verify the
265    correctness. SYCL math built-in function rounding mode is aligned with
266    OpenCL C 1.2 standard.
267    */
268    hidden[i] = hidden[i] + gated[i] + activation;
269}
270// the history after the chunk: the last nine normalized rows (older ones from the history when T < 9)
271__dpct_inline__ void history_batch_kernel(float *history,
272                                          const float *normalized, int T) {
273    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
274    const int c = item_ct1.get_group(2) * item_ct1.get_local_range(2) +
275                  item_ct1.get_local_id(2);
276    if (c >= D) return;
277    float h[HISTORY];
278#pragma unroll
279    for (int r = 0; r < HISTORY; ++r) {
280        const int p = T - HISTORY + r;
281        h[r] = p >= 0 ? normalized[size_t(p) * D + c] : history[size_t(c) * HISTORY + (T + r)];
282    }
283#pragma unroll
284    for (int r = 0; r < HISTORY; ++r) history[size_t(c) * HISTORY + r] = h[r];
285}
286
287struct Span { const void* p; size_t bytes; size_t alignment; };
288bool overlaps(Span a, Span b) {
289    const auto x = reinterpret_cast<uintptr_t>(a.p), y = reinterpret_cast<uintptr_t>(b.p);
290    return x < y + b.bytes && y < x + a.bytes;
291}
292void validate(Span span) {
293    const auto p = reinterpret_cast<uintptr_t>(span.p);
294    if (!p || p % span.alignment || p > std::numeric_limits<uintptr_t>::max() - span.bytes)
295        throw std::invalid_argument("native PLE postops require nonnull aligned bounded spans");
296}
297void launch_check() {
298    /*
299    DPCT1010: SYCL uses exceptions to report errors and does not use the
300    error codes. The cudaGetLastError function call was replaced with 0. You
301    need to rewrite this code.
302    */
303    const auto error = 0;
304    /*
305    DPCT1009: SYCL reports errors using exceptions and does not use error
306    codes. Please replace the "get_error_string_dummy(...)" with a real
307    error-handling function.
308    */
309    /*
310    DPCT1001: The statement could not be removed.
311    */
312    /*
313    DPCT1000: Error handling if-stmt was detected but could not be
314    rewritten.
315    */
316    if (error !=
317        0) throw std::runtime_error(std::string("native PLE postops launch: ") +
318                                    dpct::get_error_string_dummy(error));
319}
320} // namespace
321
322void native_ple_postops(const float* projected_key, const float* hidden,
323                        const float* value, const float* history,
324                        const PleWeights& w, const NativePlePostopsBuffers& b, void* stream) {
325    if (!stream) throw std::invalid_argument("native PLE postops require an explicit stream");
326    const Span inputs[] = {{projected_key,D*4,4}, {hidden,D*4,4}, {value,N*4,4},
327        {history,HISTORY*D*4,4}, {w.norm_key,D*4,4}, {w.norm_query,D*4,4},
328        {w.norm_conv,D*4,4}, {w.conv1d_f16,4*D*2,2}};
329    const Span outputs[] = {{b.key,D*4,4}, {b.query,D*4,4}, {b.gate,H*4,4},
330        {b.gated,D*4,4}, {b.normalized,D*4,4}, {b.conv,D*4,4}, {b.result,D*4,4}};
331    for (const auto& span : inputs) validate(span);
332    for (const auto& span : outputs) validate(span);
333    for (size_t i = 0; i < 7; ++i) {
334        for (size_t j = 0; j < 8; ++j)
335            if (!(i == 6 && j == 1 && b.result == hidden) && overlaps(outputs[i], inputs[j]))
336                throw std::invalid_argument("native PLE postops output overlaps an input or weight");
337        for (size_t j = i + 1; j < 7; ++j)
338            if (!(i == 1 && j == 4 && b.query == b.normalized) && overlaps(outputs[i], outputs[j]))
339                throw std::invalid_argument("native PLE postops writable spans overlap");
340    }
341    native_gr_rms_norm_weighted(projected_key,w.norm_key,b.key,N,H,NG_RMS_EPS,stream);
342    native_gr_rms_norm_weighted(hidden,w.norm_query,b.query,N,H,NG_RMS_EPS,stream);
343    auto st = strata::q_of(stream);
344    /*
345    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
346    limit. To get the device limit, query info::device::max_work_group_size.
347    Adjust the work-group size if needed.
348    */
349    {
350        auto exp_props = sycl::ext::oneapi::experimental::properties{
351            sycl::ext::oneapi::experimental::use_root_sync};
352
353        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) {
354            auto std_sqrt_float_N_ct3 = 1.0f / std::sqrt(float(N));
355
356            cgh.parallel_for<dpct_kernel_name<class gate_kernel_f8e4fc>>(
357                sycl::nd_range<3>(sycl::range(1, 1, H) * sycl::range(1, 1, 512),
358                                  sycl::range(1, 1, 512)),
359                exp_props,
360                [=](sycl::nd_item<3> item_ct1)
361                    [[sycl::reqd_sub_group_size(32)]] {
362                        gate_kernel(b.key, b.query, b.gate,
363                                    std_sqrt_float_N_ct3);
364                    });
365        });
366    }
367    {
368        auto exp_props = sycl::ext::oneapi::experimental::properties{
369            sycl::ext::oneapi::experimental::use_root_sync};
370
371        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class broadcast_kernel_50d78d>>(
372            sycl::nd_range<3>(sycl::range(1, 1, D / 256) *
373                                  sycl::range(1, 1, 256),
374                              sycl::range(1, 1, 256)),
375            exp_props, [=](sycl::nd_item<3> item_ct1) {
376                broadcast_kernel(value, b.gate, b.gated);
377            });
378    }
379    launch_check();
380    native_gr_rms_norm_weighted(b.gated,w.norm_conv,b.normalized,N,H,NG_RMS_EPS,stream);
381    {
382        auto exp_props = sycl::ext::oneapi::experimental::properties{
383            sycl::ext::oneapi::experimental::use_root_sync};
384
385        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class conv_residual_kernel_6182eb>>(
386            sycl::nd_range<3>(sycl::range(1, 1, D / 256) *
387                                  sycl::range(1, 1, 256),
388                              sycl::range(1, 1, 256)),
389            exp_props, [=](sycl::nd_item<3> item_ct1) {
390                conv_residual_kernel(history, b.normalized, w.conv1d_f16,
391                                     hidden, b.gated, b.conv, b.result);
392            });
393    }
394    launch_check();
395}
396
397void native_ple_postops_batch(float* key, float* hidden, const float* value, float* history, const PleWeights& w,
398                              float* query_norm, float* gated, float* gate, int T, void* stream) {
399    if (!stream || T <= 0 || !key || !hidden || !value || !history || !query_norm || !gated || !gate)
400        throw std::invalid_argument("native PLE postops batch: null input or empty batch");
401    auto st = strata::q_of(stream);
402    const unsigned rows = unsigned(T) * H;
403    const unsigned blocks = unsigned((size_t(T) * D + 255) / 256);
404    /*
405    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
406    limit. To get the device limit, query info::device::max_work_group_size.
407    Adjust the work-group size if needed.
408    */
409    {
410        auto exp_props = sycl::ext::oneapi::experimental::properties{
411            sycl::ext::oneapi::experimental::use_root_sync};
412
413        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class rms_rep_kernel_dde36c>>(
414            sycl::nd_range<3>(sycl::range(1, 1, rows) * sycl::range(1, 1, 1024),
415                              sycl::range(1, 1, 1024)),
416            exp_props,
417            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(32)]] {
418                rms_rep_kernel(key, w.norm_key, key);
419            });
420    }
421    /*
422    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
423    limit. To get the device limit, query info::device::max_work_group_size.
424    Adjust the work-group size if needed.
425    */
426    {
427        auto exp_props = sycl::ext::oneapi::experimental::properties{
428            sycl::ext::oneapi::experimental::use_root_sync};
429
430        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class rms_rep_kernel_9b5d94>>(
431            sycl::nd_range<3>(sycl::range(1, 1, rows) * sycl::range(1, 1, 1024),
432                              sycl::range(1, 1, 1024)),
433            exp_props,
434            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(32)]] {
435                rms_rep_kernel(hidden, w.norm_query, query_norm);
436            });
437    }
438    /*
439    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
440    limit. To get the device limit, query info::device::max_work_group_size.
441    Adjust the work-group size if needed.
442    */
443    {
444        auto exp_props = sycl::ext::oneapi::experimental::properties{
445            sycl::ext::oneapi::experimental::use_root_sync};
446
447        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->submit([&](sycl::handler &cgh) {
448            auto std_sqrt_float_N_ct3 = 1.0f / std::sqrt(float(N));
449
450            cgh.parallel_for<dpct_kernel_name<class gate_kernel_558e90>>(
451                sycl::nd_range<3>(sycl::range(1, 1, rows) *
452                                      sycl::range(1, 1, 512),
453                                  sycl::range(1, 1, 512)),
454                exp_props,
455                [=](sycl::nd_item<3> item_ct1)
456                    [[sycl::reqd_sub_group_size(32)]] {
457                        gate_kernel(key, query_norm, gate,
458                                    std_sqrt_float_N_ct3);
459                    });
460        });
461    }
462    {
463        auto exp_props = sycl::ext::oneapi::experimental::properties{
464            sycl::ext::oneapi::experimental::use_root_sync};
465
466        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class broadcast_batch_kernel_24ebaf>>(
467            sycl::nd_range<3>(sycl::range(1, 1, blocks) *
468                                  sycl::range(1, 1, 256),
469                              sycl::range(1, 1, 256)),
470            exp_props, [=](sycl::nd_item<3> item_ct1) {
471                broadcast_batch_kernel(value, gate, gated, T);
472            });
473    }
474    /*
475    DPCT1049: The work-group size passed to the SYCL kernel may exceed the
476    limit. To get the device limit, query info::device::max_work_group_size.
477    Adjust the work-group size if needed.
478    */
479    {
480        auto exp_props = sycl::ext::oneapi::experimental::properties{
481            sycl::ext::oneapi::experimental::use_root_sync};
482
483        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class rms_rep_kernel_e4e0bd>>(
484            sycl::nd_range<3>(sycl::range(1, 1, rows) * sycl::range(1, 1, 1024),
485                              sycl::range(1, 1, 1024)),
486            exp_props,
487            [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(32)]] {
488                rms_rep_kernel(gated, w.norm_conv, query_norm);
489            });
490    }
491    {
492        auto exp_props = sycl::ext::oneapi::experimental::properties{
493            sycl::ext::oneapi::experimental::use_root_sync};
494
495        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<
496            dpct_kernel_name<class conv_residual_batch_kernel_3906fe>>(
497            sycl::nd_range<3>(sycl::range(1, 1, blocks) *
498                                  sycl::range(1, 1, 256),
499                              sycl::range(1, 1, 256)),
500            exp_props, [=](sycl::nd_item<3> item_ct1) {
501                conv_residual_batch_kernel(history, query_norm, w.conv1d_f16,
502                                           hidden, gated, T);
503            });
504    }
505    {
506        auto exp_props = sycl::ext::oneapi::experimental::properties{
507            sycl::ext::oneapi::experimental::use_root_sync};
508
509        strata::kprof::kp(st, __FILE__, __func__, __LINE__)->template parallel_for<dpct_kernel_name<class history_batch_kernel_8243c6>>(
510            sycl::nd_range<3>(sycl::range(1, 1, D / 256) *
511                                  sycl::range(1, 1, 256),
512                              sycl::range(1, 1, 256)),
513            exp_props, [=](sycl::nd_item<3> item_ct1) {
514                history_batch_kernel(history, query_norm, T);
515            });
516    }
517    launch_check();
518}
519} // namespace strata::kernels