Merge f-143-amd: gfx12 decode defaults

This commit is contained in:
Niko1221 committed 2026-10-11 01:49:18 +02:00
commit f5a0126762
1 file changed
+18 -9
+18 -9
View File
@@ -37,6 +37,7 @@
#include "strata/core/layout.hpp"
#include "strata/core/session.hpp"
#include "strata/core/weights.hpp"
#include "strata/kernels/gfx_arch.hpp"
#include "strata/kernels/cpu/expert.hpp"
#include "strata/kernels/cpu/pool.hpp"
#include "strata/platform/aux_cpus.hpp"
@@ -1554,6 +1555,19 @@ bool load_control_vectors(const Options& o, const strata::core::ModelGeometry& g
return true;
}
// 0.1.43: the HIP defaults of the decode speed push (route tail skip, measured PCIe share) were measured on gfx1201 (Radeon AI PRO
// R9700) and apply on gfx1200 / gfx1201 only; every other AMD part (gfx11, gfx906, ...) keeps its earlier behaviour. CUDA: always true.
[[maybe_unused]] static bool decode_defaults_arch_ok() {
#if defined(STRATA_USE_HIP)
int dev = 0;
cudaDeviceProp p{};
return cudaGetDevice(&dev) == cudaSuccess && cudaGetDeviceProperties(&p, dev) == cudaSuccess &&
strata::kernels::gfx_arch_is_gfx12_wmma(p.gcnArchName);
#else
return true;
#endif
}
// The effective host->device bandwidth of the PCIe link: copies from pinned host memory, as the expert arena's
// reads are. The native default share (0.55) was measured on x16 links (~26-28 GB/s); a x8 card in a x8 slot
// carries about half of that. Returns < 0 when the probe cannot run (then the caller keeps the default).
@@ -2718,11 +2732,9 @@ int main(int argc, char** argv) {
o.pcie_frac = pcie_frac_for_gbps(bw, base);
std::fprintf(stderr, "strata generate: PCIe probe: %.1f GB/s host->device (best of %s) -> pcie_frac %.2f "
"(default %.2f)\n", bw, bursts.c_str(), o.pcie_frac, base);
#if !defined(STRATA_USE_HIP)
const char* pfd = std::getenv("STRATA_PCIE_FRAC_DEFAULT");
o.pcie_frac_auto = o.layer_split.empty() && !(pfd != nullptr && std::strcmp(pfd, "old") == 0);
o.pcie_frac_auto = o.layer_split.empty() && decode_defaults_arch_ok() && !(pfd != nullptr && std::strcmp(pfd, "old") == 0);
o.pcie_probe_gbps = bw;
#endif
} else {
o.pcie_frac = base;
std::fprintf(stderr, "strata generate: PCIe probe failed -> pcie_frac default %.2f\n", base);
@@ -8114,14 +8126,13 @@ int main(int argc, char** argv) {
drive.d.pcie_num = std::max(0, std::min(256, (int) (o.pcie_frac * 256.0 + 0.5)));
const bool all_experts_resident = !host_res.empty() &&
std::all_of(host_res.begin(), host_res.end(), [](int32_t r) { return r >= 0; });
// STRATA_ROUTE_TAIL_SKIP: ON BY DEFAULT on CUDA builds (owner decision, 0.1.42): a missed expert that every token of
// STRATA_ROUTE_TAIL_SKIP: ON BY DEFAULT on CUDA builds (owner decision, 0.1.42) and on HIP gfx1200/gfx1201 (0.1.43): a missed expert that every token of
// a verify window routes at rank 7 or lower is neither copied nor computed (answers differ slightly from 0.1.41,
// KL ~0.003-0.006; docs/DETAILS.md). =0 restores 0.1.41's bytes. Nothing to do, so no default and no line, when every
// expert is in VRAM; off with --batch slots (a window then mixes requests, and one request's skip would depend on
// another's tokens) and, as in the dispatch, with a peer or helper GPU. A layer split is fine: each stage skips by itself.
{
const char* tse = std::getenv("STRATA_ROUTE_TAIL_SKIP");
#if !defined(STRATA_USE_HIP)
// #1884: with nearly every expert in the GPU cache (V100 32 GB, Coder IQ1_M: 94.8% of the experts, 99.9% decode hits) the few
// misses are cheap and the skip costs more draft acceptance (70.1% -> 68.2%) than it saves: -1..2% decode. No default then.
size_t cached_experts = 0;
@@ -8132,14 +8143,12 @@ int main(int argc, char** argv) {
const bool nearly_all_cached = !host_res.empty() && !all_experts_resident &&
(double) cached_experts >= max_cached * (double) host_res.size();
const bool tail_default_ok = tse == nullptr && !all_experts_resident && !nearly_all_cached && o.batch == 0 &&
decode_defaults_arch_ok() &&
o.peer_device < 0;
if (tse == nullptr && nearly_all_cached && o.batch == 0 && o.peer_device < 0)
if (tse == nullptr && nearly_all_cached && o.batch == 0 && o.peer_device < 0 && decode_defaults_arch_ok())
std::fprintf(stderr, "strata serve: STRATA_ROUTE_TAIL_SKIP is off by default: %.1f%% of the experts are in the GPU cache, so "
"few are missed and skipping them costs more draft acceptance than it saves; "
"STRATA_ROUTE_TAIL_SKIP=7 turns it on\n", 100.0 * (double) cached_experts / (double) host_res.size());
#else
const bool tail_default_ok = false; // HIP and SYCL stay as they were
#endif
if (tail_default_ok) strata::core::set_tail_skip_rank(7);
if (strata::core::tail_skip_rank() > 0 && !all_experts_resident)
std::fprintf(stderr, "strata serve: STRATA_ROUTE_TAIL_SKIP=%d is ON%s: a missed expert that every token of a verify window routes at rank %d or "