okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
db137d917
main
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 48for (int offset = 16 ;offset ;offset >>=1 )x += 49 dpct::experimental::permute_sub_group_by_xor ( 500xffffffffu , sycl::ext::oneapi::this_work_item::get_sub_group (),x , 51offset ); 52return x ; 53} 54__dpct_inline__ void gate_kernel (const float * key ,const float * query , 55float * 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). 58auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 59float sums [8 ]= {}; 60#pragma unroll 61for (int j = 0 ;j < 8 ;++ j ) { 62const int d = item_ct1 .get_local_id (2 )+ j * 512 ; 63/* 64DPCT1013: The rounding mode could not be specified and the generated 65code may have different accuracy than the original code. Verify the 66correctness. SYCL math built-in function rounding mode is aligned with 67OpenCL C 1.2 standard. 68*/ 69const float p = d < N ?key [item_ct1 .get_group (2 )* N + d ]* 70query [item_ct1 .get_group (2 )* N + d ] 71 :0.0f ; 72sums [j ]+= p ; 73 } 74float sum = 0 ; 75#pragma unroll 76for (int j = 0 ;j < 8 ;++ j )sum += sums [j ]; 77auto & partials = 78* sycl::ext::oneapi::group_local_memory_for_overwrite < float [32 ]> ( 79 sycl::ext::oneapi::this_work_item::get_work_group < 3 > ()); 80sum = warp_sum (sum ); 81const int lane = item_ct1 .get_local_id (2 ) %32 ; 82if (!lane )partials [item_ct1 .get_local_id (2 ) /32 ]= sum ; 83item_ct1 .barrier (sycl::access::fence_space::local_space ); 84sum = lane < 16 ?partials [lane ] :0.0f ; 85sum = warp_sum (sum ); 86if (item_ct1 .get_local_id (2 )== 0 ) { 87/* 88DPCT1013: The rounding mode could not be specified and the generated 89code may have different accuracy than the original code. Verify the 90correctness. SYCL math built-in function rounding mode is aligned with 91OpenCL C 1.2 standard. 92*/ 93const float s = sycl::fma (scale ,sum ,0.0f );// ggml SCALE's zero bias 94const float mag = sycl::sqrt (sycl::fmax (sycl::fabs (s ),1e-6f )); 95const float sign = float ((s > 0.0f )- (s < 0.0f )); 96/* 97DPCT1013: The rounding mode could not be specified and the generated 98code may have different accuracy than the original code. Verify the 99correctness. SYCL math built-in function rounding mode is aligned with 100OpenCL C 1.2 standard. 101*/ 102gate [item_ct1 .get_group (2 )]= 1031.0f / (1.0f + sycl::native::exp (- sign * mag )); 104 } 105} 106__dpct_inline__ void broadcast_kernel (const float * value ,const float * gate , 107float * gated ) { 108auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 109const int i = item_ct1 .get_group (2 )* item_ct1 .get_local_range (2 )+ 110item_ct1 .get_local_id (2 ); 111/* 112DPCT1013: The rounding mode could not be specified and the generated 113code may have different accuracy than the original code. Verify the 114correctness. SYCL math built-in function rounding mode is aligned with 115OpenCL C 1.2 standard. 116*/ 117if (i < D )gated [i ]= value [i %N ]* gate [i /N ]; 118} 119__dpct_inline__ void 120conv_residual_kernel (const float * history ,const float * normalized , 121const uint16_t * weights ,const float * hidden , 122const float * gated ,float * conv ,float * result ) { 123auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 124const int c = item_ct1 .get_group (2 )* item_ct1 .get_local_range (2 )+ 125item_ct1 .get_local_id (2 ); 126if (c >=D )return ; 127float sum = 0 ; 128#pragma unroll 129for (int k = 0 ;k < 4 ;++ k ) { 130const float x = k == 3 ?normalized [c ] :history [c * HISTORY + 3 * k ]; 131const 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/* 136DPCT1013: The rounding mode could not be specified and the generated 137code may have different accuracy than the original code. Verify the 138correctness. SYCL math built-in function rounding mode is aligned with 139OpenCL C 1.2 standard. 140*/ 141const float term = x * w ; 142/* 143DPCT1013: The rounding mode could not be specified and the generated 144code may have different accuracy than the original code. Verify the 145correctness. SYCL math built-in function rounding mode is aligned with 146OpenCL C 1.2 standard. 147*/ 148sum = k == 0 ?term :sum + term ; 149 } 150const float activation = sum / (1.0f + sycl::native::exp (- sum )); 151conv [c ]= activation ; 152// Exact hidden/result alias is safe: each thread owns one element. 153/* 154DPCT1013: The rounding mode could not be specified and the generated 155code may have different accuracy than the original code. Verify the 156correctness. SYCL math built-in function rounding mode is aligned with 157OpenCL C 1.2 standard. 158*/ 159result [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/* 166DPCT1108: '__shfl_xor_sync' was migrated with the experimental feature 167masked sub_group function which may not be supported by all compilers or 168runtimes. You may need to adjust the code. 169*/ 170for (int offset = 16 ;offset > 0 ;offset >>=1 )value += 171 dpct::experimental::permute_sub_group_by_xor ( 1720xffffffffu , sycl::ext::oneapi::this_work_item::get_sub_group (), 173value ,offset ); 174return value ; 175} 176__dpct_inline__ void rms_rep_kernel (const float * __restrict__input , 177const float * __restrict__gamma , 178float * __restrict__output ) { 179auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 180constexpr int BlockSize = 1811024 ;// native_gr_rms_norm_weighted's choice for 2560 columns 182const int tid = item_ct1 .get_local_id (2 ); 183const size_t row_offset = size_t (item_ct1 .get_group (2 ))* N ; 184input += row_offset ; 185output += row_offset ; 186gamma += size_t (item_ct1 .get_group (2 ) %H )* N ; 187float partial = 0.0f ; 188for (int col = tid ;col < N ;col += BlockSize ) { 189const float value = input [col ]; 190partial += value * value ; 191 } 192auto & sums = 193* sycl::ext::oneapi::group_local_memory_for_overwrite < float [32 ]> ( 194 sycl::ext::oneapi::this_work_item::get_work_group < 3 > ()); 195partial = norm_warp_sum (partial ); 196const int lane = tid %32 ; 197if (lane == 0 )sums [tid /32 ]= partial ; 198item_ct1 .barrier (sycl::access::fence_space::local_space ); 199partial = 0.0f ; 200if (lane < BlockSize /32 )partial = sums [lane ]; 201partial = norm_warp_sum (partial ); 202const float mean = partial /N ; 203const float scale = sycl::rsqrt (mean + NG_RMS_EPS ); 204#pragma unroll 205for (int col = tid ;col < N ;col += BlockSize ) 206output [col ]= scale * input [col ]* gamma [col ]; 207} 208__dpct_inline__ void broadcast_batch_kernel (const float * value , 209const float * gate ,float * gated , 210int T ) { 211auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 212const size_t i = 213size_t (item_ct1 .get_group (2 ))* item_ct1 .get_local_range (2 )+ 214item_ct1 .get_local_id (2 ); 215if (i >=size_t (T )* D )return ; 216const size_t t = i /D ,d = i %D ; 217/* 218DPCT1013: The rounding mode could not be specified and the generated 219code may have different accuracy than the original code. Verify the 220correctness. SYCL math built-in function rounding mode is aligned with 221OpenCL C 1.2 standard. 222*/ 223gated [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 , 227const float * normalized , 228const uint16_t * weights , 229float * hidden , 230const float * gated ,int T ) { 231auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 232const size_t i = 233size_t (item_ct1 .get_group (2 ))* item_ct1 .get_local_range (2 )+ 234item_ct1 .get_local_id (2 ); 235if (i >=size_t (T )* D )return ; 236const int t = int (i /D ),c = int (i %D ); 237float sum = 0 ; 238#pragma unroll 239for (int k = 0 ;k < 4 ;++ k ) { 240const int p = t - 9 + 3 * k ;// the token this tap reads (k == 3: this one) 241const float x = p >=0 ?normalized [size_t (p )* D + c ] :history [size_t (c )* HISTORY + (9 + p )]; 242const 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/* 247DPCT1013: The rounding mode could not be specified and the generated 248code may have different accuracy than the original code. Verify the 249correctness. SYCL math built-in function rounding mode is aligned with 250OpenCL C 1.2 standard. 251*/ 252const float term = x * wk ; 253/* 254DPCT1013: The rounding mode could not be specified and the generated 255code may have different accuracy than the original code. Verify the 256correctness. SYCL math built-in function rounding mode is aligned with 257OpenCL C 1.2 standard. 258*/ 259sum = k == 0 ?term :sum + term ; 260 } 261const float activation = sum / (1.0f + sycl::native::exp (- sum )); 262/* 263DPCT1013: The rounding mode could not be specified and the generated 264code may have different accuracy than the original code. Verify the 265correctness. SYCL math built-in function rounding mode is aligned with 266OpenCL C 1.2 standard. 267*/ 268hidden [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 , 272const float * normalized ,int T ) { 273auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item < 3 > (); 274const int c = item_ct1 .get_group (2 )* item_ct1 .get_local_range (2 )+ 275item_ct1 .get_local_id (2 ); 276if (c >=D )return ; 277float h [HISTORY ]; 278#pragma unroll 279for (int r = 0 ;r < HISTORY ;++ r ) { 280const int p = T - HISTORY + r ; 281h [r ]= p >=0 ?normalized [size_t (p )* D + c ] :history [size_t (c )* HISTORY + (T + r )]; 282 } 283#pragma unroll 284for (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 ) { 289const auto x = reinterpret_cast < uintptr_t > (a .p ),y = reinterpret_cast < uintptr_t > (b .p ); 290return x < y + b .bytes && y < x + a .bytes ; 291} 292void validate (Span span ) { 293const auto p = reinterpret_cast < uintptr_t > (span .p ); 294if (!p || p %span .alignment || p > std::numeric_limits < uintptr_t > ::max ()- span .bytes ) 295throw std::invalid_argument ("native PLE postops require nonnull aligned bounded spans" ); 296} 297void launch_check () { 298/* 299DPCT1010: SYCL uses exceptions to report errors and does not use the 300error codes. The cudaGetLastError function call was replaced with 0. You 301need to rewrite this code. 302*/ 303const auto error = 0 ; 304/* 305DPCT1009: SYCL reports errors using exceptions and does not use error 306codes. Please replace the "get_error_string_dummy(...)" with a real 307error-handling function. 308*/ 309/* 310DPCT1001: The statement could not be removed. 311*/ 312/* 313DPCT1000: Error handling if-stmt was detected but could not be 314rewritten. 315*/ 316if (error != 3170 )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 , 323const float * value ,const float * history , 324const PleWeights & w ,const NativePlePostopsBuffers & b ,void * stream ) { 325if (!stream )throw std::invalid_argument ("native PLE postops require an explicit stream" ); 326const 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 }}; 329const 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 }}; 331for (const auto & span :inputs )validate (span ); 332for (const auto & span :outputs )validate (span ); 333for (size_t i = 0 ;i < 7 ;++ i ) { 334for (size_t j = 0 ;j < 8 ;++ j ) 335if (!(i == 6 && j == 1 && b .result == hidden )&& overlaps (outputs [i ],inputs [j ])) 336throw std::invalid_argument ("native PLE postops output overlaps an input or weight" ); 337for (size_t j = i + 1 ;j < 7 ;++ j ) 338if (!(i == 1 && j == 4 && b .query == b .normalized )&& overlaps (outputs [i ],outputs [j ])) 339throw std::invalid_argument ("native PLE postops writable spans overlap" ); 340 } 341native_gr_rms_norm_weighted (projected_key ,w .norm_key ,b .key ,N ,H ,NG_RMS_EPS ,stream ); 342native_gr_rms_norm_weighted (hidden ,w .norm_query ,b .query ,N ,H ,NG_RMS_EPS ,stream ); 343auto st = strata::q_of (stream ); 344/* 345DPCT1049: The work-group size passed to the SYCL kernel may exceed the 346limit. To get the device limit, query info::device::max_work_group_size. 347Adjust the work-group size if needed. 348*/ 349 { 350auto 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 ) { 354auto std_sqrt_float_N_ct3 = 1.0f / std::sqrt (float (N )); 355 356cgh .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 )), 359exp_props , 360 [= ](sycl::nd_item < 3 > item_ct1 ) 361 [[sycl ::reqd_sub_group_size (32 )]] { 362gate_kernel (b .key ,b .query ,b .gate , 363std_sqrt_float_N_ct3 ); 364 }); 365 }); 366 } 367 { 368auto 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 )), 375exp_props , [= ](sycl::nd_item < 3 > item_ct1 ) { 376broadcast_kernel (value ,b .gate ,b .gated ); 377 }); 378 } 379launch_check (); 380native_gr_rms_norm_weighted (b .gated ,w .norm_conv ,b .normalized ,N ,H ,NG_RMS_EPS ,stream ); 381 { 382auto 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 )), 389exp_props , [= ](sycl::nd_item < 3 > item_ct1 ) { 390conv_residual_kernel (history ,b .normalized ,w .conv1d_f16 , 391hidden ,b .gated ,b .conv ,b .result ); 392 }); 393 } 394launch_check (); 395} 396 397void native_ple_postops_batch (float * key ,float * hidden ,const float * value ,float * history ,const PleWeights & w , 398float * query_norm ,float * gated ,float * gate ,int T ,void * stream ) { 399if (!stream || T <=0 || !key || !hidden || !value || !history || !query_norm || !gated || !gate ) 400throw std::invalid_argument ("native PLE postops batch: null input or empty batch" ); 401auto st = strata::q_of (stream ); 402const unsigned rows = unsigned (T )* H ; 403const unsigned blocks = unsigned ((size_t (T )* D + 255 ) /256 ); 404/* 405DPCT1049: The work-group size passed to the SYCL kernel may exceed the 406limit. To get the device limit, query info::device::max_work_group_size. 407Adjust the work-group size if needed. 408*/ 409 { 410auto 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 )), 416exp_props , 417 [= ](sycl::nd_item < 3 > item_ct1 ) [[sycl ::reqd_sub_group_size (32 )]] { 418rms_rep_kernel (key ,w .norm_key ,key ); 419 }); 420 } 421/* 422DPCT1049: The work-group size passed to the SYCL kernel may exceed the 423limit. To get the device limit, query info::device::max_work_group_size. 424Adjust the work-group size if needed. 425*/ 426 { 427auto 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 )), 433exp_props , 434 [= ](sycl::nd_item < 3 > item_ct1 ) [[sycl ::reqd_sub_group_size (32 )]] { 435rms_rep_kernel (hidden ,w .norm_query ,query_norm ); 436 }); 437 } 438/* 439DPCT1049: The work-group size passed to the SYCL kernel may exceed the 440limit. To get the device limit, query info::device::max_work_group_size. 441Adjust the work-group size if needed. 442*/ 443 { 444auto 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 ) { 448auto std_sqrt_float_N_ct3 = 1.0f / std::sqrt (float (N )); 449 450cgh .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 )), 454exp_props , 455 [= ](sycl::nd_item < 3 > item_ct1 ) 456 [[sycl ::reqd_sub_group_size (32 )]] { 457gate_kernel (key ,query_norm ,gate , 458std_sqrt_float_N_ct3 ); 459 }); 460 }); 461 } 462 { 463auto 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 )), 470exp_props , [= ](sycl::nd_item < 3 > item_ct1 ) { 471broadcast_batch_kernel (value ,gate ,gated ,T ); 472 }); 473 } 474/* 475DPCT1049: The work-group size passed to the SYCL kernel may exceed the 476limit. To get the device limit, query info::device::max_work_group_size. 477Adjust the work-group size if needed. 478*/ 479 { 480auto 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 )), 486exp_props , 487 [= ](sycl::nd_item < 3 > item_ct1 ) [[sycl ::reqd_sub_group_size (32 )]] { 488rms_rep_kernel (gated ,w .norm_conv ,query_norm ); 489 }); 490 } 491 { 492auto 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 < 496dpct_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 )), 500exp_props , [= ](sycl::nd_item < 3 > item_ct1 ) { 501conv_residual_batch_kernel (history ,query_norm ,w .conv1d_f16 , 502hidden ,gated ,T ); 503 }); 504 } 505 { 506auto 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 )), 513exp_props , [= ](sycl::nd_item < 3 > item_ct1 ) { 514history_batch_kernel (history ,query_norm ,T ); 515 }); 516 } 517launch_check (); 518} 519}// namespace strata::kernels