mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 14:21:06 -10:00
CPU prefill share: the default limit goes from 1,024 to 3,072 tokens (CUDA, one GPU, only where experts are missing): TTFT of a 1-2K prompt on a card holding half the experts drops 30-60%, P100 +25% at 1K and +13% at 2K, 4K and above unchanged; share_rules::default_share_limit keeps a class gate, STRATA_PREFILL_CPU_SHARE_MAX=1024 restores the old limit, unit test added
This commit is contained in:
1 parent
081d1c04d2
commit
c4082ce8c4
3 files changed
+23
-3
No files matched your search
@@ -12,6 +12,17 @@
|
||||
|
||||
namespace strata::prefill::share_rules {
|
||||
|
||||
// ---- the limit (BW-MEASURE E25, owner decision 10-31) ----
|
||||
// The DEFAULT share applies to staged chunks up to this many tokens. 0.1.41 armed it below 1,024 tokens (RTX 3060, P100, RTX 5070: -20..-35% at 512 and
|
||||
// 1,000 tokens). A chunk of 1-3K tokens routes to nearly every expert of every layer, so with half the experts resident one pass over the rest at the link's
|
||||
// speed is its floor (RTX PRO 5000 with a 28 GB/s link and 12,437 of 24,576 experts resident: 0.97-1.04 s for any 1K-4K prompt) and the CPU share takes
|
||||
// part of that pass: prompt speed +151% at 1K, +45% at 2K (TTFT 1.07 -> 0.74 s), +99% / +32% with 8 pool workers; 4K and above unchanged, and a limit
|
||||
// of 8,192 loses 1-6% at 4K-8K. First-token KL after a 1.1-2.8K prompt: mean 0.011, top-1 100%. STRATA_PREFILL_CPU_SHARE_MAX=1024 restores the old limit.
|
||||
constexpr int64_t kShareLimitOld = 1024;
|
||||
constexpr int64_t kShareLimitNew = 3072;
|
||||
/// `raise`: the card class may take the new limit (a class whose A/B lost at 1-3K keeps 1,024, automatically).
|
||||
constexpr int64_t default_share_limit(bool raise = true) { return raise ? kShareLimitNew : kShareLimitOld; }
|
||||
|
||||
/// resident_slots: the expert cache's live slots; total_pairs: layers x routed experts per layer (<= 0: unknown, arm).
|
||||
constexpr bool default_share_has_work(int64_t resident_slots, int64_t total_pairs) {
|
||||
return total_pairs <= 0 || resident_slots < total_pairs;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "strata/kernels/dflash2.hpp"
|
||||
#endif
|
||||
#include "strata/prefill/warm_policy.hpp"
|
||||
#include "strata/prefill/share_rules.hpp"
|
||||
#include <atomic>
|
||||
#if defined(__cpp_lib_atomic_wait)
|
||||
#define STRATA_ATOMIC_WAIT 1 // #1488: std::atomic::wait / notify_all are a GCC 11 library feature; GCC 10 spins instead
|
||||
@@ -262,7 +263,8 @@ inline int64_t cpu_share_max() {
|
||||
return e ? std::max<int64_t>(kStreamAllMinDefault, (int64_t) std::atoll(e)) : (int64_t) 3072;
|
||||
}();
|
||||
static const bool explicit_max = std::getenv("STRATA_PREFILL_CPU_SHARE_MAX") != nullptr;
|
||||
if (g_share_default && cpu_share_explicit() == -2.0 && !explicit_max) return kStreamAllMinDefault; // its measured range
|
||||
if (g_share_default && cpu_share_explicit() == -2.0 && !explicit_max) // the default-armed share: share_rules::default_share_limit (STRATA_PREFILL_CPU_SHARE_MAX=1024 restores the old 1,024)
|
||||
return strata::prefill::share_rules::default_share_limit();
|
||||
return v;
|
||||
}
|
||||
// On a layer split every stage may have the pool (set_cpu_pool), and the stages read different chunks at the same time:
|
||||
@@ -2626,9 +2628,10 @@ void Prefill::arm_cpu_share(bool applies, bool by_default) {
|
||||
#if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906)
|
||||
if (applies && by_default && cpu_share_explicit() == -2.0 && !g_share_default) {
|
||||
g_share_default = true;
|
||||
std::fprintf(stderr, "prefill: the CPU share is ON by default for prompt chunks below 1024 tokens (the idle CPU "
|
||||
std::fprintf(stderr, "prefill: the CPU share is ON by default for prompt chunks up to %lld tokens (the idle CPU "
|
||||
"takes some of the experts the GPU would stream; answers can differ slightly from 0.1.40.3, "
|
||||
"mean KL ~0.004). STRATA_PREFILL_CPU_SHARE=0 turns it off.\n");
|
||||
"mean KL ~0.004 below 1024 tokens, ~0.011 at 1-3K). STRATA_PREFILL_CPU_SHARE=0 turns it off, "
|
||||
"STRATA_PREFILL_CPU_SHARE_MAX=1024 keeps the old limit.\n", (long long) cpu_share_max());
|
||||
}
|
||||
#else
|
||||
(void) by_default;
|
||||
|
||||
@@ -19,6 +19,12 @@ int main() {
|
||||
CHECK(default_share_has_work(100000, 0)); // total unknown: keep today's behaviour
|
||||
static_assert(!default_share_has_work(10, 10), "constexpr");
|
||||
|
||||
// BW-MEASURE E25: the default limit is 3,072 tokens, 1,024 for a class that keeps the old one
|
||||
CHECK(strata::prefill::share_rules::default_share_limit() == 3072);
|
||||
CHECK(strata::prefill::share_rules::default_share_limit(true) == strata::prefill::share_rules::kShareLimitNew);
|
||||
CHECK(strata::prefill::share_rules::default_share_limit(false) == 1024);
|
||||
static_assert(strata::prefill::share_rules::kShareLimitOld == 1024, "the old limit (the way back is STRATA_PREFILL_CPU_SHARE_MAX=1024)");
|
||||
|
||||
// H11: memory verdicts
|
||||
using namespace strata::prefill::share_rules;
|
||||
const uint64_t G = 1ull << 30;
|
||||
|
||||
Reference in new issue
Block a user