mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 07:48:45 +00:00
[Engine] use larger INT8 expert tiles on sm_61
This commit is contained in:
1 parent
c3fefe0caa
commit
b569fd723b
2 files changed
+29
-5
No files matched your search
@@ -1222,6 +1222,7 @@ bits of the answer: a switch that changes rounding can change a greedy answer at
|
||||
| PCIe share from the CPU's speed | CUDA, one GPU or a layer split, no `--pcie-frac` | `--pcie-frac N` always wins; `STRATA_PCIE_FRAC_DEFAULT=old` keeps the probe-only rule; `STRATA_PCIE_AUTO_SPLIT=0` keeps the fixed probe share on a CUDA layer split; `STRATA_PCIE_K_RULE=0` and `STRATA_PCIE_SHARE_MAX=0.60` keep the 0.2.10 rule | The share starts at the probe's value and is refined in the first decode windows from the CPU pool's time per missed expert: `L / (L + k R)`, rounded to 0.05 and kept between 0.10 and 0.95, changed at most three times. k is 1.85 from a pool rate R of 30 GB/s of expert bytes and falls linearly to 0.8 at 12 GB/s (a weak pool is compute-bound), so a strong pool gets exactly the 0.2.10 shares (below 0.60) and a weak one up to 0.95. A CUDA layer split refines each stage by its own probed link. Integrated GPUs (Strix Halo and the other APUs) and `STRATA_DEFAULTS=026` keep k 1.85 and 0.60; on HIP the layer-split refinement stays opt-in (`STRATA_PCIE_AUTO_SPLIT=1`). Each change prints a `PCIe share:` line. On HIP it is the default for gfx1200/gfx1201 and for a discrete gfx103x card (RX 6000, #4007); `STRATA_PCIE_FRAC_DEFAULT=auto` turns it on for other HIP parts. Measured on an RTX PRO 6000 (12 GB free): 2 x 12 GB layer split +12% decode; one card with 4 pool workers 56 -> 79 tok/s, 2 workers 31 -> 63, 32 workers unchanged. Output changes in the last bits (first-window KL 0.03 on the decode-window yardstick, the same as the single-card rule). |
|
||||
| Chunk follows the host's memory | Linux file tier | `STRATA_PREFILL_HOST_PLAN=0` | See [Linux file tier](#linux-file-tier). |
|
||||
| Fused int8 prompt experts | gfx12 (R9700): IQ3_S and IQ3_XXS packs. 12.0 NVIDIA cards with 80 or more SMs: IQ2_S, IQ3_XXS, IQ3_S, IQ4_XS gate/up | `STRATA_PF_FUSED=0` | Replaces the MMQ prompt kernels. `STRATA_PF_FUSED=1` opts in every covered format on other cards (on HIP gfx11 and gfx1200/gfx1201 too; see [AMD_HIP.md](AMD_HIP.md)). |
|
||||
| `STRATA_I8_PASCAL_GRID=1` | CUDA, compute capability 6.1, INT8 prompt expert path | unset (off) | Uses the global IQ grid table when it allows a larger tile to fit in shared memory. |
|
||||
| Bare `--prefill auto` takes 32768-token chunks (16384 up to 0.2.10) | gfx12, Linux, one card | `STRATA_GFX12_CHUNK=0` (8192) or `=16` (16384), or `STRATA_GFX12_DEFAULTS=0` | An explicit `--prefill N`, `auto:N` or `STRATA_PREFILL_AUTO_MAX` is untouched. A 20K prompt is one chunk instead of 16384 + a tail (R9700, IQ3_S: 20K +12%, 32K +1.3%, 64K +2.6%; UD-Q4_K_XL 20K +26%); first-token KL against 16384 is at most 5e-5. The loan of cache slots is taken only for what a prompt needs; when the RAM left does not cover it the ceiling steps down to 16384, then 8192. |
|
||||
| K-quant experts read the prompt on MMQ | gfx12, Linux: UD-Q4/Q5/Q6_K_XL files (Q4_K, Q5_K, Q5_1, Q6_K experts) | `STRATA_MMQ_KQ=0` or `STRATA_GFX12_DEFAULTS=0` | Instead of dequantizing the experts to FP16 for hipBLASLt (R9700, UD-Q4_K_XL: prompt 4K +10%, 8K +14%, 32K +17%). It rounds differently: first-token KL against the FP16 path about 0.03. Models without K-quant experts never read it. |
|
||||
| gfx12 prompt staging ring | gfx12, Linux | `STRATA_GFX12_RING=0` or `STRATA_PREFILL_RING=96` | 256 slots below ~6K-token chunks, 192 up to 12K, 96 above (was 96): prompt 4K +16%, 2K +2%, 8K +3% on an R9700; bit-identical. |
|
||||
|
||||
@@ -6862,17 +6862,22 @@ const char* i8_device_gcn() {
|
||||
struct I8Volta {
|
||||
bool on = false;
|
||||
size_t smem_sm = 0, reserved = 0;
|
||||
bool pascal_grid = false;
|
||||
};
|
||||
I8Volta i8_volta() {
|
||||
#if defined(__HIPCC__)
|
||||
return {};
|
||||
#else
|
||||
static const int sw = strata::kernels::i8_switch_parse(std::getenv("STRATA_I8_SM70"));
|
||||
static const bool volta = strata::kernels::i8_volta_rule_on(strata::kernels::i8_switch_parse(std::getenv("STRATA_I8_SM70")));
|
||||
static const bool pascal = [] {
|
||||
const char* v = std::getenv("STRATA_I8_PASCAL_GRID");
|
||||
return v && v[0] == '1';
|
||||
}();
|
||||
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 {};
|
||||
if ((!volta && !pascal) || cudaGetDevice(&dev) != cudaSuccess || dev < 0 || dev >= 64) return {};
|
||||
std::lock_guard<std::mutex> lk(mu);
|
||||
if (!done[dev]) {
|
||||
done[dev] = true;
|
||||
@@ -6881,7 +6886,7 @@ I8Volta i8_volta() {
|
||||
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
|
||||
cudaDeviceGetAttribute(&sm, cudaDevAttrMaxSharedMemoryPerMultiprocessor, dev);
|
||||
if (cudaDeviceGetAttribute(&res, cudaDevAttrReservedSharedMemoryPerBlock, dev) != cudaSuccess) { cudaGetLastError(); res = 0; }
|
||||
per[dev] = {strata::cc_of(major, minor) == 70 && sm > 0, (size_t) sm, (size_t) res};
|
||||
per[dev] = {volta && strata::cc_of(major, minor) == 70 && sm > 0, (size_t) sm, (size_t) res, pascal && major == 6 && minor == 1};
|
||||
}
|
||||
return per[dev];
|
||||
#endif
|
||||
@@ -7017,12 +7022,30 @@ void native_expert_i8(const NativeExpertLayout& L, const unsigned long long* grp
|
||||
if (tm != 5) 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 bool gg = vo.on && i8_gg_type(L.gu_type);
|
||||
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);
|
||||
if (vo.on && !tm_set) tm = strata::kernels::i8_tile_volta(tm, avg, h_ok); // the tensor-core form from kI8hMinAvg entries an expert (i8_expert_rule.hpp)
|
||||
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, gg) > smem_limit) tm = tm == 8 || tm == 5 ? 4 : tm - 1;
|
||||
const auto fitting_tile = [&](bool global_grid) {
|
||||
int t = tm;
|
||||
while (t > 2 && i8_smem_bytes(L.gu_type, L.d_type, t, global_grid) > smem_limit)
|
||||
t = t == 8 || t == 5 ? 4 : t - 1;
|
||||
return t;
|
||||
};
|
||||
const int stock_tile = fitting_tile(gg);
|
||||
if (vo.pascal_grid && i8_gg_type(L.gu_type)) {
|
||||
// Keep the shared table unless global lookup lets Pascal launch a larger tile.
|
||||
const int global_tile = fitting_tile(true);
|
||||
if (global_tile > stock_tile) {
|
||||
tm = global_tile;
|
||||
gg = true;
|
||||
} else {
|
||||
tm = stock_tile;
|
||||
}
|
||||
} else {
|
||||
tm = stock_tile;
|
||||
}
|
||||
const int bm = tm == 8 ? 128 : tm == 5 ? 64 : 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,
|
||||
|
||||
Reference in new issue
Block a user