mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
Merge f-0226-q4-small (ef587884ea): Pascal sm_61 INT8 expert tiles (PR 7775), Volta sm_70 kernels and defaults (PR 7765), the register entry
b569fd723b(Codex): larger INT8 expert tiles on sm_61, opt-in STRATA_I8_PASCAL_GRID=1.92879c33de(Xavier Port Builder): Volta (sm_70) kernels and defaults also for sm_72 (Jetson Xavier).ef587884ea: settings register + docs/SETTINGS.md for STRATA_I8_PASCAL_GRID. Contributors keep authorship, no trailers. For every other card the INT8 tile choice is the same loop as before.
This commit is contained in:
commit
c8f52ad60e
8 files changed
+74
-13
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. |
|
||||
|
||||
+2
-1
@@ -10,7 +10,7 @@ debugging and are kept in `terminal/data/settings-register.json`.
|
||||
A number or a word is set like any environment variable, for example `STRATA_KVA=1`. In the Terminal, `strata launch --set NAME=value`
|
||||
puts it in the model's run configuration.
|
||||
|
||||
## Switches you can turn on (472)
|
||||
## Switches you can turn on (473)
|
||||
|
||||
Off unless you set them. The last column says where each one is described.
|
||||
|
||||
@@ -124,6 +124,7 @@ Off unless you set them. The last column says where each one is described.
|
||||
| `STRATA_I8_DEFER` | on / off | NVIDIA and AMD | - |
|
||||
| `STRATA_I8_GRF` | number | Intel Arc | [INTEL_INT8_EXPERTS.md](INTEL_INT8_EXPERTS.md) |
|
||||
| `STRATA_I8_MT` | number | Intel Arc | [INTEL_INT8_EXPERTS.md](INTEL_INT8_EXPERTS.md) |
|
||||
| `STRATA_I8_PASCAL_GRID` | on / off | NVIDIA and AMD | [DETAILS.md](DETAILS.md) |
|
||||
| `STRATA_I8_WG` | number | Intel Arc | [INTEL_INT8_EXPERTS.md](INTEL_INT8_EXPERTS.md) |
|
||||
| `STRATA_INK_5060TI_MACRO_BF16` | text | NVIDIA and AMD | - |
|
||||
| `STRATA_INK_5090_DRAFTPOL_EXACT` | number | NVIDIA | - |
|
||||
|
||||
@@ -133,7 +133,7 @@ std::vector<std::pair<std::string, std::string>> nv_default_env(int major, int m
|
||||
// (the engine turns it off, with a line, for a layer split, helper cards, --batch and the other cases of the DETAILS.md row). STRATA_ADAPT_FETCH=0 is the way back.
|
||||
if (adapt_fetch_default_card(major, minor, main_vram_bytes)) t.push_back({"STRATA_ADAPT_FETCH", "2"});
|
||||
else if (main_vram_bytes > kAdaptFetchMaxVramBytes) t.push_back({"STRATA_VERIFY_DEVICE_HITS", "1"});
|
||||
} else if (mj == 7 && mn == 0) {
|
||||
} else if (mj == 7 && (mn == 0 || mn == 2)) {
|
||||
// Volta (Tesla V100 / Titan V / Quadro GV100, sm_70): 21 validated bit-exact switches measured on locked-clock
|
||||
// dual V100-SXM2-16GB (200 W / 1020 MHz and 300 W / 1530 MHz SM / 877 MHz MEM; identical sha and needle checks).
|
||||
// STRATA_SM70_PERF=0 and STRATA_DEFAULTS=026 leave the table out.
|
||||
@@ -244,7 +244,7 @@ std::vector<std::string> apply_nv_defaults(int major, int minor, uint64_t main_v
|
||||
// sm_86 / sm_89 / sm_70 / sm_60: bit-exact switches. sm_121: the fused prompt path and the FP4-activation NVFP4 prompt round differently from the
|
||||
// paths they replace (24 of 24 greedy answers were identical on the Spark; no KL run), so the line does not say "exact".
|
||||
const bool sm120 = mj == 12 && mn == 0;
|
||||
const bool sm70 = mj == 7 && mn == 0;
|
||||
const bool sm70 = mj == 7 && (mn == 0 || mn == 2);
|
||||
// ADAPT_FETCH (a card of 16 GiB or less) is not bit-exact either: the line then says so and names its own way back
|
||||
std::fprintf(stderr, "strata: %s: %zu %sspeed switches on by default (%s=0 turns them off%s; a switch you set is kept%s): ",
|
||||
sm86 ? "sm_86 (Ampere)" : sm89 ? "sm_89 (Ada)" : sm121 ? "sm_121 (GB10)" : sm120 ? "sm_120 (Blackwell)" : sm70 ? "sm_70 (Volta)" : "sm_60 (Pascal)", set.size(), sm121 || fetch_set ? "" : "exact ",
|
||||
|
||||
@@ -1413,7 +1413,7 @@ bool cur_dev_volta() {
|
||||
int major = 0, minor = 0;
|
||||
cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev);
|
||||
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
|
||||
per_dev[dev] = major == 7 && minor == 0 ? 2 : 1;
|
||||
per_dev[dev] = major == 7 && minor < 5 ? 2 : 1;
|
||||
}
|
||||
return per_dev[dev] == 2;
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,7 @@ __device__ __forceinline__ uint2 i8h_cvt4(uint32_t w) {
|
||||
return make_uint2(*(const uint32_t*) &l, *(const uint32_t*) &h);
|
||||
}
|
||||
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ == 700
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 && __CUDA_ARCH__ < 750
|
||||
__device__ __forceinline__ void i8h_mma(float (&d)[8], uint2 a, uint2 b) {
|
||||
asm volatile("mma.sync.aligned.m8n8k4.row.col.f32.f16.f16.f32 {%0,%1,%2,%3,%4,%5,%6,%7}, {%8,%9}, {%10,%11}, {%0,%1,%2,%3,%4,%5,%6,%7};\n"
|
||||
: "+f"(d[0]), "+f"(d[1]), "+f"(d[2]), "+f"(d[3]), "+f"(d[4]), "+f"(d[5]), "+f"(d[6]), "+f"(d[7])
|
||||
@@ -60,7 +60,7 @@ __global__ void __launch_bounds__(I8_NT, 2)
|
||||
i8h_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) {
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ == 700
|
||||
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 && __CUDA_ARCH__ < 750
|
||||
using SM = I8HSmem<T>;
|
||||
extern __shared__ uint4 i8_dyn[];
|
||||
uint32_t* const smem = (uint32_t*) i8_dyn;
|
||||
|
||||
@@ -6797,7 +6797,7 @@ int exp_mode() {
|
||||
// layout in windows of 4+ tokens (sm75_down_em below). STRATA_SM75_EXP=0 keeps the CUDA layout.
|
||||
// (off unless STRATA_SM75_PERF=1; STRATA_SM75_EXP=0 / 1 forces it off / on)
|
||||
const bool turing = strata::sm75_switch("STRATA_SM75_EXP", major, minor);
|
||||
per_dev[dev] = 1 + ((major == 7 && minor == 0 && sm70 != nullptr && std::atoi(sm70) != 0) || p100 || p40 || gb10 ? 8 : turing ? 4 : kExpModeDefault);
|
||||
per_dev[dev] = 1 + ((major == 7 && minor < 5 && sm70 != nullptr && std::atoi(sm70) != 0) || p100 || p40 || gb10 ? 8 : turing ? 4 : kExpModeDefault);
|
||||
}
|
||||
return per_dev[dev] - 1;
|
||||
#endif
|
||||
@@ -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,
|
||||
|
||||
@@ -4159,6 +4159,7 @@ int il_cc() {
|
||||
cc[dev] = 1201;
|
||||
// STRATA_MMVQ_IL_SM80=0: an sm_80 card takes the shared table as before kIlRows_80 (A/B)
|
||||
if (cc[dev] == 80 && !strata::sm80_default_on(std::getenv("STRATA_MMVQ_IL_SM80"), strata::qwen_defaults_026())) cc[dev] = 81; // =0 or STRATA_DEFAULTS=026
|
||||
if (cc[dev] == 72) cc[dev] = 70; // Jetson Xavier (sm_72) uses the Volta (sm_70) interleaved tables
|
||||
cudaGetLastError();
|
||||
}
|
||||
return cc[dev];
|
||||
@@ -4208,7 +4209,7 @@ bool il_arch_ok() {
|
||||
int minor = 0;
|
||||
cudaDeviceGetAttribute(&minor, cudaDevAttrComputeCapabilityMinor, dev);
|
||||
ok[dev] = (cudaDeviceGetAttribute(&major, cudaDevAttrComputeCapabilityMajor, dev) == cudaSuccess &&
|
||||
(major >= 8 || (major == 7 && minor == 0 && sm70_opt_in()) || (major == 7 && minor == 5 && sm75_il_on(major, minor)) ||
|
||||
(major >= 8 || (major == 7 && minor < 5 && sm70_opt_in()) || (major == 7 && minor == 5 && sm75_il_on(major, minor)) ||
|
||||
(major == 6 && minor == 0 && sm60_table_on()) || (major == 6 && minor == 1 && sm61_table_on()))) ? 1 : -1;
|
||||
}
|
||||
return ok[dev] > 0;
|
||||
|
||||
@@ -20624,6 +20624,41 @@
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
{
|
||||
"name": "STRATA_I8_PASCAL_GRID",
|
||||
"backends": [
|
||||
"cuda-hip"
|
||||
],
|
||||
"reads": [
|
||||
{
|
||||
"file": "engine/src/kernels/cuda/iq_kernels.cu",
|
||||
"line": 6873,
|
||||
"backend": "cuda-hip",
|
||||
"fn": "getenv"
|
||||
}
|
||||
],
|
||||
"parse": "flag",
|
||||
"default_state": "off",
|
||||
"code_default": null,
|
||||
"engine_sets": [],
|
||||
"engine_defaults": [],
|
||||
"launch_files": [],
|
||||
"launch_sets": [],
|
||||
"launch_reads": [],
|
||||
"doc_mentions": [
|
||||
"docs/DETAILS.md:1225"
|
||||
],
|
||||
"first_commit": "b569fd723b",
|
||||
"first_date": "2026-12-04",
|
||||
"since": null,
|
||||
"last_commit": "b569fd723b",
|
||||
"last_date": "2026-12-04",
|
||||
"status": "opt-in",
|
||||
"owner": "kernels",
|
||||
"note": "1: the sm_61 (Pascal GP102/GP104) int8 expert kernel may take a larger tile with a global grid lookup when the shared table does not fit (PR 7775, Codex). Not set: off, the stock tile pick is used.",
|
||||
"retire_after": "",
|
||||
"retired_in": ""
|
||||
},
|
||||
{
|
||||
"name": "STRATA_I8_SM70",
|
||||
"backends": [
|
||||
|
||||
Reference in new issue
Block a user