STRATA_ADAPT_OVERLAP: opt-in on every backend (RTX 5090 Laptop, Linux CUDA: 84.6 vs 106.6 tok/s decode median with it, 5 generations of 256 tokens from one build); log the state in both directions
Linux CUDA had it on by default since 0.1.43, measured on an RTX A4000 (+5.5..8.3% decode) and a Tesla P100 (+4.4%). An RTX 5090 Laptop with a native IQ3_XXS pack and --expert-cache-per-layer decodes 21% slower with it, and the overlap is the default only there. The switch is now =1 turns it on everywhere, and the startup log names the state (with the reason when it cannot run), so a decode-rate drop is not the only way to see it. Unchanged: the copy path, the gate predicates and the tokens (same tokens with or without it). Fixes #2010
This commit is contained in:
1 parent
88892dbde4
commit
661ff29339
2 files changed
+31
-22
No files matched your search
+8
-4
@@ -1697,14 +1697,18 @@ the pairs in which the switched arm won). They are here so you can try them on y
|
||||
-0.1% (5/6). Boxes that hold all experts in RAM never use the stage buffers.
|
||||
- **`STRATA_ADAPT_LAG=2`: the adaptive tier's copies are waited for one window later** (#764). Decode, 6 pairs: Tesla P100
|
||||
(PCIe 3.0 x16) +3.5% (6/6 pairs faster), RTX 5070 +0.2% (4/6), RTX 3060 -1.3% (0/6), so it stays opt-in.
|
||||
- **`STRATA_ADAPT_OVERLAP` (CUDA on Linux: on, `=0` turns it off; CUDA on Windows and HIP: `=1` turns it on, since an RTX 5070 on Windows decoded Q2_0 2.6% slower with it and IQ3_XXS no faster): the adaptive tier's copies land while the next
|
||||
- **`STRATA_ADAPT_OVERLAP` (`=1` turns it on, on every backend; the startup log names the state and, when it cannot run, why): the adaptive tier's copies land while the next
|
||||
window runs, with the same tokens.** The window takes the swaps at the same moment as with #463's wait (so the same experts run
|
||||
on the GPU and the CPU in every window), but the copies go in layer order and the verify window holds a layer's plan back
|
||||
until that layer's copies have landed, instead of the whole window waiting for the round (about 10 ms every fourth window on
|
||||
an A4000, PCIe 3.0 x16). One GPU, the whole arena in RAM, no `--adapt-async`, `--pipeline-windows`, `STRATA_ADAPT_LAG`,
|
||||
`STRATA_ADAPT_NOWAIT` or `STRATA_DMA_BATCH`; otherwise the log says why it is off. RTX A4000, 6 interleaved pairs each,
|
||||
decode median tok/s: Q2_0 16 GB 62.5 -> 66.2 (+5.9%), Q2_0 as a 12 GB card 51.3 -> 54.2 (+5.7%), IQ3_XXS 16 GB 48.6 -> 52.6 (+8.3%),
|
||||
IQ3_XXS as 12 GB 39.3 -> 41.5 (+5.5%), 6/6 pairs faster every time.
|
||||
`STRATA_ADAPT_NOWAIT` or `STRATA_DMA_BATCH`. On by default on CUDA on Linux since 0.1.43, opt-in on Windows and HIP;
|
||||
opt-in on every backend since #2010, after an RTX 5090 Laptop lost 21% decode with it. What it is worth per box: an RTX A4000 (6
|
||||
interleaved pairs each, decode median tok/s: Q2_0 16 GB 62.5 -> 66.2 (+5.9%), Q2_0 as a 12 GB card 51.3 -> 54.2 (+5.7%),
|
||||
IQ3_XXS 16 GB 48.6 -> 52.6 (+8.3%), IQ3_XXS as 12 GB 39.3 -> 41.5 (+5.5%), 6/6 pairs faster every time) and a Tesla P100
|
||||
(+4.4%) gain, but an RTX 5070 on Windows loses 2.6% on Q2_0 (IQ3_XXS no faster) and an RTX 5090 Laptop (WSL2, Core Ultra 9
|
||||
275HX, native IQ3_XXS pack, `--expert-cache-per-layer`) loses 21%: 84.6 vs 106.6 tok/s medians of 5 generations of 256
|
||||
tokens from one build, the slowest of the fast run above the fastest of the slow one (#2010).
|
||||
- **`STRATA_ADAPT_CALLBACK_WARMUP` (Linux, on by default since 0.1.43.1; =0 turns it off): start the GPU host-callback thread before the CPU
|
||||
pool pins the host thread.** A callback thread created later can inherit the host's one-CPU affinity and compete
|
||||
with the verifier spinning for its signal (#1975). The warm-up runs and synchronizes one no-op host callback before
|
||||
|
||||
+23
-18
@@ -1336,21 +1336,21 @@ int adapt_lag() {
|
||||
return v;
|
||||
}
|
||||
|
||||
/// 0.1.43 STRATA_ADAPT_OVERLAP=1: the adaptive tier's copies land while the next decode window already runs. The window
|
||||
/// STRATA_ADAPT_OVERLAP=1: the adaptive tier's copies land while the next decode window already runs. The window
|
||||
/// sees the swapped-in experts as resident from its first layer, exactly as after #463's wait (so the tokens are the same
|
||||
/// ones); what changes is only when the bytes arrive: the copies go in layer order and the verify window holds a layer's
|
||||
/// plan back until that layer's copies have landed (AdaptGate in strata/core/verify.hpp). The ~10 ms a 96-swap round
|
||||
/// took at the next window's start (PCIe 3.0 x16, Q2_0) is then hidden behind the window. On for CUDA (=0 turns it off), opt-in on HIP.
|
||||
/// took at the next window's start (PCIe 3.0 x16, Q2_0) is then hidden behind the window. Opt-in on every backend
|
||||
/// (=1 turns it on); the startup log names the state, and why when it cannot run.
|
||||
bool adapt_overlap() {
|
||||
static const bool v = [] {
|
||||
const char* e = std::getenv("STRATA_ADAPT_OVERLAP");
|
||||
#if defined(STRATA_USE_HIP)
|
||||
return e && e[0] == '1'; // HIP: not measured yet, opt-in
|
||||
#elif defined(_WIN32)
|
||||
return e && e[0] == '1'; // Windows CUDA: opt-in (RTX 5070, Q2_0: -2.6% story decode with it, IQ3_XXS neutral)
|
||||
#else
|
||||
return !(e && e[0] == '0'); // Linux CUDA: on since 0.1.43 (same tokens, +5.5..8.3% decode on an A4000, +4.4% P100); =0 turns it off
|
||||
#endif
|
||||
// Opt-in on every backend (#2010). Windows CUDA since 0.1.43: an RTX 5070 decoded Q2_0 2.6% slower with it
|
||||
// (story decode, -2.1% code), IQ3_XXS no faster. Linux CUDA was on by default from 0.1.43 (same tokens, +5.5..8.3%
|
||||
// decode on an A4000, +4.4% on a P100) until an RTX 5090 Laptop (WSL2, Core Ultra 9 275HX, native IQ3_XXS pack,
|
||||
// --expert-cache-per-layer) decoded 21% slower with it: 84.6 vs 106.6 tok/s medians of 5 generations of 256
|
||||
// tokens from one build, the slowest of the fast run above the fastest of the slow one.
|
||||
return e && e[0] == '1';
|
||||
}();
|
||||
return v;
|
||||
}
|
||||
@@ -8307,8 +8307,10 @@ int main(int argc, char** argv) {
|
||||
bool aflipped = false; // the pending swaps are in the tables and their copies may still be landing
|
||||
bool aov = false;
|
||||
int64_t aov_flips = 0;
|
||||
if (adapt_overlap()) {
|
||||
const char* why = multi_gpu || !stages.empty() ? "not on a layer split"
|
||||
// #2010: the overlap is opt-in on every backend now, so the off state is the default and has to be visible too.
|
||||
// The predicates are side-effect free, so they are read in both states: they name why it could not run.
|
||||
const bool aov_want = adapt_overlap();
|
||||
const char* aov_why = multi_gpu || !stages.empty() ? "not on a layer split"
|
||||
: peer.valid() ? "not with --peer-device"
|
||||
: remote_opt ? "not with --remote-expert-opt"
|
||||
: o.adapt_async ? "not with --adapt-async"
|
||||
@@ -8323,12 +8325,13 @@ int main(int argc, char** argv) {
|
||||
? "not in the resident RAM mode unless STRATA_ADAPT_OVERLAP_RESIDENT=1"
|
||||
: drive.d.usage.empty() ? "the adaptive tier is off"
|
||||
: nullptr;
|
||||
if (why == nullptr) {
|
||||
if (aov_want) {
|
||||
if (aov_why == nullptr) {
|
||||
agate.ticks.resize((size_t) g.n_layers + 1);
|
||||
for (int64_t l = 0; l <= g.n_layers; ++l) agate.ticks[(size_t) l] = {&agate, (int32_t) l};
|
||||
agate.has.assign((size_t) g.n_layers, 0);
|
||||
if (!ver.set_adapt_gate(&agate)) why = "the device-planned layers (STRATA_VERIFY_DEVICE_PLAN) are on";
|
||||
if (why == nullptr && !(std::getenv("STRATA_ADAPT_SIGNAL") && std::getenv("STRATA_ADAPT_SIGNAL")[0] == 'h')) {
|
||||
if (!ver.set_adapt_gate(&agate)) aov_why = "the device-planned layers (STRATA_VERIFY_DEVICE_PLAN) are on";
|
||||
if (aov_why == nullptr && !(std::getenv("STRATA_ADAPT_SIGNAL") && std::getenv("STRATA_ADAPT_SIGNAL")[0] == 'h')) {
|
||||
// the landing of each layer's copies is told by a stream-ordered D2H copy of the layer number into pinned memory
|
||||
// (STRATA_ADAPT_SIGNAL=host: a host function instead). No callback thread has to be scheduled while the pool's workers spin on every other CPU
|
||||
int32_t* vals = nullptr; void* hp = nullptr;
|
||||
@@ -8344,13 +8347,15 @@ int main(int argc, char** argv) {
|
||||
} else { (void) cudaGetLastError(); }
|
||||
}
|
||||
}
|
||||
aov = why == nullptr;
|
||||
aov = aov_why == nullptr;
|
||||
if (aov)
|
||||
std::fprintf(stderr, "strata serve: adaptive overlap (STRATA_ADAPT_OVERLAP=0 turns it off): the adaptive tier's copies land while the next window runs "
|
||||
"(same tokens, a layer waits for its own copies)\n");
|
||||
else if (std::getenv("STRATA_ADAPT_OVERLAP") != nullptr) // quiet when it was only the default
|
||||
std::fprintf(stderr, "strata serve: STRATA_ADAPT_OVERLAP=1 is off: %s\n", why);
|
||||
}
|
||||
else if (std::getenv("STRATA_ADAPT_OVERLAP") != nullptr) // the env var was set: say what stopped it
|
||||
std::fprintf(stderr, "strata serve: STRATA_ADAPT_OVERLAP=1 is off: %s\n", aov_why);
|
||||
} else
|
||||
std::fprintf(stderr, "strata serve: adaptive overlap: off%s%s\n",
|
||||
aov_why ? ": " : " (STRATA_ADAPT_OVERLAP=1 turns it on)", aov_why);
|
||||
// a layer split's later stages keep a copy of the residency table on their devices, and swap on their own
|
||||
auto res_upload = [&]() {
|
||||
if (d_res != nullptr)
|
||||
|
||||
Reference in new issue
Block a user