mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
ling32 --mtp-auto: with the pool size known the pool decides (>= 4500 experts on the card), the link only has to clear a 16 GB/s floor
The first version (link >= 32 GB/s AND >= 4500 card experts) would switch MTP off on the AMD R9700 (about 5958 slots, 24-26 GB/s link), where it was measured winning: L32-PREFILL 4K decode 38.6 against 33.8 plain, 32K 36.3 against 32.8; L32-HIP short set about 58 with K=1. All measured cards agree with the pool size alone: RTX 5090 5466 slots +4..11 %, R9700 5958 slots +11..14 %, RTX 5070 Ti 2413 slots -0.7 %, RTX 3090 / 4090 about 4000 slots never (forced K=1: 1.83 tokens per verify at 48.0 tok/s against 49.0 plain). With the pool size known the rule is: pool >= 4500 and link >= 16 GB/s (PCIe 3.0 x16 measures about 12 GB/s and has no measurement with a big pool); without it (-1) the old link-only rule (>= 32 GB/s) stays. Tests: planner table (R9700, 3090, PCIe 3.0, unmeasured link rows), ling32_mtp_auto_regress legs (3090-like small pool not loaded, R9700-like big pool loaded, 12 GB/s not loaded, 46 GB/s both ways). z440 CTest planner + mtp_auto pass. To be A/B-checked on the R9700 by L32-HIP (auto against forced-on against plain, 4K and 32K).
This commit is contained in:
1 parent
875d0ec86a
commit
81e5e72729
3 files changed
+23
-6
No files matched your search
@@ -293,16 +293,24 @@ constexpr double kMtpAutoMinLinkGbps = 32.0; // between PCIe 4.0 x16 (24.4 GB/
|
||||
// Tier B also needs a big enough card pool: a verify batch of 2 tokens needs the experts of both tokens and consecutive tokens share only about 19 % of their expert uses, so with an LRU pool the misses of a
|
||||
// 2-row verify are 2.0x those of one row (cache simulation on 2810 real decode tokens, L32-MID2): 1.8 tokens per verify then run at 0.90x on a link-bound card. MTP only pays when the GPU, not the link, limits
|
||||
// the step, i.e. from a hit rate of about 90 %. Measured: RTX 5090 (PCIe 5.0, 5466 slots) +4..11 %; RTX 5070 Ti (PCIe 5.0, 2413 slots) -0.7 %, 12 GB emulation (1485 slots) -2.4 %; RTX 4090 / 3090 (PCIe 4.0,
|
||||
// about 4000 slots) never. No point between 2413 and 5466 slots on a fast link: 4500 (22 % of the 20480 routed experts) is the conservative side of the cut.
|
||||
// about 4000 slots) never; AMD R9700 (PCIe 4.0 at 24-26 GB/s, 5958 slots): MTP wins +11..14 % (L32-PREFILL: 4K decode 38.6 against 33.8, 32K 36.3 against 32.8; L32-HIP short set about 58 with K=1), so with a big
|
||||
// pool the link speed is not what decides: the pool size is. No point between 4076 and 5466 slots: 4500 (22 % of the 20480 routed experts) is the conservative side of the cut. With the pool size known the link
|
||||
// only has to clear a floor (PCIe 3.0 x16 measures about 12 GB/s: no measurement of a big pool there); without it the old link-only rule (>= 32 GB/s) applies.
|
||||
constexpr int kMtpAutoMinCardExperts = 4500;
|
||||
constexpr double kMtpAutoMinLinkWithPoolGbps = 16.0;
|
||||
inline bool mtp_auto_pays(TierMode mode, bool unified, double h2d_gbps, std::string* why = nullptr, int card_experts = -1, int min_card_experts = kMtpAutoMinCardExperts) {
|
||||
auto say = [&](const char* s) { if (why) *why = s; };
|
||||
if (unified) { say("unified memory: no link to wait for"); return true; }
|
||||
if (mode == TierMode::A) { say("all experts resident: no link to wait for"); return true; }
|
||||
if (mode == TierMode::C) { say("the SSD tier is slower than any drafter gain"); return false; }
|
||||
if (h2d_gbps >= kMtpAutoMinLinkGbps && card_experts >= 0 && card_experts < min_card_experts) { say("tier B with fewer than 4500 experts on the card: a 2-token verify misses twice as much as one token"); return false; }
|
||||
if (h2d_gbps >= kMtpAutoMinLinkGbps) { say("the host-to-device link has room (>= 32 GB/s)"); return true; }
|
||||
if (h2d_gbps <= 0.0) { say("the host-to-device link could not be measured"); return false; }
|
||||
if (card_experts >= 0) { // the pool size is known: it decides (see above), the link only has to clear a floor
|
||||
if (card_experts < min_card_experts) { say("tier B with fewer than 4500 experts on the card: a 2-token verify misses twice as much as one token"); return false; }
|
||||
if (h2d_gbps < kMtpAutoMinLinkWithPoolGbps) { say("tier B over a link below 16 GB/s: not measured with a big pool"); return false; }
|
||||
say("tier B with a big card pool (>= 4500 experts): the GPU, not the link, limits the step");
|
||||
return true;
|
||||
}
|
||||
if (h2d_gbps >= kMtpAutoMinLinkGbps) { say("the host-to-device link has room (>= 32 GB/s)"); return true; }
|
||||
say("tier B over a link below 32 GB/s: the controller never finds a gain");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
The rule (mtp_auto_pays in ling32_tier_planner.hpp, table-tested in ling32_tier_planner_test) decides from the memory tier and the measured host-to-device link; STRATA_L32_H2D_GBPS replaces the measurement here.
|
||||
Legs (greedy, 24 generated tokens, 300-token prompt):
|
||||
|
||||
tier B, link 24.4 GB/s (a PCIe 4.0 x16 card) --mtp-auto: 'not loaded', no speculative decoding, the plan is made again without the sidecar
|
||||
tier B, link 46 GB/s (PCIe 5.0 x16) --mtp-auto: 'loaded', speculative decoding on
|
||||
tier B, link 24.4 GB/s, small pool (3090 / 4090) --mtp-auto: 'not loaded', no speculative decoding, the plan is made again without the sidecar
|
||||
tier B, link 24.4 GB/s, big pool (R9700) --mtp-auto: 'loaded', speculative decoding on
|
||||
tier B, link 12 GB/s, big pool --mtp-auto: 'not loaded' (below the 16 GB/s floor)
|
||||
tier B, link 46 GB/s (PCIe 5.0 x16) --mtp-auto: 'loaded' with the pool cut off, 'not loaded' with a small pool
|
||||
(the pool cut is moved by STRATA_L32_MTP_AUTO_MIN_CARD: the fixture's pool is tiny in bytes but holds many fixture experts)
|
||||
tier B, link 24.4 GB/s --mtp FILE (forced): the sidecar is loaded and speculation runs
|
||||
tier A (all resident) --mtp-auto: 'loaded'
|
||||
|
||||
@@ -51,7 +54,9 @@ def main():
|
||||
legs = [
|
||||
# name, extra args, link, expected 'MTP sidecar (--mtp-auto): ' text, whether speculation runs
|
||||
("plain tier B", tier_b, None, None, False),
|
||||
("auto, tier B, link 24.4", tier_b + ["--mtp-auto", mtp] + spec, 24.4, "not loaded", False),
|
||||
("auto, tier B, link 24.4, small pool", tier_b + ["--mtp-auto", mtp] + spec, 24.4, "not loaded", False, 1000000), # RTX 3090 / 4090: about 4000 slots
|
||||
("auto, tier B, link 24.4, big pool", tier_b + ["--mtp-auto", mtp] + spec, 24.4, "loaded", True, 0), # AMD R9700: 5958 slots at 24-26 GB/s, MTP wins (the fixture's pool counts as big)
|
||||
("auto, tier B, link 12, big pool", tier_b + ["--mtp-auto", mtp] + spec, 12.0, "not loaded", False, 0), # PCIe 3.0 x16: below the 16 GB/s floor
|
||||
("auto, tier B, link 46, pool cut off", tier_b + ["--mtp-auto", mtp] + spec, 46.0, "loaded", True, 0),
|
||||
("auto, tier B, link 46, small pool", tier_b + ["--mtp-auto", mtp] + spec, 46.0, "not loaded", False, 1000000), # the fixture's pool is tiny in bytes but holds many fixture experts: the cut is moved above them
|
||||
("forced, tier B, link 24.4", tier_b + ["--mtp", mtp] + spec, 24.4, None, True),
|
||||
|
||||
@@ -188,6 +188,10 @@ int main(int argc, char** argv) {
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 39.0, &why, 2413) && !why.empty()); // RTX 5070 Ti 16 GB on PCIe 5.0: 2413 slots, -0.7 %
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 46.0, &why, 1485)); // 12 GB emulation: -2.4 %
|
||||
CHECK(mtp_auto_pays(TierMode::B, false, 46.0, &why, kMtpAutoMinCardExperts)); // the cut itself
|
||||
CHECK(mtp_auto_pays(TierMode::B, false, 25.0, &why, 5958) && !why.empty()); // AMD R9700 (PCIe 4.0, 24-26 GB/s, 5958 slots): MTP +11..14 % measured, the pool size decides, not the link
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 21.5, &why, 4076)); // RTX 3090 / 4090: 4076 slots, forced MTP never gains
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 12.0, &why, 6000) && !why.empty()); // PCIe 3.0 x16 with a big pool: not measured, below the floor
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 0.0, &why, 6000)); // link not measured: not loaded whatever the pool
|
||||
CHECK(mtp_auto_pays(TierMode::B, true, 0.0, &why, 100)); // unified memory ignores the pool size
|
||||
CHECK(mtp_auto_pays(TierMode::A, false, 0.0, &why, 100)); // tier A: everything is resident
|
||||
CHECK(!mtp_auto_pays(TierMode::B, false, 24.4, &why) && !why.empty()); // RTX 3090 / 4090, PCIe 4.0 x16: 1.00 tokens per verify
|
||||
|
||||
Reference in new issue
Block a user