mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
Int8 prompt kernels on Volta: the tile that keeps two blocks per SM, and the big grids read from global memory (#6053)
A Tesla V100 has 96 KB of shared memory per SM. The int8 tile kernels' tile 8 (54-62 KB) and tile 4 (51-59 KB) run one block of 8 warps per SM there; tiles 2 and 3 of the IQ3 formats (43 / 48 KB) run two. IQ2_S's 8 KB codebook grid in shared memory kept even its tile 2 / 3 at one block. Change (compute capability 7.0 only; STRATA_I8_SM70=0 is the research switch back): - i8_expert_rule.hpp i8_tile_two_blocks: the pick (tile 8 counts as 4) is lowered to the largest tile 2-4 whose shared memory leaves two blocks per SM (cudaDevAttrMaxSharedMemoryPerMultiprocessor and the per-block reservation, read once per device); a tile set by STRATA_I8_TM is kept. - I8Smem / i8_kernel GG: the formats with a grid over 2 KB (IQ2_S, IQ2_XS, IQ1_M) read the grid words from global memory (L1) instead of staging them: the same words, so IQ2_S's tile 3 fits two blocks. The tile only groups entries and the grid words are the same: bit-identical output (the layer bench's output hash is equal at every tile; the engine identity below). Other cards: the same code path as before (the new instances are compiled but launched only on 7.0). Tesla V100-SXM2 32 GB, one layer of Flash-Next's shape, uniform routing, MMQ time / int8 time (above 1: ours faster), the old pick -> this rule at 8,192 / 26,000 tokens: IQ3_S / IQ4_NL 0.745 -> 0.949 / 0.795 -> 0.820; IQ3_XXS / IQ4_NL 0.721 -> 0.955 / 0.795 -> 0.831; IQ2_S / IQ4_NL (with the global grid) 0.70 -> 0.90 at 8,192. Below 2,048 tokens the pick was 2 or 3 already: unchanged. End to end with the previous commit (same build): see its message; the record fix alone (t2-style rule-only build) measured 0.959 / 0.943 of 0.1.60's prompt time at 2,048 / 8,192. Identity: the previous commit's gates ran on this tree (IQ3_S streamed and Coder resident 10 of 10 dumps and tokens; P100 BASE-05 9 of 9). Unit test: i8_expert_rule_test (two blocks per SM, the reservation edge at exactly 96 KB, the IQ2_S grid form; l620, g++).
This commit is contained in:
1 parent
5480e2bad4
commit
f41d35929e
4 files changed
+110
-22
No files matched your search
@@ -11,6 +11,7 @@
|
||||
// environment read here (the caller passes the variable's text and the device's gcnArchName), so the rule is unit-tested without a card.
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "strata/kernels/gfx_arch.hpp"
|
||||
@@ -92,6 +93,24 @@ inline bool i8_n8_takes(int state, int tile) {
|
||||
return state == 1 ? tile >= 2 && tile <= 4 : tile == 2;
|
||||
}
|
||||
|
||||
// Volta (compute capability 7.0: 96 KB of shared memory per multiprocessor, no int8 matrix cores, so every routed expert of a prompt runs on these kernels). The tile the
|
||||
// other cards take from 96 entries a group on average (tile 8, 128 x 128, 54-62 KB) and tile 4 (51-59 KB) leave one block of 8 warps per multiprocessor there; tiles 2 and 3 of
|
||||
// the IQ3 formats (43 / 48 KB) run two. Tesla V100-SXM2 32 GB, one layer of Flash-Next's shape, uniform routing, MMQ time / int8 time (above 1: ours faster), the call's
|
||||
// own pick against tile 3 (phaseA-tests/tune0216, bench1-v100): IQ3_S / IQ4_NL 0.745 -> 0.949 at 8,192 tokens and 0.795 -> 0.820 at 26,000, IQ3_XXS / IQ4_NL 0.721 -> 0.955 and
|
||||
// 0.795 -> 0.831; output bits equal at every tile (the tile only groups entries). The big-grid formats (IQ2_S's 8 KB grid table) read their grid from global memory there
|
||||
// (I8Smem GG: the same words, the same bits), so their tile 3 fits two blocks too. So on Volta the call's pick is lowered to the largest tile that still gives two blocks per
|
||||
// multiprocessor (tile 8 counts as 4 first); a tile set by STRATA_I8_TM is kept as given.
|
||||
/// `tm` the pick (2, 3, 4 or 8), `bytes2/3/4` the dynamic shared memory of tiles 2-4 for the layer's formats, `smem_sm` the multiprocessor's shared memory, `reserved` the
|
||||
/// driver's reservation per block (cudaDevAttrReservedSharedMemoryPerBlock).
|
||||
inline int i8_tile_two_blocks(int tm, std::size_t bytes2, std::size_t bytes3, std::size_t bytes4, std::size_t smem_sm, std::size_t reserved) {
|
||||
int t = tm >= 4 ? 4 : tm <= 2 ? 2 : 3;
|
||||
auto fits = [&](int k) { const std::size_t b = (k == 2 ? bytes2 : k == 3 ? bytes3 : bytes4) + reserved; return 2 * b <= smem_sm; };
|
||||
while (t > 2 && !fits(t)) --t;
|
||||
return t;
|
||||
}
|
||||
/// STRATA_I8_SM70 read as a state (1 / 0 / -1 not set): the Volta tile rule above and the global grid are on unless it is 0.
|
||||
inline bool i8_volta_rule_on(int state) { return state != 0; }
|
||||
|
||||
// The Tesla P100 (compute capability 6.0) in a build without MMQ. There the build WITH MMQ takes the FP16 prompt path by default (prefill.cpp gp100_fp16_default: GP100 has no
|
||||
// dp4a), so the unset-switch int8 default of a build without MMQ (i8_switch_effective) must not replace it where the int8 kernel loses to it. Measured on the P100 (OUT build,
|
||||
// prompt read ms int8 / FP16, par/RESULTS-P100-GATE.md): 300 0.874, 600 0.865, 1,000 0.844, then 1,200 1.196, 1,500 1.142, 2,048 1.085, 8,192 1.081: the step sits at the chunk size from
|
||||
|
||||
@@ -462,10 +462,13 @@ __device__ __forceinline__ const uint32_t* i8_grid_src() {
|
||||
|
||||
// shared memory of an instance, in dwords: grid | sign table | stage weights x2 | stage activations x2 | scale records x2 |
|
||||
// activation scales x2 | source rows
|
||||
template <int T, int TM>
|
||||
// GG (TUNE-0216, Volta): the codebook grid is read from global memory (L1-cached) instead of being staged in shared memory, so that a tile of a big-grid format
|
||||
// (IQ2_S 8 KB, IQ2_XS 4 KB, IQ1_M 8 KB) fits two blocks into a Volta multiprocessor's 96 KB. The same grid words are read: the output is bit-identical.
|
||||
__host__ __device__ constexpr bool i8_gg_type(int t) { return i8_grid_words(t) > 512; }
|
||||
template <int T, int TM, bool GG = false>
|
||||
struct I8Smem {
|
||||
static constexpr int BM = 16 * TM;
|
||||
static constexpr int GW = (i8_grid_words(T) + 3) / 4 * 4;
|
||||
static constexpr int GW = GG ? 0 : (i8_grid_words(T) + 3) / 4 * 4;
|
||||
static constexpr int SG = i8_sign_type(T) ? 512 : 0;
|
||||
static constexpr int SZ_W = 64 * I8_LD, SZ_A = BM * I8_LD, SZ_R = 64 * I8_RS, SZ_D = BM * 4, SZ_S = i8_min_type(T) ? BM * 4 : 0; // SZ_S: the activation sums of the minimum formats
|
||||
static constexpr int o_sg = GW, o_w = o_sg + SG, o_a = o_w + 2 * SZ_W, o_r = o_a + 2 * SZ_A, o_d = o_r + 2 * SZ_R, o_s = o_d + 2 * SZ_D, o_src = o_s + 2 * SZ_S,
|
||||
@@ -536,16 +539,17 @@ __device__ __forceinline__ int i8_row_t(const uint4 (&w)[2], const uint4& rc, co
|
||||
// rows tx + 16 (2 half + i2)) and one entry of each 8-entry slice (entry ty % 8 + 8 js), so a block with 6 entries runs one slice with all 256 threads busy
|
||||
// where the 16-entry slice left 10 of 16 entry rows computing nothing. Every (row, entry) accumulates the same terms in the same order: bit-identical output.
|
||||
// The gate/up epilogue needs the gate (row pair 0) and up (row pair 1) values of one entry together: the up half hands them over through shared memory.
|
||||
template <int T, bool GU, int TM, bool NR>
|
||||
template <int T, bool GU, int TM, bool NR, bool GG = false>
|
||||
__global__ void __launch_bounds__(I8_NT)
|
||||
i8_kernel(const unsigned long long* __restrict__ grp_ptr, const int32_t* __restrict__ grp_start, const int32_t* __restrict__ n_groups,
|
||||
const int32_t* __restrict__ tile_off, const int32_t* __restrict__ ent_idx, const block_q8_1* __restrict__ A,
|
||||
block_q8_1* __restrict__ hq, float* __restrict__ out, NativeExpertLayout L, int bisect) {
|
||||
using SM = I8Smem<T, TM>;
|
||||
using SM = I8Smem<T, TM, GG>;
|
||||
constexpr int BM = SM::BM;
|
||||
extern __shared__ uint4 i8_dyn[];
|
||||
uint32_t* const smem = (uint32_t*) i8_dyn;
|
||||
uint32_t* const s_grid = smem;
|
||||
const uint32_t* const grid_rd = GG ? i8_grid_src<T>() : s_grid; // GG: the grid words straight from global memory (through L1)
|
||||
uint32_t* const s_sg = smem + SM::o_sg;
|
||||
uint32_t* const s_w = smem + SM::o_w;
|
||||
uint32_t* const s_a = smem + SM::o_a;
|
||||
@@ -579,7 +583,7 @@ i8_kernel(const unsigned long long* __restrict__ grp_ptr, const int32_t* __restr
|
||||
const int ns = K / I8_KS;
|
||||
const size_t wrb = GU ? L.gu_row : L.d_row;
|
||||
|
||||
if constexpr (i8_grid_words(T) > 4) {
|
||||
if constexpr (i8_grid_words(T) > 4 && !GG) {
|
||||
const uint32_t* src = i8_grid_src<T>();
|
||||
for (int i = tid; i < i8_grid_words(T); i += I8_NT) s_grid[i] = src[i];
|
||||
}
|
||||
@@ -628,7 +632,7 @@ i8_kernel(const unsigned long long* __restrict__ grp_ptr, const int32_t* __restr
|
||||
float base, minv = 0.0f;
|
||||
const int ibs = (st * 4 + wp) & 7;
|
||||
i8_pack<T>(r, ibs, w); // (ib of a 256-value super-block; the K-quants and IQ3_S read it)
|
||||
i8_convert<T>(w, s_grid, (const uint2*) s_sg, kv, q, m0, m1, base, ibs, &minv);
|
||||
i8_convert<T>(w, grid_rd, (const uint2*) s_sg, kv, q, m0, m1, base, ibs, &minv);
|
||||
uint4* dst = (uint4*) (s_w + b * SM::SZ_W + wr * I8_LD + wp * 8);
|
||||
dst[0] = make_uint4(q[0], q[1], q[2], q[3]);
|
||||
dst[1] = make_uint4(q[4], q[5], q[6], q[7]);
|
||||
@@ -1104,6 +1108,7 @@ struct I8Args {
|
||||
int64_t tiles_ub;
|
||||
int bisect;
|
||||
bool n8 = false; // tile codes 2-4: 8-entry slices with two weight rows per thread (see i8_kernel, NR)
|
||||
bool gg = false; // tile codes 2-4, a big-grid format (i8_gg_type): the grid read from global memory (see I8Smem, GG; Volta)
|
||||
};
|
||||
|
||||
// what the last native_expert_i8 call asked its two launches for (the tile code, the dynamic shared memory in bytes passed as the launch's third argument, and
|
||||
@@ -1120,29 +1125,36 @@ void i8_note_launch(bool gu, int tile, size_t bytes) {
|
||||
else { g_i8_last.down_bytes = bytes; g_i8_last.down_err = e; }
|
||||
}
|
||||
|
||||
template <int T, bool GU, int TM>
|
||||
void i8_launch_tm(const I8Args& a, cudaStream_t s) {
|
||||
constexpr size_t smem = I8Smem<T, TM>::bytes;
|
||||
template <int T, bool GU, int TM, bool GG>
|
||||
void i8_launch_tm_g(const I8Args& a, cudaStream_t s) {
|
||||
constexpr size_t smem = I8Smem<T, TM, GG>::bytes;
|
||||
#if !defined(__HIPCC__)
|
||||
if (smem > 48 * 1024) {
|
||||
cudaFuncSetAttribute(i8_kernel<T, GU, TM, false>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem);
|
||||
cudaFuncSetAttribute(i8_kernel<T, GU, TM, true>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem);
|
||||
cudaFuncSetAttribute(i8_kernel<T, GU, TM, false, GG>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem);
|
||||
cudaFuncSetAttribute(i8_kernel<T, GU, TM, true, GG>, cudaFuncAttributeMaxDynamicSharedMemorySize, (int) smem);
|
||||
}
|
||||
#endif
|
||||
const dim3 grid((unsigned) a.tiles_ub, (unsigned) (GU ? a.L.n_ff / 32 : a.L.n_embd / 64));
|
||||
if (a.n8) { // 8-entry slices (i8_n8_takes)
|
||||
if constexpr (GU)
|
||||
i8_kernel<T, true, TM, true><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_tok, a.x, a.hq, a.out, a.L, a.bisect);
|
||||
i8_kernel<T, true, TM, true, GG><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_tok, a.x, a.hq, a.out, a.L, a.bisect);
|
||||
else
|
||||
i8_kernel<T, false, TM, true><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_dst, a.hq, nullptr, a.out, a.L, a.bisect);
|
||||
i8_kernel<T, false, TM, true, GG><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_dst, a.hq, nullptr, a.out, a.L, a.bisect);
|
||||
} else {
|
||||
if constexpr (GU)
|
||||
i8_kernel<T, true, TM, false><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_tok, a.x, a.hq, a.out, a.L, a.bisect);
|
||||
i8_kernel<T, true, TM, false, GG><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_tok, a.x, a.hq, a.out, a.L, a.bisect);
|
||||
else
|
||||
i8_kernel<T, false, TM, false><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_dst, a.hq, nullptr, a.out, a.L, a.bisect);
|
||||
i8_kernel<T, false, TM, false, GG><<<grid, I8_NT, smem, s>>>(a.grp_ptr, a.grp_start, a.n_groups, a.tile_off, a.ent_dst, a.hq, nullptr, a.out, a.L, a.bisect);
|
||||
}
|
||||
i8_note_launch(GU, TM, smem);
|
||||
}
|
||||
template <int T, bool GU, int TM>
|
||||
void i8_launch_tm(const I8Args& a, cudaStream_t s) {
|
||||
if constexpr (i8_gg_type(T)) {
|
||||
if (a.gg) { i8_launch_tm_g<T, GU, TM, true>(a, s); return; }
|
||||
}
|
||||
i8_launch_tm_g<T, GU, TM, false>(a, s);
|
||||
}
|
||||
template <int T, bool GU>
|
||||
void i8b_launch(const I8Args& a, cudaStream_t s) {
|
||||
constexpr size_t smem = I8BSmem<T>::bytes;
|
||||
@@ -1158,13 +1170,16 @@ void i8b_launch(const I8Args& a, cudaStream_t s) {
|
||||
}
|
||||
// shared memory of the instances of a gate/up and a down type for tile code tm (2, 3, 4: rows of 16 entries; 8: variant B), and the device's limit per block
|
||||
template <int T>
|
||||
size_t i8_sm(int tm) {
|
||||
size_t i8_sm(int tm, bool gg = false) {
|
||||
if (gg && i8_gg_type(T) && tm != 8) return tm <= 2 ? I8Smem<T, 2, true>::bytes : tm == 3 ? I8Smem<T, 3, true>::bytes : I8Smem<T, 4, true>::bytes;
|
||||
return tm == 8 ? I8BSmem<T>::bytes : tm <= 2 ? I8Smem<T, 2>::bytes : tm == 3 ? I8Smem<T, 3>::bytes : I8Smem<T, 4>::bytes;
|
||||
}
|
||||
size_t i8_smem_bytes(int gu, int dt, int tm) {
|
||||
const size_t a = gu == 16 ? i8_sm<16>(tm) : gu == 17 ? i8_sm<17>(tm) : gu == 18 ? i8_sm<18>(tm) : gu == 21 ? i8_sm<21>(tm) : gu == 23 ? i8_sm<23>(tm) :
|
||||
gu == 29 ? i8_sm<29>(tm) : gu == 42 ? i8_sm<42>(tm) : gu == 12 ? i8_sm<12>(tm) : gu == 13 ? i8_sm<13>(tm) : gu == 14 ? i8_sm<14>(tm) : gu == 8 ? i8_sm<8>(tm) : i8_sm<22>(tm);
|
||||
const size_t b = dt == 20 ? i8_sm<20>(tm) : dt == 6 ? i8_sm<6>(tm) : dt == 8 ? i8_sm<8>(tm) : dt == 7 ? i8_sm<7>(tm) : dt == 13 ? i8_sm<13>(tm) : dt == 14 ? i8_sm<14>(tm) : i8_sm<42>(tm);
|
||||
size_t i8_smem_bytes(int gu, int dt, int tm, bool gg = false) {
|
||||
const size_t a = gu == 16 ? i8_sm<16>(tm, gg) : gu == 17 ? i8_sm<17>(tm, gg) : gu == 18 ? i8_sm<18>(tm, gg) : gu == 21 ? i8_sm<21>(tm, gg) : gu == 23 ? i8_sm<23>(tm, gg) :
|
||||
gu == 29 ? i8_sm<29>(tm, gg) : gu == 42 ? i8_sm<42>(tm, gg) : gu == 12 ? i8_sm<12>(tm, gg) : gu == 13 ? i8_sm<13>(tm, gg) : gu == 14 ? i8_sm<14>(tm, gg) :
|
||||
gu == 8 ? i8_sm<8>(tm, gg) : i8_sm<22>(tm, gg);
|
||||
const size_t b = dt == 20 ? i8_sm<20>(tm, gg) : dt == 6 ? i8_sm<6>(tm, gg) : dt == 8 ? i8_sm<8>(tm, gg) : dt == 7 ? i8_sm<7>(tm, gg) : dt == 13 ? i8_sm<13>(tm, gg) :
|
||||
dt == 14 ? i8_sm<14>(tm, gg) : i8_sm<42>(tm, gg);
|
||||
return a > b ? a : b;
|
||||
}
|
||||
int i8_env_int(const char* name, int dflt);
|
||||
|
||||
@@ -6264,6 +6264,35 @@ const char* i8_device_gcn() {
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
// TUNE-0216: the Volta rule of the int8 kernels (i8_expert_rule.hpp, i8_tile_two_blocks; the global grid of I8Smem GG) - on for a compute capability 7.0 card unless
|
||||
// STRATA_I8_SM70=0; the multiprocessor's shared memory and the per-block reservation read once per device. A HIP card: off.
|
||||
struct I8Volta {
|
||||
bool on = false;
|
||||
size_t smem_sm = 0, reserved = 0;
|
||||
};
|
||||
I8Volta i8_volta() {
|
||||
#if defined(__HIPCC__)
|
||||
return {};
|
||||
#else
|
||||
static const int sw = strata::kernels::i8_switch_parse(std::getenv("STRATA_I8_SM70"));
|
||||
static std::mutex mu;
|
||||
static I8Volta per[64];
|
||||
static bool done[64] = {};
|
||||
int dev = 0;
|
||||
if (!strata::kernels::i8_volta_rule_on(sw) || cudaGetDevice(&dev) != cudaSuccess || dev < 0 || dev >= 64) return {};
|
||||
std::lock_guard<std::mutex> lk(mu);
|
||||
if (!done[dev]) {
|
||||
done[dev] = true;
|
||||
int major = 0, minor = 0, sm = 0, res = 0;
|
||||
cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev);
|
||||
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
|
||||
cudaDeviceGetAttribute(&sm, cudaDevAttrMaxSharedMemoryPerMultiprocessor, dev);
|
||||
if (cudaDeviceGetAttribute(&res, cudaDevAttrReservedSharedMemoryPerBlock, dev) != cudaSuccess) { cudaGetLastError(); res = 0; }
|
||||
per[dev] = {strata::cc_major_of(major) == 7 && strata::cc_minor_of(minor) == 0 && sm > 0, (size_t) sm, (size_t) res};
|
||||
}
|
||||
return per[dev];
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void native_grouped_set_v1(bool v1) { g_grouped_v1 = v1; }
|
||||
@@ -6382,14 +6411,21 @@ void native_expert_i8(const NativeExpertLayout& L, const unsigned long long* grp
|
||||
int tm = i8_env_int("STRATA_I8_TM", 0); // research: the tile code (2, 3 or 4 rows of 16 entries per thread -> 32, 48 or 64 entries; 8 = variant B, 128 entries)
|
||||
const int64_t avg = cap_entries / cap_groups;
|
||||
const bool b_ok = L.n_embd % 128 == 0 && L.n_ff % 64 == 0;
|
||||
const bool tm_set = tm > 0;
|
||||
if (tm <= 0) tm = (avg >= 96 && b_ok) ? 8 : (int) std::max<int64_t>(2, std::min<int64_t>(4, (avg + 8) / 16));
|
||||
tm = tm <= 2 ? 2 : tm == 3 ? 3 : tm >= 8 && b_ok && i8_tile8_type(L.gu_type) && i8_tile8_type(L.d_type) ? 8 : 4; // (the K-quants and Q5_1 have no tile 8)
|
||||
// Volta (i8_expert_rule.hpp, i8_tile_two_blocks): the big-grid formats read their grid from global memory, and the pick is lowered to the largest tile that keeps two blocks
|
||||
// per multiprocessor (a tile set by STRATA_I8_TM is kept; STRATA_I8_SM70=0 turns both off)
|
||||
const I8Volta vo = i8_volta();
|
||||
const bool gg = vo.on && i8_gg_type(L.gu_type);
|
||||
if (vo.on && !tm_set) tm = strata::kernels::i8_tile_two_blocks(tm, i8_smem_bytes(L.gu_type, L.d_type, 2, gg), i8_smem_bytes(L.gu_type, L.d_type, 3, gg),
|
||||
i8_smem_bytes(L.gu_type, L.d_type, 4, gg), vo.smem_sm, vo.reserved);
|
||||
const size_t smem_limit = i8_smem_limit(); // a tile that does not fit the device's shared memory per block falls to the next smaller one
|
||||
while (tm > 2 && i8_smem_bytes(L.gu_type, L.d_type, tm) > smem_limit) tm = tm == 8 ? 4 : tm - 1;
|
||||
while (tm > 2 && i8_smem_bytes(L.gu_type, L.d_type, tm, gg) > smem_limit) tm = tm == 8 ? 4 : tm - 1;
|
||||
const int bm = tm == 8 ? 128 : 16 * tm;
|
||||
i8_tiles_kernel<<<1, 256, 0, s>>>(grp_start, n_groups, bm, tile_off);
|
||||
I8Args a{grp_ptr, grp_start, n_groups, tile_off, ent_tok, ent_dst, (const block_q8_1*) x_q8_1, hq, out, L,
|
||||
cap_entries / bm + cap_groups, i8_env_int("STRATA_I8_BISECT", 0), i8_n8_takes(i8_switch_parse(std::getenv("STRATA_I8_N8")), tm)}; // 8-entry slices: tile 2 by default, 2-4 with STRATA_I8_N8=1, none with 0
|
||||
cap_entries / bm + cap_groups, i8_env_int("STRATA_I8_BISECT", 0), i8_n8_takes(i8_switch_parse(std::getenv("STRATA_I8_N8")), tm), gg}; // 8-entry slices: tile 2 by default, 2-4 with STRATA_I8_N8=1, none with 0
|
||||
switch (L.gu_type) {
|
||||
case 16: i8_launch<16, true>(tm, a, s); break;
|
||||
case 17: i8_launch<17, true>(tm, a, s); break;
|
||||
|
||||
@@ -171,6 +171,24 @@ int main() {
|
||||
CHECK(i8_chunk_default_allows(-1, false, true, 8192, lim));
|
||||
CHECK(i8_chunk_default_allows(-1, false, false, 8192, lim));
|
||||
}
|
||||
// the Volta tile rule (TUNE-0216): the largest tile 2-4 (8 counts as 4) whose shared memory leaves two blocks per multiprocessor; tile 2 when none does
|
||||
{
|
||||
const std::size_t v100 = 98304, res = 0; // Tesla V100: 96 KB per multiprocessor, no reservation
|
||||
// IQ3_S / IQ4_NL (bytes of the bench's I8-LAUNCH lines): tiles 2 / 3 / 4 = 43,008 / 48,128 / 53,248
|
||||
CHECK(i8_tile_two_blocks(8, 43008, 48128, 53248, v100, res) == 3);
|
||||
CHECK(i8_tile_two_blocks(4, 43008, 48128, 53248, v100, res) == 3);
|
||||
CHECK(i8_tile_two_blocks(3, 43008, 48128, 53248, v100, res) == 3);
|
||||
CHECK(i8_tile_two_blocks(2, 43008, 48128, 53248, v100, res) == 2);
|
||||
// IQ2_S with its grid in shared memory (49,152 / 54,272 / 59,392): no tile gives two blocks -> tile 2; with the global grid (40,960 / 46,080 / 51,200) -> tile 3
|
||||
CHECK(i8_tile_two_blocks(8, 49152, 54272, 59392, v100, res) == 2);
|
||||
CHECK(i8_tile_two_blocks(8, 40960, 46080, 51200, v100, res) == 3);
|
||||
// a reservation per block counts against the fit: 2 x (48,128 + 1,024) is exactly 96 KB (fits), 2 x (48,128 + 1,025) is not
|
||||
CHECK(i8_tile_two_blocks(3, 43008, 48128, 53248, v100, 1024) == 3);
|
||||
CHECK(i8_tile_two_blocks(3, 43008, 48128, 53248, v100, 1025) == 2);
|
||||
// a bigger multiprocessor keeps the larger tile (never above 4: tile 8 is not this rule's pick)
|
||||
CHECK(i8_tile_two_blocks(8, 43008, 48128, 53248, 233472, 1024) == 4);
|
||||
CHECK(i8_volta_rule_on(-1) && i8_volta_rule_on(1) && !i8_volta_rule_on(0));
|
||||
}
|
||||
if (failed) {
|
||||
std::fprintf(stderr, "i8_expert_rule_test: %d check(s) failed\n", failed);
|
||||
return 1;
|
||||
|
||||
Reference in new issue
Block a user