diff --git a/include/strata/core/sm120_series.hpp b/include/strata/core/sm120_series.hpp index 7dad43d7..9059d312 100644 --- a/include/strata/core/sm120_series.hpp +++ b/include/strata/core/sm120_series.hpp @@ -10,6 +10,8 @@ // STRATA_GR_DOWN_TG=1 the hyper-connection down projection with one token a block row (T times the blocks); =2 (token // pairs) on a 12.0 card with fewer than 80 SMs // STRATA_GU_SWIGLU=1 gate/up, SwiGLU and the q8_1 blocks of the routed experts in one launch +// STRATA_GR_UP_WIDE=1 the hyper-connection up projection with one warp a row (1,280 blocks instead of 160; +1.9% +// story / +0.7% code decode on the RTX PRO 5000, 5 pairs, token ids identical; bitwise) // and one that rounds differently (KL-checked, the AMD gfx12 rule): STRATA_PF_FUSED (the native packs' prompt experts on the // fused int8 kernels, IQ2_S / IQ3_XXS / IQ3_S / IQ4_XS gate/up only, 12.0 cards with 80+ SMs only; =0 keeps MMQ, =1 takes every // covered format on any card). diff --git a/src/kernels/cuda/fused_gr.cu b/src/kernels/cuda/fused_gr.cu index a1f2fe6c..6c2b1677 100644 --- a/src/kernels/cuda/fused_gr.cu +++ b/src/kernels/cuda/fused_gr.cu @@ -439,13 +439,27 @@ __global__ void __launch_bounds__(THREADS) gr_up_multi_kernel(GrMulti m) { constexpr int UPW_COLS = 2; constexpr int UPW_BLOCKS = N / UPW_COLS; -/// STRATA_GR_UP_WIDE=1: the wide up read; default off (each card's own A/B decides). +/// STRATA_GR_UP_WIDE: the wide up read. ON BY DEFAULT on a 12.0 card (sm120_series.hpp; STRATA_SM120_PERF=0 or +/// STRATA_GR_UP_WIDE=0 turns it off, =1 forces it on any card). Measured on the RTX PRO 5000 (IQ3_S, all experts +/// resident, 5 interleaved pairs of fresh engines): story 197.6 -> 201.3 tok/s (+1.9%), code 243.5 -> 245.1 (+0.7%), +/// the produced token ids identical in 6/6 runs; the isolated read (fused_gr_bench) is bitwise the old kernel's. bool gr_up_wide_on() { - static const bool on = [] { + static const int env = [] { const char* v = std::getenv("STRATA_GR_UP_WIDE"); - return v != nullptr && std::atoi(v) != 0; + return v != nullptr ? (std::atoi(v) != 0 ? 1 : 0) : -1; }(); - return on; + if (env >= 0) return env != 0; + static int per_dev[64]; // 0 unknown, 1 no, 2 yes + int dev = 0; + if (cudaGetDevice(&dev) != cudaSuccess || dev < 0 || dev >= 64) return false; + if (!per_dev[dev]) { + int major = 0, minor = 0; + cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev); + cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev); + per_dev[dev] = strata::sm120_default(major, minor) ? 2 : 1; + cudaGetLastError(); // drop what an attribute query on a CPU-only box leaves behind + } + return per_dev[dev] == 2; } template