Pascal (sm_60): bring the engine up on compute capability 6.0
Two gates stand between this engine and a 6.0 card, plus one attribute the card does
not honour. None of them needs the kernels rewritten:
* `CMakeLists.txt` refuses to configure below sm_75;
* `__dp4a` (6.1+) appears 29 times in the i-quant kernels (`native_mmvq.cu`,
`s2_expert_grouped.cu`, `iq_kernels.cu`) and `__nanosleep` (7.0+) in the three
doorbell waits (`elementwise.cu`, `verify_kernels.cu`);
* the Turing port sizes `fused_gr_read_multi`'s slice from
`cudaDevAttrMaxSharedMemoryPerBlockOptin`, which on an sm_60 answers 65536 - a card
whose launch validator enforces the 49152 B per-block limit instead. The capacity
comes out 6 tokens and every 6- or 8-token window fails the launch with
"invalid argument".
## The changes
* **`include/strata/kernels/dp4a.hpp` (new)** - `STRATA_DP4A` and `strata_spin_pause()`.
The dp4a fallback is llama.cpp's own (`ggml/src/ggml-cuda/common.cuh`): both operands
read as SIGNED bytes, accumulated into int32 - which is what `__dp4a` does for exactly
these call sites, the kernels here being transcribed from `vecdotq.cuh`/`mmvq.cu`. The
fallback is bit-exact, not approximate; the nanosleep sites only pace single-thread
doorbell waits, so on sm_6x the loop spins. Both are `__CUDA_ARCH__` selections, so a
HIP build takes neither: its `__dp4a` and `__nanosleep` are `hip_compat`'s own.
* **`CMakeLists.txt`** - `-DSTRATA_EXPERIMENTAL_SM60=ON` relaxes the architecture gate,
and the refusal message names it. The UTF-8 BOM stays.
* **`fused_gr.cu`** - below sm_70 the slice capacity comes from
`cudaDevAttrMaxSharedMemoryPerBlock` (49152 B -> 4 tokens) instead of the opt-in. The
Turing port's slicing, its no-opt-in fallback and the HIP expression are unchanged.
On sm_70 and newer this is a no-op: the opt-in is honoured there, so the capacity is the
value it already was, and `STRATA_DP4A` and `strata_spin_pause()` compile to `__dp4a` and
`__nanosleep` exactly as before. Building for a 6.0 card needs a CUDA release that still
targets Pascal (CUDA 13 removed it; 12.x has compute_60), and `CMAKE_CUDA_STANDARD` has
to stay 17 for it: nvcc 12.9 refuses `-std=c++20` when the host compiler is VS2019's `cl`
and silently falls back to C++14, which rejects the nested
`namespace strata::kernels {` declarations.
Rebased onto 0.1.27 (0.1.21 -> 0.1.24 -> 0.1.27). The 0.1.21 form of this patch clamped
the MTP and verify windows instead, because the fused GR read could not launch a 6-token
window at all. Now that `fused_gr_read_multi` slices the batch itself, the clamp, its
`fused_gr_max_window` helper and the two `generate.cpp` call sites are gone, and the full
window runs:
strata verify: window up to 6 tokens, 69.1 MiB of device buffers
strata verify: captured the 6-token window (upload no error, sync no error)
Measured on a 6.0 card (GP100-class, four dies through the layer split, the model's
IQ3_XXS quant, an 883-token prompt, 256 generated, the shipped `--spec 4`): every one of
the 24576 experts resident, 100% decode cache hit rate, 110 tok/s prefill and 21.3 tok/s
decode (warm median). This port on the 0.1.21 base measured 110.6 and 17.9 in the same
session with the same prompt, so the full window is worth about 19% of decode here. One
RTX 3090 Ti with the release engine measures 305 and 79 tok/s for the same model. The
port is about fitting, not speed: decode is bounded by Pascal's per-layer arithmetic, not
by capacity or memory. Only the 6.0 path was exercised on hardware.
This commit is contained in:
1 parent
b782066e3c
commit
e200e08f54
8 files changed
+98
-33
No files matched your search
+7
-2
@@ -68,10 +68,15 @@ if(STRATA_ENABLE_CUDA)
|
||||
if(_base STREQUAL "native" OR _base STREQUAL "all" OR _base STREQUAL "all-major")
|
||||
continue()
|
||||
endif()
|
||||
if(_base LESS 75)
|
||||
# STRATA_EXPERIMENTAL_SM60: a Pascal (sm_60, GP100-class) build. It sits below every architecture
|
||||
# these kernels were written for, so two intrinsics are replaced for it - `__dp4a` (6.1+) and
|
||||
# `__nanosleep` (7.0+) - in include/strata/kernels/dp4a.hpp, which is bit-exact for the first and
|
||||
# merely a shorter pause for the second. RTX 20/30/40/50 cards must use the release engine instead.
|
||||
if(_base LESS 75 AND NOT STRATA_EXPERIMENTAL_SM60)
|
||||
message(FATAL_ERROR
|
||||
"Strata needs an NVIDIA GPU of compute capability 7.5 or newer (RTX 20 / 30 / 40 / 50 series), but "
|
||||
"CMAKE_CUDA_ARCHITECTURES is '${CMAKE_CUDA_ARCHITECTURES}'.")
|
||||
"CMAKE_CUDA_ARCHITECTURES is '${CMAKE_CUDA_ARCHITECTURES}'. (A Pascal build is "
|
||||
"-DSTRATA_EXPERIMENTAL_SM60=ON; upstream does not support it.)")
|
||||
endif()
|
||||
# #220 / #224: RTX 50 engines built with CUDA 12.8 crashed in the prompt path on Linux (13.0 and newer did not)
|
||||
if(_base GREATER_EQUAL 120 AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 13.0)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
// include/strata/kernels/dp4a.hpp - the two instructions the kernels use that Pascal (sm_60) does not have.
|
||||
//
|
||||
// The engine is written for compute capability 7.5 and newer and refuses older cards at CMake configure time
|
||||
// (a Pascal build passes -DSTRATA_EXPERIMENTAL_SM60=ON). A GP100-class card is compute capability 6.0, which is
|
||||
// missing exactly two things the i-quant kernels rely on:
|
||||
//
|
||||
// * `__dp4a`, a byte-wise dot product, available from 6.1 (Pascal GP10x/GV11x). Its fallback below is
|
||||
// llama.cpp's own (`ggml/src/ggml-cuda/common.cuh`), which is the reference for the kernels in this
|
||||
// directory: they are transcribed from llama.cpp's vecdotq.cuh, and that wrapper's operands are the same
|
||||
// sites. It reinterprets the operands as SIGNED bytes and accumulates in int32, which is what `__dp4a`
|
||||
// does for these calls, so the fallback is bit-exact rather than merely close.
|
||||
// * `__nanosleep`, available from 7.0 (Volta). It only paces single-thread doorbell waits, so a loop that
|
||||
// spins without it is correct, merely busier.
|
||||
//
|
||||
// Both are compile-time selections on `__CUDA_ARCH__`, so one source tree builds for Pascal and for RTX
|
||||
// 20/30/40/50 without a #define at the call sites. A HIP build never takes either fallback: `__CUDA_ARCH__` is
|
||||
// undefined there, so `STRATA_DP4A` is `__dp4a` (which `hip_compat/intrinsics.hpp` provides) and the pause is
|
||||
// HIP's own `__nanosleep`.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 610
|
||||
__device__ __forceinline__ int strata_dp4a(const int a, const int b, const int c) {
|
||||
const int8_t* a8 = (const int8_t*) &a;
|
||||
const int8_t* b8 = (const int8_t*) &b;
|
||||
return c + a8[0] * b8[0] + a8[1] * b8[1] + a8[2] * b8[2] + a8[3] * b8[3];
|
||||
}
|
||||
#define STRATA_DP4A(a, b, c) strata_dp4a((a), (b), (c))
|
||||
#else
|
||||
#define STRATA_DP4A(a, b, c) __dp4a((a), (b), (c))
|
||||
#endif
|
||||
|
||||
/// Yield the thread while a doorbell flag is being polled. The length of the pause is a backoff hint, not a
|
||||
/// contract, and only pre-Volta CUDA has no `__nanosleep` at all.
|
||||
__device__ __forceinline__ void strata_spin_pause() {
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 700
|
||||
// sm_6x: the loop spins. Every call site is a single-thread doorbell wait, so nothing else is delayed.
|
||||
#else
|
||||
__nanosleep(100);
|
||||
#endif
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// src/kernels/cuda/elementwise.cu - P2.S5's glue kernels. See the header for why each exists.
|
||||
#include "strata/kernels/elementwise.hpp"
|
||||
#include "strata/kernels/dp4a.hpp"
|
||||
|
||||
#include "strata/kernels/bf16_bits.hpp"
|
||||
#include "strata/kernels/f16_bits.hpp"
|
||||
@@ -208,7 +209,7 @@ __global__ void doorbell_ring_kernel(uint32_t* seq) {
|
||||
|
||||
__global__ void doorbell_wait_kernel(const volatile uint32_t* flag, const volatile uint32_t* seq) {
|
||||
const uint32_t want = *seq;
|
||||
while (*flag != want) __nanosleep(100);
|
||||
while (*flag != want) strata_spin_pause();
|
||||
__threadfence_system();
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,20 @@ void fused_gr_read_multi(const FusedGrArgs* a, int n_tok, float* xn_scratch, voi
|
||||
// fits the 48 KB default (4 tokens of the CUDA tile; all 8 of HIP's smaller tile). The down kernel's
|
||||
// outputs (lo, inject_out) are strictly per-token, so the chunk boundaries are safe, and the up kernel
|
||||
// below still sees every token of the batch in one launch.
|
||||
const int capacity = (optin > 0 ? optin : 48 * 1024) / (int) (TILE * sizeof(float));
|
||||
//
|
||||
// The opt-in is a promise a pre-Volta card does not keep: an sm_60 answers 65536 and accepts the
|
||||
// cudaFuncSetAttribute for 61440 B, then fails the LAUNCH with "invalid argument". What such a card
|
||||
// will launch is its per-block limit, so the capacity comes from that below sm_70 - the same 4 tokens
|
||||
// the "no opt-in" branch assumes, but taken from the attribute that is actually enforced.
|
||||
#if defined(__HIPCC__)
|
||||
const int usable = optin > 0 ? optin : 48 * 1024;
|
||||
#else
|
||||
int cc = 0, per_block = 0;
|
||||
cudaDeviceGetAttribute(&cc, cudaDevAttrComputeCapabilityMajor, dev);
|
||||
cudaDeviceGetAttribute(&per_block, cudaDevAttrMaxSharedMemoryPerBlock, dev);
|
||||
const int usable = (cc >= 7 && optin > 0) ? optin : per_block;
|
||||
#endif
|
||||
const int capacity = usable / (int) (TILE * sizeof(float));
|
||||
chunk[dev] = capacity < 1 ? 1 : (capacity > kFusedGrMaxT ? kFusedGrMaxT : capacity);
|
||||
attr[dev] = true;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// MIT license, third_party/ggml/LICENSE). The block structs and codebook grids come from its ggml-common.h,
|
||||
// included unchanged.
|
||||
#include "strata/kernels/iq_kernels.hpp"
|
||||
#include "strata/kernels/dp4a.hpp"
|
||||
|
||||
#include <cuda_fp16.h>
|
||||
#include <cuda_runtime.h>
|
||||
@@ -50,7 +51,7 @@ __device__ __forceinline__ int2 get_int_from_table_16(const int& q4, const int8_
|
||||
}
|
||||
return make_int2(__byte_perm(tmp[0], tmp[1], 0x6420), __byte_perm(tmp[0], tmp[1], 0x7531));
|
||||
}
|
||||
#define ggml_cuda_dp4a(a, b, c) __dp4a((a), (b), (c))
|
||||
#define ggml_cuda_dp4a(a, b, c) STRATA_DP4A((a), (b), (c))
|
||||
|
||||
// ---------------------------------------------------------------- the dot products (vecdotq.cuh)
|
||||
__device__ __forceinline__ float vec_dot_q2_0_q8_1(const void* __restrict__ vbq, const block_q8_1* __restrict__ bq8_1,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "strata/kernels/native_mmvq.hpp"
|
||||
#include "strata/kernels/dp4a.hpp"
|
||||
#include "strata/kernels/iq_kernels.hpp"
|
||||
|
||||
#include <cuda_fp16.h>
|
||||
@@ -165,8 +166,8 @@ __device__ __forceinline__ float q5_q8_dot_impl(
|
||||
const int vh1i = ((vh[1] >> i) << 4) & 0x10101010;
|
||||
const int v0i = vl0i | vh0i;
|
||||
const int v1i = vl1i | vh1i;
|
||||
const int dot1 = __dp4a(v0i, u[2 * i], __dp4a(v1i, u[2 * i + 1], 0));
|
||||
const int dot2 = __dp4a(0x01010101, u[2 * i], __dp4a(0x01010101, u[2 * i + 1], 0));
|
||||
const int dot1 = STRATA_DP4A(v0i, u[2 * i], STRATA_DP4A(v1i, u[2 * i + 1], 0));
|
||||
const int dot2 = STRATA_DP4A(0x01010101, u[2 * i], STRATA_DP4A(0x01010101, u[2 * i + 1], 0));
|
||||
sumf_d += d8[i] * (dot1 * sc[i]);
|
||||
sumf_m += d8[i] * (dot2 * m[i]);
|
||||
}
|
||||
@@ -274,8 +275,8 @@ __device__ __forceinline__ float q2_q8_dot(const Q20Block* __restrict__ w,
|
||||
const int qo = __byte_perm(0x020100ff, 0x020100ff, q >> 2);
|
||||
const int qx = __byte_perm(qe, qo, 0x5140);
|
||||
const int qy = __byte_perm(qe, qo, 0x7362);
|
||||
sumi = __dp4a(u, qx, sumi);
|
||||
sumi = __dp4a(v, qy, sumi);
|
||||
sumi = STRATA_DP4A(u, qx, sumi);
|
||||
sumi = STRATA_DP4A(v, qy, sumi);
|
||||
}
|
||||
const float d8 = __low2float(chunk->ds);
|
||||
return d2 * d8 * sumi;
|
||||
@@ -348,7 +349,7 @@ __device__ __forceinline__ float q3_q8_dot_impl(int vl, int vh, const int* __res
|
||||
const int vil = (vl >> (2 * i)) & 0x03030303;
|
||||
const int vih = ((vh >> i) << 2) & 0x04040404;
|
||||
const int vi = __vsubss4(vil, vih);
|
||||
sumf += d8[i] * (__dp4a(vi, u[i], 0) * sc);
|
||||
sumf += d8[i] * (STRATA_DP4A(vi, u[i], 0) * sc);
|
||||
}
|
||||
return d3 * sumf;
|
||||
}
|
||||
@@ -441,8 +442,8 @@ __device__ __forceinline__ float iq4_xs_q8_dot(const IQ4XSBlock* __restrict__ w,
|
||||
const int2 v = iq4_table_lookup(aux_q4);
|
||||
const int u0 = reinterpret_cast<const int*>(x[iqs / 4].qs)[j];
|
||||
const int u1 = reinterpret_cast<const int*>(x[iqs / 4].qs)[j + 4];
|
||||
sumi = __dp4a(v.x, u0, sumi);
|
||||
sumi = __dp4a(v.y, u1, sumi);
|
||||
sumi = STRATA_DP4A(v.x, u0, sumi);
|
||||
sumi = STRATA_DP4A(v.y, u1, sumi);
|
||||
}
|
||||
const int ls = ((w->scales_l[iqs / 8] >> (iqs & 0x04)) & 0x0f) |
|
||||
(((w->scales_h >> (iqs / 2)) & 0x03) << 4);
|
||||
@@ -501,8 +502,8 @@ __device__ __forceinline__ float q4_q8_dot_impl(
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
const int v0i = (v[0] >> (4 * i)) & 0x0f0f0f0f;
|
||||
const int v1i = (v[1] >> (4 * i)) & 0x0f0f0f0f;
|
||||
const int dot1 = __dp4a(v1i, u[2 * i + 1], __dp4a(v0i, u[2 * i], 0));
|
||||
const int dot2 = __dp4a(0x01010101, u[2 * i + 1], __dp4a(0x01010101, u[2 * i], 0));
|
||||
const int dot1 = STRATA_DP4A(v1i, u[2 * i + 1], STRATA_DP4A(v0i, u[2 * i], 0));
|
||||
const int dot2 = STRATA_DP4A(0x01010101, u[2 * i + 1], STRATA_DP4A(0x01010101, u[2 * i], 0));
|
||||
sumf_d += d8[i] * (dot1 * sc[i]);
|
||||
sumf_m += d8[i] * (dot2 * m[i]);
|
||||
}
|
||||
@@ -599,7 +600,7 @@ __device__ __forceinline__ float q6_q8_dot_impl(int vl, int vh, const int* __res
|
||||
const int vil = (vl >> (4 * i)) & 0x0f0f0f0f;
|
||||
const int vih = ((vh >> (4 * i)) << 4) & 0x30303030;
|
||||
const int vi = __vsubss4(vil | vih, 0x20202020);
|
||||
sumf += d8[i] * (__dp4a(vi, u[i], 0) * sc);
|
||||
sumf += d8[i] * (STRATA_DP4A(vi, u[i], 0) * sc);
|
||||
}
|
||||
return d * sumf;
|
||||
}
|
||||
@@ -671,8 +672,8 @@ __device__ __forceinline__ float small_q8_dot(const Q40Block* __restrict__ w,
|
||||
const int v = load_int_b2(w->qs, iqs + i);
|
||||
const int vi0 = (v >> 0) & 0x0f0f0f0f;
|
||||
const int vi1 = (v >> 4) & 0x0f0f0f0f;
|
||||
sumi = __dp4a(vi0, reinterpret_cast<const int*>(x->qs)[iqs + i], sumi);
|
||||
sumi = __dp4a(vi1, reinterpret_cast<const int*>(x->qs)[iqs + i + 4], sumi);
|
||||
sumi = STRATA_DP4A(vi0, reinterpret_cast<const int*>(x->qs)[iqs + i], sumi);
|
||||
sumi = STRATA_DP4A(vi1, reinterpret_cast<const int*>(x->qs)[iqs + i + 4], sumi);
|
||||
}
|
||||
const float2 ds = __half22float2(x->ds);
|
||||
const float d = w->d;
|
||||
@@ -691,13 +692,13 @@ __device__ __forceinline__ float small_q8_dot(const Q50Block* __restrict__ w,
|
||||
vi0 |= (vh << 11) & 0x00001000;
|
||||
vi0 |= (vh << 18) & 0x00100000;
|
||||
vi0 |= (vh << 25) & 0x10000000;
|
||||
sumi = __dp4a(vi0, reinterpret_cast<const int*>(x->qs)[iqs + i], sumi);
|
||||
sumi = STRATA_DP4A(vi0, reinterpret_cast<const int*>(x->qs)[iqs + i], sumi);
|
||||
int vi1 = (vl >> 4) & 0x0f0f0f0f;
|
||||
vi1 |= (vh >> 12) & 0x00000010;
|
||||
vi1 |= (vh >> 5) & 0x00001000;
|
||||
vi1 |= (vh << 2) & 0x00100000;
|
||||
vi1 |= (vh << 9) & 0x10000000;
|
||||
sumi = __dp4a(vi1, reinterpret_cast<const int*>(x->qs)[iqs + i + 4], sumi);
|
||||
sumi = STRATA_DP4A(vi1, reinterpret_cast<const int*>(x->qs)[iqs + i + 4], sumi);
|
||||
}
|
||||
const float2 ds = __half22float2(x->ds);
|
||||
const float d = w->d;
|
||||
@@ -711,7 +712,7 @@ __device__ __forceinline__ float small_q8_dot(const Q80Block* __restrict__ w,
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
const int v = load_int_b2(w->qs, iqs + i);
|
||||
const int u = reinterpret_cast<const int*>(x->qs)[iqs + i];
|
||||
sumi = __dp4a(v, u, sumi);
|
||||
sumi = STRATA_DP4A(v, u, sumi);
|
||||
}
|
||||
const float d0 = w->d;
|
||||
const float d1 = __low2float(x->ds);
|
||||
@@ -725,8 +726,8 @@ __device__ __forceinline__ float small_q8_dot(const IQ4NLBlock* __restrict__ w,
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
const int2 v = iq4_table_lookup(load_int_b2(w->qs, iqs + i));
|
||||
sumi = __dp4a(v.x, q8[i], sumi);
|
||||
sumi = __dp4a(v.y, q8[i + 4], sumi);
|
||||
sumi = STRATA_DP4A(v.x, q8[i], sumi);
|
||||
sumi = STRATA_DP4A(v.y, q8[i + 4], sumi);
|
||||
}
|
||||
const float d = __half2float(w->d) * __low2float(x->ds);
|
||||
return d * sumi;
|
||||
@@ -890,8 +891,8 @@ struct Q20Traits {
|
||||
int sumi = 0;
|
||||
#pragma unroll
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
sumi = __dp4a(q8[j * 2], r.qx[j], sumi);
|
||||
sumi = __dp4a(q8[j * 2 + 1], r.qy[j], sumi);
|
||||
sumi = STRATA_DP4A(q8[j * 2], r.qx[j], sumi);
|
||||
sumi = STRATA_DP4A(q8[j * 2 + 1], r.qy[j], sumi);
|
||||
}
|
||||
const float d8 = __low2float(chunk->ds);
|
||||
return r.d2 * d8 * sumi;
|
||||
@@ -969,8 +970,8 @@ struct IQ4XSTraits {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
const int u0 = reinterpret_cast<const int*>(x[iqs / 4].qs)[j];
|
||||
const int u1 = reinterpret_cast<const int*>(x[iqs / 4].qs)[j + 4];
|
||||
sumi = __dp4a(r.v[j].x, u0, sumi);
|
||||
sumi = __dp4a(r.v[j].y, u1, sumi);
|
||||
sumi = STRATA_DP4A(r.v[j].x, u0, sumi);
|
||||
sumi = STRATA_DP4A(r.v[j].y, u1, sumi);
|
||||
}
|
||||
sumi *= r.ls - 32;
|
||||
const float d = r.dw * __low2float(x[iqs / 4].ds);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// The two agree to float rounding and not to the bit, which is the same contract `s_gemv_parity` carries for
|
||||
// the same reason. `bench/micro/moe_hit_parity.cu` is the check.
|
||||
#include "strata/kernels/s2_expert_grouped.hpp"
|
||||
#include "strata/kernels/dp4a.hpp"
|
||||
|
||||
#include "strata/kernels/quantize_act.hpp"
|
||||
#include "strata/kernels/verify_kernels.hpp"
|
||||
@@ -89,8 +90,8 @@ __device__ __forceinline__ float row_dot_s2_q8(const uint8_t* __restrict__ codes
|
||||
// it rather than reasoning about which cast happens to work.
|
||||
int xw;
|
||||
memcpy(&xw, xq + 4 * j, 4);
|
||||
s = __dp4a(cw, xw, s);
|
||||
hx = __dp4a(ones, xw, hx);
|
||||
s = STRATA_DP4A(cw, xw, s);
|
||||
hx = STRATA_DP4A(ones, xw, hx);
|
||||
}
|
||||
// One weight scale per 64 elements, so per TWO 32-element chunks.
|
||||
const float dw = f16_at(scales + (size_t) (c >> 1) * 2);
|
||||
@@ -211,7 +212,7 @@ __device__ __forceinline__ int dot4(const uint8_t* codes, const int8_t* q) {
|
||||
(((c >> 4) & 3u) << 16) | (((c >> 6) & 3u) << 24));
|
||||
int xw;
|
||||
memcpy(&xw, q, sizeof xw);
|
||||
return __dp4a(cw, xw, 0);
|
||||
return STRATA_DP4A(cw, xw, 0);
|
||||
}
|
||||
|
||||
__device__ __forceinline__ float row_dot_cpu_order(const uint8_t* codes, const uint8_t* scales,
|
||||
@@ -530,8 +531,8 @@ __device__ __forceinline__ float chunk_dot(uint2 cb, const int* xw, float dw, fl
|
||||
const unsigned cbyte = cbytes[j];
|
||||
const int cw = (int) ((cbyte & 3u) | (((cbyte >> 2) & 3u) << 8) | (((cbyte >> 4) & 3u) << 16) |
|
||||
(((cbyte >> 6) & 3u) << 24));
|
||||
s = __dp4a(cw, xw[j], s);
|
||||
hx = __dp4a(ones, xw[j], hx);
|
||||
s = STRATA_DP4A(cw, xw[j], s);
|
||||
hx = STRATA_DP4A(ones, xw[j], hx);
|
||||
}
|
||||
return dw * dx * (float) (s - hx);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// The per-token arithmetic of every kernel here is transcribed from its single-token original (fused_gdn.cu,
|
||||
// elementwise.cu) with the same operation order, so a verify window reproduces plain decode bit for bit.
|
||||
#include "strata/kernels/verify_kernels.hpp"
|
||||
#include "strata/kernels/dp4a.hpp"
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
@@ -423,7 +424,7 @@ void gdn_step_norm_multi(float* state, const float* h, int conv_channels, const
|
||||
|
||||
namespace {
|
||||
__global__ void wait_flag_ge_kernel(const volatile uint32_t* flag, uint32_t value) {
|
||||
while (*flag < value) __nanosleep(100);
|
||||
while (*flag < value) strata_spin_pause();
|
||||
__threadfence_system();
|
||||
}
|
||||
} // namespace
|
||||
@@ -472,7 +473,7 @@ __global__ void resident_plan_kernel(const int32_t* __restrict__ ids, int n, int
|
||||
}
|
||||
__global__ void wait_flag_ge_or_kernel(const volatile uint32_t* flag, uint32_t value, const volatile uint32_t* skip) {
|
||||
if (*skip == value) return;
|
||||
while (*flag < value) __nanosleep(100);
|
||||
while (*flag < value) strata_spin_pause();
|
||||
__threadfence_system();
|
||||
}
|
||||
__global__ void copy_i32_unless_kernel(int32_t* __restrict__ dst, const volatile int32_t* src, int n,
|
||||
|
||||
Reference in new issue
Block a user