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++
BF16 tensor-core path: default on for all of compute capability 7.x (Volta too)
Rafab34cf81417ec
diff --git a/CMakeLists.txt b/CMakeLists.txtindex c25a6feb5..daef8bfe7 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -584,7 +584,7 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)add_executable(gdn_rec_parity src/prefill/gdn_rec_parity.cu)target_link_libraries(gdn_rec_parity PRIVATE ${_strata_gpu_runtime_target})add_test(NAME gdn_rec_parity COMMAND gdn_rec_parity)- # the prompt path's BF16 products against cuBLAS's own BF16 GEMM, within fp32 rounding (sm_75 runs them on the+ # the prompt path's BF16 products against cuBLAS's own BF16 GEMM, within fp32 rounding (sm_7x runs them on the# FP16 tensor cores; GPU, synthetic, no model; --bench adds timings)add_executable(gemm_bf16_parity src/prefill/gemm_bf16_parity.cu)target_link_libraries(gemm_bf16_parity PRIVATE strata_prefill )diff --git a/include/strata/prefill/gemm.hpp b/include/strata/prefill/gemm.hppindex b2cc9933b..6915ee691 100644--- a/include/strata/prefill/gemm.hpp+++ b/include/strata/prefill/gemm.hpp@@ -26,7 +26,7 @@ public:std::string& err);/// Y[T, N] (fp32, row stride ldy) = X[T, K] (bf16, row-major) . W[N, K]^T (bf16, row-major). `beta` = 1 adds.- /// sm_75 (no BF16 tensor cores) converts both to FP16 and runs the FP16 tensor-core GEMM (STRATA_BF16_TC).+ /// sm_7x (no BF16 tensor cores) converts both to FP16 and runs the FP16 tensor-core GEMM (STRATA_BF16_TC).void bf16(const uint16_t* X, const uint16_t* W, float* Y, int64_t T, int64_t N, int64_t K, int64_t ldy = 0,float beta = 0.0f);@@ -53,7 +53,7 @@ private:void* workspace_ = nullptr;bool external_ = false;void* hipblaslt_state_ = nullptr;- // sm_75: FP16 copies of a BF16 product's weight and activation slice (Gemm::bf16, STRATA_BF16_TC)+ // sm_7x: FP16 copies of a BF16 product's weight and activation slice (Gemm::bf16, STRATA_BF16_TC)uint16_t* tc_w_ = nullptr;int64_t tc_w_elems_ = 0;uint16_t* tc_x_ = nullptr;diff --git a/src/prefill/gemm.cu b/src/prefill/gemm.cuindex dd8c9cd7d..babeee80f 100644--- a/src/prefill/gemm.cu+++ b/src/prefill/gemm.cu@@ -377,11 +377,11 @@ bool Gemm::init(void* stream, int64_t scratch_elems, std::string& err) {return true;}-// ---- sm_75: BF16 GEMMs through the FP16 tensor cores ----------------------------------------------------------------// Turing has no BF16 tensor cores: cublasGemmEx on CUDA_R_16BF inputs falls back to a SIMT fp32 kernel-// (magma_sgemmEx) that ran at ~13 TFLOPS, a fifth of the 4K prompt. BF16 -> FP16 is exact for every value inside+// ---- sm_7x: BF16 GEMMs through the FP16 tensor cores ---------------------------------------------------------------+// Turing and Volta have no BF16 tensor cores: cublasGemmEx on CUDA_R_16BF inputs falls back to a SIMT fp32 kernel+// (magma_sgemmEx), a fifth of a 4K prompt on an RTX 2080 Ti. BF16 -> FP16 is exact for every value inside// FP16's range (the 7-bit mantissa fits in 10 bits); weights and normalized activations sit there. With-// STRATA_BF16_TC (default on for sm_75), the weight is converted once per call and the activations in row slices,+// STRATA_BF16_TC (default on for compute capability 7.x), the weight is converted once per call and the activations in row slices,// into the instance's own scratch, and the product runs as the FP16 GEMM (fp32 accumulate) on the tensor cores.namespace {__global__ void bf16_to_f16_kernel(const uint16_t* __restrict__ in, __half* __restrict__ out, int64_t n) {@@ -396,11 +396,10 @@ int bf16_tc_mode() {static int mode = [] {const char* v = std::getenv("STRATA_BF16_TC");if (v != nullptr && v[0] != '\0') return std::atoi(v) != 0 ? 1 : 0;- int dev = 0, maj = 0, min = 0;+ int dev = 0, maj = 0;cudaGetDevice(&dev);cudaDeviceGetAttribute(&maj, cudaDevAttrComputeCapabilityMajor, dev);- cudaDeviceGetAttribute(&min, cudaDevAttrComputeCapabilityMinor, dev);- return (maj == 7 && min == 5) ? 1 : 0;+ return maj == 7 ? 1 : 0; // Volta (sm_70, sm_72) and Turing (sm_75)}();return mode;}diff --git a/src/prefill/gemm_bf16_parity.cu b/src/prefill/gemm_bf16_parity.cuindex 89bd8a25e..00d3d0642 100644--- a/src/prefill/gemm_bf16_parity.cu+++ b/src/prefill/gemm_bf16_parity.cu@@ -1,6 +1,6 @@// src/prefill/gemm_bf16_parity.cu - Gemm::bf16 against cuBLAS's own BF16 product (GPU, synthetic, no model).//-// On sm_75 (no BF16 tensor cores) Gemm::bf16 converts the weight and the activations to FP16 and runs the FP16+// On sm_7x (Volta / Turing, no BF16 tensor cores) Gemm::bf16 converts the weight and the activations to FP16 and runs the FP16// tensor-core GEMM (STRATA_BF16_TC, default on there); everywhere else it is the cuBLAS BF16 call itself. This// checks the result against cublasGemmEx on the same BF16 inputs, within fp32-accumulation rounding, over the prompt// path's shapes: the hyper-connection down / up projections, the router and indexer rows, the PLE value matrix, a T