Skip to content

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++

QSA scorer: an FP32 fallback for Turing (the experimental sm_75 build, a layer-split stage on a 2080 Ti)

Niko1221c8b10915aa85
diff --git a/src/kernels/cuda/native_qsa_score.cu b/src/kernels/cuda/native_qsa_score.cu
index 9ae4d117e..fe5d447a3 100644
--- a/src/kernels/cuda/native_qsa_score.cu
+++ b/src/kernels/cuda/native_qsa_score.cu
@@ -32,6 +32,7 @@ constexpr int D=128, HEADS=4, R=4, ROWS=32, WARPS=2, STRIDE=36, COMBINE=68;
struct TileA { uint32_t x[4]; };
struct TileB { uint32_t x[2]; };
struct TileC { float x[4]={0.0f,0.0f,0.0f,0.0f}; };
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
__device__ __forceinline__ void load_a(TileA& a,const float* p) {
const float* src=p+(threadIdx.x%16)*STRIDE+(threadIdx.x/16)*4;
asm volatile("ldmatrix.sync.aligned.m8n8.x4.b16 {%0,%1,%2,%3}, [%4];"
@@ -48,6 +49,7 @@ __device__ __forceinline__ void mma(TileC& c,const TileA& a,const TileB& b) {
: "+f"(c.x[0]),"+f"(c.x[1]),"+f"(c.x[2]),"+f"(c.x[3])
: "r"(a.x[0]),"r"(a.x[1]),"r"(a.x[2]),"r"(a.x[3]),"r"(b.x[0]),"r"(b.x[1]));
}
+#endif
__global__ __launch_bounds__(64,1) void score_kernel(
const float* __restrict__ pooled,const float* __restrict__ query,
const float* __restrict__ bias,const int32_t* __restrict__ step,
@@ -58,6 +60,23 @@ __global__ __launch_bounds__(64,1) void score_kernel(
const int row0=blockIdx.x*ROWS;
if(row0>full)return;
const int lane=threadIdx.x,warp=threadIdx.y;
+#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 800
+ // Turing (STRATA_EXPERIMENTAL_SM75, a layer-split stage): no tf32 mma. The same scores with FP32 FMAs, one row
+ // per thread of the first warp - rounded differently from the tensor-core path (FP32 instead of TF32 inputs).
+ if(warp!=0)return;
+ const int row=row0+lane;
+ if(row>full)return;
+ float h[HEADS];
+ for(int j=0;j<HEADS;++j){
+ float acc=0.0f;
+ for(int d=0;d<D;++d)acc=fmaf(pooled[size_t(row)*D+d],query[j*D+d],acc);
+ h[j]=fmaxf(acc,0.0f);
+ }
+ float sum=__fadd_rn(__fadd_rn(__fadd_rn(h[0],h[1]),h[2]),h[3]);
+ if(bias)sum=__fadd_rn(sum,bias[row]);
+ sum=__fadd_rn(sum,row==full&&n%R?1e9f:0.0f);
+ for(int i=row*R;i<n&&i<(row+1)*R;++i)cells[i]=sum;
+#else
__shared__ __align__(16) float shared[WARPS*16*STRIDE];
float* tile=shared+warp*16*STRIDE;
TileC c[2];
@@ -118,6 +137,7 @@ __global__ __launch_bounds__(64,1) void score_kernel(
sum=__fadd_rn(sum,0.0f);
for(int i=row*R;i<n&&i<(row+1)*R;++i)cells[i]=sum;
}
+#endif
}
struct Span{const void* p;size_t n;};
void validate(Span s){