Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Pascal decode: keep __restrict__ and drop the PDL prefetch below sm_70 (#1469, #1470)
Niko1221fbb362425c89
diff --git a/include/strata/kernels/pdl.hpp b/include/strata/kernels/pdl.hppindex 14d84234f..8031bb8fe 100644--- a/include/strata/kernels/pdl.hpp+++ b/include/strata/kernels/pdl.hpp@@ -33,10 +33,16 @@ bool pdl_supported();#if (defined(__CUDACC__) || defined(__HIPCC__))-// not __CUDA_ARCH__-dependent: the host pass must see the same kernel signature (MSVC rejects the template stubs-// otherwise), so on CUDA these parameters lose __restrict__ for every architecture+// STRATA_PDL_RESTRICT never goes on a __global__ signature: the host pass and the stub must see the same signature on+// every architecture (MSVC rejects the template stubs otherwise, and so does g++ when the stub is generated from a+// device pass). A kernel takes plain pointers and declares `const T* STRATA_PDL_RESTRICT p = p_;` locals in its body.+// On CUDA the activation pointers lose __restrict__ so the compiler cannot load them before pdl_wait() - but only+// where PDL can run (sm_70 and newer here). On Pascal and older (__CUDA_ARCH__ < 700, no PDL) `__restrict__` is what+// lets the compiler use the read-only data path (LDG.CI): without it decode on sm_61 halves (#1469).#if defined(__HIPCC__)#define STRATA_PDL_RESTRICT __restrict__+#elif defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 700)+#define STRATA_PDL_RESTRICT __restrict__#else#define STRATA_PDL_RESTRICT#endif@@ -44,7 +50,11 @@ bool pdl_supported();#if defined(__HIPCC__)inline constexpr bool kPdlPrefetch = false; // HIP: no PDL, the kernels keep their plain loops#else+#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ < 700)+inline constexpr bool kPdlPrefetch = false; // Pascal and older: no PDL, the prefetch only costs registers (#1469)+#elseinline constexpr bool kPdlPrefetch = true; // CUDA: the weights a kernel can load before pdl_wait() are loaded there+#endif/// `kernel` may be launched with the PDL attribute into `stream` now (see the header comment).bool pdl_launch_ok(const void* kernel, cudaStream_t stream);#endifdiff --git a/src/kernels/cuda/native_bf16.cu b/src/kernels/cuda/native_bf16.cuindex 3bbad5a5b..1f4b98acc 100644--- a/src/kernels/cuda/native_bf16.cu+++ b/src/kernels/cuda/native_bf16.cu@@ -75,8 +75,10 @@ __global__ void bf16_f32_mmvf_kernel(const float* __restrict__ x, const uint16_t// token keeps its own accumulator with exactly the single-row kernel's order (pairs, two ordered FMAs, the same warp// and block reductions), so each output is bit-identical to a bf16_f32_mmvf_kernel launch of its own.template <int BLOCK_SIZE, int NT, bool EXACT_T = true>-__global__ void bf16_f32_mmvf_multi_kernel(const float* STRATA_PDL_RESTRICT x, int64_t ldx, const uint16_t* __restrict__ w,- float* STRATA_PDL_RESTRICT y, int64_t ldy, int n_in, int n_tok) {+__global__ void bf16_f32_mmvf_multi_kernel(const float* x_, int64_t ldx, const uint16_t* __restrict__ w,+ float* y_, int64_t ldy, int n_in, int n_tok) {+ const float* STRATA_PDL_RESTRICT x = x_; // __restrict__ below sm_70 only (pdl.hpp, #1469)+ float* STRATA_PDL_RESTRICT y = y_;const int t = threadIdx.x;const uint16_t* row = w + (size_t) blockIdx.x * n_in;const uint32_t* weights2 = reinterpret_cast<const uint32_t*>(row);diff --git a/src/kernels/cuda/native_mmvq.cu b/src/kernels/cuda/native_mmvq.cuindex 3ef2dcbfa..cb4fdc8e5 100644--- a/src/kernels/cuda/native_mmvq.cu+++ b/src/kernels/cuda/native_mmvq.cu@@ -150,8 +150,9 @@ __device__ __forceinline__ float warp_max(float x) {}__launch_bounds__(QUANT_THREADS, 1)-__global__ void native_quantize_q8_1_kernel(const float* STRATA_PDL_RESTRICT x,- Q81Block* STRATA_PDL_RESTRICT y, int n_in) {+__global__ void native_quantize_q8_1_kernel(const float* x_, Q81Block* y_, int n_in) {+ const float* STRATA_PDL_RESTRICT x = x_; // __restrict__ below sm_70 only (pdl.hpp, #1469)+ Q81Block* STRATA_PDL_RESTRICT y = y_;pdl_trigger(); // PDL (pdl.hpp): the projection after this one may start loading its weightspdl_wait();const int i = int(blockIdx.x) * QUANT_THREADS + int(threadIdx.x);@@ -1162,10 +1163,11 @@ static bool s26_tsum_on() {// input in one launch; each output's code is the single matrix's)template<typename F, int NCOLS, int NW, int ROWS, bool TS = false, bool PAIR = false>__launch_bounds__(NW * WARP, (ROWS <= 2 ? 4 : 1))-__global__ void native_mmvq_multi_kernel(const typename F::Block* __restrict__ w,- const Q81Block* STRATA_PDL_RESTRICT x,- float* STRATA_PDL_RESTRICT y, int n_in, int n_out,+__global__ void native_mmvq_multi_kernel(const typename F::Block* __restrict__ w, const Q81Block* x_, float* y_,+ int n_in, int n_out,const typename F::Block* __restrict__ w2 = nullptr, float* __restrict__ y2 = nullptr) {+ const Q81Block* STRATA_PDL_RESTRICT x = x_; // __restrict__ below sm_70 only (pdl.hpp, #1469)+ float* STRATA_PDL_RESTRICT y = y_;constexpr int BPI = F::BPI * NW / WARPS; // blocks per iteration scale with the warp countconst int tid = WARP * int(threadIdx.y) + int(threadIdx.x);int bxi = int(blockIdx.x);