okami.mom/strata

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

Niko1221Merge f-037-arc (5eaee81a4)86bed1c92

main
21.8 KiB475 linesraw
1// src/kernels/cuda/quantize_act.cu - P2.S2: quantize an activation the way ggml converts src1.
2//
3// WHY THIS EXISTS AT ALL.  `ggml_mul_mat` converts the ACTIVATION (src1) to the weight's `vec_dot_type`
4// before the dot product - the rule established over rounds 119-136 and written into `ref/quant.py` as
5// `apply_src1`.  The CPU expert path already honours it (`bench/micro/cpu_s2.cpp` quantizes to int8 and uses
6// `vpdpbusd`), and its P0.T2 parity passes at 1.461e-06.  The GPU kernels added in rounds 166-177 take FP16
7// activations instead.  **Left that way, the two paths would compute different numbers for different experts
8// of the SAME token** - not a tolerance question, an inconsistency inside one forward pass.
9//
10// Q2_0 IS THE CASE THAT MATTERS: the routed experts are all Q2_0, `Q2_0 -> Q8_0`, and that is 31.64 GiB of the
11// 38 GiB pack.  Q8_K (for the K-quants and IQ4_XS) is the other half of the table and is not here yet.
12//
13// THE THREE SUBTLETIES, each of which was paid for once already and is transcribed rather than recalled:
14//
15//   1. `d32 = amax / 127.0f` is computed in FP32, and the QUANTIZED INTEGERS divide by **d32**, not by the
16//      fp16-rounded value that gets stored.  Conflating the two shifts every quant near a rounding boundary -
17//      measured against ggml's own bytes, 18 of 80 blocks differed, and because Q2_0 experts convert to Q8_0
18//      the error landed in all 48 MoE blocks and made the end-to-end KL WORSE.
19//   2. The reference divides in FLOAT64 (`blk.astype(np.float64) / float(np.float32(d32))`) and rounds with
20//      `rint` - half to even.  This kernel therefore divides in double too: an FP32 division followed by
21//      `rintf` differs from the reference wherever the f32 quotient rounds across a .5 boundary.
22//   3. The DEQUANTIZED value is `q * d16`, the fp16 scale, not `q * d32`.  The block stores fp16 and that is
23//      what a reader multiplies by.
24#define DPCT_PROFILING_ENABLED
25#include <sycl/sycl.hpp>
26#include "strata/kprof.hpp"
27#include <dpct/dpct.hpp>
28#include "strata/sycl_queue.hpp"
29#include "strata/kernels/quantize_act.hpp"
30#include "strata/kernels/f16_bits.hpp"
31
32#include <cmath>
33#include <cstdio>
34#include <cstdlib>
35
36namespace strata::kernels {
37namespace {
38
39constexpr int QK8_0 = 32;
40
41// THE fp16 CONVERSION LIVES IN `strata/kernels/f16_bits.hpp`, and this file used to carry its own copy.
42//
43// Round 198 found the private copy wrong in a way no fixture here could see: it tested `if (exp >= 31)` to
44// detect an out-of-range exponent, which conflates an f32 INF/NAN (raw exponent 255) with a FINITE value too
45// large for fp16.  Every finite overflow - 1e30, 65536, 1e45 - came back as a NaN instead of saturating to
46// inf, and this file's fixture is O(1) throughout, so it passed.  A numpy-generated oracle caught it on its
47// first run.  Three copies of a converter whose failure mode is silent wrong bits was two copies too many.
48
49__dpct_inline__ void quantize_q8_0_kernel(const float *__restrict__ x,
50                                          uint8_t *__restrict__ blocks,
51                                          long long n_blocks) {
52    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
53    const long long b =
54        (long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
55        item_ct1.get_local_id(2);
56    if (b >= n_blocks) return;
57    const float* xb = x + b * QK8_0;
58    uint8_t* out = blocks + b * 34;                 // { fp16 d ; int8 qs[32] }
59
60    float amax = 0.0f;
61#pragma unroll
62    for (int i = 0; i < QK8_0; ++i) amax = sycl::fmax(amax, sycl::fabs(xb[i]));
63    if (amax == 0.0f) {
64        // ggml leaves the block zeroed: d = 0 and every q = 0.  Writing the fp16 zero explicitly rather than
65        // skipping keeps the block layout deterministic for the byte comparison.
66        const uint16_t zb = f16_from_f32(0.0f);
67        out[0] = (uint8_t) (zb & 0xFF);
68        out[1] = (uint8_t) (zb >> 8);
69#pragma unroll
70        for (int i = 0; i < QK8_0; ++i) out[2 + i] = 0;
71        return;
72    }
73    const float d32 = amax / 127.0f;
74    const uint16_t d16bits = f16_from_f32(d32);
75    out[0] = (uint8_t) (d16bits & 0xFF);
76    out[1] = (uint8_t) (d16bits >> 8);
77
78    // double division, matching the reference exactly (subtlety 2)
79    for (int i = 0; i < QK8_0; ++i) {
80        double q = sycl::rint((double)xb[i] / (double)d32);
81        if (q > 127.0) q = 127.0;
82        if (q < -128.0) q = -128.0;
83        out[2 + i] = (uint8_t) (int8_t) q;
84    }
85}
86
87/// **THE HIT PATH'S QUANTIZER, AND IT EXISTS TO REPRODUCE `act_quant_q8_1` EXACTLY (R4.2h, round 331).**
88///
89/// The engine computes every routed expert twice.  MISSES go through `cpu/expert.cpp:138 act_quant_q8_1`
90/// into the VNNI kernel; HITS went through `quantize_q8_0` above.  **Those are not the same quantization**,
91/// and round 330 measured the difference with both real implementations linked
92/// (`bench/micro/act_quant_parity.cu`):
93///
94///     int8 activations differing : 0 of 2560                       <- this rule's ties are measure-zero
95///     chunks whose SCALE differs : 80 of 80, max rel 4.761e-04     <- 2^-11: fp32 vs the block's fp16
96///
97/// The scale is the difference that matters: `ActQ::scale` is `float` and the CPU kernel multiplies by it
98/// (`expert.cpp:92`), while `row_dot_s2_q8` read `f16_at(xb)` out of the `block_q8_0`.  So this variant
99/// writes the SAME 34-byte blocks (the kernel's indexing is unchanged) **and** a parallel fp32 scale array
100/// carrying `d32` unrounded.
101///
102/// It also adopts the CPU's ROUNDING RULE - multiply by the reciprocal, round half AWAY FROM ZERO - rather
103/// than this file's `rint`.  That is deliberate and it is the opposite of the direction the comment above
104/// argues for.  `quantize_q8_0` was tuned to match **ggml's Q8_0 bytes**, which is right for the pack and for
105/// `moe_hit_parity`.  This function's job is different: it must match **this engine's own CPU reference**,
106/// because a hit and a miss for the same expert on the same layer have to produce the same number.  The CPU
107/// path is the reference - C1 passes on it - so the hit path is brought to it, not the reverse.
108#if defined(__HIPCC__)   // AMD keeps the thread-a-block kernel
109__global__ void quantize_q8_0_scaled_kernel(const float* __restrict__ x, uint8_t* __restrict__ blocks,
110                                            float* __restrict__ scales, long long n_blocks) {
111    const long long b = (long long) blockIdx.x * blockDim.x + threadIdx.x;
112    if (b >= n_blocks) return;
113    const float* xb = x + b * QK8_0;
114    uint8_t* out = blocks + b * 34;
115
116    float amax = 0.0f;
117    for (int i = 0; i < QK8_0; ++i) amax = fmaxf(amax, fabsf(xb[i]));
118    // VERBATIM from `cpu/expert.cpp:144-145`, including the `amax > 0` guard, so the fp32 value written here
119    // is bit-identical to the `s` the CPU path used.
120    const float s = amax > 0.f ? amax / 127.f : 0.f;
121    const float inv = s > 0.f ? 1.f / s : 0.f;
122    scales[b] = s;
123
124    const uint16_t d16bits = f16_from_f32(s);
125    out[0] = (uint8_t) (d16bits & 0xFF);
126    out[1] = (uint8_t) (d16bits >> 8);
127    for (int i = 0; i < QK8_0; ++i) {
128        // VERBATIM from `cpu/expert.cpp:159-162`: reciprocal multiply, then `t + copysign(0.5, t)` truncated
129        // toward zero, which is `lround`'s rule - round half away from zero.
130        const float t = xb[i] * inv;
131        const float r = t + (t >= 0.f ? 0.5f : -0.5f);
132        int v = (int) r;
133        v = v < -127 ? -127 : (v > 127 ? 127 : v);
134        out[2 + i] = (uint8_t) (int8_t) v;
135    }
136}
137
138#else
139// A warp a block, lane i on value i: the block's |max| is a max over the same values (0 for none above it, as the
140// serial scan from 0 through fmaxf), so every byte is the per-thread loop's.
141__dpct_inline__ void quantize_q8_0_scaled_kernel(const float *__restrict__ x,
142                                                 uint8_t *__restrict__ blocks,
143                                                 float *__restrict__ scales,
144                                                 long long n_blocks) {
145    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
146    const long long b =
147        ((long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
148         item_ct1.get_local_id(2)) >>
149        5;
150    const int i = (int)(item_ct1.get_local_id(2) & 31);
151    if (b >= n_blocks) return;
152    const float xi = x[b * QK8_0 + i];
153    uint8_t* out = blocks + b * 34;
154
155    float amax = sycl::fmax(0.0f, sycl::fabs(xi));
156    /*
157DPCT1108: '__shfl_xor_sync' was migrated with the experimental feature
158masked sub_group function which may not be supported by all compilers or
159runtimes. You may need to adjust the code.
160*/
161#pragma unroll
162    for (int o = 16; o > 0; o >>= 1) amax = sycl::fmax(
163        amax, dpct::experimental::permute_sub_group_by_xor(
164                  0xffffffffu,
165                  sycl::ext::oneapi::this_work_item::get_sub_group(), amax, o));
166    // VERBATIM from `cpu/expert.cpp:144-145`, including the `amax > 0` guard, so the fp32 value written here
167    // is bit-identical to the `s` the CPU path used.
168    const float s = amax > 0.f ? amax / 127.f : 0.f;
169    const float inv = s > 0.f ? 1.f / s : 0.f;
170    if (i == 0) {
171        scales[b] = s;
172        const uint16_t d16bits = f16_from_f32(s);
173        out[0] = (uint8_t) (d16bits & 0xFF);
174        out[1] = (uint8_t) (d16bits >> 8);
175    }
176    // VERBATIM from `cpu/expert.cpp:159-162`: reciprocal multiply, then `t + copysign(0.5, t)` truncated
177    // toward zero, which is `lround`'s rule - round half away from zero.
178    const float t = xi * inv;
179    const float r = t + (t >= 0.f ? 0.5f : -0.5f);
180    int v = (int) r;
181    v = v < -127 ? -127 : (v > 127 ? 127 : v);
182    out[2 + i] = (uint8_t) (int8_t) v;
183}
184
185#endif
186
187__dpct_inline__ void dequant_q8_0_kernel(const uint8_t *__restrict__ blocks,
188                                         float *__restrict__ x,
189                                         long long n_blocks) {
190    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
191    const long long b =
192        (long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
193        item_ct1.get_local_id(2);
194    if (b >= n_blocks) return;
195    const uint8_t* blk = blocks + b * 34;
196    const uint16_t dbits = (uint16_t) (blk[0] | (blk[1] << 8));
197    const float d = f32_from_f16(dbits);
198    float* out = x + b * QK8_0;
199#pragma unroll
200    for (int i = 0; i < QK8_0; ++i) out[i] = (float)(int8_t)blk[2 + i] * d;
201}
202
203// ===================== Q8_K =====================
204//
205// `block_q8_K` = { float d ; int8_t qs[256] ; int16_t bsums[16] } = 292 bytes, no padding
206// (`static_assert` in ggml-common.h).  QK_K = 256.
207
208constexpr int QK_K = 256;
209constexpr int Q8K_BYTES = 292;
210
211/// ggml's `nearest_int` (ggml-quants.c L621), transcribed rather than replaced.
212///
213/// The magic number is 1.5 * 2^23: adding it forces the mantissa's integer part into the low bits, and the
214/// mask/subtract recover it.  The reason it is transcribed and not written as `rintf` is that the two differ
215/// on exact ties - and that is the whole point of the constant, so a "cleaner" rewrite would silently change
216/// which way ties go.
217__dpct_inline__ int nearest_int_dev(float fval) {
218    const float val = fval + 12582912.0f;
219    int i;
220    memcpy(&i, &val, 4);
221    return (i & 0x007fffff) - 0x00400000;
222}
223
224__dpct_inline__ void quantize_q8_K_kernel(const float *__restrict__ x,
225                                          uint8_t *__restrict__ blocks,
226                                          long long n_blocks) {
227    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
228    const long long b =
229        (long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
230        item_ct1.get_local_id(2);
231    if (b >= n_blocks) return;
232    const float* xb = x + b * QK_K;
233    uint8_t* out = blocks + b * Q8K_BYTES;
234    float* d = (float*) out;
235    int8_t* qs = (int8_t*) (out + 4);
236    int16_t* bsums = (int16_t*) (out + 4 + QK_K);
237
238    // `max` is the SIGNED value at the largest magnitude position, and the comparison is STRICTLY greater,
239    // so a tie keeps the FIRST maximum - which is what `np.argmax` does in the reference transcription too.
240    float max = 0.0f, amax = 0.0f;
241    for (int j = 0; j < QK_K; ++j) {
242        const float ax = sycl::fabs(xb[j]);
243        if (ax > amax) {
244            amax = ax;
245            max = xb[j];
246        }
247    }
248    if (amax == 0.0f) {
249        // ggml writes d = 0 and zeroes qs, then `continue`s - which LEAVES bsums UNWRITTEN.  A zeroed block
250        // and an untouched one are indistinguishable to the dot product, but not to a byte comparison, so
251        // this zeroes bsums as well and the parity test's reference does the same.  Recorded because it is a
252        // deliberate divergence from the letter of the source.
253        *d = 0.0f;
254#pragma unroll
255        for (int j = 0; j < QK_K; ++j) qs[j] = 0;
256#pragma unroll
257        for (int j = 0; j < QK_K / 16; ++j) bsums[j] = 0;
258        return;
259    }
260    const float iscale = -127.0f / max;          // -127, NOT -128; see the header
261    for (int j = 0; j < QK_K; ++j) {
262        // `__fmul_rn`, NOT `iscale * xb[j]`.  ggml computes the product, ROUNDS IT TO F32, and then adds
263        // 12582912.0f inside `nearest_int`.  Written as a plain expression, nvcc CONTRACTS the multiply into
264        // the add as an FMA - which is a more accurate product but not the same one, and it flips the result
265        // wherever the true product sits just off a .5 boundary.  The first version of this kernel differed
266        // from the reference in 1 element of 524,288 for exactly this reason, and `__fmul_rn` pins the
267        // rounding step the source actually performs.
268        /*
269        DPCT1013: The rounding mode could not be specified and the generated
270        code may have different accuracy than the original code. Verify the
271        correctness. SYCL math built-in function rounding mode is aligned with
272        OpenCL C 1.2 standard.
273        */
274        const int v = nearest_int_dev(iscale * xb[j]);
275        qs[j] = (int8_t)sycl::min(
276            127, v); // MIN only - the source has no lower clamp
277    }
278    for (int j = 0; j < QK_K / 16; ++j) {
279        int sum = 0;
280#pragma unroll
281        for (int ii = 0; ii < 16; ++ii) sum += qs[j * 16 + ii];
282        bsums[j] = (int16_t) sum;
283    }
284    *d = 1.0f / iscale;
285}
286
287__dpct_inline__ void dequant_q8_K_kernel(const uint8_t *__restrict__ blocks,
288                                         float *__restrict__ x,
289                                         long long n_blocks) {
290    auto item_ct1 = sycl::ext::oneapi::this_work_item::get_nd_item<3>();
291    const long long b =
292        (long long)item_ct1.get_group(2) * item_ct1.get_local_range(2) +
293        item_ct1.get_local_id(2);
294    if (b >= n_blocks) return;
295    const uint8_t* blk = blocks + b * Q8K_BYTES;
296    float d;
297    memcpy(&d, blk, 4);
298    const int8_t* qs = (const int8_t*) (blk + 4);
299    float* out = x + b * QK_K;
300#pragma unroll
301    for (int i = 0; i < QK_K; ++i) out[i] = (float)qs[i] * d;
302}
303
304}  // namespace
305
306void quantize_q8_0(const float* x, uint8_t* blocks, int64_t n, void* stream) {
307    if (n <= 0) return;
308    if (n % QK8_0 != 0) {
309        std::fprintf(stderr, "quantize_q8_0: n %lld is not a multiple of %d\n", (long long) n, QK8_0);
310        std::exit(1);
311    }
312    const long long nb = n / QK8_0;
313    const int threads = 128;
314    const unsigned grid = (unsigned) ((nb + threads - 1) / threads);
315    {
316        auto exp_props = sycl::ext::oneapi::experimental::properties{
317            sycl::ext::oneapi::experimental::use_root_sync};
318        dpct::has_capability_or_fail(
319            strata::q_of(stream)->get_device(),
320            {sycl::aspect::fp64});
321
322        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
323            ->template parallel_for<dpct_kernel_name<class quantize_q8_0_kernel_5451b9>>(
324                sycl::nd_range<3>(sycl::range(1, 1, grid) *
325                                      sycl::range(1, 1, threads),
326                                  sycl::range(1, 1, threads)),
327                exp_props, [=](sycl::nd_item<3> item_ct1) {
328                    quantize_q8_0_kernel(x, blocks, nb);
329                });
330    }
331    /*
332    DPCT1010: SYCL uses exceptions to report errors and does not use the
333    error codes. The cudaGetLastError function call was replaced with 0. You
334    need to rewrite this code.
335    */
336    const dpct::err0 e = 0;
337
338    if (stream == nullptr) dpct::get_current_device().queues_wait_and_throw();
339}
340
341/// See `quantize_q8_0_scaled_kernel`.  Writes the same 34-byte `block_q8_0` layout as `quantize_q8_0`, plus
342/// `scales[n/32]` carrying the fp32 `s` the CPU path used - so a hit can be computed with the CPU's
343/// multiplier instead of the block's fp16 `d`.  `scales` must not be null.
344void quantize_q8_0_scaled(const float* x, uint8_t* blocks, float* scales, int64_t n, void* stream) {
345    if (n <= 0) return;
346    if (n % QK8_0 != 0) {
347        std::fprintf(stderr, "quantize_q8_0_scaled: n %lld is not a multiple of %d\n", (long long) n, QK8_0);
348        std::exit(1);
349    }
350    if (scales == nullptr) {
351        std::fprintf(stderr, "quantize_q8_0_scaled: scales is null\n");
352        std::exit(1);
353    }
354    const long long nb = n / QK8_0;
355    const int threads = 128;
356#if defined(__HIPCC__)
357    const unsigned grid = (unsigned) ((nb + threads - 1) / threads);
358#else
359    const unsigned grid = (unsigned) ((nb + threads / 32 - 1) / (threads / 32));   // a warp a block
360#endif
361    {
362        auto exp_props = sycl::ext::oneapi::experimental::properties{
363            sycl::ext::oneapi::experimental::use_root_sync};
364
365        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
366            ->template parallel_for<
367                dpct_kernel_name<class quantize_q8_0_scaled_kernel_caf6f4>>(
368                sycl::nd_range<3>(sycl::range(1, 1, grid) *
369                                      sycl::range(1, 1, threads),
370                                  sycl::range(1, 1, threads)),
371                exp_props,
372                [=](sycl::nd_item<3> item_ct1)
373                    [[sycl::reqd_sub_group_size(32)]] {
374                        quantize_q8_0_scaled_kernel(x, blocks, scales, nb);
375                    });
376    }
377    /*
378    DPCT1010: SYCL uses exceptions to report errors and does not use the
379    error codes. The cudaGetLastError function call was replaced with 0. You
380    need to rewrite this code.
381    */
382    const dpct::err0 e = 0;
383
384    if (stream == nullptr) dpct::get_current_device().queues_wait_and_throw();
385}
386
387void dequant_q8_0(const uint8_t* blocks, float* x, int64_t n, void* stream) {
388    if (n <= 0) return;
389    const long long nb = n / QK8_0;
390    const int threads = 128;
391    const unsigned grid = (unsigned) ((nb + threads - 1) / threads);
392    {
393        auto exp_props = sycl::ext::oneapi::experimental::properties{
394            sycl::ext::oneapi::experimental::use_root_sync};
395
396        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
397            ->template parallel_for<dpct_kernel_name<class dequant_q8_0_kernel_154e61>>(
398                sycl::nd_range<3>(sycl::range(1, 1, grid) *
399                                      sycl::range(1, 1, threads),
400                                  sycl::range(1, 1, threads)),
401                exp_props, [=](sycl::nd_item<3> item_ct1) {
402                    dequant_q8_0_kernel(blocks, x, nb);
403                });
404    }
405    /*
406    DPCT1010: SYCL uses exceptions to report errors and does not use the
407    error codes. The cudaGetLastError function call was replaced with 0. You
408    need to rewrite this code.
409    */
410    const dpct::err0 e = 0;
411
412    if (stream == nullptr) dpct::get_current_device().queues_wait_and_throw();
413}
414
415void quantize_q8_K(const float* x, uint8_t* blocks, int64_t n, void* stream) {
416    if (n <= 0) return;
417    if (n % QK_K != 0) {
418        std::fprintf(stderr, "quantize_q8_K: n %lld is not a multiple of %d\n", (long long) n, QK_K);
419        std::exit(1);
420    }
421    const long long nb = n / QK_K;
422    const int threads = 64;                       // one block per thread, and a block is 256 elements
423    const unsigned grid = (unsigned) ((nb + threads - 1) / threads);
424    {
425        auto exp_props = sycl::ext::oneapi::experimental::properties{
426            sycl::ext::oneapi::experimental::use_root_sync};
427
428        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
429            ->template parallel_for<dpct_kernel_name<class quantize_q8_K_kernel_7aadb2>>(
430                sycl::nd_range<3>(sycl::range(1, 1, grid) *
431                                      sycl::range(1, 1, threads),
432                                  sycl::range(1, 1, threads)),
433                exp_props, [=](sycl::nd_item<3> item_ct1) {
434                    quantize_q8_K_kernel(x, blocks, nb);
435                });
436    }
437    /*
438    DPCT1010: SYCL uses exceptions to report errors and does not use the
439    error codes. The cudaGetLastError function call was replaced with 0. You
440    need to rewrite this code.
441    */
442    const dpct::err0 e = 0;
443
444    if (stream == nullptr) dpct::get_current_device().queues_wait_and_throw();
445}
446
447void dequant_q8_K(const uint8_t* blocks, float* x, int64_t n, void* stream) {
448    if (n <= 0) return;
449    const long long nb = n / QK_K;
450    const int threads = 64;
451    const unsigned grid = (unsigned) ((nb + threads - 1) / threads);
452    {
453        auto exp_props = sycl::ext::oneapi::experimental::properties{
454            sycl::ext::oneapi::experimental::use_root_sync};
455
456        strata::kprof::kp(strata::q_of(stream), __FILE__, __func__, __LINE__)
457            ->template parallel_for<dpct_kernel_name<class dequant_q8_K_kernel_e03426>>(
458                sycl::nd_range<3>(sycl::range(1, 1, grid) *
459                                      sycl::range(1, 1, threads),
460                                  sycl::range(1, 1, threads)),
461                exp_props, [=](sycl::nd_item<3> item_ct1) {
462                    dequant_q8_K_kernel(blocks, x, nb);
463                });
464    }
465    /*
466    DPCT1010: SYCL uses exceptions to report errors and does not use the
467    error codes. The cudaGetLastError function call was replaced with 0. You
468    need to rewrite this code.
469    */
470    const dpct::err0 e = 0;
471
472    if (stream == nullptr) dpct::get_current_device().queues_wait_and_throw();
473}
474
475}  // namespace strata::kernels