From e84392acc072ba19c0fb8e688608f34785f3e2d2 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Thu, 12 Nov 2026 22:20:22 +0100 Subject: [PATCH 1/9] prefill: research switch STRATA_SWITCH_POINT, the walk of a chunk by estimated cost With STRATA_SWITCH_POINT=1 (CUDA builds, default off) the chunk size from which a prompt chunk streams every expert the card does not hold is taken from a cost estimate of the staged and the streamed walk, from the card's share of non-resident experts, instead of the fixed 1,024. A card that holds every expert keeps 1,024 exactly. STRATA_PREFILL_STREAM_MIN, the CPU share's limit and the Windows gfx1151 floor keep precedence; the small-card walk is not touched. The rule is a pure header (switch_point_rule.hpp) with a unit test; the card's counts reach it through Prefill::set_card_expert_share, called before the first lend. Register entry: research. --- CMakeLists.txt | 5 + data/settings-register.json | 609 ++++++++++--------- include/strata/prefill/prefill.hpp | 3 + include/strata/prefill/switch_point_rule.hpp | 61 ++ src/prefill/prefill.cpp | 27 +- src/program/generate.cpp | 4 + tests/prefill/switch_point_rule_test.cpp | 73 +++ 7 files changed, 493 insertions(+), 289 deletions(-) create mode 100644 include/strata/prefill/switch_point_rule.hpp create mode 100644 tests/prefill/switch_point_rule_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f44268cf01..b77058c274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,6 +424,11 @@ if(STRATA_BUILD_TESTS) target_include_directories(staged_fo_rule_test PRIVATE include) add_test(NAME staged_fo_rule_test COMMAND staged_fo_rule_test) + # STRATA_SWITCH_POINT (research): the floor from the card's share of non-resident experts, a cost estimate of the staged and the streamed walk (header-only, no GPU) + add_executable(switch_point_rule_test tests/prefill/switch_point_rule_test.cpp) + target_include_directories(switch_point_rule_test PRIVATE include) + add_test(NAME switch_point_rule_test COMMAND switch_point_rule_test) + # whether the CUDA fused prompt kernels take the Gyro trellis experts by default (STRATA_PF_FUSED_TQ unset: the sm_86 cards with 80+ SMs; =1 any card; =0 off): the pure # rule, pinned for every card class (header-only, no GPU) add_executable(fused_tq_default_test tests/prefill/fused_tq_default_test.cpp) diff --git a/data/settings-register.json b/data/settings-register.json index 7b46d45871..0a865a99da 100644 --- a/data/settings-register.json +++ b/data/settings-register.json @@ -169,7 +169,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13829, + "line": 13831, "backend": "cuda-hip", "fn": "a_env" } @@ -202,7 +202,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13828, + "line": 13830, "backend": "cuda-hip", "fn": "a_env" } @@ -271,13 +271,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13492, + "line": 13494, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21193, + "line": 21197, "backend": "cuda-hip", "fn": "getenv" } @@ -378,13 +378,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13319, + "line": 13321, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21182, + "line": 21186, "backend": "cuda-hip", "fn": "getenv" } @@ -419,13 +419,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13318, + "line": 13320, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21181, + "line": 21185, "backend": "cuda-hip", "fn": "getenv" } @@ -460,7 +460,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21183, + "line": 21187, "backend": "cuda-hip", "fn": "getenv" } @@ -658,7 +658,7 @@ }, { "file": "src/program/generate.cpp", - "line": 13417, + "line": 13419, "backend": "cuda-hip", "fn": "getenv" } @@ -697,13 +697,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13367, + "line": 13369, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 13368, + "line": 13370, "backend": "cuda-hip", "fn": "getenv" } @@ -736,7 +736,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13662, + "line": 13664, "backend": "cuda-hip", "fn": "getenv" } @@ -769,7 +769,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13827, + "line": 13829, "backend": "cuda-hip", "fn": "a_env" } @@ -802,7 +802,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13383, + "line": 13385, "backend": "cuda-hip", "fn": "getenv" } @@ -1910,7 +1910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 902, + "line": 923, "backend": "cuda-hip", "fn": "getenv" } @@ -2046,7 +2046,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17878, + "line": 17880, "backend": "cuda-hip", "fn": "getenv" } @@ -2080,7 +2080,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17722, + "line": 17724, "backend": "cuda-hip", "fn": "getenv" }, @@ -2159,7 +2159,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14779, + "line": 14781, "backend": "cuda-hip", "fn": "getenv" } @@ -2192,7 +2192,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14781, + "line": 14783, "backend": "cuda-hip", "fn": "getenv" } @@ -2225,7 +2225,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14780, + "line": 14782, "backend": "cuda-hip", "fn": "getenv" } @@ -2552,7 +2552,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14800, + "line": 14802, "backend": "cuda-hip", "fn": "getenv" } @@ -2604,7 +2604,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17942, + "line": 17944, "backend": "cuda-hip", "fn": "getenv" } @@ -2791,7 +2791,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18483, + "line": 18485, "backend": "cuda-hip", "fn": "getenv" }, @@ -3064,13 +3064,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17195, + "line": 17197, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17328, + "line": 17330, "backend": "cuda-hip", "fn": "getenv" }, @@ -3206,7 +3206,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20558, + "line": 20560, "backend": "cuda-hip", "fn": "getenv" } @@ -3242,7 +3242,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3280, + "line": 3305, "backend": "cuda-hip", "fn": "getenv" } @@ -3602,7 +3602,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 755, + "line": 776, "backend": "cuda-hip", "fn": "getenv" }, @@ -3666,7 +3666,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6554, + "line": 6579, "backend": "cuda-hip", "fn": "getenv" }, @@ -3705,7 +3705,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5225, + "line": 5250, "backend": "cuda-hip", "fn": "getenv" } @@ -3771,13 +3771,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4881, + "line": 4906, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7052, "backend": "cuda-hip", "fn": "getenv" } @@ -3810,7 +3810,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4887, + "line": 4912, "backend": "cuda-hip", "fn": "getenv" } @@ -3844,7 +3844,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5006, + "line": 5031, "backend": "cuda-hip", "fn": "getenv" }, @@ -3938,19 +3938,19 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5586, + "line": 5611, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6507, + "line": 6532, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6731, + "line": 6756, "backend": "cuda-hip", "fn": "getenv" }, @@ -4010,19 +4010,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4882, + "line": 4907, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4897, + "line": 4922, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7052, "backend": "cuda-hip", "fn": "getenv" } @@ -4056,7 +4056,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18730, + "line": 18732, "backend": "cuda-hip", "fn": "getenv" }, @@ -4626,13 +4626,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19915, + "line": 19917, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 19915, + "line": 19917, "backend": "cuda-hip", "fn": "getenv" } @@ -5554,7 +5554,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21545, + "line": 21549, "backend": "cuda-hip", "fn": "getenv" } @@ -6036,13 +6036,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14543, + "line": 14545, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14543, + "line": 14545, "backend": "cuda-hip", "fn": "getenv" } @@ -6075,7 +6075,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14542, + "line": 14544, "backend": "cuda-hip", "fn": "getenv" } @@ -6115,7 +6115,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 2560, + "line": 2581, "backend": "cuda-hip", "fn": "getenv" }, @@ -6188,13 +6188,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19787, + "line": 19789, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21762, + "line": 21766, "backend": "cuda-hip", "fn": "getenv" }, @@ -6235,7 +6235,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5383, + "line": 5408, "backend": "cuda-hip", "fn": "getenv" } @@ -6271,13 +6271,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5385, + "line": 5410, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 5385, + "line": 5410, "backend": "cuda-hip", "fn": "getenv" } @@ -6451,7 +6451,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 554, + "line": 575, "backend": "cuda-hip", "fn": "getenv" } @@ -7343,13 +7343,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2226, + "line": 2247, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6793, + "line": 6818, "backend": "cuda-hip", "fn": "getenv" } @@ -7725,7 +7725,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18669, + "line": 18671, "backend": "cuda-hip", "fn": "getenv" }, @@ -7767,7 +7767,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18684, + "line": 18686, "backend": "cuda-hip", "fn": "getenv" }, @@ -8062,7 +8062,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18013, + "line": 18015, "backend": "cuda-hip", "fn": "env_on" } @@ -9801,7 +9801,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 583, + "line": 604, "backend": "hip", "fn": "getenv" } @@ -10127,7 +10127,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2149, + "line": 2170, "backend": "cuda-hip", "fn": "getenv" }, @@ -10785,7 +10785,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 781, + "line": 802, "backend": "cuda-hip", "fn": "getenv" }, @@ -11183,7 +11183,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 633, + "line": 654, "backend": "cuda-hip", "fn": "getenv" } @@ -11218,7 +11218,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 650, + "line": 671, "backend": "cuda-hip", "fn": "getenv" } @@ -11252,7 +11252,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 737, + "line": 758, "backend": "cuda-hip", "fn": "getenv" }, @@ -11666,7 +11666,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 710, + "line": 731, "backend": "cuda-hip", "fn": "getenv" }, @@ -11738,7 +11738,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4420, + "line": 4445, "backend": "cuda-hip", "fn": "getenv" }, @@ -12778,7 +12778,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4753, + "line": 4778, "backend": "cuda-hip", "fn": "getenv" }, @@ -12927,13 +12927,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4618, + "line": 4643, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8159, + "line": 8184, "backend": "cuda-hip", "fn": "getenv" }, @@ -13566,7 +13566,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20558, + "line": 20560, "backend": "cuda-hip", "fn": "getenv" } @@ -14557,7 +14557,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4475, + "line": 4500, "backend": "cuda-hip", "fn": "getenv" } @@ -15024,7 +15024,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17169, + "line": 17171, "backend": "cuda-hip", "fn": "getenv" } @@ -15138,13 +15138,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4560, + "line": 4585, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8106, + "line": 8131, "backend": "hip", "fn": "getenv" }, @@ -15262,7 +15262,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3590, + "line": 3615, "backend": "cuda-hip", "fn": "getenv" }, @@ -15383,7 +15383,7 @@ }, { "file": "src/program/generate.cpp", - "line": 12489, + "line": 12491, "backend": "cuda-hip", "fn": "getenv" }, @@ -15433,7 +15433,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1464, + "line": 1485, "backend": "cuda-hip", "fn": "getenv" }, @@ -15818,7 +15818,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6994, + "line": 7019, "backend": "hip", "fn": "getenv" } @@ -15851,7 +15851,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7390, + "line": 7415, "backend": "cuda-hip", "fn": "getenv" } @@ -15929,19 +15929,19 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17483, + "line": 17485, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17523, + "line": 17525, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18529, + "line": 18531, "backend": "cuda-hip", "fn": "getenv" }, @@ -15997,7 +15997,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17527, + "line": 17529, "backend": "cuda-hip", "fn": "getenv" }, @@ -16202,13 +16202,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18702, + "line": 18704, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21659, + "line": 21663, "backend": "cuda-hip", "fn": "getenv" }, @@ -18819,7 +18819,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 8436, + "line": 8461, "backend": "cuda-hip", "fn": "getenv" } @@ -20082,7 +20082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2482, + "line": 2503, "backend": "cuda-hip", "fn": "getenv" }, @@ -20122,7 +20122,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2526, + "line": 2547, "backend": "cuda-hip", "fn": "getenv" }, @@ -20162,7 +20162,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2487, + "line": 2508, "backend": "cuda-hip", "fn": "getenv" }, @@ -20581,13 +20581,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11380, + "line": 11382, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11389, + "line": 11391, "backend": "cuda-hip", "fn": "getenv" } @@ -22689,25 +22689,25 @@ }, { "file": "src/program/generate.cpp", - "line": 12424, + "line": 12426, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12428, + "line": 12430, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12434, + "line": 12436, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12777, + "line": 12779, "backend": "cuda-hip", "fn": "getenv" } @@ -23407,7 +23407,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13178, + "line": 13180, "backend": "cuda-hip", "fn": "getenv" } @@ -23589,7 +23589,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18446, + "line": 18448, "backend": "cuda-hip", "fn": "getenv" }, @@ -23636,7 +23636,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 790, + "line": 811, "backend": "cuda-hip", "fn": "getenv" } @@ -23669,7 +23669,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5054, + "line": 5079, "backend": "cuda-hip", "fn": "getenv" } @@ -23738,7 +23738,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 706, + "line": 727, "backend": "cuda-hip", "fn": "getenv" } @@ -23923,7 +23923,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6096, + "line": 6121, "backend": "cuda-hip", "fn": "getenv" } @@ -24073,13 +24073,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 284, + "line": 285, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11159, + "line": 11161, "backend": "cuda-hip", "fn": "getenv" }, @@ -24864,7 +24864,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 763, + "line": 784, "backend": "cuda-hip", "fn": "getenv" }, @@ -24941,7 +24941,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1871, + "line": 1892, "backend": "cuda-hip", "fn": "getenv" } @@ -24974,7 +24974,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1851, + "line": 1872, "backend": "cuda-hip", "fn": "getenv" } @@ -25043,7 +25043,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 729, + "line": 750, "backend": "cuda-hip", "fn": "getenv" }, @@ -25082,7 +25082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1887, + "line": 1908, "backend": "cuda-hip", "fn": "getenv" } @@ -25270,7 +25270,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11598, + "line": 11600, "backend": "cuda-hip", "fn": "getenv" } @@ -25344,7 +25344,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 763, + "line": 784, "backend": "cuda-hip", "fn": "getenv" }, @@ -25412,7 +25412,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2864, + "line": 2885, "backend": "cuda-hip", "fn": "getenv" }, @@ -25451,7 +25451,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 451, + "line": 472, "backend": "cuda-hip", "fn": "getenv" } @@ -25484,7 +25484,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2909, + "line": 2930, "backend": "cuda-hip", "fn": "getenv" } @@ -25517,7 +25517,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2912, + "line": 2933, "backend": "cuda-hip", "fn": "getenv" } @@ -25550,7 +25550,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2807, + "line": 2828, "backend": "cuda-hip", "fn": "getenv" } @@ -25584,7 +25584,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2848, + "line": 2869, "backend": "cuda-hip", "fn": "getenv" }, @@ -25624,7 +25624,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2882, + "line": 2903, "backend": "cuda-hip", "fn": "getenv" }, @@ -25664,7 +25664,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2878, + "line": 2899, "backend": "cuda-hip", "fn": "getenv" }, @@ -25703,7 +25703,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2905, + "line": 2926, "backend": "cuda-hip", "fn": "getenv" } @@ -25736,7 +25736,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2833, + "line": 2854, "backend": "cuda-hip", "fn": "getenv" } @@ -25802,13 +25802,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11153, + "line": 11155, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11153, + "line": 11155, "backend": "cuda-hip", "fn": "getenv" } @@ -25841,7 +25841,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11168, + "line": 11170, "backend": "cuda-hip", "fn": "getenv" } @@ -25874,7 +25874,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 384, + "line": 385, "backend": "cuda-hip", "fn": "getenv" } @@ -25910,7 +25910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4270, + "line": 4295, "backend": "cuda-hip", "fn": "getenv" }, @@ -25971,7 +25971,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 701, + "line": 722, "backend": "cuda-hip", "fn": "getenv" }, @@ -26106,7 +26106,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1663, + "line": 1684, "backend": "cuda-hip", "fn": "getenv" } @@ -26491,7 +26491,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18004, + "line": 18006, "backend": "cuda-hip", "fn": "getenv" } @@ -26528,7 +26528,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18030, + "line": 18032, "backend": "cuda-hip", "fn": "getenv" } @@ -26596,7 +26596,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18050, + "line": 18052, "backend": "cuda-hip", "fn": "getenv" } @@ -26629,7 +26629,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18268, + "line": 18270, "backend": "cuda-hip", "fn": "getenv" } @@ -26664,7 +26664,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18272, + "line": 18274, "backend": "cuda-hip", "fn": "getenv" } @@ -26744,7 +26744,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18264, + "line": 18266, "backend": "cuda-hip", "fn": "getenv" } @@ -26814,7 +26814,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19044, + "line": 19046, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -26971,7 +26971,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18873, + "line": 18875, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27056,7 +27056,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17352, + "line": 17354, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27096,7 +27096,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18800, + "line": 18802, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27136,7 +27136,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18993, + "line": 18995, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27176,7 +27176,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19040, + "line": 19042, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27216,7 +27216,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 12209, + "line": 12211, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27255,7 +27255,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19200, + "line": 19202, "backend": "cuda-hip", "fn": "pipe_dbg_env" } @@ -27289,7 +27289,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17355, + "line": 17357, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27329,7 +27329,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17348, + "line": 17350, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27369,7 +27369,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18857, + "line": 18859, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27414,7 +27414,7 @@ }, { "file": "src/program/generate.cpp", - "line": 15622, + "line": 15624, "backend": "cuda-hip", "fn": "getenv" } @@ -27611,7 +27611,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 82, + "line": 83, "backend": "cuda-hip", "fn": "getenv" }, @@ -27716,7 +27716,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 244, + "line": 245, "backend": "cuda-hip", "fn": "getenv" } @@ -27751,7 +27751,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 250, + "line": 251, "backend": "cuda-hip", "fn": "getenv" } @@ -28179,7 +28179,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 617, + "line": 638, "backend": "cuda-hip", "fn": "getenv" }, @@ -28261,7 +28261,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4075, + "line": 4100, "backend": "cuda-hip", "fn": "getenv" } @@ -28296,7 +28296,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4079, + "line": 4104, "backend": "cuda-hip", "fn": "getenv" } @@ -28331,7 +28331,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 432, + "line": 453, "backend": "cuda-hip", "fn": "getenv" }, @@ -28384,7 +28384,7 @@ }, { "file": "src/program/generate.cpp", - "line": 17742, + "line": 17744, "backend": "cuda-hip", "fn": "getenv" } @@ -28417,13 +28417,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 460, + "line": 481, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 463, + "line": 484, "backend": "cuda-hip", "fn": "getenv" } @@ -28459,13 +28459,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6673, + "line": 6698, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7918, + "line": 7943, "backend": "cuda-hip", "fn": "getenv" }, @@ -28505,13 +28505,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6686, + "line": 6711, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7052, "backend": "cuda-hip", "fn": "getenv" }, @@ -28629,13 +28629,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 292, + "line": 293, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 5942, + "line": 5967, "backend": "cuda-hip", "fn": "getenv" }, @@ -28677,13 +28677,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2658, + "line": 2679, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18011, + "line": 18013, "backend": "cuda-hip", "fn": "env_on" }, @@ -28762,7 +28762,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2670, + "line": 2691, "backend": "cuda-hip", "fn": "getenv" }, @@ -28841,7 +28841,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4071, + "line": 4096, "backend": "cuda-hip", "fn": "getenv" }, @@ -28882,13 +28882,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6907, + "line": 6932, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11160, + "line": 11162, "backend": "cuda-hip", "fn": "getenv" } @@ -28897,21 +28897,21 @@ "default_state": null, "code_default": null, "engine_sets": [ - { - "file": "src/program/generate.cpp", - "line": 11171 - }, { "file": "src/program/generate.cpp", "line": 11173 }, { "file": "src/program/generate.cpp", - "line": 11181 + "line": 11175 }, { "file": "src/program/generate.cpp", "line": 11183 + }, + { + "file": "src/program/generate.cpp", + "line": 11185 } ], "engine_defaults": [], @@ -28992,7 +28992,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6918, + "line": 6943, "backend": "cuda-hip", "fn": "getenv" } @@ -29025,7 +29025,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6913, + "line": 6938, "backend": "cuda-hip", "fn": "getenv" } @@ -29058,7 +29058,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6939, + "line": 6964, "backend": "cuda-hip", "fn": "getenv" } @@ -29091,7 +29091,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6928, + "line": 6953, "backend": "cuda-hip", "fn": "getenv" } @@ -29124,7 +29124,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6923, + "line": 6948, "backend": "cuda-hip", "fn": "getenv" } @@ -29171,11 +29171,11 @@ "launch_sets": [], "launch_reads": [], "doc_mentions": [], - "first_commit": null, - "first_date": null, + "first_commit": "b637627a37", + "first_date": "2026-11-13", "since": null, - "last_commit": null, - "last_date": null, + "last_commit": "b637627a37", + "last_date": "2026-11-13", "status": "rollback", "owner": "program", "note": "[reviewed] \"STRATA_PREFILL_LOAN_WALK=0 keeps the rounded chunk\"; a prompt piece below the walk floor lends buffers for the staged walk (default on).", @@ -29191,19 +29191,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 344, + "line": 345, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 1718, + "line": 1739, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6096, + "line": 6121, "backend": "cuda-hip", "fn": "getenv" }, @@ -29324,7 +29324,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3030, + "line": 3055, "backend": "cuda-hip", "fn": "getenv" } @@ -29393,7 +29393,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 568, + "line": 589, "backend": "cuda-hip", "fn": "getenv" }, @@ -29436,7 +29436,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4090, + "line": 4115, "backend": "cuda-hip", "fn": "getenv" } @@ -29471,7 +29471,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4091, + "line": 4116, "backend": "cuda-hip", "fn": "getenv" } @@ -29506,7 +29506,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 300, + "line": 301, "backend": "cuda-hip", "fn": "getenv" } @@ -29575,7 +29575,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 407, + "line": 428, "backend": "cuda-hip", "fn": "getenv" }, @@ -29654,13 +29654,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3346, + "line": 3371, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 3387, + "line": 3412, "backend": "cuda-hip", "fn": "getenv" }, @@ -29709,19 +29709,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1953, + "line": 1974, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 1967, + "line": 1988, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2132, + "line": 2153, "backend": "cuda-hip", "fn": "getenv" } @@ -29902,13 +29902,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4829, + "line": 4854, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8190, + "line": 8215, "backend": "cuda-hip", "fn": "getenv" }, @@ -31627,7 +31627,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4801, + "line": 4826, "backend": "cuda-hip", "fn": "getenv" }, @@ -31667,13 +31667,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4802, + "line": 4827, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4803, + "line": 4828, "backend": "cuda-hip", "fn": "getenv" }, @@ -31718,13 +31718,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4804, + "line": 4829, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4804, + "line": 4829, "backend": "cuda-hip", "fn": "getenv" } @@ -31757,7 +31757,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4813, + "line": 4838, "backend": "cuda-hip", "fn": "getenv" } @@ -31848,7 +31848,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 747, + "line": 768, "backend": "cuda-hip", "fn": "getenv" } @@ -31881,7 +31881,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 751, + "line": 772, "backend": "cuda-hip", "fn": "getenv" } @@ -32214,7 +32214,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19632, + "line": 19634, "backend": "cuda-hip", "fn": "getenv" } @@ -32603,7 +32603,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17562, + "line": 17564, "backend": "cuda-hip", "fn": "getenv" } @@ -32640,7 +32640,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17603, + "line": 17605, "backend": "cuda-hip", "fn": "getenv" }, @@ -32918,7 +32918,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 558, + "line": 579, "backend": "cuda-hip", "fn": "getenv" }, @@ -33342,13 +33342,13 @@ }, { "file": "src/program/generate.cpp", - "line": 11752, + "line": 11754, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11754, + "line": 11756, "backend": "cuda-hip", "fn": "getenv" } @@ -33383,13 +33383,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11753, + "line": 11755, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11753, + "line": 11755, "backend": "cuda-hip", "fn": "getenv" } @@ -33430,7 +33430,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11756, + "line": 11758, "backend": "cuda-hip", "fn": "getenv" } @@ -33502,25 +33502,7 @@ }, { "file": "src/program/generate.cpp", - "line": 13204, - "backend": "cuda-hip", - "fn": "getenv" - }, - { - "file": "src/program/generate.cpp", - "line": 14450, - "backend": "cuda-hip", - "fn": "getenv" - }, - { - "file": "src/program/generate.cpp", - "line": 14450, - "backend": "cuda-hip", - "fn": "getenv" - }, - { - "file": "src/program/generate.cpp", - "line": 14451, + "line": 13206, "backend": "cuda-hip", "fn": "getenv" }, @@ -33529,6 +33511,24 @@ "line": 14452, "backend": "cuda-hip", "fn": "getenv" + }, + { + "file": "src/program/generate.cpp", + "line": 14452, + "backend": "cuda-hip", + "fn": "getenv" + }, + { + "file": "src/program/generate.cpp", + "line": 14453, + "backend": "cuda-hip", + "fn": "getenv" + }, + { + "file": "src/program/generate.cpp", + "line": 14454, + "backend": "cuda-hip", + "fn": "getenv" } ], "parse": "flag", @@ -34127,13 +34127,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4667, + "line": 4692, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8178, + "line": 8203, "backend": "cuda-hip", "fn": "getenv" }, @@ -34242,13 +34242,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 8362, + "line": 8387, "backend": "metal", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8404, + "line": 8429, "backend": "cuda-hip", "fn": "getenv" }, @@ -34468,7 +34468,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4731, + "line": 4756, "backend": "cuda-hip", "fn": "getenv" }, @@ -34507,7 +34507,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18693, + "line": 18695, "backend": "cuda-hip", "fn": "getenv" } @@ -34540,7 +34540,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18696, + "line": 18698, "backend": "cuda-hip", "fn": "getenv" } @@ -35015,7 +35015,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14843, + "line": 14845, "backend": "cuda-hip", "fn": "getenv" } @@ -35371,7 +35371,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17136, + "line": 17138, "backend": "cuda-hip", "fn": "getenv" }, @@ -35413,13 +35413,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13070, + "line": 13072, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17109, + "line": 17111, "backend": "cuda-hip", "fn": "getenv" }, @@ -35577,13 +35577,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14545, + "line": 14547, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21413, + "line": 21417, "backend": "cuda-hip", "fn": "getenv" } @@ -35627,7 +35627,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21461, + "line": 21465, "backend": "cuda-hip", "fn": "getenv" } @@ -35697,7 +35697,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20608, + "line": 20610, "backend": "cuda-hip", "fn": "getenv" } @@ -35976,13 +35976,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18640, + "line": 18642, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21416, + "line": 21420, "backend": "cuda-hip", "fn": "getenv" } @@ -36015,7 +36015,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18641, + "line": 18643, "backend": "cuda-hip", "fn": "getenv" } @@ -36048,7 +36048,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21401, + "line": 21405, "backend": "cuda-hip", "fn": "getenv" } @@ -36081,7 +36081,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21503, + "line": 21507, "backend": "cuda-hip", "fn": "getenv" } @@ -36498,13 +36498,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13034, + "line": 13036, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18012, + "line": 18014, "backend": "cuda-hip", "fn": "env_on" } @@ -36580,7 +36580,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11837, + "line": 11839, "backend": "cuda-hip", "fn": "getenv" } @@ -36668,7 +36668,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11300, + "line": 11302, "backend": "cuda-hip", "fn": "getenv" }, @@ -36790,7 +36790,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11702, + "line": 11704, "backend": "cuda-hip", "fn": "getenv" }, @@ -36830,7 +36830,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11700, + "line": 11702, "backend": "cuda-hip", "fn": "getenv" }, @@ -36903,7 +36903,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20579, + "line": 20581, "backend": "cuda-hip", "fn": "getenv" }, @@ -37127,7 +37127,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 22193, + "line": 22197, "backend": "hip", "fn": "getenv" } @@ -37162,7 +37162,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2123, + "line": 2144, "backend": "cuda-hip", "fn": "getenv" } @@ -37196,13 +37196,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 881, + "line": 902, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2119, + "line": 2140, "backend": "cuda-hip", "fn": "getenv" }, @@ -37249,7 +37249,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 320, + "line": 321, "backend": "cuda-hip", "fn": "getenv" } @@ -37285,7 +37285,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2111, + "line": 2132, "backend": "cuda-hip", "fn": "getenv" } @@ -37321,7 +37321,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2099, + "line": 2120, "backend": "cuda-hip", "fn": "getenv" }, @@ -37569,7 +37569,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20166, + "line": 20168, "backend": "cuda-hip", "fn": "getenv" }, @@ -37644,13 +37644,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6870, + "line": 6895, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20204, + "line": 20206, "backend": "cuda-hip", "fn": "getenv" }, @@ -37687,6 +37687,39 @@ "retire_after": "", "retired_in": "" }, + { + "name": "STRATA_SWITCH_POINT", + "backends": [ + "cuda-hip" + ], + "reads": [ + { + "file": "src/prefill/prefill.cpp", + "line": 399, + "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": [], + "first_commit": null, + "first_date": null, + "since": null, + "last_commit": null, + "last_date": null, + "status": "research", + "owner": "prefill", + "note": "research switch (default off, CUDA builds): the chunk size from which a prompt chunk streams every expert the card does not hold comes from a cost estimate of the staged and the streamed walk (include/strata/prefill/switch_point_rule.hpp) instead of 1,024; a card holding every expert keeps 1,024. STRATA_PREFILL_STREAM_MIN and the CPU share's limit keep precedence.", + "retire_after": "", + "retired_in": "" + }, { "name": "STRATA_SYCL_BF16_DET", "backends": [ @@ -37803,7 +37836,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13216, + "line": 13218, "backend": "cuda-hip", "fn": "getenv" } @@ -37904,7 +37937,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18137, + "line": 18139, "backend": "cuda-hip", "fn": "getenv" } @@ -38024,7 +38057,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18054, + "line": 18056, "backend": "cuda-hip", "fn": "getenv" } @@ -38124,7 +38157,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 311, + "line": 312, "backend": "cuda-hip", "fn": "getenv" }, @@ -38998,13 +39031,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3716, + "line": 3741, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6610, + "line": 6635, "backend": "cuda-hip", "fn": "getenv" }, @@ -39028,19 +39061,19 @@ }, { "file": "src/program/generate.cpp", - "line": 12851, + "line": 12853, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14289, + "line": 14291, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20749, + "line": 20753, "backend": "cuda-hip", "fn": "getenv" }, @@ -39096,13 +39129,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21258, + "line": 21262, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21295, + "line": 21299, "backend": "cuda-hip", "fn": "getenv" }, @@ -39253,13 +39286,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11487, + "line": 11489, "backend": "cuda", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11505, + "line": 11507, "backend": "cuda", "fn": "getenv" } @@ -40692,7 +40725,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14467, + "line": 14469, "backend": "cuda-hip", "fn": "getenv" } @@ -40726,7 +40759,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14463, + "line": 14465, "backend": "cuda-hip", "fn": "getenv" }, @@ -40969,7 +41002,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2230, + "line": 2251, "backend": "cuda-hip", "fn": "getenv" } diff --git a/include/strata/prefill/prefill.hpp b/include/strata/prefill/prefill.hpp index ea62fa8697..8e561d03d6 100644 --- a/include/strata/prefill/prefill.hpp +++ b/include/strata/prefill/prefill.hpp @@ -100,6 +100,9 @@ public: /// (staged_fo_rule.hpp: Windows gfx1151, every layer without an MMQ tile and on the fused kernels, entry on), the measured crossing of the verify windows and that entry. /// A `--short-read` given on the command line is not asked. Call once the expert layout is known. static int64_t short_read_default(int64_t base); + /// STRATA_SWITCH_POINT=1 (research): the expert cache's live slots and layers x experts of the single card's own model, before the first lend; the floor above is then + /// chosen from the share of experts the card does not hold (switch_point_rule.hpp). Without the switch this changes nothing. + static void set_card_expert_share(int64_t resident_slots, int64_t total_pairs); /// --prefill-pipe (opt-in): the chunk a layer split's first stage reads an `n`-token prompt in, for `stages` /// stages, chunks of at most `cap` (the buffers' size) and a stage-chunk cost of b + a C with b/a = `ratio` tokens /// (0: unknown - STRATA_PREFILL_EQUAL's rule: the same chunk count as `cap` gives, evened out when its last chunk diff --git a/include/strata/prefill/switch_point_rule.hpp b/include/strata/prefill/switch_point_rule.hpp new file mode 100644 index 0000000000..e8a62fcec3 --- /dev/null +++ b/include/strata/prefill/switch_point_rule.hpp @@ -0,0 +1,61 @@ +// include/strata/prefill/switch_point_rule.hpp - the chunk size below which a prompt chunk takes the STAGED walk and from which it takes the STREAMED walk +// (src/prefill/prefill.cpp stream_all_min()), chosen by estimated cost from the card's share of non-resident experts instead of the fixed 1,024. +// Research switch STRATA_SWITCH_POINT=1, default off. Pure: no GPU, no environment read here. +// +// The two walks (prefill.cpp): +// streamed: every expert the card does not hold is copied through a ring in layer order, whatever the chunk routes; the copy runs through the attention +// halves, so the chunk costs about its copy time: P(T) = c_p * X + a_p * T (X = non-resident experts, T = chunk tokens). +// staged: the routing is read back per layer and only the routed non-resident experts are staged; the copy cannot overlap the layer's own compute: +// S(T) = s0 + c_s * Xs(T) + a_s * T, with Xs(T) = X * (1 - u(T)) the routed ones. u(T) is the share of the non-resident experts NOT routed by T tokens. +// Fitted on an RTX A6000 (48 GB, 12 GB/s link) with Qwen3.8-Flash-Next UD-Q4_K_XL (111 GB set, 55% of the expert slots resident), K-quant fused kernels, CPU share off +// (par/RESULTS-SWITCH-POINT.md, par/switchpt/fit1.py): c_p = 0.2612 ms, a_p = 0.0566 ms/token (at X = 12,097), c_s = 0.2278, a_s = 0.2294, s0 = 202 ms, +// u(T) = (T / 391)^-0.702 (measured routed shares 51 / 70 / 80 / 88 % at 1,100 / 2,049 / 4,097 / 8,193 tokens; the uniform-routing formula says 100% at all of them). +// Staged wins while advantage(T) = P(T) - S(T) = (c_p - c_s) * X - s0 + c_s * X * u(T) - (a_s - a_p) * T is positive. +// +// The floor is ONE scalar for the card, decided before the first lend (the lent cache slots, ring_slots(T), fused_layout(T) and moe_bufs() all read stream_all_min()), so it +// depends on the card's counts and never on the chunk in hand. X = 0 (every expert resident) gives exactly the default 1,024. +#pragma once + +#include +#include +#include + +namespace strata::prefill::switch_point { + +inline constexpr int64_t kFloorDefault = 1024; // = kStreamFloorDefault (stream_floor_rule.hpp): the floor of every card the rule does not move +inline constexpr int64_t kGrid = 256; // the prompt path's chunk grid +inline constexpr int64_t kFloorMax = 8192; // never past the auto chunk's usual top: above it the streamed walk's one pass is cheaper on every card measured + +struct Constants { + double c_p = 0.2612; // ms per non-resident expert, streamed walk (its copy-bound floor) + double c_s = 0.2278; // ms per streamed expert, staged walk + double a_p = 0.0566; // ms per token, streamed walk + double a_s = 0.2294; // ms per token, staged walk + double s0 = 201.75; // ms, staged walk's fixed part + double t0 = 391.0; // u(T) = (T / t0)^-gamma, 1 below t0 + double gamma = 0.702; + double x_inflate = 1.0; // the streamed walk's lend: X as streamed / X as counted from the cache before the lend +}; + +/// Share of the non-resident experts no token of a chunk of T tokens routes to. +inline double uncovered(int64_t T, const Constants& k) { + if (T <= 0) return 1.0; + return std::min(1.0, std::pow((double) T / k.t0, -k.gamma)); +} + +/// Milliseconds the staged walk saves over the streamed walk for a chunk of T tokens on a card with X non-resident experts (negative: it costs). +inline double advantage_ms(int64_t T, double X, const Constants& k) { + return (k.c_p - k.c_s) * X - k.s0 + k.c_s * X * uncovered(T, k) - (k.a_s - k.a_p) * (double) T; +} + +/// The floor for a card holding `resident_slots` of `total_pairs` (layers x experts): staged below it, streamed from it. +/// total_pairs <= 0 (unknown) or nothing non-resident: the default. A card that gains nothing at 1,024 keeps 1,024 (never lower). +inline int64_t floor_for(int64_t resident_slots, int64_t total_pairs, const Constants& k = Constants{}) { + if (total_pairs <= 0 || resident_slots < 0 || resident_slots >= total_pairs) return kFloorDefault; + const double X = (double) (total_pairs - resident_slots) * k.x_inflate; + int64_t T = kFloorDefault; + while (T < kFloorMax && advantage_ms(T, X, k) > 0.0) T += kGrid; // advantage falls with T: the first T where it is not positive is the floor + return T; +} + +} // namespace strata::prefill::switch_point diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 15362ea8c4..92078f63d8 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -10,6 +10,7 @@ #include "strata/prefill/staged_group_rule.hpp" #include "strata/prefill/staged_fo_rule.hpp" #include "strata/prefill/stream_floor_rule.hpp" +#include "strata/prefill/switch_point_rule.hpp" #include "strata/kernels/gfx_arch.hpp" #include "strata/prefill/fewrows.hpp" #include "strata/prefill/gp100_prompt_default.hpp" @@ -389,6 +390,17 @@ inline bool staged_fo_on() { cached.store(v ? 1 : 0, std::memory_order_release); return v; } +// STRATA_SWITCH_POINT=1 (research, default off; CUDA builds only): the floor of a card that streams part of the experts comes from switch_point_rule.hpp's cost estimate. +// The card's counts arrive from Prefill::set_card_expert_share (the cache's slots and layers x experts, known before the first lend); until then the default answers. +inline bool switch_point_on() { +#if defined(STRATA_USE_HIP) || defined(__HIPCC__) || defined(STRATA_HIP_GFX906) + return false; // measured on CUDA only +#else + static const bool on = [] { const char* e = std::getenv("STRATA_SWITCH_POINT"); return e != nullptr && e[0] == '1' && e[1] == '\0'; }(); + return on; +#endif +} +std::atomic g_sp_resident{-1}, g_sp_total{0}; // The floor without STRATA_PREFILL_STREAM_MIN and the CPU share: stream_floor_rule.hpp's answer, decided once when the expert layout is known (a call before that gets the default and is not cached). inline int64_t default_stream_floor() { static std::atomic cached{-1}; @@ -397,7 +409,16 @@ inline int64_t default_stream_floor() { const auto& lay = strata::kernels::cpu::expert_layout(); if (!lay.native || lay.fmt.empty()) return strata::prefill::kStreamFloorDefault; const bool cls = stream_floor_class_measured(); - const int64_t v = strata::prefill::stream_floor_default(cls, cls && layers_all_fused_only(), staged_fo_on()); + int64_t v = strata::prefill::stream_floor_default(cls, cls && layers_all_fused_only(), staged_fo_on()); + if (v == strata::prefill::kStreamFloorDefault && switch_point_on()) { + const int64_t res = g_sp_resident.load(std::memory_order_acquire), tot = g_sp_total.load(std::memory_order_acquire); + if (res < 0) return v; // the card's counts are not known yet: the default, not cached + v = strata::prefill::switch_point::floor_for(res, tot); + std::fprintf(stderr, "prefill: STRATA_SWITCH_POINT=1: prompt chunks of %lld tokens or more stream every expert the card does not hold (%lld of %lld experts resident); a shorter chunk stages only the routed ones\n", + (long long) v, (long long) res, (long long) tot); + cached.store(v, std::memory_order_release); + return v; + } cached.store(v, std::memory_order_release); if (v != strata::prefill::kStreamFloorDefault) std::fprintf(stderr, "prefill: prompt pieces of %lld tokens or more read on the fused kernels, as long prompts do. STRATA_PREFILL_STREAM_MIN=1024 keeps the old rule.\n", (long long) v); @@ -3002,6 +3023,10 @@ int64_t Prefill::short_read_default(int64_t base) { const bool cls = stream_floor_class_measured(); return strata::prefill::short_read_default(base, cls, cls && layers_all_fused_only(), staged_fo_on()); } +void Prefill::set_card_expert_share(int64_t resident_slots, int64_t total_pairs) { + g_sp_total.store(total_pairs, std::memory_order_release); + g_sp_resident.store(resident_slots, std::memory_order_release); +} // --prefill-pipe (opt-in; STRATA_PREFILL_PIPE): a layer split reads a prompt as a pipeline - stage s reads chunk c while // stage s+1 reads chunk c-1. A stage-chunk costs its layers x (b + a C): a fixed part per chunk (b: the pass over the diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 9d8bf92b98..e289b0335b 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -11001,6 +11001,8 @@ int main(int argc, char** argv) { "nothing to take, so it is not armed by default (STRATA_PREFILL_CPU_SHARE=auto forces it)\n", (long long) xcache.slots(), (long long) (g.n_layers * g.n_expert)); if (share_pool && stages.empty() && !multi_gpu && share_has_work && !share_default_ok()) share_has_work = false; // H11 + if (stages.empty() && !multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): one card, no batch slots; before any bytes_needed, like the share + strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert)); strata::prefill::Prefill::arm_cpu_share(share_pool, share_pool && stages.empty() && !multi_gpu && share_has_work); void* borrow = nullptr; uint64_t borrow_bytes = 0; @@ -20650,6 +20652,8 @@ int main(int argc, char** argv) { int64_t pos_start = 0; int64_t spec_pos = strata::spec::kSpecNotStarted; // plan v0.3 P6: where the speculative loop starts (0 is a real position: a 1-token prompt on a native pack) strata::prefill::Prefill prefill; + if (!multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): before any bytes_needed, like the share + strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert)); // #1595: not by default when the cache holds every expert (nothing to take) strata::prefill::Prefill::arm_cpu_share(!multi_gpu && !o.no_pool, !multi_gpu && !o.no_pool && o.batch <= 0 && diff --git a/tests/prefill/switch_point_rule_test.cpp b/tests/prefill/switch_point_rule_test.cpp new file mode 100644 index 0000000000..5ec3480a77 --- /dev/null +++ b/tests/prefill/switch_point_rule_test.cpp @@ -0,0 +1,73 @@ +// switch_point_rule.hpp: the floor from which a prompt chunk takes the streamed walk, from the card's share of non-resident experts. No GPU, no model. +#include +#include + +#include "strata/prefill/switch_point_rule.hpp" + +namespace sp = strata::prefill::switch_point; + +static int failed = 0; +#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0) + +int main() { + static_assert(sp::kFloorDefault == 1024, "the default floor is 1,024"); + const sp::Constants k; + const int64_t total = 24576; // 48 layers x 512 experts (Flash-Next) + + // every expert resident (or an unknown card): exactly the default + CHECK(sp::floor_for(total, total) == 1024); + CHECK(sp::floor_for(total + 5, total) == 1024); + CHECK(sp::floor_for(0, 0) == 1024); + CHECK(sp::floor_for(-1, total) == 1024); + CHECK(sp::floor_for(5000, 0) == 1024); + + // the floor is a multiple of the chunk grid, within [1024, kFloorMax], for every resident count + int64_t prev = 0; + bool seen_move = false; + for (int64_t res = 0; res <= total; res += 64) { + const int64_t f = sp::floor_for(res, total); + CHECK(f >= 1024 && f <= sp::kFloorMax); + CHECK((f - 1024) % sp::kGrid == 0); + if (f != 1024) seen_move = true; + (void) prev; + prev = f; + } + CHECK(seen_move); + + // the A6000 / UD-Q4_K_XL card (55% resident): between the measured 2,049 (staged 1.28x faster) and 8,193 (staged 26% slower), about the measured crossing at 4,097 + { + const int64_t res = (int64_t) (0.55 * (double) total); + const int64_t f = sp::floor_for(res, total); + CHECK(f > 2049 && f < 8193); + } + // the same card with the measured X (about 12,097 non-resident): the model's own crossing is 4,0xx + { + const int64_t f = sp::floor_for(total - 12097, total); + CHECK(f >= 3584 && f <= 4608); + CHECK(sp::advantage_ms(1100, 12097, k) > 1000.0); // measured 1,390 ms (3,236 against 1,838) + CHECK(sp::advantage_ms(2049, 12097, k) > 500.0); // measured 710 ms + CHECK(std::fabs(sp::advantage_ms(4097, 12097, k)) < 120.0); // measured 18 ms + CHECK(sp::advantage_ms(8193, 12097, k) < -700.0); // measured -950 ms + } + // a card with fewer non-resident experts stages less often: the floor does not rise as more experts are resident + { + int64_t last = sp::kFloorMax + 1; + for (int64_t res = total / 8; res <= total; res += 256) { + const int64_t f = sp::floor_for(res, total); + CHECK(f <= last); + last = f; + } + } + // the uncovered share: 1 below t0, falling, never above 1 + CHECK(sp::uncovered(100, k) == 1.0); + CHECK(sp::uncovered(1100, k) > sp::uncovered(4097, k)); + CHECK(sp::uncovered(8193, k) < 0.2); + CHECK(sp::uncovered(0, k) == 1.0); + + if (failed) { + std::fprintf(stderr, "switch_point_rule_test: %d check(s) failed\n", failed); + return 1; + } + std::printf("switch_point_rule_test: OK\n"); + return 0; +} From d877f150a06f4fdfd3a7e01acfe7be4dde844ca4 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 02:29:07 +0100 Subject: [PATCH 2/9] prefill: scale the research switch-point rule per card The floor from STRATA_SWITCH_POINT=1 now takes the cache mean blob, the start-up link probe and the SM count (copy terms by blob / link, compute terms by 1 / SM); the floor is the real crossing rounded down to the 256 grid, and the CPU share limit of a card whose floor moved is floor x 1.6. An unknown card (no probe) keeps 1,024. Research only, default off. --- data/settings-register.json | 256 +++++++++---------- include/strata/prefill/prefill.hpp | 4 +- include/strata/prefill/switch_point_rule.hpp | 33 +++ src/prefill/prefill.cpp | 31 ++- src/program/generate.cpp | 4 +- tests/prefill/switch_point_rule_test.cpp | 28 ++ 6 files changed, 220 insertions(+), 136 deletions(-) diff --git a/data/settings-register.json b/data/settings-register.json index 0a865a99da..287674f0ad 100644 --- a/data/settings-register.json +++ b/data/settings-register.json @@ -1910,7 +1910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 923, + "line": 933, "backend": "cuda-hip", "fn": "getenv" } @@ -3242,7 +3242,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3305, + "line": 3328, "backend": "cuda-hip", "fn": "getenv" } @@ -3602,7 +3602,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 776, + "line": 786, "backend": "cuda-hip", "fn": "getenv" }, @@ -3666,7 +3666,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6579, + "line": 6602, "backend": "cuda-hip", "fn": "getenv" }, @@ -3705,7 +3705,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5250, + "line": 5273, "backend": "cuda-hip", "fn": "getenv" } @@ -3771,13 +3771,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4906, + "line": 4929, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7052, + "line": 7075, "backend": "cuda-hip", "fn": "getenv" } @@ -3810,7 +3810,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4912, + "line": 4935, "backend": "cuda-hip", "fn": "getenv" } @@ -3844,7 +3844,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5031, + "line": 5054, "backend": "cuda-hip", "fn": "getenv" }, @@ -3938,19 +3938,19 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5611, + "line": 5634, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6532, + "line": 6555, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6756, + "line": 6779, "backend": "cuda-hip", "fn": "getenv" }, @@ -4010,19 +4010,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4907, + "line": 4930, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4922, + "line": 4945, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7052, + "line": 7075, "backend": "cuda-hip", "fn": "getenv" } @@ -6115,7 +6115,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 2581, + "line": 2591, "backend": "cuda-hip", "fn": "getenv" }, @@ -6235,7 +6235,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5408, + "line": 5431, "backend": "cuda-hip", "fn": "getenv" } @@ -6271,13 +6271,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5410, + "line": 5433, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 5410, + "line": 5433, "backend": "cuda-hip", "fn": "getenv" } @@ -6451,7 +6451,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 575, + "line": 585, "backend": "cuda-hip", "fn": "getenv" } @@ -7343,13 +7343,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2247, + "line": 2257, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6818, + "line": 6841, "backend": "cuda-hip", "fn": "getenv" } @@ -9801,7 +9801,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 604, + "line": 614, "backend": "hip", "fn": "getenv" } @@ -10127,7 +10127,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2170, + "line": 2180, "backend": "cuda-hip", "fn": "getenv" }, @@ -10785,7 +10785,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 802, + "line": 812, "backend": "cuda-hip", "fn": "getenv" }, @@ -11183,7 +11183,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 654, + "line": 664, "backend": "cuda-hip", "fn": "getenv" } @@ -11218,7 +11218,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 671, + "line": 681, "backend": "cuda-hip", "fn": "getenv" } @@ -11252,7 +11252,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 758, + "line": 768, "backend": "cuda-hip", "fn": "getenv" }, @@ -11666,7 +11666,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 731, + "line": 741, "backend": "cuda-hip", "fn": "getenv" }, @@ -11738,7 +11738,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4445, + "line": 4468, "backend": "cuda-hip", "fn": "getenv" }, @@ -12778,7 +12778,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4778, + "line": 4801, "backend": "cuda-hip", "fn": "getenv" }, @@ -12927,13 +12927,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4643, + "line": 4666, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8184, + "line": 8207, "backend": "cuda-hip", "fn": "getenv" }, @@ -14557,7 +14557,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4500, + "line": 4523, "backend": "cuda-hip", "fn": "getenv" } @@ -15138,13 +15138,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4585, + "line": 4608, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8131, + "line": 8154, "backend": "hip", "fn": "getenv" }, @@ -15262,7 +15262,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3615, + "line": 3638, "backend": "cuda-hip", "fn": "getenv" }, @@ -15433,7 +15433,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1485, + "line": 1495, "backend": "cuda-hip", "fn": "getenv" }, @@ -15818,7 +15818,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7019, + "line": 7042, "backend": "hip", "fn": "getenv" } @@ -15851,7 +15851,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7415, + "line": 7438, "backend": "cuda-hip", "fn": "getenv" } @@ -18819,7 +18819,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 8461, + "line": 8484, "backend": "cuda-hip", "fn": "getenv" } @@ -20082,7 +20082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2503, + "line": 2513, "backend": "cuda-hip", "fn": "getenv" }, @@ -20122,7 +20122,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2547, + "line": 2557, "backend": "cuda-hip", "fn": "getenv" }, @@ -20162,7 +20162,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2508, + "line": 2518, "backend": "cuda-hip", "fn": "getenv" }, @@ -23636,7 +23636,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 811, + "line": 821, "backend": "cuda-hip", "fn": "getenv" } @@ -23669,7 +23669,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5079, + "line": 5102, "backend": "cuda-hip", "fn": "getenv" } @@ -23738,7 +23738,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 727, + "line": 737, "backend": "cuda-hip", "fn": "getenv" } @@ -23923,7 +23923,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6121, + "line": 6144, "backend": "cuda-hip", "fn": "getenv" } @@ -24864,7 +24864,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 784, + "line": 794, "backend": "cuda-hip", "fn": "getenv" }, @@ -24941,7 +24941,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1892, + "line": 1902, "backend": "cuda-hip", "fn": "getenv" } @@ -24974,7 +24974,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1872, + "line": 1882, "backend": "cuda-hip", "fn": "getenv" } @@ -25043,7 +25043,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 750, + "line": 760, "backend": "cuda-hip", "fn": "getenv" }, @@ -25082,7 +25082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1908, + "line": 1918, "backend": "cuda-hip", "fn": "getenv" } @@ -25344,7 +25344,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 784, + "line": 794, "backend": "cuda-hip", "fn": "getenv" }, @@ -25412,7 +25412,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2885, + "line": 2895, "backend": "cuda-hip", "fn": "getenv" }, @@ -25451,7 +25451,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 472, + "line": 482, "backend": "cuda-hip", "fn": "getenv" } @@ -25484,7 +25484,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2930, + "line": 2940, "backend": "cuda-hip", "fn": "getenv" } @@ -25517,7 +25517,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2933, + "line": 2943, "backend": "cuda-hip", "fn": "getenv" } @@ -25550,7 +25550,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2828, + "line": 2838, "backend": "cuda-hip", "fn": "getenv" } @@ -25584,7 +25584,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2869, + "line": 2879, "backend": "cuda-hip", "fn": "getenv" }, @@ -25624,7 +25624,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2903, + "line": 2913, "backend": "cuda-hip", "fn": "getenv" }, @@ -25664,7 +25664,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2899, + "line": 2909, "backend": "cuda-hip", "fn": "getenv" }, @@ -25703,7 +25703,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2926, + "line": 2936, "backend": "cuda-hip", "fn": "getenv" } @@ -25736,7 +25736,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2854, + "line": 2864, "backend": "cuda-hip", "fn": "getenv" } @@ -25910,7 +25910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4295, + "line": 4318, "backend": "cuda-hip", "fn": "getenv" }, @@ -25971,7 +25971,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 722, + "line": 732, "backend": "cuda-hip", "fn": "getenv" }, @@ -26106,7 +26106,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1684, + "line": 1694, "backend": "cuda-hip", "fn": "getenv" } @@ -28179,7 +28179,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 638, + "line": 648, "backend": "cuda-hip", "fn": "getenv" }, @@ -28261,7 +28261,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4100, + "line": 4123, "backend": "cuda-hip", "fn": "getenv" } @@ -28296,7 +28296,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4104, + "line": 4127, "backend": "cuda-hip", "fn": "getenv" } @@ -28331,7 +28331,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 453, + "line": 463, "backend": "cuda-hip", "fn": "getenv" }, @@ -28417,13 +28417,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 481, + "line": 491, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 484, + "line": 494, "backend": "cuda-hip", "fn": "getenv" } @@ -28459,13 +28459,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6698, + "line": 6721, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7943, + "line": 7966, "backend": "cuda-hip", "fn": "getenv" }, @@ -28505,13 +28505,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6711, + "line": 6734, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7052, + "line": 7075, "backend": "cuda-hip", "fn": "getenv" }, @@ -28635,7 +28635,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5967, + "line": 5990, "backend": "cuda-hip", "fn": "getenv" }, @@ -28677,7 +28677,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2679, + "line": 2689, "backend": "cuda-hip", "fn": "getenv" }, @@ -28762,7 +28762,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2691, + "line": 2701, "backend": "cuda-hip", "fn": "getenv" }, @@ -28841,7 +28841,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4096, + "line": 4119, "backend": "cuda-hip", "fn": "getenv" }, @@ -28882,7 +28882,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6932, + "line": 6955, "backend": "cuda-hip", "fn": "getenv" }, @@ -28992,7 +28992,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6943, + "line": 6966, "backend": "cuda-hip", "fn": "getenv" } @@ -29025,7 +29025,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6938, + "line": 6961, "backend": "cuda-hip", "fn": "getenv" } @@ -29058,7 +29058,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6964, + "line": 6987, "backend": "cuda-hip", "fn": "getenv" } @@ -29091,7 +29091,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6953, + "line": 6976, "backend": "cuda-hip", "fn": "getenv" } @@ -29124,7 +29124,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6948, + "line": 6971, "backend": "cuda-hip", "fn": "getenv" } @@ -29197,13 +29197,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 1739, + "line": 1749, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6121, + "line": 6144, "backend": "cuda-hip", "fn": "getenv" }, @@ -29324,7 +29324,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3055, + "line": 3072, "backend": "cuda-hip", "fn": "getenv" } @@ -29393,7 +29393,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 589, + "line": 599, "backend": "cuda-hip", "fn": "getenv" }, @@ -29436,7 +29436,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4115, + "line": 4138, "backend": "cuda-hip", "fn": "getenv" } @@ -29471,7 +29471,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4116, + "line": 4139, "backend": "cuda-hip", "fn": "getenv" } @@ -29575,7 +29575,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 428, + "line": 438, "backend": "cuda-hip", "fn": "getenv" }, @@ -29654,13 +29654,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3371, + "line": 3394, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 3412, + "line": 3435, "backend": "cuda-hip", "fn": "getenv" }, @@ -29709,19 +29709,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1974, + "line": 1984, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 1988, + "line": 1998, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2153, + "line": 2163, "backend": "cuda-hip", "fn": "getenv" } @@ -29902,13 +29902,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4854, + "line": 4877, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8215, + "line": 8238, "backend": "cuda-hip", "fn": "getenv" }, @@ -31627,7 +31627,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4826, + "line": 4849, "backend": "cuda-hip", "fn": "getenv" }, @@ -31667,13 +31667,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4827, + "line": 4850, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4828, + "line": 4851, "backend": "cuda-hip", "fn": "getenv" }, @@ -31718,13 +31718,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4829, + "line": 4852, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4829, + "line": 4852, "backend": "cuda-hip", "fn": "getenv" } @@ -31757,7 +31757,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4838, + "line": 4861, "backend": "cuda-hip", "fn": "getenv" } @@ -31848,7 +31848,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 768, + "line": 778, "backend": "cuda-hip", "fn": "getenv" } @@ -31881,7 +31881,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 772, + "line": 782, "backend": "cuda-hip", "fn": "getenv" } @@ -32918,7 +32918,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 579, + "line": 589, "backend": "cuda-hip", "fn": "getenv" }, @@ -34127,13 +34127,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4692, + "line": 4715, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8203, + "line": 8226, "backend": "cuda-hip", "fn": "getenv" }, @@ -34242,13 +34242,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 8387, + "line": 8410, "backend": "metal", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8429, + "line": 8452, "backend": "cuda-hip", "fn": "getenv" }, @@ -34468,7 +34468,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4756, + "line": 4779, "backend": "cuda-hip", "fn": "getenv" }, @@ -37162,7 +37162,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2144, + "line": 2154, "backend": "cuda-hip", "fn": "getenv" } @@ -37196,13 +37196,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 902, + "line": 912, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2140, + "line": 2150, "backend": "cuda-hip", "fn": "getenv" }, @@ -37285,7 +37285,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2132, + "line": 2142, "backend": "cuda-hip", "fn": "getenv" } @@ -37321,7 +37321,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2120, + "line": 2130, "backend": "cuda-hip", "fn": "getenv" }, @@ -37644,7 +37644,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6895, + "line": 6918, "backend": "cuda-hip", "fn": "getenv" }, @@ -37709,11 +37709,11 @@ "launch_sets": [], "launch_reads": [], "doc_mentions": [], - "first_commit": null, - "first_date": null, + "first_commit": "e84392acc0", + "first_date": "2026-11-13", "since": null, - "last_commit": null, - "last_date": null, + "last_commit": "e84392acc0", + "last_date": "2026-11-13", "status": "research", "owner": "prefill", "note": "research switch (default off, CUDA builds): the chunk size from which a prompt chunk streams every expert the card does not hold comes from a cost estimate of the staged and the streamed walk (include/strata/prefill/switch_point_rule.hpp) instead of 1,024; a card holding every expert keeps 1,024. STRATA_PREFILL_STREAM_MIN and the CPU share's limit keep precedence.", @@ -39031,13 +39031,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3741, + "line": 3764, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6635, + "line": 6658, "backend": "cuda-hip", "fn": "getenv" }, @@ -41002,7 +41002,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2251, + "line": 2261, "backend": "cuda-hip", "fn": "getenv" } diff --git a/include/strata/prefill/prefill.hpp b/include/strata/prefill/prefill.hpp index 8e561d03d6..74e5f7a7cb 100644 --- a/include/strata/prefill/prefill.hpp +++ b/include/strata/prefill/prefill.hpp @@ -101,8 +101,8 @@ public: /// A `--short-read` given on the command line is not asked. Call once the expert layout is known. static int64_t short_read_default(int64_t base); /// STRATA_SWITCH_POINT=1 (research): the expert cache's live slots and layers x experts of the single card's own model, before the first lend; the floor above is then - /// chosen from the share of experts the card does not hold (switch_point_rule.hpp). Without the switch this changes nothing. - static void set_card_expert_share(int64_t resident_slots, int64_t total_pairs); + /// chosen from the share of experts the card does not hold, scaled by the cache's mean blob (MB), the start-up link probe (GB/s) and the card's SM count (switch_point_rule.hpp; 0 = unknown: the default floor). Without the switch this changes nothing. + static void set_card_expert_share(int64_t resident_slots, int64_t total_pairs, double blob_mb = 0.0, double link_gbps = 0.0); /// --prefill-pipe (opt-in): the chunk a layer split's first stage reads an `n`-token prompt in, for `stages` /// stages, chunks of at most `cap` (the buffers' size) and a stage-chunk cost of b + a C with b/a = `ratio` tokens /// (0: unknown - STRATA_PREFILL_EQUAL's rule: the same chunk count as `cap` gives, evened out when its last chunk diff --git a/include/strata/prefill/switch_point_rule.hpp b/include/strata/prefill/switch_point_rule.hpp index e8a62fcec3..2415e4aa03 100644 --- a/include/strata/prefill/switch_point_rule.hpp +++ b/include/strata/prefill/switch_point_rule.hpp @@ -58,4 +58,37 @@ inline int64_t floor_for(int64_t resident_slots, int64_t total_pairs, const Cons return T; } +// ---- per-card scaling (SWITCH-POINT-2) ---- +// The A6000 fit above does not transfer as it is (the A4000's crossing is about 1,930 tokens, the fit's 5,632), but its structure does: the copy terms scale with the cost of moving one expert +// (mean blob bytes / the link's GB/s) and the compute terms with 1 / the SM count (the A4000 streams at 0.63 ms a token against the A6000's 0.36: 84 / 48). s0 and u(T) stay as fitted. +// Measured crossings of the staged walk against the streamed one with the CPU share off (RTX A6000 3.8K, RTX A4000 1.9K) are matched to within one 256-token step by the real crossing +// rounded DOWN to the grid. The R9700 (HIP, 28.3 GB/s probe but 0.14 ms a streamed expert) is not matched (model 1.1K, measured 1.5K): CUDA builds only. +struct Card { + double blob_mb = 3.19; // mean expert blob of the cache (cache bytes / slots), MB: the A6000 fit's value + double link_gbps = 12.2; // the start-up host-to-device probe, GB/s + int sm = 84; // multiprocessor count +}; +inline bool card_known(const Card& c) { return c.blob_mb > 0.0 && c.link_gbps > 0.0 && c.sm > 0; } +inline Constants constants_for(const Card& c) { + Constants k; + const double copy = (c.blob_mb / c.link_gbps) / (3.19 / 12.2); + const double comp = 84.0 / (double) c.sm; + k.c_p *= copy; k.c_s *= copy; + k.a_p *= comp; k.a_s *= comp; + return k; +} +/// The floor for this card with the CPU share off: the largest grid size at which the staged walk still wins (the first size where it does not, one step back), never below 1,024. +inline int64_t floor_for_card(int64_t resident_slots, int64_t total_pairs, const Card& c) { + if (!card_known(c)) return kFloorDefault; + const int64_t first = floor_for(resident_slots, total_pairs, constants_for(c)); + return std::max(kFloorDefault, first - kGrid); +} +/// With the share on, the staged walk's limit is the floor times this ratio (measured share-on / share-off break-evens: A4000 2.9K / 1.9K = 1.5, R9700 2.5K / 1.5K = 1.7, A6000 see the results file). +inline constexpr double kShareRatio = 1.6; +/// The share's limit for a card whose floor moved: floor x kShareRatio on the grid; 0 (the share's own default stays) when the floor is the default. +inline int64_t share_limit_for(int64_t floor) { + if (floor <= kFloorDefault) return 0; + return std::min(2 * kFloorMax, ((int64_t) ((double) floor * kShareRatio) / kGrid) * kGrid); +} + } // namespace strata::prefill::switch_point diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 92078f63d8..fee7c4cc10 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -401,6 +401,14 @@ inline bool switch_point_on() { #endif } std::atomic g_sp_resident{-1}, g_sp_total{0}; +double g_sp_blob_mb = 0.0, g_sp_link_gbps = 0.0; // the cache's mean blob (MB) and the start-up probe (GB/s), from Prefill::set_card_expert_share +int g_sp_sm = 0; // the card's multiprocessor count +// the card as the rule scales it; a field not set gives card_known() == false and the default floor +inline strata::prefill::switch_point::Card sp_card() { + strata::prefill::switch_point::Card c; + c.blob_mb = g_sp_blob_mb; c.link_gbps = g_sp_link_gbps; c.sm = g_sp_sm; + return c; +} // The floor without STRATA_PREFILL_STREAM_MIN and the CPU share: stream_floor_rule.hpp's answer, decided once when the expert layout is known (a call before that gets the default and is not cached). inline int64_t default_stream_floor() { static std::atomic cached{-1}; @@ -413,9 +421,11 @@ inline int64_t default_stream_floor() { if (v == strata::prefill::kStreamFloorDefault && switch_point_on()) { const int64_t res = g_sp_resident.load(std::memory_order_acquire), tot = g_sp_total.load(std::memory_order_acquire); if (res < 0) return v; // the card's counts are not known yet: the default, not cached - v = strata::prefill::switch_point::floor_for(res, tot); - std::fprintf(stderr, "prefill: STRATA_SWITCH_POINT=1: prompt chunks of %lld tokens or more stream every expert the card does not hold (%lld of %lld experts resident); a shorter chunk stages only the routed ones\n", - (long long) v, (long long) res, (long long) tot); + const auto card = sp_card(); + if (!strata::prefill::switch_point::card_known(card)) return v; // the link or the card is not known: the default, not cached + v = strata::prefill::switch_point::floor_for_card(res, tot, card); + std::fprintf(stderr, "prefill: STRATA_SWITCH_POINT=1: prompt chunks of %lld tokens or more stream every expert the card does not hold (%lld of %lld experts resident; %.2f MB experts, %.1f GB/s link, %d SMs); a shorter chunk stages only the routed ones\n", + (long long) v, (long long) res, (long long) tot, card.blob_mb, card.link_gbps, card.sm); cached.store(v, std::memory_order_release); return v; } @@ -3023,7 +3033,14 @@ int64_t Prefill::short_read_default(int64_t base) { const bool cls = stream_floor_class_measured(); return strata::prefill::short_read_default(base, cls, cls && layers_all_fused_only(), staged_fo_on()); } -void Prefill::set_card_expert_share(int64_t resident_slots, int64_t total_pairs) { +void Prefill::set_card_expert_share(int64_t resident_slots, int64_t total_pairs, double blob_mb, double link_gbps) { +#if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) + int dev = 0; + cudaDeviceProp prop; + g_sp_sm = (cudaGetDevice(&dev) == cudaSuccess && cudaGetDeviceProperties(&prop, dev) == cudaSuccess) ? prop.multiProcessorCount : 0; +#endif + g_sp_blob_mb = blob_mb; + g_sp_link_gbps = link_gbps; g_sp_total.store(total_pairs, std::memory_order_release); g_sp_resident.store(resident_slots, std::memory_order_release); } @@ -3232,6 +3249,12 @@ 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; + if (switch_point_on() && g_sp_resident.load(std::memory_order_acquire) >= 0 && strata::prefill::switch_point::card_known(sp_card())) { + // STRATA_SWITCH_POINT=1 (research): the share's limit scales with the card's own floor (floor x kShareRatio), not the fixed 3,072 + const int64_t lim = strata::prefill::switch_point::share_limit_for(strata::prefill::switch_point::floor_for_card( + g_sp_resident.load(std::memory_order_acquire), g_sp_total.load(std::memory_order_acquire), sp_card())); + if (lim > 0) g_share_limit_arch = lim; + } 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 below 1024 tokens, ~0.011 at 1-3K). STRATA_PREFILL_CPU_SHARE=0 turns it off, " diff --git a/src/program/generate.cpp b/src/program/generate.cpp index e289b0335b..a86ae089d1 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -11002,7 +11002,7 @@ int main(int argc, char** argv) { (long long) xcache.slots(), (long long) (g.n_layers * g.n_expert)); if (share_pool && stages.empty() && !multi_gpu && share_has_work && !share_default_ok()) share_has_work = false; // H11 if (stages.empty() && !multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): one card, no batch slots; before any bytes_needed, like the share - strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert)); + strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert), xcache.slots() > 0 ? (double) xcache.bytes() / (double) xcache.slots() / 1e6 : 0.0, o.pcie_probe_gbps); strata::prefill::Prefill::arm_cpu_share(share_pool, share_pool && stages.empty() && !multi_gpu && share_has_work); void* borrow = nullptr; uint64_t borrow_bytes = 0; @@ -20653,7 +20653,7 @@ int main(int argc, char** argv) { int64_t spec_pos = strata::spec::kSpecNotStarted; // plan v0.3 P6: where the speculative loop starts (0 is a real position: a 1-token prompt on a native pack) strata::prefill::Prefill prefill; if (!multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): before any bytes_needed, like the share - strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert)); + strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert), xcache.slots() > 0 ? (double) xcache.bytes() / (double) xcache.slots() / 1e6 : 0.0, o.pcie_probe_gbps); // #1595: not by default when the cache holds every expert (nothing to take) strata::prefill::Prefill::arm_cpu_share(!multi_gpu && !o.no_pool, !multi_gpu && !o.no_pool && o.batch <= 0 && diff --git a/tests/prefill/switch_point_rule_test.cpp b/tests/prefill/switch_point_rule_test.cpp index 5ec3480a77..4969725c5a 100644 --- a/tests/prefill/switch_point_rule_test.cpp +++ b/tests/prefill/switch_point_rule_test.cpp @@ -64,6 +64,34 @@ int main() { CHECK(sp::uncovered(8193, k) < 0.2); CHECK(sp::uncovered(0, k) == 1.0); + // per-card scaling: the A6000 (3.19 MB experts, 12.2 GB/s, 84 SMs, 13,580 of 24,576 resident) and the A4000 (1.44 MB, 10.5 GB/s, 48 SMs, 7,836 resident), CPU share off: + // measured crossings about 3,840 and 1,930 tokens, the rule's floors are within one grid step of them + { + const sp::Card a6000{3.19, 12.2, 84}, a4000{1.44, 10.5, 48}; + const int64_t f6 = sp::floor_for_card(13580, total, a6000); + const int64_t f4 = sp::floor_for_card(7836, total, a4000); + CHECK(f6 >= 3584 && f6 <= 4096); + CHECK(f4 >= 1792 && f4 <= 2048); + CHECK(f4 < f6); // the slower card of the two crosses earlier, as measured + CHECK((f6 - 1024) % sp::kGrid == 0 && (f4 - 1024) % sp::kGrid == 0); + // an unknown card (no probe, no SM count): the default + CHECK(sp::floor_for_card(13580, total, sp::Card{0.0, 12.2, 84}) == 1024); + CHECK(sp::floor_for_card(13580, total, sp::Card{3.19, 0.0, 84}) == 1024); + CHECK(sp::floor_for_card(13580, total, sp::Card{3.19, 12.2, 0}) == 1024); + // every expert resident: the default whatever the card + CHECK(sp::floor_for_card(total, total, a6000) == 1024); + // the A6000-class card's constants are the fit's own + const sp::Constants kc = sp::constants_for(sp::Card{}); + CHECK(std::fabs(kc.c_p - 0.2612) < 1e-9 && std::fabs(kc.a_s - 0.2294) < 1e-9); + // faster link, same card: a smaller floor; more SMs, same link: a higher one + CHECK(sp::floor_for_card(13580, total, sp::Card{3.19, 24.0, 84}) <= f6); + CHECK(sp::floor_for_card(13580, total, sp::Card{3.19, 12.2, 120}) >= f6); + } + // the share's limit: the floor times the measured ratio on the grid, 0 (the share's own default stays) when the floor did not move + CHECK(sp::share_limit_for(1024) == 0); + CHECK(sp::share_limit_for(2048) == 3072); // A4000: measured break-even about 2,900 + CHECK(sp::share_limit_for(3840) % sp::kGrid == 0 && sp::share_limit_for(3840) > 3840); + if (failed) { std::fprintf(stderr, "switch_point_rule_test: %d check(s) failed\n", failed); return 1; From 995fde04e1b975ff3727e3689f6a9643b5855454 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 05:45:03 +0100 Subject: [PATCH 3/9] prefill: note the measured share ratios on the switch-point rule Comment only. The share limit's ratio to the floor (kShareRatio 1.6) now cites its measurements: break-even / crossing 1.50 (RTX A4000), 1.48 (RTX A6000), 1.67 (R9700); against the rule's own floors 1.42 and 1.61. No code change. --- include/strata/prefill/switch_point_rule.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/strata/prefill/switch_point_rule.hpp b/include/strata/prefill/switch_point_rule.hpp index 2415e4aa03..b78a41b2d7 100644 --- a/include/strata/prefill/switch_point_rule.hpp +++ b/include/strata/prefill/switch_point_rule.hpp @@ -83,7 +83,9 @@ inline int64_t floor_for_card(int64_t resident_slots, int64_t total_pairs, const const int64_t first = floor_for(resident_slots, total_pairs, constants_for(c)); return std::max(kFloorDefault, first - kGrid); } -/// With the share on, the staged walk's limit is the floor times this ratio (measured share-on / share-off break-evens: A4000 2.9K / 1.9K = 1.5, R9700 2.5K / 1.5K = 1.7, A6000 see the results file). +/// With the share on, the staged walk's limit is the floor times this ratio. Measured share-on break-even / share-off crossing: RTX A4000 2.9K / 1.93K = 1.50, RTX A6000 6.19K / 4.18K = 1.48, +/// R9700 2.5K / 1.5K = 1.67 (not covered by this rule). Against this rule's own floors (A6000 3,840, A4000 2,048) the same break-evens are 1.61 and 1.42: 1.6 lands within one grid step of both +/// (limits 6,144 and 3,072); 1.5 would give 5,760 on the A6000 and lose about 5% between 5,760 and 6,190 tokens (par/RESULTS-SWITCH-POINT.md). inline constexpr double kShareRatio = 1.6; /// The share's limit for a card whose floor moved: floor x kShareRatio on the grid; 0 (the share's own default stays) when the floor is the default. inline int64_t share_limit_for(int64_t floor) { From 302f7d0398e2d49ec21bef4453065f3468a2f5bd Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 06:12:38 +0100 Subject: [PATCH 4/9] prefill: correct the floors quoted in the share ratio note Comment only. The Boston run printed the A6000 floor as 3,584 (not 3,840), so the limit with the 1.6 ratio is 5,632 and the break-even over the rule's floor is 1.73 (A4000 1.42). No code change. --- include/strata/prefill/switch_point_rule.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/strata/prefill/switch_point_rule.hpp b/include/strata/prefill/switch_point_rule.hpp index b78a41b2d7..013e9c9335 100644 --- a/include/strata/prefill/switch_point_rule.hpp +++ b/include/strata/prefill/switch_point_rule.hpp @@ -84,8 +84,9 @@ inline int64_t floor_for_card(int64_t resident_slots, int64_t total_pairs, const return std::max(kFloorDefault, first - kGrid); } /// With the share on, the staged walk's limit is the floor times this ratio. Measured share-on break-even / share-off crossing: RTX A4000 2.9K / 1.93K = 1.50, RTX A6000 6.19K / 4.18K = 1.48, -/// R9700 2.5K / 1.5K = 1.67 (not covered by this rule). Against this rule's own floors (A6000 3,840, A4000 2,048) the same break-evens are 1.61 and 1.42: 1.6 lands within one grid step of both -/// (limits 6,144 and 3,072); 1.5 would give 5,760 on the A6000 and lose about 5% between 5,760 and 6,190 tokens (par/RESULTS-SWITCH-POINT.md). +/// R9700 2.5K / 1.5K = 1.67 (not covered by this rule). Against this rule's own floors as the engine printed them (A6000 3,584, A4000 2,048) the same break-evens are 1.73 and 1.42, so no single ratio +/// fits both: 1.6 gives limits 5,632 (A6000, 558 under its break-even: up to 6% left on the table at 5,633) and 3,072 (A4000, 172 over: up to 3% lost at 2,900-3,072); both are far better than the +/// fixed 3,072 on the A6000 (par/RESULTS-SWITCH-POINT.md, 06:12 block). inline constexpr double kShareRatio = 1.6; /// The share's limit for a card whose floor moved: floor x kShareRatio on the grid; 0 (the share's own default stays) when the floor is the default. inline int64_t share_limit_for(int64_t floor) { From 62b4a5e93ee3f8b75d37d3074da457a68b35120c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 07:07:02 +0100 Subject: [PATCH 5/9] Rules for sizing a lent fused layout's MMQ tail from the segment A lent fused MoE layout holds MMQ's rows for a last chunk below the stream floor. Sizing that for floor - 1 tokens costs expert slots on every prompt (a floor of 3,584 against 1,024: about 289 MB, 92 slots of an RTX A6000). This adds the header-only rules: the tail a segment read in chunks of C needs (tail_need), its 256-token grid (tail_layout), the grow-only choice while the layout's chunk stays (next_tail: one growth to today's size at most) and the reuse test of a loan by a later segment (reuse_ok: the chunk AND the tail, the later segment being read in the loan's own chunks), with unit rows. --- include/strata/prefill/loan_rules.hpp | 48 +++++++++++++++ tests/prefill/loan_rules_test.cpp | 88 +++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/include/strata/prefill/loan_rules.hpp b/include/strata/prefill/loan_rules.hpp index 7bad80fba0..128f04dff2 100644 --- a/include/strata/prefill/loan_rules.hpp +++ b/include/strata/prefill/loan_rules.hpp @@ -24,4 +24,52 @@ constexpr int64_t walk_chunk(int64_t tokens, int64_t chunk, int64_t floor) { return (tokens > 0 && chunk > 0 && tokens < floor && chunk >= floor) ? floor - 1 : chunk; } +// The tail of a lent fused layout. A layout laid out for chunks at or above the floor (the fused MoE buffers) also +// holds MMQ's rows for a chunk BELOW the floor, which runs staged in the same buffers. Sizing that for floor - 1 +// tokens costs expert slots on every prompt, whatever its own chunks are (a floor of 3,584 against 1,024: about 289 MB, +// 92 slots of an RTX A6000). A segment of `tokens` read in chunks of `chunk` has a chunk below the floor only at its +// end, so that is all the tail it needs. + +/// The most MMQ rows (in tokens) a segment of `tokens` read in chunks of `chunk` puts into the fused layout's buffers: +/// the last chunk when it is below `floor`, else 0 (every other chunk is a full one, at or above the floor, and runs +/// the fused kernels). A layout whose chunk is itself below the floor is not a fused layout: min(chunk, tokens). +constexpr int64_t tail_need(int64_t tokens, int64_t chunk, int64_t floor) { + if (tokens <= 0 || chunk <= 0) return 0; + if (chunk < floor) return tokens < chunk ? tokens : chunk; + const int64_t last = tokens > chunk ? tokens - ((tokens - 1) / chunk) * chunk : tokens; + return last < floor ? last : 0; +} + +/// The tail a layout is carved with for that need: on the 256-token grid (so that two requests with nearly the same tail +/// keep one layout), at most floor - 1 (today's size), 0 for no need. +constexpr int64_t tail_layout(int64_t need, int64_t floor) { + if (need <= 0 || floor <= 1) return 0; + const int64_t grid = (need + 255) / 256 * 256; + return grid < floor - 1 ? grid : floor - 1; +} + +/// The tail a layout for a segment is carved with (what lend asks the layout for). +constexpr int64_t segment_tail(int64_t tokens, int64_t chunk, int64_t floor) { + return tail_layout(tail_need(tokens, chunk, floor), floor); +} + +/// The tail a lend carves a layout with, given the layout that is in place: GROW-ONLY while the layout's chunk stays. +/// `layout_chunk` / `layout_tail`: the layout now laid out (a tail of -1: carved with today's floor - 1, i.e. never sized +/// by a segment: the start-up layout, or the way-back switch); `want`: the chunk this segment's loan is for; `need`: its +/// segment_tail(). A layout of the same chunk that is tail-sized keeps its tail when it covers the need (no relayout +/// for a smaller follow-up) and otherwise goes straight to today's size: floor - 1, so a sequence of segments costs at +/// most ONE relayout more than today's sizing, then runs on today's bytes. Any other case (another chunk: a relayout +/// today as well; a start-up layout) starts again from the need of that moment. +constexpr int64_t next_tail(int64_t layout_chunk, int64_t layout_tail, int64_t want, int64_t need, int64_t floor) { + if (layout_tail >= 0 && layout_chunk == want) return layout_tail >= need ? layout_tail : (floor > 1 ? floor - 1 : 0); + return need; +} + +/// A loan carved for `lent_chunk` with room for `lent_tail` MMQ tokens serves a later segment of `tokens` (wanting +/// chunks of `want`) without a new layout only if its chunk covers `want` AND the segment, read in the loan's own +/// chunks (a layout always reads in its own chunk), needs no more tail than the loan holds. +constexpr bool reuse_ok(int64_t want, int64_t tokens, int64_t lent_chunk, int64_t lent_tail, int64_t floor) { + return want <= lent_chunk && tail_need(tokens, lent_chunk, floor) <= lent_tail; +} + } // namespace strata::prefill::loan_rules diff --git a/tests/prefill/loan_rules_test.cpp b/tests/prefill/loan_rules_test.cpp index 7a2eafd617..d47098cb23 100644 --- a/tests/prefill/loan_rules_test.cpp +++ b/tests/prefill/loan_rules_test.cpp @@ -6,6 +6,11 @@ #include "strata/prefill/loan_rules.hpp" using strata::prefill::loan_rules::walk_chunk; +using strata::prefill::loan_rules::tail_need; +using strata::prefill::loan_rules::tail_layout; +using strata::prefill::loan_rules::segment_tail; +using strata::prefill::loan_rules::reuse_ok; +using strata::prefill::loan_rules::next_tail; static int failed = 0; #define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0) @@ -52,6 +57,89 @@ int main() { // empty or negative requests are passed through CHECK(walk_chunk(0, 256, 1024) == 256 && walk_chunk(10, 0, 1024) == 0); static_assert(walk_chunk(999, 1024, 1024) == 1023, "constexpr"); + + // ---- the tail of a lent fused layout (tail_need / tail_layout / segment_tail / reuse_ok) + // one chunk at or above the floor: no MMQ rows at all + CHECK(tail_need(1024, 1024, 1024) == 0); + CHECK(tail_need(8192, 8192, 1024) == 0); + CHECK(tail_need(4096, 2048, 1024) == 0); // two full chunks + // a short last chunk is the whole need + CHECK(tail_need(4097, 2048, 1024) == 1); + CHECK(tail_need(5000, 2048, 1024) == 904); + CHECK(tail_need(5120 + 1023, 5120, 1024) == 1023); + CHECK(tail_need(5120 + 1024, 5120, 1024) == 0); // a last chunk at the floor streams: fused + // a floor of 3,584 (the rule on an RTX A6000): the same segments now have a tail up to 3,583 + CHECK(tail_need(4097, 2048, 3584) == 1); + CHECK(tail_need(8193 + 2000, 8192, 3584) == 2001); + CHECK(tail_need(8192 + 3584, 8192, 3584) == 0); + // a segment read in one chunk below the floor, in a layout whose chunk reaches it (a reused big loan) + CHECK(tail_need(2000, 8192, 3584) == 2000); + CHECK(tail_need(2000, 8192, 1024) == 0); + // a layout whose own chunk is below the floor is not fused: every chunk is MMQ's + CHECK(tail_need(5000, 1023, 1024) == 1023 && tail_need(500, 1023, 1024) == 500); + CHECK(tail_need(0, 4096, 1024) == 0 && tail_need(10, 0, 1024) == 0); + // never above floor - 1, never negative, last chunk exact for every size + for (int64_t floor : std::initializer_list{1, 64, 1024, 3072, 3584}) + for (int64_t c : std::initializer_list{256, 1023, 1024, 2048, 4096, 8192}) + for (int64_t t = 1; t <= 20000; t += 37) { + const int64_t need = tail_need(t, c, floor); + CHECK(need >= 0 && need <= (floor > 1 ? floor - 1 : 0)); + int64_t worst = 0; // walk the chunks one by one + for (int64_t at = 0; at < t; at += c) { + const int64_t len = t - at < c ? t - at : c; + if (len < floor && len > worst) worst = len; + } + CHECK(need == worst); + const int64_t lay = tail_layout(need, floor); + CHECK(lay >= need && (need == 0 ? lay == 0 : lay % 256 == 0 || lay == floor - 1)); + CHECK(lay <= (floor > 1 ? floor - 1 : 0)); + CHECK(segment_tail(t, c, floor) == lay); + } + // the grid: 904 -> 1,024; clamped to today's floor - 1 + CHECK(tail_layout(904, 3584) == 1024 && tail_layout(1, 3584) == 256 && tail_layout(1023, 1024) == 1023); + CHECK(tail_layout(0, 3584) == 0 && tail_layout(5, 1) == 0); + // the overflow case: a loan made for an 8,193+ segment whose last chunk is 1 token, then a 2,000-token segment + // (the 2,000 tokens read as ONE chunk of the loan's layout, staged under a 3,584 floor) + { + const int64_t floor = 3584, lent_chunk = 8192; + const int64_t lent_tail = segment_tail(8193, lent_chunk, floor); // 256: the last chunk is 1 token + CHECK(lent_tail == 256); + CHECK(!reuse_ok(2048, 2000, lent_chunk, lent_tail, floor)); // needs 2,000 (grid 2,048): relayout + CHECK(tail_need(2000, lent_chunk, floor) > lent_tail); + CHECK(reuse_ok(256, 100, lent_chunk, lent_tail, floor)); // 100 <= 256: reuse + CHECK(reuse_ok(2048, 4096 + 100, lent_chunk, lent_tail, floor) == false); // chunk 8,192 > 4,196: one chunk of 4,196 >= floor: need 0 + CHECK(tail_need(4196, lent_chunk, floor) == 0); // (it is fused, so it reuses) + } + // a smaller want never reuses a smaller loan, a bigger tail never reuses a smaller one + CHECK(!reuse_ok(4096, 4096, 2048, 4095, 1024)); + CHECK(reuse_ok(2048, 4096, 2048, 0, 1024)); + CHECK(reuse_ok(2048, 4096, 4096, 0, 1024) && !reuse_ok(2048, 4097 + 4096, 4096, 0, 8192)); + // ---- grow-only (next_tail): need grows, need shrinks, chunk grows + { + const int64_t floor = 3584; + CHECK(next_tail(8192, -1, 8192, 256, floor) == 256); // a start-up layout (default-sized): the need of the moment + CHECK(next_tail(8192, 1024, 8192, 256, floor) == 1024); // need shrinks: the tail stays (no relayout) + CHECK(next_tail(8192, 1024, 8192, 0, floor) == 1024); + CHECK(next_tail(8192, 1024, 8192, 1024, floor) == 1024); // equal: stays + CHECK(next_tail(8192, 1024, 8192, 1280, floor) == 3583); // need grows: today's size, once + CHECK(next_tail(8192, 3583, 8192, 3000, floor) == 3583); // and then it is today's: nothing grows past it + CHECK(next_tail(8192, 1024, 4096, 256, floor) == 256); // chunk shrinks: another layout, from its own need + CHECK(next_tail(4096, 1024, 8192, 2048, floor) == 2048); // chunk grows: from the need of that moment + CHECK(next_tail(8192, 0, 8192, 0, floor) == 0); // no tail needed, none carved + CHECK(next_tail(8192, 0, 8192, 256, floor) == 3583); + CHECK(next_tail(8192, 256, 8192, 256, 1) == 256 && next_tail(8192, 0, 8192, 5, 1) == 0); + // a sequence of needs on one chunk: at most one growth, every layout tail covers its segment, never shrinks + int64_t cap = -1, grown = 0; + for (int64_t need : std::initializer_list{256, 0, 1024, 256, 2048, 3583, 0, 512, 3000}) { + const int64_t t = next_tail(8192, cap, 8192, need, floor); + CHECK(t >= need); + if (cap >= 0) CHECK(t >= cap); + if (t != cap) ++grown; + cap = t; + } + CHECK(grown == 2); // the first carve (256), one growth (1024 > 256 -> today's 3583), then it stays + } + static_assert(tail_need(5000, 2048, 1024) == 904 && segment_tail(5000, 2048, 1024) == 1023, "constexpr"); if (failed != 0) return 1; std::printf("loan_rules_test: all checks passed\n"); return 0; From 71f3c6db6798a4c9ef2f0661f882474a13ce523d Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 07:07:03 +0100 Subject: [PATCH 6/9] Size the lent prompt buffers' MMQ tail from the request's own last chunk The loan of expert-cache slots laid out the fused MoE buffers for a tail of stream floor - 1 tokens of MMQ rows, taken out of the expert cache, so every chunk above the floor streamed more experts (+1.2 to +1.5% prompt time on an RTX A6000 at a floor of 3,584; a smaller share under today's CPU-share limit). The lend now sizes the tail from the segment: Prefill::relayout and bytes_needed take a tail, the lend asks loan_rules for it (grow-only while the layout's chunk stays), the reuse of a loan by a later segment also needs its tail to fit, and a chunk below the floor that does not fit the tail ends with a clear error instead of an overrun. One GPU, no peer, no --batch above one slot, no head alias; a layer split keeps the floor's tail. STRATA_PREFILL_TAIL_LOAN=0 restores today's sizing. --- data/settings-register.json | 561 +++++++++++++++-------------- docs/SETTINGS.md | 3 +- include/strata/prefill/prefill.hpp | 14 +- src/prefill/prefill.cpp | 45 ++- src/program/generate.cpp | 49 ++- 5 files changed, 385 insertions(+), 287 deletions(-) diff --git a/data/settings-register.json b/data/settings-register.json index 0d6cedb874..1890c446c0 100644 --- a/data/settings-register.json +++ b/data/settings-register.json @@ -169,7 +169,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13967, + "line": 13972, "backend": "cuda-hip", "fn": "a_env" } @@ -202,7 +202,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13966, + "line": 13971, "backend": "cuda-hip", "fn": "a_env" } @@ -271,13 +271,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13630, + "line": 13635, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21331, + "line": 21366, "backend": "cuda-hip", "fn": "getenv" } @@ -378,13 +378,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13457, + "line": 13462, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21320, + "line": 21355, "backend": "cuda-hip", "fn": "getenv" } @@ -419,13 +419,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13456, + "line": 13461, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21319, + "line": 21354, "backend": "cuda-hip", "fn": "getenv" } @@ -460,7 +460,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21321, + "line": 21356, "backend": "cuda-hip", "fn": "getenv" } @@ -658,7 +658,7 @@ }, { "file": "src/program/generate.cpp", - "line": 13555, + "line": 13560, "backend": "cuda-hip", "fn": "getenv" } @@ -697,13 +697,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13505, + "line": 13510, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 13506, + "line": 13511, "backend": "cuda-hip", "fn": "getenv" } @@ -736,7 +736,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13800, + "line": 13805, "backend": "cuda-hip", "fn": "getenv" } @@ -769,7 +769,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13965, + "line": 13970, "backend": "cuda-hip", "fn": "a_env" } @@ -802,7 +802,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13521, + "line": 13526, "backend": "cuda-hip", "fn": "getenv" } @@ -2046,7 +2046,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18016, + "line": 18051, "backend": "cuda-hip", "fn": "getenv" } @@ -2080,7 +2080,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17860, + "line": 17895, "backend": "cuda-hip", "fn": "getenv" }, @@ -2159,7 +2159,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14917, + "line": 14922, "backend": "cuda-hip", "fn": "getenv" } @@ -2192,7 +2192,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14919, + "line": 14924, "backend": "cuda-hip", "fn": "getenv" } @@ -2225,7 +2225,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14918, + "line": 14923, "backend": "cuda-hip", "fn": "getenv" } @@ -2552,7 +2552,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14938, + "line": 14943, "backend": "cuda-hip", "fn": "getenv" } @@ -2604,7 +2604,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18080, + "line": 18115, "backend": "cuda-hip", "fn": "getenv" } @@ -2791,7 +2791,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18621, + "line": 18656, "backend": "cuda-hip", "fn": "getenv" }, @@ -3064,13 +3064,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17333, + "line": 17338, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17466, + "line": 17471, "backend": "cuda-hip", "fn": "getenv" }, @@ -3206,7 +3206,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20696, + "line": 20731, "backend": "cuda-hip", "fn": "getenv" } @@ -3242,7 +3242,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3280, + "line": 3293, "backend": "cuda-hip", "fn": "getenv" } @@ -3666,7 +3666,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6554, + "line": 6575, "backend": "cuda-hip", "fn": "getenv" }, @@ -3705,7 +3705,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5225, + "line": 5246, "backend": "cuda-hip", "fn": "getenv" } @@ -3771,13 +3771,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4881, + "line": 4902, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7048, "backend": "cuda-hip", "fn": "getenv" } @@ -3810,7 +3810,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4887, + "line": 4908, "backend": "cuda-hip", "fn": "getenv" } @@ -3844,7 +3844,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5006, + "line": 5027, "backend": "cuda-hip", "fn": "getenv" }, @@ -3938,19 +3938,19 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5586, + "line": 5607, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6507, + "line": 6528, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6731, + "line": 6752, "backend": "cuda-hip", "fn": "getenv" }, @@ -4010,19 +4010,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4882, + "line": 4903, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4897, + "line": 4918, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7048, "backend": "cuda-hip", "fn": "getenv" } @@ -4056,7 +4056,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18868, + "line": 18903, "backend": "cuda-hip", "fn": "getenv" }, @@ -4626,13 +4626,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20053, + "line": 20088, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20053, + "line": 20088, "backend": "cuda-hip", "fn": "getenv" } @@ -5554,7 +5554,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21683, + "line": 21718, "backend": "cuda-hip", "fn": "getenv" } @@ -6036,13 +6036,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14681, + "line": 14686, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14681, + "line": 14686, "backend": "cuda-hip", "fn": "getenv" } @@ -6075,7 +6075,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14680, + "line": 14685, "backend": "cuda-hip", "fn": "getenv" } @@ -6115,7 +6115,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 2560, + "line": 2573, "backend": "cuda-hip", "fn": "getenv" }, @@ -6188,13 +6188,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19925, + "line": 19960, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21900, + "line": 21935, "backend": "cuda-hip", "fn": "getenv" }, @@ -6235,7 +6235,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5383, + "line": 5404, "backend": "cuda-hip", "fn": "getenv" } @@ -6271,13 +6271,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5385, + "line": 5406, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 5385, + "line": 5406, "backend": "cuda-hip", "fn": "getenv" } @@ -7343,13 +7343,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2226, + "line": 2230, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6793, + "line": 6814, "backend": "cuda-hip", "fn": "getenv" } @@ -7725,7 +7725,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18807, + "line": 18842, "backend": "cuda-hip", "fn": "getenv" }, @@ -7767,7 +7767,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18822, + "line": 18857, "backend": "cuda-hip", "fn": "getenv" }, @@ -8062,7 +8062,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18151, + "line": 18186, "backend": "cuda-hip", "fn": "env_on" } @@ -10127,7 +10127,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2149, + "line": 2153, "backend": "cuda-hip", "fn": "getenv" }, @@ -11458,8 +11458,8 @@ "first_commit": "fe6c5260ec", "first_date": "2026-10-03", "since": "v0.1.40.1", - "last_commit": "567c46873f", - "last_date": "2026-11-07", + "last_commit": "0b3364d416", + "last_date": "2026-11-12", "status": "default", "owner": "core", "note": "on by default on CUDA when the GGUF carries the hyper-connection projections as Q8_0 (an Unsloth UD-* file; generate.cpp via NativeDense::gguf_carries_q8_hc; owner yes 2026-11-07); gfx12 and gfx1151 HIP keep their own rule; STRATA_HC_Q8=0 turns it off; the GSQ-RCO packs (BF16 projections) are unchanged", @@ -11531,8 +11531,8 @@ "first_commit": "58729711d9", "first_date": "2026-10-03", "since": "v0.1.40.1", - "last_commit": "23a38a0bb7", - "last_date": "2026-10-07", + "last_commit": "0b3364d416", + "last_date": "2026-11-12", "status": "research", "owner": "core", "note": "[auto] off unless set, not documented for users", @@ -11738,7 +11738,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4420, + "line": 4441, "backend": "cuda-hip", "fn": "getenv" }, @@ -12778,7 +12778,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4753, + "line": 4774, "backend": "cuda-hip", "fn": "getenv" }, @@ -12927,13 +12927,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4618, + "line": 4639, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8159, + "line": 8180, "backend": "cuda-hip", "fn": "getenv" }, @@ -13566,7 +13566,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20696, + "line": 20731, "backend": "cuda-hip", "fn": "getenv" } @@ -14193,7 +14193,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11020, + "line": 11024, "backend": "cuda-hip", "fn": "getenv" } @@ -14557,7 +14557,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4475, + "line": 4496, "backend": "cuda-hip", "fn": "getenv" } @@ -14985,7 +14985,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10487, + "line": 10491, "backend": "cuda-hip", "fn": "getenv" }, @@ -15024,7 +15024,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17307, + "line": 17312, "backend": "cuda-hip", "fn": "getenv" } @@ -15098,7 +15098,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10485, + "line": 10489, "backend": "cuda-hip", "fn": "getenv" }, @@ -15138,13 +15138,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4560, + "line": 4581, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8106, + "line": 8127, "backend": "hip", "fn": "getenv" }, @@ -15262,7 +15262,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3590, + "line": 3603, "backend": "cuda-hip", "fn": "getenv" }, @@ -15383,7 +15383,7 @@ }, { "file": "src/program/generate.cpp", - "line": 12627, + "line": 12632, "backend": "cuda-hip", "fn": "getenv" }, @@ -15433,7 +15433,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1464, + "line": 1465, "backend": "cuda-hip", "fn": "getenv" }, @@ -15818,7 +15818,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6994, + "line": 7015, "backend": "hip", "fn": "getenv" } @@ -15851,7 +15851,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7390, + "line": 7411, "backend": "cuda-hip", "fn": "getenv" } @@ -15929,19 +15929,19 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17621, + "line": 17626, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17661, + "line": 17666, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18667, + "line": 18702, "backend": "cuda-hip", "fn": "getenv" }, @@ -15997,7 +15997,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17665, + "line": 17670, "backend": "cuda-hip", "fn": "getenv" }, @@ -16202,13 +16202,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18840, + "line": 18875, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21797, + "line": 21832, "backend": "cuda-hip", "fn": "getenv" }, @@ -18819,7 +18819,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 8436, + "line": 8457, "backend": "cuda-hip", "fn": "getenv" } @@ -20082,7 +20082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2482, + "line": 2495, "backend": "cuda-hip", "fn": "getenv" }, @@ -20122,7 +20122,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2526, + "line": 2539, "backend": "cuda-hip", "fn": "getenv" }, @@ -20162,7 +20162,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2487, + "line": 2500, "backend": "cuda-hip", "fn": "getenv" }, @@ -20581,13 +20581,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11518, + "line": 11523, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11527, + "line": 11532, "backend": "cuda-hip", "fn": "getenv" } @@ -22689,25 +22689,25 @@ }, { "file": "src/program/generate.cpp", - "line": 12562, + "line": 12567, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12566, + "line": 12571, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12572, + "line": 12577, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12915, + "line": 12920, "backend": "cuda-hip", "fn": "getenv" } @@ -23407,7 +23407,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13316, + "line": 13321, "backend": "cuda-hip", "fn": "getenv" } @@ -23589,7 +23589,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18584, + "line": 18619, "backend": "cuda-hip", "fn": "getenv" }, @@ -23669,7 +23669,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5054, + "line": 5075, "backend": "cuda-hip", "fn": "getenv" } @@ -23923,7 +23923,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6096, + "line": 6117, "backend": "cuda-hip", "fn": "getenv" } @@ -24079,7 +24079,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11297, + "line": 11302, "backend": "cuda-hip", "fn": "getenv" }, @@ -24941,7 +24941,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1871, + "line": 1872, "backend": "cuda-hip", "fn": "getenv" } @@ -24974,7 +24974,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1851, + "line": 1852, "backend": "cuda-hip", "fn": "getenv" } @@ -25082,7 +25082,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1887, + "line": 1888, "backend": "cuda-hip", "fn": "getenv" } @@ -25270,7 +25270,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11736, + "line": 11741, "backend": "cuda-hip", "fn": "getenv" } @@ -25412,7 +25412,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2864, + "line": 2877, "backend": "cuda-hip", "fn": "getenv" }, @@ -25484,7 +25484,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2909, + "line": 2922, "backend": "cuda-hip", "fn": "getenv" } @@ -25517,7 +25517,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2912, + "line": 2925, "backend": "cuda-hip", "fn": "getenv" } @@ -25550,7 +25550,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2807, + "line": 2820, "backend": "cuda-hip", "fn": "getenv" } @@ -25584,7 +25584,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2848, + "line": 2861, "backend": "cuda-hip", "fn": "getenv" }, @@ -25624,7 +25624,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2882, + "line": 2895, "backend": "cuda-hip", "fn": "getenv" }, @@ -25664,7 +25664,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2878, + "line": 2891, "backend": "cuda-hip", "fn": "getenv" }, @@ -25703,7 +25703,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2905, + "line": 2918, "backend": "cuda-hip", "fn": "getenv" } @@ -25736,7 +25736,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2833, + "line": 2846, "backend": "cuda-hip", "fn": "getenv" } @@ -25802,13 +25802,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11291, + "line": 11296, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11291, + "line": 11296, "backend": "cuda-hip", "fn": "getenv" } @@ -25841,7 +25841,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11306, + "line": 11311, "backend": "cuda-hip", "fn": "getenv" } @@ -25910,7 +25910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4270, + "line": 4291, "backend": "cuda-hip", "fn": "getenv" }, @@ -26106,7 +26106,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1663, + "line": 1664, "backend": "cuda-hip", "fn": "getenv" } @@ -26491,7 +26491,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18142, + "line": 18177, "backend": "cuda-hip", "fn": "getenv" } @@ -26528,7 +26528,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18168, + "line": 18203, "backend": "cuda-hip", "fn": "getenv" } @@ -26596,7 +26596,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18188, + "line": 18223, "backend": "cuda-hip", "fn": "getenv" } @@ -26629,7 +26629,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18406, + "line": 18441, "backend": "cuda-hip", "fn": "getenv" } @@ -26664,7 +26664,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18410, + "line": 18445, "backend": "cuda-hip", "fn": "getenv" } @@ -26744,7 +26744,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18402, + "line": 18437, "backend": "cuda-hip", "fn": "getenv" } @@ -26780,7 +26780,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10718, + "line": 10722, "backend": "cuda-hip", "fn": "getenv" } @@ -26814,7 +26814,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19182, + "line": 19217, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -26971,7 +26971,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19011, + "line": 19046, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27056,7 +27056,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17490, + "line": 17495, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27096,7 +27096,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18938, + "line": 18973, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27136,7 +27136,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19131, + "line": 19166, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27176,7 +27176,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19178, + "line": 19213, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27216,7 +27216,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 12347, + "line": 12352, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27255,7 +27255,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19338, + "line": 19373, "backend": "cuda-hip", "fn": "pipe_dbg_env" } @@ -27289,7 +27289,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17493, + "line": 17498, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27329,7 +27329,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17486, + "line": 17491, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27369,7 +27369,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18995, + "line": 19030, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27408,13 +27408,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10736, + "line": 10740, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 15760, + "line": 15765, "backend": "cuda-hip", "fn": "getenv" } @@ -28261,7 +28261,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4075, + "line": 4096, "backend": "cuda-hip", "fn": "getenv" } @@ -28296,7 +28296,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4079, + "line": 4100, "backend": "cuda-hip", "fn": "getenv" } @@ -28337,7 +28337,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11051, + "line": 11055, "backend": "cuda-hip", "fn": "getenv" } @@ -28378,13 +28378,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11130, + "line": 11134, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17880, + "line": 17915, "backend": "cuda-hip", "fn": "getenv" } @@ -28459,13 +28459,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6673, + "line": 6694, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7918, + "line": 7939, "backend": "cuda-hip", "fn": "getenv" }, @@ -28505,13 +28505,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6686, + "line": 6707, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7027, + "line": 7048, "backend": "cuda-hip", "fn": "getenv" }, @@ -28551,7 +28551,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10179, + "line": 10183, "backend": "cuda-hip", "fn": "getenv" }, @@ -28635,7 +28635,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5942, + "line": 5963, "backend": "cuda-hip", "fn": "getenv" }, @@ -28677,13 +28677,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2658, + "line": 2671, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18149, + "line": 18184, "backend": "cuda-hip", "fn": "env_on" }, @@ -28728,7 +28728,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11084, + "line": 11088, "backend": "cuda-hip", "fn": "getenv" } @@ -28762,7 +28762,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2670, + "line": 2683, "backend": "cuda-hip", "fn": "getenv" }, @@ -28803,7 +28803,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10381, + "line": 10385, "backend": "cuda-hip", "fn": "getenv" } @@ -28841,7 +28841,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4071, + "line": 4092, "backend": "cuda-hip", "fn": "getenv" }, @@ -28882,13 +28882,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6907, + "line": 6928, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11298, + "line": 11303, "backend": "cuda-hip", "fn": "getenv" } @@ -28899,19 +28899,19 @@ "engine_sets": [ { "file": "src/program/generate.cpp", - "line": 11309 + "line": 11314 }, { "file": "src/program/generate.cpp", - "line": 11311 + "line": 11316 }, { "file": "src/program/generate.cpp", - "line": 11319 + "line": 11324 }, { "file": "src/program/generate.cpp", - "line": 11321 + "line": 11326 } ], "engine_defaults": [], @@ -28953,7 +28953,7 @@ }, { "file": "src/program/generate.cpp", - "line": 10208, + "line": 10212, "backend": "cuda-hip", "fn": "getenv" }, @@ -28992,7 +28992,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6918, + "line": 6939, "backend": "cuda-hip", "fn": "getenv" } @@ -29025,7 +29025,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6913, + "line": 6934, "backend": "cuda-hip", "fn": "getenv" } @@ -29058,7 +29058,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6939, + "line": 6960, "backend": "cuda-hip", "fn": "getenv" } @@ -29091,7 +29091,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6928, + "line": 6949, "backend": "cuda-hip", "fn": "getenv" } @@ -29124,7 +29124,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6923, + "line": 6944, "backend": "cuda-hip", "fn": "getenv" } @@ -29197,13 +29197,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 1718, + "line": 1719, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6096, + "line": 6117, "backend": "cuda-hip", "fn": "getenv" }, @@ -29324,7 +29324,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3030, + "line": 3043, "backend": "cuda-hip", "fn": "getenv" } @@ -29359,7 +29359,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10397, + "line": 10401, "backend": "cuda-hip", "fn": "getenv" } @@ -29436,7 +29436,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4090, + "line": 4111, "backend": "cuda-hip", "fn": "getenv" } @@ -29471,7 +29471,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4091, + "line": 4112, "backend": "cuda-hip", "fn": "getenv" } @@ -29645,6 +29645,39 @@ "retire_after": "", "retired_in": "" }, + { + "name": "STRATA_PREFILL_TAIL_LOAN", + "backends": [ + "cuda-hip" + ], + "reads": [ + { + "file": "src/program/generate.cpp", + "line": 10171, + "backend": "cuda-hip", + "fn": "getenv" + } + ], + "parse": "flag", + "default_state": null, + "code_default": null, + "engine_sets": [], + "engine_defaults": [], + "launch_files": [], + "launch_sets": [], + "launch_reads": [], + "doc_mentions": [], + "first_commit": null, + "first_date": null, + "since": null, + "last_commit": null, + "last_date": null, + "status": "rollback", + "owner": "program", + "note": "[reviewed] \"STRATA_PREFILL_TAIL_LOAN=0 keeps the stream floor's tail\"; the lent fused MoE buffers are sized for the segment's own short last chunk, not for stream floor - 1 tokens (default on; one GPU).", + "retire_after": "", + "retired_in": "" + }, { "name": "STRATA_PREFILL_TIMING", "backends": [ @@ -29654,13 +29687,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3346, + "line": 3359, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 3387, + "line": 3400, "backend": "cuda-hip", "fn": "getenv" }, @@ -29709,19 +29742,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1953, + "line": 1957, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 1967, + "line": 1971, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2132, + "line": 2136, "backend": "cuda-hip", "fn": "getenv" } @@ -29902,13 +29935,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4829, + "line": 4850, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8190, + "line": 8211, "backend": "cuda-hip", "fn": "getenv" }, @@ -30110,7 +30143,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11007, + "line": 11011, "backend": "cuda-hip", "fn": "getenv" } @@ -31627,7 +31660,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4801, + "line": 4822, "backend": "cuda-hip", "fn": "getenv" }, @@ -31667,13 +31700,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4802, + "line": 4823, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4803, + "line": 4824, "backend": "cuda-hip", "fn": "getenv" }, @@ -31718,13 +31751,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4804, + "line": 4825, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4804, + "line": 4825, "backend": "cuda-hip", "fn": "getenv" } @@ -31757,7 +31790,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4813, + "line": 4834, "backend": "cuda-hip", "fn": "getenv" } @@ -32214,7 +32247,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19770, + "line": 19805, "backend": "cuda-hip", "fn": "getenv" } @@ -32253,7 +32286,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11102, + "line": 11106, "backend": "cuda-hip", "fn": "getenv" } @@ -32286,7 +32319,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11105, + "line": 11109, "backend": "cuda-hip", "fn": "getenv" } @@ -32319,7 +32352,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11106, + "line": 11110, "backend": "cuda-hip", "fn": "getenv" } @@ -32352,7 +32385,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11104, + "line": 11108, "backend": "cuda-hip", "fn": "getenv" } @@ -32418,7 +32451,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11107, + "line": 11111, "backend": "cuda-hip", "fn": "getenv" } @@ -32603,7 +32636,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17700, + "line": 17705, "backend": "cuda-hip", "fn": "getenv" } @@ -32640,7 +32673,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17741, + "line": 17746, "backend": "cuda-hip", "fn": "getenv" }, @@ -33342,13 +33375,13 @@ }, { "file": "src/program/generate.cpp", - "line": 11890, + "line": 11895, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11892, + "line": 11897, "backend": "cuda-hip", "fn": "getenv" } @@ -33383,13 +33416,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11891, + "line": 11896, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11891, + "line": 11896, "backend": "cuda-hip", "fn": "getenv" } @@ -33430,7 +33463,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11894, + "line": 11899, "backend": "cuda-hip", "fn": "getenv" } @@ -33502,31 +33535,31 @@ }, { "file": "src/program/generate.cpp", - "line": 13342, + "line": 13347, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14588, + "line": 14593, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14588, + "line": 14593, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14589, + "line": 14594, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14590, + "line": 14595, "backend": "cuda-hip", "fn": "getenv" } @@ -34127,13 +34160,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4667, + "line": 4688, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8178, + "line": 8199, "backend": "cuda-hip", "fn": "getenv" }, @@ -34242,13 +34275,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 8362, + "line": 8383, "backend": "metal", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8404, + "line": 8425, "backend": "cuda-hip", "fn": "getenv" }, @@ -34468,7 +34501,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4731, + "line": 4752, "backend": "cuda-hip", "fn": "getenv" }, @@ -34507,7 +34540,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18831, + "line": 18866, "backend": "cuda-hip", "fn": "getenv" } @@ -34540,7 +34573,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18834, + "line": 18869, "backend": "cuda-hip", "fn": "getenv" } @@ -35015,7 +35048,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14981, + "line": 14986, "backend": "cuda-hip", "fn": "getenv" } @@ -35371,7 +35404,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17274, + "line": 17279, "backend": "cuda-hip", "fn": "getenv" }, @@ -35413,13 +35446,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13208, + "line": 13213, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17247, + "line": 17252, "backend": "cuda-hip", "fn": "getenv" }, @@ -35577,13 +35610,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14683, + "line": 14688, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21551, + "line": 21586, "backend": "cuda-hip", "fn": "getenv" } @@ -35627,7 +35660,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21599, + "line": 21634, "backend": "cuda-hip", "fn": "getenv" } @@ -35697,7 +35730,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20746, + "line": 20781, "backend": "cuda-hip", "fn": "getenv" } @@ -35976,13 +36009,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18778, + "line": 18813, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21554, + "line": 21589, "backend": "cuda-hip", "fn": "getenv" } @@ -36015,7 +36048,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18779, + "line": 18814, "backend": "cuda-hip", "fn": "getenv" } @@ -36048,7 +36081,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21539, + "line": 21574, "backend": "cuda-hip", "fn": "getenv" } @@ -36081,7 +36114,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21641, + "line": 21676, "backend": "cuda-hip", "fn": "getenv" } @@ -36189,8 +36222,8 @@ "first_commit": "ecf7424b53", "first_date": "2026-11-02", "since": "v0.2.10", - "last_commit": "ee0b367fb7", - "last_date": "2026-11-03", + "last_commit": "4c39e8624e", + "last_date": "2026-11-12", "status": "default", "owner": "program", "note": "[auto] on unless set to 0 (src/program/generate.cpp:4077)", @@ -36205,7 +36238,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10222, + "line": 10226, "backend": "cuda-hip", "fn": "getenv" } @@ -36498,13 +36531,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13172, + "line": 13177, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18150, + "line": 18185, "backend": "cuda-hip", "fn": "env_on" } @@ -36580,7 +36613,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11975, + "line": 11980, "backend": "cuda-hip", "fn": "getenv" } @@ -36662,13 +36695,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10803, + "line": 10807, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11438, + "line": 11443, "backend": "cuda-hip", "fn": "getenv" }, @@ -36748,7 +36781,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10753, + "line": 10757, "backend": "cuda-hip", "fn": "getenv" }, @@ -36790,7 +36823,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11840, + "line": 11845, "backend": "cuda-hip", "fn": "getenv" }, @@ -36830,7 +36863,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11838, + "line": 11843, "backend": "cuda-hip", "fn": "getenv" }, @@ -36903,7 +36936,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20717, + "line": 20752, "backend": "cuda-hip", "fn": "getenv" }, @@ -37127,7 +37160,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 22331, + "line": 22366, "backend": "hip", "fn": "getenv" } @@ -37162,7 +37195,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2123, + "line": 2127, "backend": "cuda-hip", "fn": "getenv" } @@ -37202,7 +37235,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 2119, + "line": 2123, "backend": "cuda-hip", "fn": "getenv" }, @@ -37285,7 +37318,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2111, + "line": 2115, "backend": "cuda-hip", "fn": "getenv" } @@ -37321,7 +37354,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2099, + "line": 2103, "backend": "cuda-hip", "fn": "getenv" }, @@ -37453,8 +37486,8 @@ "first_commit": "d95805c61a", "first_date": "2026-10-03", "since": "v0.1.40.1", - "last_commit": "ee0b367fb7", - "last_date": "2026-11-03", + "last_commit": "4c39e8624e", + "last_date": "2026-11-12", "status": "research", "owner": "program", "note": "[reviewed] Experimental split-stack flag; no change in report. [_issues_dump/2239.md:67]", @@ -37569,7 +37602,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20304, + "line": 20339, "backend": "cuda-hip", "fn": "getenv" }, @@ -37644,13 +37677,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6870, + "line": 6891, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20342, + "line": 20377, "backend": "cuda-hip", "fn": "getenv" }, @@ -37803,7 +37836,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13354, + "line": 13359, "backend": "cuda-hip", "fn": "getenv" } @@ -37904,7 +37937,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18275, + "line": 18310, "backend": "cuda-hip", "fn": "getenv" } @@ -38024,7 +38057,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18192, + "line": 18227, "backend": "cuda-hip", "fn": "getenv" } @@ -38998,13 +39031,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3716, + "line": 3729, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6610, + "line": 6631, "backend": "cuda-hip", "fn": "getenv" }, @@ -39022,25 +39055,25 @@ }, { "file": "src/program/generate.cpp", - "line": 10997, + "line": 11001, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12989, + "line": 12994, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14427, + "line": 14432, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20887, + "line": 20922, "backend": "cuda-hip", "fn": "getenv" }, @@ -39096,13 +39129,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21396, + "line": 21431, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21433, + "line": 21468, "backend": "cuda-hip", "fn": "getenv" }, @@ -39253,13 +39286,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11625, + "line": 11630, "backend": "cuda", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11643, + "line": 11648, "backend": "cuda", "fn": "getenv" } @@ -39334,7 +39367,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10863, + "line": 10867, "backend": "hip", "fn": "getenv" } @@ -40692,7 +40725,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14605, + "line": 14610, "backend": "cuda-hip", "fn": "getenv" } @@ -40726,7 +40759,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14601, + "line": 14606, "backend": "cuda-hip", "fn": "getenv" }, @@ -40969,7 +41002,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2230, + "line": 2234, "backend": "cuda-hip", "fn": "getenv" } diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index 7c78f720c2..9513f7bc23 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -289,7 +289,7 @@ Off unless you set them. The last column says where each one is described. | `STRATA_WDDM_BUDGET` | number | AMD, Intel Arc | [AMD_HIP.md](AMD_HIP.md) | | `STRATA_WS_FAST` | number | NVIDIA and AMD | [OLDER_GPUS.md](OLDER_GPUS.md) | -## Switches that go back to earlier behaviour (67) +## Switches that go back to earlier behaviour (68) These behaviours are on by default. Setting the switch returns the earlier behaviour; the notes in the register say which version made it the default. @@ -339,6 +339,7 @@ version made it the default. | `STRATA_PLE_AUTO_MMAP` | number | NVIDIA and AMD, Intel Arc | v0.1.43.1 | [DETAILS.md](DETAILS.md) | | `STRATA_PREFILL_LOAN_WALK` | on / off | NVIDIA and AMD | - | - | | `STRATA_PREFILL_STREAM_MIN` | number | NVIDIA and AMD, Intel Arc | v0.1.40.1 | [AMD_HIP.md](AMD_HIP.md), [STRIX_HALO.md](STRIX_HALO.md) | +| `STRATA_PREFILL_TAIL_LOAN` | on / off | NVIDIA and AMD | - | - | | `STRATA_PROMPT_ATTN_ESIMD` | number | Intel Arc | v0.2.9 | - | | `STRATA_PROMPT_ATTN_OLD` | on / off | NVIDIA and AMD, Intel Arc | v0.1.40.1 | [NVIDIA_V100.md](NVIDIA_V100.md), [OLDER_GPUS.md](OLDER_GPUS.md) | | `STRATA_Q2_WARP` | on / off | NVIDIA and AMD | v0.1.45 | [DETAILS.md](DETAILS.md) | diff --git a/include/strata/prefill/prefill.hpp b/include/strata/prefill/prefill.hpp index ea62fa8697..fbb4745b27 100644 --- a/include/strata/prefill/prefill.hpp +++ b/include/strata/prefill/prefill.hpp @@ -85,8 +85,16 @@ public: /// With borrowed buffers: lay them out again for chunks of `chunk` tokens (at most `init`'s) in `borrow` - a /// request lends only the slots its prompt needs. The stream must be idle (between prompts). - bool relayout(int64_t chunk, void* borrow, uint64_t borrow_bytes, std::string& err); + /// `tail` (>= 0, a fused layout only): the MMQ rows, in tokens, the layout holds for a chunk below the stream floor + /// (loan_rules.hpp: a lent layout is sized for its segment's own short last chunk, not for floor - 1); -1: floor - 1. + bool relayout(int64_t chunk, void* borrow, uint64_t borrow_bytes, std::string& err, int64_t tail = -1); int64_t chunk() const; + /// The tail the layout in place was carved with (-1: the default, floor - 1), and the MMQ tokens a chunk below the + /// floor may bring into it (a layout that is not fused takes any chunk it has: INT64_MAX). + int64_t layout_tail() const; + int64_t tail_room() const; + /// True when a layout for `chunk` is the fused one, whose MoE buffers carry a tail (see relayout). + static bool tail_matters(int64_t chunk, bool src); /// The share of the streamed experts' bytes DMA-able straight from pinned RAM (1 = all). Sizes the streamed /// ring (a big one only pays when the copy engine, not the host copies, is the limit); set before bytes_needed. @@ -168,7 +176,7 @@ public: /// Device bytes `init` needs for a chunk of `chunk` tokens (what a borrowed region must hold). `src`: init gets an /// ExpertSource (carve picks the fused MoE layout only then). static uint64_t bytes_needed(const core::ModelGeometry& g, const core::SessionState& ss, int64_t chunk, - bool src = true); + bool src = true, int64_t tail = -1); /// The same without the streamed ring: what the chunk's own buffers cost. The auto chunk scan sizes the chunk /// first and hands the ring what the chunk leaves over, so it needs the chunk priced on its own. @@ -331,7 +339,7 @@ public: private: static uint64_t bytes_needed_impl(const core::ModelGeometry& g, const core::SessionState& ss, int64_t chunk, - bool owned_pages, bool src); + bool owned_pages, bool src, int64_t tail = -1); kernels::cpu::ExpertPool* cpu_pool_ = nullptr; ///< set_cpu_pool // Layer-major prefill: the super-chunk's buffers for an n-token prompt (its size, 0 = not this prompt: `why`), // the run, and the buffers given back after it. `cap` (> 0): at most that many tokens (a layer split's stages diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index 15362ea8c4..3c19b115c7 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -1384,7 +1384,8 @@ struct Prefill::Impl { // this layout's GU, H and Xq are the fused path's (moe_bufs' `fused`), so a layer that runs MMQ or the FP16 path may // only write stream_all_min() - 1 of its rows into them; fused_layout() keeps the two in step (#583, #954) bool fused_bufs = false; - std::unique_ptr stager; // the unpinned experts' host copies (step 4) + int64_t tail_req = -1; // the MMQ tail (tokens) the fused layout was carved for: -1 = stream_all_min() - 1 (start-up, the way back); relayout's `tail` + std::unique_ptr stager; // the unpinned experts' host copies (step 4) std::unique_ptr warmer; // STRATA_PREFILL_WARM=1: the per-layer walk's page warming std::vector> warm_prev; // per layer: the file-tier experts of the previous chunk cudaEvent_t copied[RING_MAX] = {}, used[RING_MAX] = {}; @@ -1906,21 +1907,24 @@ bool fused_layout(size_t T, bool src) { // The MoE buffers MMQ and the fused path share: GU and H in floats, Xq and Hq in bytes. Without `fused` (the // default): MMQ's, for T tokens. struct MoeBufs { size_t gu, h, xq, hq; }; -MoeBufs moe_bufs(size_t T, int64_t n_expert, bool fused) { +// `tail` (>= 0, fused only): the MMQ rows a chunk below the floor may bring, in tokens (a lent layout sized for its +// segment's own last chunk, loan_rules.hpp); -1: stream_all_min() - 1, as the start-up layout. +MoeBufs moe_bufs(size_t T, int64_t n_expert, bool fused, int64_t tail = -1) { if (!fused && pf_group_scratch()) { // GU, H, Hq: one group's rows (Xq keeps every row: gate/up reads the layer's) const size_t gc = (size_t) group_cap_rows(T, n_expert); return {gc * kFF2, gc * kFF, mmq::q8_bytes((int64_t) (T * K), N), mmq::q8_bytes((int64_t) gc, kFF)}; } if (!fused) return {T * K * kFF2, T * K * kFF, mmq::q8_bytes((int64_t) (T * K), N), mmq::q8_bytes((int64_t) (T * K), kFF)}; - const size_t ts = (size_t) std::min((int64_t) T, stream_all_min() - 1); // MMQ's last small chunk + const int64_t tail_tokens = tail >= 0 ? std::min(tail, std::max(stream_all_min() - 1, 0)) : stream_all_min() - 1; + const size_t ts = (size_t) std::min((int64_t) T, tail_tokens); // MMQ's last small chunk return {std::max(ts * K * kFF2, (fused::group_bytes((int64_t) (T * K), (int) n_expert) + 3) / 4), std::max(ts * K * kFF, (fused::act_bytes((int64_t) (T * K), kFF) + 3) / 4), std::max(mmq::q8_bytes((int64_t) (ts * K), N), fused::act_bytes((int64_t) T, N)), mmq::q8_bytes((int64_t) (ts * K), kFF)}; } -uint64_t moe_set_bytes(size_t T, int64_t n_expert, bool fused) { +uint64_t moe_set_bytes(size_t T, int64_t n_expert, bool fused, int64_t tail = -1) { const MmqPlan& mp = mmq_plan(); - const MoeBufs mb = moe_bufs(T, n_expert, fused); + const MoeBufs mb = moe_bufs(T, n_expert, fused, tail); Alloc a; a.count_only = true; bool ok = true; a.take(T * n_expert, ok); a.take(T * K, ok); a.take(T * K, ok); a.take(T * K, ok); a.take(T * K, ok); @@ -2282,9 +2286,9 @@ bool Prefill::carve(size_t T, void* alloc) { // one region for the attention half's and the MoE half's scratch (see gdn_set_bytes) const bool fz = fused_layout(T, m.src != nullptr); m.fused_bufs = fz; - const MoeBufs mb = moe_bufs(T, m.g->n_expert, fz); + const MoeBufs mb = moe_bufs(T, m.g->n_expert, fz, m.tail_req); const uint64_t region = std::max({gdn_set_bytes(T), qsa_set_bytes(T, m.cap, m.max_blocks, m.sel_batch, - m.attn_batch, s), moe_set_bytes(T, m.g->n_expert, fz), + m.attn_batch, s), moe_set_bytes(T, m.g->n_expert, fz, m.tail_req), hcr ? hc_set_bytes(T, m.f16_io) : (uint64_t) 0}); uint8_t* base = o.take((size_t) region, ok); // No region: the sub-allocators below would each cudaMalloc their share (hundreds of MiB) on a card that has just @@ -2410,8 +2414,9 @@ bool Prefill::carve(size_t T, void* alloc) { return ok; } -bool Prefill::relayout(int64_t chunk, void* borrow, uint64_t borrow_bytes, std::string& err) { +bool Prefill::relayout(int64_t chunk, void* borrow, uint64_t borrow_bytes, std::string& err, int64_t tail) { Impl& m = *impl_; + m.tail_req = tail; // read by carve (a failure leaves the layout unusable as before; the caller ends the request) if (m.borrow_spill) { err = "prefill: a hybrid borrowed/owned layout cannot be changed between requests"; return false; @@ -2449,6 +2454,14 @@ bool Prefill::relayout(int64_t chunk, void* borrow, uint64_t borrow_bytes, std:: } int64_t Prefill::chunk() const { return impl_->T; } +int64_t Prefill::layout_tail() const { return impl_->tail_req; } +int64_t Prefill::tail_room() const { + const Impl& m = *impl_; + if (!m.fused_bufs) return std::numeric_limits::max(); // MMQ-sized buffers: any chunk the layout has + const int64_t d = std::max(stream_all_min() - 1, 0); + return m.tail_req >= 0 ? std::min(m.tail_req, d) : d; +} +bool Prefill::tail_matters(int64_t chunk, bool src) { return chunk > 0 && fused_layout((size_t) chunk, src); } void Prefill::set_ring_room_active(bool on) { ring_room_active_ = on; @@ -3102,8 +3115,8 @@ int64_t Prefill::chain_experts_streamed() const { return sum; } -uint64_t Prefill::bytes_needed(const core::ModelGeometry& g, const core::SessionState& ss, int64_t chunk, bool src) { - return bytes_needed_impl(g, ss, chunk, false, src); +uint64_t Prefill::bytes_needed(const core::ModelGeometry& g, const core::SessionState& ss, int64_t chunk, bool src, int64_t tail) { + return bytes_needed_impl(g, ss, chunk, false, src, tail); } // What `init` really allocates when the prompt path owns its buffers (no loan): every cudaMalloc rounds up to a 2 MiB @@ -3114,7 +3127,7 @@ uint64_t Prefill::bytes_needed_owned(const core::ModelGeometry& g, const core::S } uint64_t Prefill::bytes_needed_impl(const core::ModelGeometry& g, const core::SessionState& ss, int64_t chunk, - bool owned_pages, bool src) { + bool owned_pages, bool src, int64_t tail) { // the same allocation sequence as `init` (`carve`), counted - with the MoE layout `carve` picks for the same source const size_t T = (size_t) chunk; bool ok = true; @@ -3149,7 +3162,7 @@ uint64_t Prefill::bytes_needed_impl(const core::ModelGeometry& g, const core::Se const int64_t cap = strata::kernels::qsa_selection_width(strata::kernels::kTopkMaxCells, s); const int64_t max_blocks = ss.qsa_states[ss.qsa_primary()].max_cells / s.idx_block + 2; o.take((size_t) std::max({gdn_set_bytes(T), qsa_set_bytes(T, cap, max_blocks, 256, 32, s), - moe_set_bytes(T, g.n_expert, fused_layout(T, src)), + moe_set_bytes(T, g.n_expert, fused_layout(T, src), tail), hcr ? hc_set_bytes(T, f16_io) : (uint64_t) 0}), ok); for (int i = 0; i < DQ; ++i) { o.take(kFF2 * kEmbd, ok); o.take(kEmbd * kFF, ok); } if (mmq_plan().any) { @@ -3723,6 +3736,14 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri std::fflush(stderr); } const int64_t T = std::min(C, n - c0), p0 = pos0 + c0; + // A fused layout carved with a tail (relayout's `tail`, loan_rules.hpp) holds MMQ's rows for that many tokens of a + // chunk below the stream floor: a longer one would overrun GU / H / Xq / Hq (an illegal access, or a hang). The + // lend sizes the tail from the segment, so this is the clean error for anything that drifts from it. + if (m.fused_bufs && T < stream_all_min() && T > tail_room()) { + err = "prefill: a chunk of " + std::to_string((long long) T) + " tokens below the stream floor does not fit the fused layout's tail of " + + std::to_string((long long) tail_room()) + " tokens"; + return false; + } // STRATA_KVA: this chunk is approximated in the layers at and after the split when its last position is // before the request's full-computation suffix; a chunk in the suffix runs the ordinary path everywhere. const bool kva_approx = kva_run && (p0 + T <= kva_frontier); diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 4bf89337b3..76cbe03a51 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -10165,6 +10165,10 @@ int main(int argc, char** argv) { // tokens (RTX A6000). Applies to every piece within 255 tokens under the floor (769-1,023 at 1,024; 2,817-3,071 under the CPU // share's 3,072). STRATA_PREFILL_LOAN_WALK=0 keeps the rounded chunk. static const bool loan_by_walk = [] { const char* e = std::getenv("STRATA_PREFILL_LOAN_WALK"); return !(e != nullptr && e[0] == '0'); }(); + // The lent fused layout's MMQ tail is sized from the segment's own last chunk, not from the stream floor (a floor of 3,584 + // against 1,024 costs ~92 expert slots on an RTX A6000, streamed again by every chunk above the floor). One GPU, no peer, no + // --batch above one slot, no head alias; a layer split keeps the floor's tail. STRATA_PREFILL_TAIL_LOAN=0 keeps today's size. + static const bool tail_loan_on = [] { const char* e = std::getenv("STRATA_PREFILL_TAIL_LOAN"); return !(e != nullptr && e[0] == '0'); }(); auto loan_chunk = [&](int64_t tokens, int64_t chunk) -> int64_t { return loan_by_walk ? strata::prefill::loan_rules::walk_chunk(tokens, chunk, strata::prefill::Prefill::stream_all_min_tokens()) : chunk; @@ -11171,9 +11175,10 @@ int main(int argc, char** argv) { (uint64_t) strata::kernels::cpu::expert_layout().max_blob, need); }; auto on_part_device = [](int dev) { return strata::core::OnDevice(dev); }; - auto part_slots = [&](const PfPart& p, int64_t c) -> int64_t { + // `tail` (>= 0): the lent fused layout's MMQ tail in tokens (loan_rules.hpp); -1: today's floor - 1 + auto part_slots = [&](const PfPart& p, int64_t c, int64_t tail = -1) -> int64_t { return cache_slots_for(*p.cache, strata::program::split_part_figure(on_part_device, p.dev, [&] { - return strata::prefill::Prefill::bytes_needed(g, *p.ses, c, srcp != nullptr); + return strata::prefill::Prefill::bytes_needed(g, *p.ses, c, srcp != nullptr, tail); })); }; auto part_bytes = [&](const PfPart& p, int32_t first) -> uint64_t { @@ -17784,10 +17789,17 @@ int main(int argc, char** argv) { return false; } bool any = false; + namespace lr = strata::prefill::loan_rules; + using strata::prefill::Prefill; + const int64_t floor_t = Prefill::stream_all_min_tokens(); + const bool tail_ok = tail_loan_on && pf_parts.size() == 1 && stages.empty() && !multi_gpu && !peer.valid() && + !o.prefill_head_alias && o.batch <= 1; for (PfPart& p : pf_parts) { if (p.first < 0) continue; if (!p.lent.empty()) { - if (want <= p.lent_chunk) continue; // its current loan already covers this + // its current loan already covers this: the chunk, and (a fused layout) the tail the segment's last + // chunk needs when it is read in the loan's own chunks + if (tail_ok ? lr::reuse_ok(want, tokens, p.lent_chunk, p.sp->tail_room(), floor_t) : want <= p.lent_chunk) continue; // ONLY this participant's loan goes back: `refill` would return the other participants' // loans too, and their buffers are still laid out in their caches - marking those slots // resident again would hand the next window a prompt buffer in place of an expert @@ -17795,6 +17807,7 @@ int main(int argc, char** argv) { } const strata::core::OnDevice on(p.dev); int64_t want_p = want; + int64_t tail_p = -1; // the tail the layout is laid out with (-1: floor - 1) int32_t first = p.first_now; // --prefill-head-alias: the loan laid out at start (slot 1 on) is kept; a hybrid layout cannot relayout. // (STRATA_MTP_ROOM_MIN's room is not one: its slots are the drafter's own bytes, so a roomed @@ -17805,10 +17818,18 @@ int main(int argc, char** argv) { // a request's smaller chunk can need MORE slots than the auto chunk's region (p.first) holds. The // loan starts where the chunk itself needs it (the 128-slot floor aside); a chunk that cannot be // lent even then is halved until it can, instead of ending the engine. - int64_t need_p = part_slots(p, want_p); + // the tail this layout is carved with for chunks of `w` (-1: today's floor - 1): grow-only while the layout's + // chunk stays (loan_rules::next_tail), the need of the moment otherwise + auto tail_for = [&](int64_t w) -> int64_t { + if (!tail_ok || !Prefill::tail_matters(w, srcp != nullptr)) return -1; + return lr::next_tail(p.sp->chunk(), p.sp->layout_tail(), w, lr::segment_tail(tokens, w, floor_t), floor_t); + }; + tail_p = tail_for(want_p); + int64_t need_p = part_slots(p, want_p, tail_p); while ((need_p <= 0 || need_p + g_lend_keep > p.cache->slots()) && want_p > 256) { want_p = std::max(256, want_p / 2 / 256 * 256); - need_p = part_slots(p, want_p); + tail_p = tail_for(want_p); + need_p = part_slots(p, want_p, tail_p); } if (need_p <= 0 || need_p + g_lend_keep > p.cache->slots()) { e = "prefill: no chunk of this request fits the slots that can be lent (#2090)"; @@ -17824,9 +17845,23 @@ int main(int argc, char** argv) { (long long) need_p, (long long) (p.cache->slots() - p.first)); first = (int32_t) (p.cache->slots() - need_p); } - if (want_p != p.sp->chunk() || first != p.first_now) { - if (!p.sp->relayout(want_p, p.cache->device_slot(first), part_bytes(p, first), e)) return false; + if (want_p != p.sp->chunk() || first != p.first_now || (tail_p >= 0 && tail_p != p.sp->layout_tail())) { + const auto t_rl = Clock::now(); + if (!p.sp->relayout(want_p, p.cache->device_slot(first), part_bytes(p, first), e, tail_p)) return false; p.first_now = first; + if (tail_p >= 0) { + static bool said = false; + if (!said) { + said = true; + std::fprintf(stderr, "strata serve: the lent prompt buffers are sized for the request's own short last chunk " + "(tail %lld tokens, not the stream floor's %lld); STRATA_PREFILL_TAIL_LOAN=0 keeps the floor's\n", + (long long) tail_p, (long long) (floor_t - 1)); + } + if (trace) + std::fprintf(stderr, "strata trace: relayout for %lld tokens, tail %lld, first slot %d: %.1f ms\n", (long long) want_p, + (long long) tail_p, (int) first, + std::chrono::duration(Clock::now() - t_rl).count()); + } } for (int64_t l = p.lb; l < p.le; ++l) // THIS participant's layers only for (int64_t ex = 0; ex < g.n_expert; ++ex) { From 832d83c7a1f880bf08dacc9c716b287a643decfb Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 07:10:46 +0100 Subject: [PATCH 7/9] Correct two unit rows of the tail rules A layout whose own chunk is below the stream floor is not a fused layout, so its tail need is the whole chunk; the rows that assumed the opposite are replaced by the case they meant (a last chunk of one token after 8,192) and the reuse of a loan by a segment that reads as one fused chunk. --- tests/prefill/loan_rules_test.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/prefill/loan_rules_test.cpp b/tests/prefill/loan_rules_test.cpp index d47098cb23..a1410b14e1 100644 --- a/tests/prefill/loan_rules_test.cpp +++ b/tests/prefill/loan_rules_test.cpp @@ -69,7 +69,8 @@ int main() { CHECK(tail_need(5120 + 1023, 5120, 1024) == 1023); CHECK(tail_need(5120 + 1024, 5120, 1024) == 0); // a last chunk at the floor streams: fused // a floor of 3,584 (the rule on an RTX A6000): the same segments now have a tail up to 3,583 - CHECK(tail_need(4097, 2048, 3584) == 1); + CHECK(tail_need(8193, 8192, 3584) == 1); + CHECK(tail_need(4097, 2048, 3584) == 2048); // a layout of 2,048-token chunks is below the floor: not fused, every chunk is MMQ's CHECK(tail_need(8193 + 2000, 8192, 3584) == 2001); CHECK(tail_need(8192 + 3584, 8192, 3584) == 0); // a segment read in one chunk below the floor, in a layout whose chunk reaches it (a reused big loan) @@ -107,8 +108,8 @@ int main() { CHECK(!reuse_ok(2048, 2000, lent_chunk, lent_tail, floor)); // needs 2,000 (grid 2,048): relayout CHECK(tail_need(2000, lent_chunk, floor) > lent_tail); CHECK(reuse_ok(256, 100, lent_chunk, lent_tail, floor)); // 100 <= 256: reuse - CHECK(reuse_ok(2048, 4096 + 100, lent_chunk, lent_tail, floor) == false); // chunk 8,192 > 4,196: one chunk of 4,196 >= floor: need 0 - CHECK(tail_need(4196, lent_chunk, floor) == 0); // (it is fused, so it reuses) + CHECK(tail_need(4196, lent_chunk, floor) == 0); // one chunk of 4,196 >= floor: fused, no tail + CHECK(reuse_ok(2048, 4196, lent_chunk, lent_tail, floor)); // so it reuses } // a smaller want never reuses a smaller loan, a bigger tail never reuses a smaller one CHECK(!reuse_ok(4096, 4096, 2048, 4095, 1024)); From dd404b382e9764db8b20d7972eb3cb838fa9f469 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 07:14:03 +0100 Subject: [PATCH 8/9] Add a debug switch that reuses a lent loan by chunk alone STRATA_DBG_TAIL_NOREUSE=1 turns off the tail half of the loan reuse test, so a later short segment runs in a layout whose tail is too small. It exists to show that the chunk check in the prompt path ends such a request with its error rather than an overrun. --- data/settings-register.json | 357 ++++++++++++++++++++---------------- src/program/generate.cpp | 6 +- 2 files changed, 200 insertions(+), 163 deletions(-) diff --git a/data/settings-register.json b/data/settings-register.json index 1890c446c0..dae8d38c2f 100644 --- a/data/settings-register.json +++ b/data/settings-register.json @@ -169,7 +169,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13972, + "line": 13975, "backend": "cuda-hip", "fn": "a_env" } @@ -202,7 +202,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13971, + "line": 13974, "backend": "cuda-hip", "fn": "a_env" } @@ -271,13 +271,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13635, + "line": 13638, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21366, + "line": 21370, "backend": "cuda-hip", "fn": "getenv" } @@ -378,13 +378,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13462, + "line": 13465, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21355, + "line": 21359, "backend": "cuda-hip", "fn": "getenv" } @@ -419,13 +419,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13461, + "line": 13464, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21354, + "line": 21358, "backend": "cuda-hip", "fn": "getenv" } @@ -460,7 +460,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21356, + "line": 21360, "backend": "cuda-hip", "fn": "getenv" } @@ -658,7 +658,7 @@ }, { "file": "src/program/generate.cpp", - "line": 13560, + "line": 13563, "backend": "cuda-hip", "fn": "getenv" } @@ -697,13 +697,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13510, + "line": 13513, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 13511, + "line": 13514, "backend": "cuda-hip", "fn": "getenv" } @@ -736,7 +736,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13805, + "line": 13808, "backend": "cuda-hip", "fn": "getenv" } @@ -769,7 +769,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13970, + "line": 13973, "backend": "cuda-hip", "fn": "a_env" } @@ -802,7 +802,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13526, + "line": 13529, "backend": "cuda-hip", "fn": "getenv" } @@ -2046,7 +2046,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18051, + "line": 18055, "backend": "cuda-hip", "fn": "getenv" } @@ -2080,7 +2080,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17895, + "line": 17899, "backend": "cuda-hip", "fn": "getenv" }, @@ -2159,7 +2159,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14922, + "line": 14925, "backend": "cuda-hip", "fn": "getenv" } @@ -2192,7 +2192,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14924, + "line": 14927, "backend": "cuda-hip", "fn": "getenv" } @@ -2225,7 +2225,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14923, + "line": 14926, "backend": "cuda-hip", "fn": "getenv" } @@ -2552,7 +2552,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14943, + "line": 14946, "backend": "cuda-hip", "fn": "getenv" } @@ -2604,7 +2604,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18115, + "line": 18119, "backend": "cuda-hip", "fn": "getenv" } @@ -2791,7 +2791,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18656, + "line": 18660, "backend": "cuda-hip", "fn": "getenv" }, @@ -3064,13 +3064,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17338, + "line": 17341, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17471, + "line": 17474, "backend": "cuda-hip", "fn": "getenv" }, @@ -3206,7 +3206,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20731, + "line": 20735, "backend": "cuda-hip", "fn": "getenv" } @@ -4047,6 +4047,39 @@ "retire_after": "", "retired_in": "" }, + { + "name": "STRATA_DBG_TAIL_NOREUSE", + "backends": [ + "cuda-hip" + ], + "reads": [ + { + "file": "src/program/generate.cpp", + "line": 10174, + "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": [], + "first_commit": null, + "first_date": null, + "since": null, + "last_commit": null, + "last_date": null, + "status": "research", + "owner": "program", + "note": "[reviewed] a test of the backstop: a loan is reused by chunk alone, so a later short segment overruns the lent tail and Prefill::run_impl's chunk check ends the request with its error.", + "retire_after": "", + "retired_in": "" + }, { "name": "STRATA_DECODE_TIMING", "backends": [ @@ -4056,7 +4089,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18903, + "line": 18907, "backend": "cuda-hip", "fn": "getenv" }, @@ -4626,13 +4659,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20088, + "line": 20092, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20088, + "line": 20092, "backend": "cuda-hip", "fn": "getenv" } @@ -5554,7 +5587,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21718, + "line": 21722, "backend": "cuda-hip", "fn": "getenv" } @@ -6036,13 +6069,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14686, + "line": 14689, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14686, + "line": 14689, "backend": "cuda-hip", "fn": "getenv" } @@ -6075,7 +6108,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14685, + "line": 14688, "backend": "cuda-hip", "fn": "getenv" } @@ -6188,13 +6221,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19960, + "line": 19964, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21935, + "line": 21939, "backend": "cuda-hip", "fn": "getenv" }, @@ -7725,7 +7758,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18842, + "line": 18846, "backend": "cuda-hip", "fn": "getenv" }, @@ -7767,7 +7800,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18857, + "line": 18861, "backend": "cuda-hip", "fn": "getenv" }, @@ -8062,7 +8095,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18186, + "line": 18190, "backend": "cuda-hip", "fn": "env_on" } @@ -13566,7 +13599,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20731, + "line": 20735, "backend": "cuda-hip", "fn": "getenv" } @@ -14193,7 +14226,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11024, + "line": 11027, "backend": "cuda-hip", "fn": "getenv" } @@ -14985,7 +15018,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10491, + "line": 10494, "backend": "cuda-hip", "fn": "getenv" }, @@ -15024,7 +15057,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17312, + "line": 17315, "backend": "cuda-hip", "fn": "getenv" } @@ -15098,7 +15131,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10489, + "line": 10492, "backend": "cuda-hip", "fn": "getenv" }, @@ -15383,7 +15416,7 @@ }, { "file": "src/program/generate.cpp", - "line": 12632, + "line": 12635, "backend": "cuda-hip", "fn": "getenv" }, @@ -15929,19 +15962,19 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17626, + "line": 17629, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17666, + "line": 17669, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18702, + "line": 18706, "backend": "cuda-hip", "fn": "getenv" }, @@ -15997,7 +16030,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17670, + "line": 17673, "backend": "cuda-hip", "fn": "getenv" }, @@ -16202,13 +16235,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18875, + "line": 18879, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21832, + "line": 21836, "backend": "cuda-hip", "fn": "getenv" }, @@ -20581,13 +20614,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11523, + "line": 11526, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11532, + "line": 11535, "backend": "cuda-hip", "fn": "getenv" } @@ -22689,25 +22722,25 @@ }, { "file": "src/program/generate.cpp", - "line": 12567, + "line": 12570, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12571, + "line": 12574, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12577, + "line": 12580, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12920, + "line": 12923, "backend": "cuda-hip", "fn": "getenv" } @@ -23407,7 +23440,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13321, + "line": 13324, "backend": "cuda-hip", "fn": "getenv" } @@ -23589,7 +23622,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18619, + "line": 18623, "backend": "cuda-hip", "fn": "getenv" }, @@ -24079,7 +24112,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11302, + "line": 11305, "backend": "cuda-hip", "fn": "getenv" }, @@ -25270,7 +25303,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11741, + "line": 11744, "backend": "cuda-hip", "fn": "getenv" } @@ -25802,13 +25835,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11296, + "line": 11299, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11296, + "line": 11299, "backend": "cuda-hip", "fn": "getenv" } @@ -25841,7 +25874,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11311, + "line": 11314, "backend": "cuda-hip", "fn": "getenv" } @@ -26491,7 +26524,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18177, + "line": 18181, "backend": "cuda-hip", "fn": "getenv" } @@ -26528,7 +26561,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18203, + "line": 18207, "backend": "cuda-hip", "fn": "getenv" } @@ -26596,7 +26629,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18223, + "line": 18227, "backend": "cuda-hip", "fn": "getenv" } @@ -26629,7 +26662,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18441, + "line": 18445, "backend": "cuda-hip", "fn": "getenv" } @@ -26664,7 +26697,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18445, + "line": 18449, "backend": "cuda-hip", "fn": "getenv" } @@ -26744,7 +26777,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18437, + "line": 18441, "backend": "cuda-hip", "fn": "getenv" } @@ -26780,7 +26813,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10722, + "line": 10725, "backend": "cuda-hip", "fn": "getenv" } @@ -26814,7 +26847,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19217, + "line": 19221, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -26971,7 +27004,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19046, + "line": 19050, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27056,7 +27089,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17495, + "line": 17498, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27096,7 +27129,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18973, + "line": 18977, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27136,7 +27169,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19166, + "line": 19170, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27176,7 +27209,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19213, + "line": 19217, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27216,7 +27249,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 12352, + "line": 12355, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27255,7 +27288,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19373, + "line": 19377, "backend": "cuda-hip", "fn": "pipe_dbg_env" } @@ -27289,7 +27322,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17498, + "line": 17501, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27329,7 +27362,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17491, + "line": 17494, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27369,7 +27402,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19030, + "line": 19034, "backend": "cuda-hip", "fn": "pipe_dbg_env" }, @@ -27408,13 +27441,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10740, + "line": 10743, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 15765, + "line": 15768, "backend": "cuda-hip", "fn": "getenv" } @@ -28337,7 +28370,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11055, + "line": 11058, "backend": "cuda-hip", "fn": "getenv" } @@ -28378,13 +28411,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11134, + "line": 11137, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17915, + "line": 17919, "backend": "cuda-hip", "fn": "getenv" } @@ -28551,7 +28584,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10183, + "line": 10186, "backend": "cuda-hip", "fn": "getenv" }, @@ -28683,7 +28716,7 @@ }, { "file": "src/program/generate.cpp", - "line": 18184, + "line": 18188, "backend": "cuda-hip", "fn": "env_on" }, @@ -28728,7 +28761,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11088, + "line": 11091, "backend": "cuda-hip", "fn": "getenv" } @@ -28803,7 +28836,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10385, + "line": 10388, "backend": "cuda-hip", "fn": "getenv" } @@ -28888,7 +28921,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11303, + "line": 11306, "backend": "cuda-hip", "fn": "getenv" } @@ -28899,19 +28932,19 @@ "engine_sets": [ { "file": "src/program/generate.cpp", - "line": 11314 + "line": 11317 }, { "file": "src/program/generate.cpp", - "line": 11316 + "line": 11319 }, { "file": "src/program/generate.cpp", - "line": 11324 + "line": 11327 }, { "file": "src/program/generate.cpp", - "line": 11326 + "line": 11329 } ], "engine_defaults": [], @@ -28953,7 +28986,7 @@ }, { "file": "src/program/generate.cpp", - "line": 10212, + "line": 10215, "backend": "cuda-hip", "fn": "getenv" }, @@ -29359,7 +29392,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10401, + "line": 10404, "backend": "cuda-hip", "fn": "getenv" } @@ -29667,11 +29700,11 @@ "launch_sets": [], "launch_reads": [], "doc_mentions": [], - "first_commit": null, - "first_date": null, + "first_commit": "71f3c6db67", + "first_date": "2026-11-13", "since": null, - "last_commit": null, - "last_date": null, + "last_commit": "71f3c6db67", + "last_date": "2026-11-13", "status": "rollback", "owner": "program", "note": "[reviewed] \"STRATA_PREFILL_TAIL_LOAN=0 keeps the stream floor's tail\"; the lent fused MoE buffers are sized for the segment's own short last chunk, not for stream floor - 1 tokens (default on; one GPU).", @@ -30143,7 +30176,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11011, + "line": 11014, "backend": "cuda-hip", "fn": "getenv" } @@ -32247,7 +32280,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 19805, + "line": 19809, "backend": "cuda-hip", "fn": "getenv" } @@ -32286,7 +32319,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11106, + "line": 11109, "backend": "cuda-hip", "fn": "getenv" } @@ -32319,7 +32352,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11109, + "line": 11112, "backend": "cuda-hip", "fn": "getenv" } @@ -32352,7 +32385,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11110, + "line": 11113, "backend": "cuda-hip", "fn": "getenv" } @@ -32385,7 +32418,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11108, + "line": 11111, "backend": "cuda-hip", "fn": "getenv" } @@ -32451,7 +32484,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11111, + "line": 11114, "backend": "cuda-hip", "fn": "getenv" } @@ -32636,7 +32669,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17705, + "line": 17708, "backend": "cuda-hip", "fn": "getenv" } @@ -32673,7 +32706,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17746, + "line": 17749, "backend": "cuda-hip", "fn": "getenv" }, @@ -33375,13 +33408,13 @@ }, { "file": "src/program/generate.cpp", - "line": 11895, + "line": 11898, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11897, + "line": 11900, "backend": "cuda-hip", "fn": "getenv" } @@ -33416,13 +33449,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11896, + "line": 11899, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11896, + "line": 11899, "backend": "cuda-hip", "fn": "getenv" } @@ -33463,7 +33496,7 @@ }, { "file": "src/program/generate.cpp", - "line": 11899, + "line": 11902, "backend": "cuda-hip", "fn": "getenv" } @@ -33535,31 +33568,31 @@ }, { "file": "src/program/generate.cpp", - "line": 13347, + "line": 13350, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14593, + "line": 14596, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14593, + "line": 14596, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14594, + "line": 14597, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14595, + "line": 14598, "backend": "cuda-hip", "fn": "getenv" } @@ -34540,7 +34573,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18866, + "line": 18870, "backend": "cuda-hip", "fn": "getenv" } @@ -34573,7 +34606,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18869, + "line": 18873, "backend": "cuda-hip", "fn": "getenv" } @@ -35048,7 +35081,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14986, + "line": 14989, "backend": "cuda-hip", "fn": "getenv" } @@ -35404,7 +35437,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 17279, + "line": 17282, "backend": "cuda-hip", "fn": "getenv" }, @@ -35446,13 +35479,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13213, + "line": 13216, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 17252, + "line": 17255, "backend": "cuda-hip", "fn": "getenv" }, @@ -35610,13 +35643,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14688, + "line": 14691, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21586, + "line": 21590, "backend": "cuda-hip", "fn": "getenv" } @@ -35660,7 +35693,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21634, + "line": 21638, "backend": "cuda-hip", "fn": "getenv" } @@ -35730,7 +35763,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20781, + "line": 20785, "backend": "cuda-hip", "fn": "getenv" } @@ -36009,13 +36042,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18813, + "line": 18817, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21589, + "line": 21593, "backend": "cuda-hip", "fn": "getenv" } @@ -36048,7 +36081,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18814, + "line": 18818, "backend": "cuda-hip", "fn": "getenv" } @@ -36081,7 +36114,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21574, + "line": 21578, "backend": "cuda-hip", "fn": "getenv" } @@ -36114,7 +36147,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21676, + "line": 21680, "backend": "cuda-hip", "fn": "getenv" } @@ -36238,7 +36271,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10226, + "line": 10229, "backend": "cuda-hip", "fn": "getenv" } @@ -36531,13 +36564,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13177, + "line": 13180, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 18185, + "line": 18189, "backend": "cuda-hip", "fn": "env_on" } @@ -36613,7 +36646,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11980, + "line": 11983, "backend": "cuda-hip", "fn": "getenv" } @@ -36695,13 +36728,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10807, + "line": 10810, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11443, + "line": 11446, "backend": "cuda-hip", "fn": "getenv" }, @@ -36781,7 +36814,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10757, + "line": 10760, "backend": "cuda-hip", "fn": "getenv" }, @@ -36823,7 +36856,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11845, + "line": 11848, "backend": "cuda-hip", "fn": "getenv" }, @@ -36863,7 +36896,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11843, + "line": 11846, "backend": "cuda-hip", "fn": "getenv" }, @@ -36936,7 +36969,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20752, + "line": 20756, "backend": "cuda-hip", "fn": "getenv" }, @@ -37160,7 +37193,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 22366, + "line": 22370, "backend": "hip", "fn": "getenv" } @@ -37602,7 +37635,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 20339, + "line": 20343, "backend": "cuda-hip", "fn": "getenv" }, @@ -37683,7 +37716,7 @@ }, { "file": "src/program/generate.cpp", - "line": 20377, + "line": 20381, "backend": "cuda-hip", "fn": "getenv" }, @@ -37836,7 +37869,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 13359, + "line": 13362, "backend": "cuda-hip", "fn": "getenv" } @@ -37937,7 +37970,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18310, + "line": 18314, "backend": "cuda-hip", "fn": "getenv" } @@ -38057,7 +38090,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 18227, + "line": 18231, "backend": "cuda-hip", "fn": "getenv" } @@ -39055,25 +39088,25 @@ }, { "file": "src/program/generate.cpp", - "line": 11001, + "line": 11004, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 12994, + "line": 12997, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 14432, + "line": 14435, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 20922, + "line": 20926, "backend": "cuda-hip", "fn": "getenv" }, @@ -39129,13 +39162,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 21431, + "line": 21435, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 21468, + "line": 21472, "backend": "cuda-hip", "fn": "getenv" }, @@ -39286,13 +39319,13 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 11630, + "line": 11633, "backend": "cuda", "fn": "getenv" }, { "file": "src/program/generate.cpp", - "line": 11648, + "line": 11651, "backend": "cuda", "fn": "getenv" } @@ -39367,7 +39400,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 10867, + "line": 10870, "backend": "hip", "fn": "getenv" } @@ -40725,7 +40758,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14610, + "line": 14613, "backend": "cuda-hip", "fn": "getenv" } @@ -40759,7 +40792,7 @@ "reads": [ { "file": "src/program/generate.cpp", - "line": 14606, + "line": 14609, "backend": "cuda-hip", "fn": "getenv" }, diff --git a/src/program/generate.cpp b/src/program/generate.cpp index 76cbe03a51..a76674f3b7 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -10169,6 +10169,9 @@ int main(int argc, char** argv) { // against 1,024 costs ~92 expert slots on an RTX A6000, streamed again by every chunk above the floor). One GPU, no peer, no // --batch above one slot, no head alias; a layer split keeps the floor's tail. STRATA_PREFILL_TAIL_LOAN=0 keeps today's size. static const bool tail_loan_on = [] { const char* e = std::getenv("STRATA_PREFILL_TAIL_LOAN"); return !(e != nullptr && e[0] == '0'); }(); + // STRATA_DBG_TAIL_NOREUSE=1 (a test of the backstop): a loan is reused by chunk alone, as before the tail rule - a later short segment then + // overruns the tail and the chunk check in Prefill::run_impl must end the request with its error + static const bool dbg_tail_noreuse = [] { const char* e = std::getenv("STRATA_DBG_TAIL_NOREUSE"); return e != nullptr && e[0] == '1'; }(); auto loan_chunk = [&](int64_t tokens, int64_t chunk) -> int64_t { return loan_by_walk ? strata::prefill::loan_rules::walk_chunk(tokens, chunk, strata::prefill::Prefill::stream_all_min_tokens()) : chunk; @@ -17799,7 +17802,8 @@ int main(int argc, char** argv) { if (!p.lent.empty()) { // its current loan already covers this: the chunk, and (a fused layout) the tail the segment's last // chunk needs when it is read in the loan's own chunks - if (tail_ok ? lr::reuse_ok(want, tokens, p.lent_chunk, p.sp->tail_room(), floor_t) : want <= p.lent_chunk) continue; + if (tail_ok && !dbg_tail_noreuse ? lr::reuse_ok(want, tokens, p.lent_chunk, p.sp->tail_room(), floor_t) + : want <= p.lent_chunk) continue; // ONLY this participant's loan goes back: `refill` would return the other participants' // loans too, and their buffers are still laid out in their caches - marking those slots // resident again would hand the next window a prompt buffer in place of an expert From 216af487d70bd6de53a0939179474dfb9f5cfe7b Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 13 Nov 2026 10:33:32 +0100 Subject: [PATCH 9/9] Turn the per-card prompt switch rule on by default for NVIDIA sm_86 cards The prompt path now picks, per card, the chunk size from which every expert the card does not hold is streamed (the floor), and sets the CPU share's limit to 1.6 times it. It is on with nothing set for one class of card: CUDA, NVIDIA discrete on PCIe, a single GPU, the start-up link probe ran, compute capability 8.6. Every other card keeps the fixed 1,024 floor and the fixed share limit. STRATA_SWITCH_POINT=0 turns it off; STRATA_SWITCH_POINT=1 asks for it on any other CUDA card. An explicit STRATA_PREFILL_STREAM_MIN or STRATA_PREFILL_CPU_SHARE_MAX still wins over the rule. On an RTX A6000 (UD-Q4_K_XL) the floor is 3,584 and the limit 5,632 against 1,024 and 3,072. With the tail-sized loan in the same build the rule equals the old default above its limit. The start-up line no longer calls the rule an opt-in and is printed only when the floor moved. The rule's unit test covers the class (and every compute capability, multi-GPU, no probe, integrated and HIP outside it) and the variable. The settings register entry becomes a rollback switch. --- CMakeLists.txt | 2 +- data/settings-register.json | 264 +++++++++---------- docs/SETTINGS.md | 3 +- include/strata/prefill/prefill.hpp | 4 +- include/strata/prefill/switch_point_rule.hpp | 29 +- src/prefill/prefill.cpp | 49 +++- src/program/generate.cpp | 4 +- tests/prefill/switch_point_rule_test.cpp | 39 +++ 8 files changed, 244 insertions(+), 150 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b77058c274..207cdb7219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -424,7 +424,7 @@ if(STRATA_BUILD_TESTS) target_include_directories(staged_fo_rule_test PRIVATE include) add_test(NAME staged_fo_rule_test COMMAND staged_fo_rule_test) - # STRATA_SWITCH_POINT (research): the floor from the card's share of non-resident experts, a cost estimate of the staged and the streamed walk (header-only, no GPU) + # STRATA_SWITCH_POINT (on by default for NVIDIA sm_86, one GPU): the floor from the card's share of non-resident experts, a cost estimate of the staged and the streamed walk (header-only, no GPU) add_executable(switch_point_rule_test tests/prefill/switch_point_rule_test.cpp) target_include_directories(switch_point_rule_test PRIVATE include) add_test(NAME switch_point_rule_test COMMAND switch_point_rule_test) diff --git a/data/settings-register.json b/data/settings-register.json index d751a63997..234a81bb3b 100644 --- a/data/settings-register.json +++ b/data/settings-register.json @@ -1910,7 +1910,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 933, + "line": 956, "backend": "cuda-hip", "fn": "getenv" } @@ -3242,7 +3242,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3341, + "line": 3368, "backend": "cuda-hip", "fn": "getenv" } @@ -3602,7 +3602,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 786, + "line": 809, "backend": "cuda-hip", "fn": "getenv" }, @@ -3666,7 +3666,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6623, + "line": 6650, "backend": "cuda-hip", "fn": "getenv" }, @@ -3705,7 +3705,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5294, + "line": 5321, "backend": "cuda-hip", "fn": "getenv" } @@ -3771,13 +3771,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4950, + "line": 4977, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7096, + "line": 7123, "backend": "cuda-hip", "fn": "getenv" } @@ -3810,7 +3810,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4956, + "line": 4983, "backend": "cuda-hip", "fn": "getenv" } @@ -3844,7 +3844,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5075, + "line": 5102, "backend": "cuda-hip", "fn": "getenv" }, @@ -3938,19 +3938,19 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 5655, + "line": 5682, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6576, + "line": 6603, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6800, + "line": 6827, "backend": "cuda-hip", "fn": "getenv" }, @@ -4010,19 +4010,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4951, + "line": 4978, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4966, + "line": 4993, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7096, + "line": 7123, "backend": "cuda-hip", "fn": "getenv" } @@ -6148,7 +6148,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 2604, + "line": 2627, "backend": "cuda-hip", "fn": "getenv" }, @@ -6268,7 +6268,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5452, + "line": 5479, "backend": "cuda-hip", "fn": "getenv" } @@ -6304,13 +6304,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5454, + "line": 5481, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 5454, + "line": 5481, "backend": "cuda-hip", "fn": "getenv" } @@ -6484,7 +6484,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 585, + "line": 608, "backend": "cuda-hip", "fn": "getenv" } @@ -7376,13 +7376,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2261, + "line": 2284, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6862, + "line": 6889, "backend": "cuda-hip", "fn": "getenv" } @@ -9834,7 +9834,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 614, + "line": 637, "backend": "hip", "fn": "getenv" } @@ -10160,7 +10160,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2184, + "line": 2207, "backend": "cuda-hip", "fn": "getenv" }, @@ -10818,7 +10818,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 812, + "line": 835, "backend": "cuda-hip", "fn": "getenv" }, @@ -11216,7 +11216,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 664, + "line": 687, "backend": "cuda-hip", "fn": "getenv" } @@ -11251,7 +11251,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 681, + "line": 704, "backend": "cuda-hip", "fn": "getenv" } @@ -11285,7 +11285,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 768, + "line": 791, "backend": "cuda-hip", "fn": "getenv" }, @@ -11699,7 +11699,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 741, + "line": 764, "backend": "cuda-hip", "fn": "getenv" }, @@ -11771,7 +11771,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4489, + "line": 4516, "backend": "cuda-hip", "fn": "getenv" }, @@ -12811,7 +12811,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4822, + "line": 4849, "backend": "cuda-hip", "fn": "getenv" }, @@ -12960,13 +12960,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4687, + "line": 4714, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8228, + "line": 8255, "backend": "cuda-hip", "fn": "getenv" }, @@ -14590,7 +14590,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4544, + "line": 4571, "backend": "cuda-hip", "fn": "getenv" } @@ -15171,13 +15171,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4629, + "line": 4656, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8175, + "line": 8202, "backend": "hip", "fn": "getenv" }, @@ -15295,7 +15295,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3651, + "line": 3678, "backend": "cuda-hip", "fn": "getenv" }, @@ -15466,7 +15466,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1496, + "line": 1519, "backend": "cuda-hip", "fn": "getenv" }, @@ -15851,7 +15851,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7063, + "line": 7090, "backend": "hip", "fn": "getenv" } @@ -15884,7 +15884,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7459, + "line": 7486, "backend": "cuda-hip", "fn": "getenv" } @@ -18852,7 +18852,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 8505, + "line": 8532, "backend": "cuda-hip", "fn": "getenv" } @@ -20115,7 +20115,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2526, + "line": 2549, "backend": "cuda-hip", "fn": "getenv" }, @@ -20155,7 +20155,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2570, + "line": 2593, "backend": "cuda-hip", "fn": "getenv" }, @@ -20195,7 +20195,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2531, + "line": 2554, "backend": "cuda-hip", "fn": "getenv" }, @@ -23669,7 +23669,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 821, + "line": 844, "backend": "cuda-hip", "fn": "getenv" } @@ -23702,7 +23702,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 5123, + "line": 5150, "backend": "cuda-hip", "fn": "getenv" } @@ -23771,7 +23771,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 737, + "line": 760, "backend": "cuda-hip", "fn": "getenv" } @@ -23956,7 +23956,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6165, + "line": 6192, "backend": "cuda-hip", "fn": "getenv" } @@ -24897,7 +24897,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 794, + "line": 817, "backend": "cuda-hip", "fn": "getenv" }, @@ -24974,7 +24974,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1903, + "line": 1926, "backend": "cuda-hip", "fn": "getenv" } @@ -25007,7 +25007,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1883, + "line": 1906, "backend": "cuda-hip", "fn": "getenv" } @@ -25076,7 +25076,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 760, + "line": 783, "backend": "cuda-hip", "fn": "getenv" }, @@ -25115,7 +25115,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1919, + "line": 1942, "backend": "cuda-hip", "fn": "getenv" } @@ -25377,7 +25377,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 794, + "line": 817, "backend": "cuda-hip", "fn": "getenv" }, @@ -25445,7 +25445,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2908, + "line": 2931, "backend": "cuda-hip", "fn": "getenv" }, @@ -25484,7 +25484,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 482, + "line": 505, "backend": "cuda-hip", "fn": "getenv" } @@ -25517,7 +25517,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2953, + "line": 2976, "backend": "cuda-hip", "fn": "getenv" } @@ -25550,7 +25550,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2956, + "line": 2979, "backend": "cuda-hip", "fn": "getenv" } @@ -25583,7 +25583,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2851, + "line": 2874, "backend": "cuda-hip", "fn": "getenv" } @@ -25617,7 +25617,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2892, + "line": 2915, "backend": "cuda-hip", "fn": "getenv" }, @@ -25657,7 +25657,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2926, + "line": 2949, "backend": "cuda-hip", "fn": "getenv" }, @@ -25697,7 +25697,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2922, + "line": 2945, "backend": "cuda-hip", "fn": "getenv" }, @@ -25736,7 +25736,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2949, + "line": 2972, "backend": "cuda-hip", "fn": "getenv" } @@ -25769,7 +25769,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2877, + "line": 2900, "backend": "cuda-hip", "fn": "getenv" } @@ -25943,7 +25943,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4339, + "line": 4366, "backend": "cuda-hip", "fn": "getenv" }, @@ -26004,7 +26004,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 732, + "line": 755, "backend": "cuda-hip", "fn": "getenv" }, @@ -26139,7 +26139,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1695, + "line": 1718, "backend": "cuda-hip", "fn": "getenv" } @@ -28212,7 +28212,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 648, + "line": 671, "backend": "cuda-hip", "fn": "getenv" }, @@ -28294,7 +28294,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4144, + "line": 4171, "backend": "cuda-hip", "fn": "getenv" } @@ -28329,7 +28329,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4148, + "line": 4175, "backend": "cuda-hip", "fn": "getenv" } @@ -28364,7 +28364,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 463, + "line": 486, "backend": "cuda-hip", "fn": "getenv" }, @@ -28450,13 +28450,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 491, + "line": 514, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 494, + "line": 517, "backend": "cuda-hip", "fn": "getenv" } @@ -28492,13 +28492,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6742, + "line": 6769, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7987, + "line": 8014, "backend": "cuda-hip", "fn": "getenv" }, @@ -28538,13 +28538,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6755, + "line": 6782, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 7096, + "line": 7123, "backend": "cuda-hip", "fn": "getenv" }, @@ -28668,7 +28668,7 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 6011, + "line": 6038, "backend": "cuda-hip", "fn": "getenv" }, @@ -28710,7 +28710,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2702, + "line": 2725, "backend": "cuda-hip", "fn": "getenv" }, @@ -28795,7 +28795,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2714, + "line": 2737, "backend": "cuda-hip", "fn": "getenv" }, @@ -28874,7 +28874,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4140, + "line": 4167, "backend": "cuda-hip", "fn": "getenv" }, @@ -28915,7 +28915,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6976, + "line": 7003, "backend": "cuda-hip", "fn": "getenv" }, @@ -29025,7 +29025,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6987, + "line": 7014, "backend": "cuda-hip", "fn": "getenv" } @@ -29058,7 +29058,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6982, + "line": 7009, "backend": "cuda-hip", "fn": "getenv" } @@ -29091,7 +29091,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 7008, + "line": 7035, "backend": "cuda-hip", "fn": "getenv" } @@ -29124,7 +29124,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6997, + "line": 7024, "backend": "cuda-hip", "fn": "getenv" } @@ -29157,7 +29157,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6992, + "line": 7019, "backend": "cuda-hip", "fn": "getenv" } @@ -29230,13 +29230,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 1750, + "line": 1773, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6165, + "line": 6192, "backend": "cuda-hip", "fn": "getenv" }, @@ -29357,7 +29357,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3085, + "line": 3112, "backend": "cuda-hip", "fn": "getenv" } @@ -29426,7 +29426,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 599, + "line": 622, "backend": "cuda-hip", "fn": "getenv" }, @@ -29469,7 +29469,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4159, + "line": 4186, "backend": "cuda-hip", "fn": "getenv" } @@ -29504,7 +29504,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4160, + "line": 4187, "backend": "cuda-hip", "fn": "getenv" } @@ -29608,7 +29608,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 438, + "line": 461, "backend": "cuda-hip", "fn": "getenv" }, @@ -29720,13 +29720,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3407, + "line": 3434, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 3448, + "line": 3475, "backend": "cuda-hip", "fn": "getenv" }, @@ -29775,19 +29775,19 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 1988, + "line": 2011, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2002, + "line": 2025, "backend": "hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2167, + "line": 2190, "backend": "cuda-hip", "fn": "getenv" } @@ -29968,13 +29968,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4898, + "line": 4925, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8259, + "line": 8286, "backend": "cuda-hip", "fn": "getenv" }, @@ -31693,7 +31693,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4870, + "line": 4897, "backend": "cuda-hip", "fn": "getenv" }, @@ -31733,13 +31733,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4871, + "line": 4898, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4872, + "line": 4899, "backend": "cuda-hip", "fn": "getenv" }, @@ -31784,13 +31784,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4873, + "line": 4900, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 4873, + "line": 4900, "backend": "cuda-hip", "fn": "getenv" } @@ -31823,7 +31823,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4882, + "line": 4909, "backend": "cuda-hip", "fn": "getenv" } @@ -31914,7 +31914,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 778, + "line": 801, "backend": "cuda-hip", "fn": "getenv" } @@ -31947,7 +31947,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 782, + "line": 805, "backend": "cuda-hip", "fn": "getenv" } @@ -32984,7 +32984,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 589, + "line": 612, "backend": "cuda-hip", "fn": "getenv" }, @@ -34193,13 +34193,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4736, + "line": 4763, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8247, + "line": 8274, "backend": "cuda-hip", "fn": "getenv" }, @@ -34308,13 +34308,13 @@ }, { "file": "src/prefill/prefill.cpp", - "line": 8431, + "line": 8458, "backend": "metal", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 8473, + "line": 8500, "backend": "cuda-hip", "fn": "getenv" }, @@ -34534,7 +34534,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 4800, + "line": 4827, "backend": "cuda-hip", "fn": "getenv" }, @@ -37228,7 +37228,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2158, + "line": 2181, "backend": "cuda-hip", "fn": "getenv" } @@ -37262,13 +37262,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 912, + "line": 935, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 2154, + "line": 2177, "backend": "cuda-hip", "fn": "getenv" }, @@ -37351,7 +37351,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2146, + "line": 2169, "backend": "cuda-hip", "fn": "getenv" } @@ -37387,7 +37387,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2134, + "line": 2157, "backend": "cuda-hip", "fn": "getenv" }, @@ -37710,7 +37710,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 6939, + "line": 6966, "backend": "cuda-hip", "fn": "getenv" }, @@ -37761,13 +37761,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 399, + "line": 404, "backend": "cuda-hip", "fn": "getenv" } ], "parse": "flag", - "default_state": "off", + "default_state": null, "code_default": null, "engine_sets": [], "engine_defaults": [], @@ -37775,14 +37775,14 @@ "launch_sets": [], "launch_reads": [], "doc_mentions": [], - "first_commit": null, - "first_date": null, + "first_commit": "e84392acc0", + "first_date": "2026-11-13", "since": null, - "last_commit": null, - "last_date": null, - "status": "research", + "last_commit": "9e59a89cc0", + "last_date": "2026-11-13", + "status": "rollback", "owner": "prefill", - "note": "research switch (default off, CUDA builds): the chunk size from which a prompt chunk streams every expert the card does not hold comes from a cost estimate of the staged and the streamed walk (include/strata/prefill/switch_point_rule.hpp) instead of 1,024; a card holding every expert keeps 1,024. STRATA_PREFILL_STREAM_MIN and the CPU share's limit keep precedence.", + "note": "Default: on for one class of card, off for every other (CUDA builds only; HIP never): NVIDIA discrete on PCIe, one GPU, link probe ran, compute capability 8.6 (RTX A6000 / A4000 class). Values: 0 = off, 1 = on for any CUDA card (not measured outside the class). STRATA_SWITCH_POINT=0 keeps the fixed 1,024-token floor and the fixed 3,072 CPU-share limit; =1 asks for the rule on any other CUDA card (not measured there). The chunk size from which a prompt chunk streams every expert the card does not hold comes from a cost estimate of the staged and the streamed walk (include/strata/prefill/switch_point_rule.hpp), and the CPU share's limit is 1.6 times it; a card holding every expert keeps 1,024. STRATA_PREFILL_STREAM_MIN and STRATA_PREFILL_CPU_SHARE_MAX keep precedence.", "retire_after": "", "retired_in": "" }, @@ -39097,13 +39097,13 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 3777, + "line": 3804, "backend": "cuda-hip", "fn": "getenv" }, { "file": "src/prefill/prefill.cpp", - "line": 6679, + "line": 6706, "backend": "cuda-hip", "fn": "getenv" }, @@ -41068,7 +41068,7 @@ "reads": [ { "file": "src/prefill/prefill.cpp", - "line": 2265, + "line": 2288, "backend": "cuda-hip", "fn": "getenv" } diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index 9513f7bc23..9e71aaf55d 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -289,7 +289,7 @@ Off unless you set them. The last column says where each one is described. | `STRATA_WDDM_BUDGET` | number | AMD, Intel Arc | [AMD_HIP.md](AMD_HIP.md) | | `STRATA_WS_FAST` | number | NVIDIA and AMD | [OLDER_GPUS.md](OLDER_GPUS.md) | -## Switches that go back to earlier behaviour (68) +## Switches that go back to earlier behaviour (69) These behaviours are on by default. Setting the switch returns the earlier behaviour; the notes in the register say which version made it the default. @@ -356,6 +356,7 @@ version made it the default. | `STRATA_SM60_TABLE` | number | NVIDIA and AMD | v0.1.43 | [OLDER_GPUS.md](OLDER_GPUS.md) | | `STRATA_SPLIT_CHUNK16K` | number | NVIDIA and AMD | v0.1.44 | [MULTI_GPU.md](MULTI_GPU.md) | | `STRATA_SPLIT_OWN` | on / off | NVIDIA and AMD, Intel Arc | v0.1.40.1 | [MULTI_GPU.md](MULTI_GPU.md) | +| `STRATA_SWITCH_POINT` | on / off | NVIDIA and AMD | - | - | | `STRATA_SYCL_BF16_DET` | number | Intel Arc | v0.2.13 | - | | `STRATA_TOPK_SAMPLE` | number | NVIDIA and AMD | v0.1.45 | [DETAILS.md](DETAILS.md) | | `STRATA_TOPK_SPLIT` | number | NVIDIA and AMD | v0.1.45 | [DETAILS.md](DETAILS.md) | diff --git a/include/strata/prefill/prefill.hpp b/include/strata/prefill/prefill.hpp index a483cd333e..dfcadaad04 100644 --- a/include/strata/prefill/prefill.hpp +++ b/include/strata/prefill/prefill.hpp @@ -108,8 +108,8 @@ public: /// (staged_fo_rule.hpp: Windows gfx1151, every layer without an MMQ tile and on the fused kernels, entry on), the measured crossing of the verify windows and that entry. /// A `--short-read` given on the command line is not asked. Call once the expert layout is known. static int64_t short_read_default(int64_t base); - /// STRATA_SWITCH_POINT=1 (research): the expert cache's live slots and layers x experts of the single card's own model, before the first lend; the floor above is then - /// chosen from the share of experts the card does not hold, scaled by the cache's mean blob (MB), the start-up link probe (GB/s) and the card's SM count (switch_point_rule.hpp; 0 = unknown: the default floor). Without the switch this changes nothing. + /// STRATA_SWITCH_POINT (on by default for the class in switch_point_rule.hpp, =0 off): the expert cache's live slots and layers x experts of the single card's own model, before the first lend; the floor above is then + /// chosen from the share of experts the card does not hold, scaled by the cache's mean blob (MB), the start-up link probe (GB/s) and the card's SM count (switch_point_rule.hpp; 0 = unknown: the default floor). With STRATA_SWITCH_POINT=0 this changes nothing. static void set_card_expert_share(int64_t resident_slots, int64_t total_pairs, double blob_mb = 0.0, double link_gbps = 0.0); /// --prefill-pipe (opt-in): the chunk a layer split's first stage reads an `n`-token prompt in, for `stages` /// stages, chunks of at most `cap` (the buffers' size) and a stage-chunk cost of b + a C with b/a = `ratio` tokens diff --git a/include/strata/prefill/switch_point_rule.hpp b/include/strata/prefill/switch_point_rule.hpp index 013e9c9335..f62cd394aa 100644 --- a/include/strata/prefill/switch_point_rule.hpp +++ b/include/strata/prefill/switch_point_rule.hpp @@ -1,6 +1,8 @@ // include/strata/prefill/switch_point_rule.hpp - the chunk size below which a prompt chunk takes the STAGED walk and from which it takes the STREAMED walk // (src/prefill/prefill.cpp stream_all_min()), chosen by estimated cost from the card's share of non-resident experts instead of the fixed 1,024. -// Research switch STRATA_SWITCH_POINT=1, default off. Pure: no GPU, no environment read here. +// ON BY DEFAULT for one class of card (enabled() below): CUDA, NVIDIA discrete card on PCIe, one GPU, the start-up link probe ran, compute capability 8.6 (RTX A6000 and +// RTX A4000 measured). STRATA_SWITCH_POINT=0 is the way back; STRATA_SWITCH_POINT=1 asks for the rule on any other CUDA card (not measured there). +// Pure: no GPU, no environment read here. // // The two walks (prefill.cpp): // streamed: every expert the card does not hold is copied through a ring in layer order, whatever the chunk routes; the copy runs through the attention @@ -94,4 +96,29 @@ inline int64_t share_limit_for(int64_t floor) { return std::min(2 * kFloorMax, ((int64_t) ((double) floor * kShareRatio) / kGrid) * kGrid); } +// ---- the class the rule is on for by default ---- +// The device facts the engine reads once the card's expert cache is built (src/prefill/prefill.cpp, Prefill::set_card_expert_share). +struct DeviceClass { + bool cuda = false; // a CUDA build (HIP builds: never) + bool discrete = false; // a discrete card, not an integrated / shared-memory GPU + bool single_gpu = false; // the engine runs on one card: no layer split, no second card + bool link_probed = false; // the start-up host-to-device probe ran and gave a rate (the PCIe cost the rule scales with) + int cc_major = 0, cc_minor = 0; // compute capability +}; +/// Measured: RTX A6000 (Boston) and RTX A4000 (z440), both 8.6. Every other compute capability (6.0, 7.0, 7.5, 8.0, 8.9, 12.0, 12.1) is outside the class until it is measured. +inline constexpr int kClassCcMajor = 8, kClassCcMinor = 6; +inline bool in_default_class(const DeviceClass& d) { + return d.cuda && d.discrete && d.single_gpu && d.link_probed && d.cc_major == kClassCcMajor && d.cc_minor == kClassCcMinor; +} +/// STRATA_SWITCH_POINT as the engine reads it: -1 unset (or empty), 1 for exactly "1", 0 for any other value. +inline int env_state(const char* v) { + if (v == nullptr || v[0] == '\0') return -1; + return (v[0] == '1' && v[1] == '\0') ? 1 : 0; +} +/// Whether the rule runs: HIP never; STRATA_SWITCH_POINT=0 (or any value but 1) never; =1 on every CUDA card; unset: the class above. +inline bool enabled(const DeviceClass& d, int env) { + if (!d.cuda || env == 0) return false; + return env == 1 || in_default_class(d); +} + } // namespace strata::prefill::switch_point diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp index eb7f344133..bc28883d07 100644 --- a/src/prefill/prefill.cpp +++ b/src/prefill/prefill.cpp @@ -390,19 +390,38 @@ inline bool staged_fo_on() { cached.store(v ? 1 : 0, std::memory_order_release); return v; } -// STRATA_SWITCH_POINT=1 (research, default off; CUDA builds only): the floor of a card that streams part of the experts comes from switch_point_rule.hpp's cost estimate. +// STRATA_SWITCH_POINT (CUDA builds only): the floor of a card that streams part of the experts comes from switch_point_rule.hpp's cost estimate. ON BY DEFAULT for the class +// in_default_class() names (NVIDIA discrete card on PCIe, one GPU, link probe ran, compute capability 8.6); STRATA_SWITCH_POINT=0 is the way back, =1 asks for it on any other CUDA card. // The card's counts arrive from Prefill::set_card_expert_share (the cache's slots and layers x experts, known before the first lend); until then the default answers. +std::atomic g_sp_resident{-1}, g_sp_total{0}; +double g_sp_blob_mb = 0.0, g_sp_link_gbps = 0.0; // the cache's mean blob (MB) and the start-up probe (GB/s), from Prefill::set_card_expert_share +int g_sp_sm = 0; // the card's multiprocessor count +int g_sp_cc_major = 0, g_sp_cc_minor = 0; // the card's compute capability +bool g_sp_integrated = true; // not known as discrete until the card answered +// STRATA_SWITCH_POINT as set: -1 unset, 1 for "1", 0 for any other value (the way back) +inline int switch_point_env() { + static const int e = [] { + const char* v = std::getenv("STRATA_SWITCH_POINT"); + return v != nullptr && v[0] != '\0' ? strata::prefill::switch_point::env_state(v) : -1; + }(); + return e; +} +// the card's counts have arrived (set_card_expert_share ran: a single card, no batch slots) +inline bool switch_point_known() { return g_sp_resident.load(std::memory_order_acquire) >= 0; } inline bool switch_point_on() { #if defined(STRATA_USE_HIP) || defined(__HIPCC__) || defined(STRATA_HIP_GFX906) return false; // measured on CUDA only #else - static const bool on = [] { const char* e = std::getenv("STRATA_SWITCH_POINT"); return e != nullptr && e[0] == '1' && e[1] == '\0'; }(); - return on; + if (!switch_point_known()) return false; + strata::prefill::switch_point::DeviceClass d; + d.cuda = true; + d.discrete = !g_sp_integrated; + d.single_gpu = true; // set_card_expert_share is called from the single-card, no-batch paths only + d.link_probed = g_sp_link_gbps > 0.0; + d.cc_major = g_sp_cc_major; d.cc_minor = g_sp_cc_minor; + return strata::prefill::switch_point::enabled(d, switch_point_env()); #endif } -std::atomic g_sp_resident{-1}, g_sp_total{0}; -double g_sp_blob_mb = 0.0, g_sp_link_gbps = 0.0; // the cache's mean blob (MB) and the start-up probe (GB/s), from Prefill::set_card_expert_share -int g_sp_sm = 0; // the card's multiprocessor count // the card as the rule scales it; a field not set gives card_known() == false and the default floor inline strata::prefill::switch_point::Card sp_card() { strata::prefill::switch_point::Card c; @@ -418,14 +437,18 @@ inline int64_t default_stream_floor() { if (!lay.native || lay.fmt.empty()) return strata::prefill::kStreamFloorDefault; const bool cls = stream_floor_class_measured(); int64_t v = strata::prefill::stream_floor_default(cls, cls && layers_all_fused_only(), staged_fo_on()); +#if !defined(STRATA_USE_HIP) && !defined(__HIPCC__) && !defined(STRATA_HIP_GFX906) + // the card's counts are not known yet (set_card_expert_share has not run) and the rule is not switched off: the default, not cached + if (v == strata::prefill::kStreamFloorDefault && switch_point_env() != 0 && !switch_point_known()) return v; +#endif if (v == strata::prefill::kStreamFloorDefault && switch_point_on()) { const int64_t res = g_sp_resident.load(std::memory_order_acquire), tot = g_sp_total.load(std::memory_order_acquire); - if (res < 0) return v; // the card's counts are not known yet: the default, not cached const auto card = sp_card(); if (!strata::prefill::switch_point::card_known(card)) return v; // the link or the card is not known: the default, not cached v = strata::prefill::switch_point::floor_for_card(res, tot, card); - std::fprintf(stderr, "prefill: STRATA_SWITCH_POINT=1: prompt chunks of %lld tokens or more stream every expert the card does not hold (%lld of %lld experts resident; %.2f MB experts, %.1f GB/s link, %d SMs); a shorter chunk stages only the routed ones\n", - (long long) v, (long long) res, (long long) tot, card.blob_mb, card.link_gbps, card.sm); + if (v != strata::prefill::kStreamFloorDefault) + std::fprintf(stderr, "prefill: prompt chunks of %lld tokens or more stream every expert the card does not hold (%lld of %lld experts resident; %.2f MB experts, %.1f GB/s link, %d SMs); a shorter chunk stages only the routed ones. STRATA_SWITCH_POINT=0 keeps the fixed 1,024.\n", + (long long) v, (long long) res, (long long) tot, card.blob_mb, card.link_gbps, card.sm); cached.store(v, std::memory_order_release); return v; } @@ -3050,7 +3073,11 @@ void Prefill::set_card_expert_share(int64_t resident_slots, int64_t total_pairs, #if !defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) int dev = 0; cudaDeviceProp prop; - g_sp_sm = (cudaGetDevice(&dev) == cudaSuccess && cudaGetDeviceProperties(&prop, dev) == cudaSuccess) ? prop.multiProcessorCount : 0; + const bool got = cudaGetDevice(&dev) == cudaSuccess && cudaGetDeviceProperties(&prop, dev) == cudaSuccess; + g_sp_sm = got ? prop.multiProcessorCount : 0; + g_sp_cc_major = got ? prop.major : 0; + g_sp_cc_minor = got ? prop.minor : 0; + g_sp_integrated = got ? prop.integrated != 0 : true; #endif g_sp_blob_mb = blob_mb; g_sp_link_gbps = link_gbps; @@ -3263,7 +3290,7 @@ void Prefill::arm_cpu_share(bool applies, bool by_default) { if (applies && by_default && cpu_share_explicit() == -2.0 && !g_share_default) { g_share_default = true; if (switch_point_on() && g_sp_resident.load(std::memory_order_acquire) >= 0 && strata::prefill::switch_point::card_known(sp_card())) { - // STRATA_SWITCH_POINT=1 (research): the share's limit scales with the card's own floor (floor x kShareRatio), not the fixed 3,072 + // STRATA_SWITCH_POINT (on by default for its class, 0 = off): the share's limit scales with the card's own floor (floor x kShareRatio), not the fixed 3,072 const int64_t lim = strata::prefill::switch_point::share_limit_for(strata::prefill::switch_point::floor_for_card( g_sp_resident.load(std::memory_order_acquire), g_sp_total.load(std::memory_order_acquire), sp_card())); if (lim > 0) g_share_limit_arch = lim; diff --git a/src/program/generate.cpp b/src/program/generate.cpp index a97aa19cf6..0d43f65a47 100644 --- a/src/program/generate.cpp +++ b/src/program/generate.cpp @@ -11146,7 +11146,7 @@ int main(int argc, char** argv) { "nothing to take, so it is not armed by default (STRATA_PREFILL_CPU_SHARE=auto forces it)\n", (long long) xcache.slots(), (long long) (g.n_layers * g.n_expert)); if (share_pool && stages.empty() && !multi_gpu && share_has_work && !share_default_ok()) share_has_work = false; // H11 - if (stages.empty() && !multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): one card, no batch slots; before any bytes_needed, like the share + if (stages.empty() && !multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT: one card, no batch slots; before any bytes_needed, like the share strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert), xcache.slots() > 0 ? (double) xcache.bytes() / (double) xcache.slots() / 1e6 : 0.0, o.pcie_probe_gbps); strata::prefill::Prefill::arm_cpu_share(share_pool, share_pool && stages.empty() && !multi_gpu && share_has_work); void* borrow = nullptr; @@ -20829,7 +20829,7 @@ int main(int argc, char** argv) { int64_t pos_start = 0; int64_t spec_pos = strata::spec::kSpecNotStarted; // plan v0.3 P6: where the speculative loop starts (0 is a real position: a 1-token prompt on a native pack) strata::prefill::Prefill prefill; - if (!multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT (research): before any bytes_needed, like the share + if (!multi_gpu && o.batch <= 0) // STRATA_SWITCH_POINT: before any bytes_needed, like the share strata::prefill::Prefill::set_card_expert_share((int64_t) xcache.slots(), (int64_t) (g.n_layers * g.n_expert), xcache.slots() > 0 ? (double) xcache.bytes() / (double) xcache.slots() / 1e6 : 0.0, o.pcie_probe_gbps); // #1595: not by default when the cache holds every expert (nothing to take) strata::prefill::Prefill::arm_cpu_share(!multi_gpu && !o.no_pool, diff --git a/tests/prefill/switch_point_rule_test.cpp b/tests/prefill/switch_point_rule_test.cpp index 4969725c5a..bcdb3d0413 100644 --- a/tests/prefill/switch_point_rule_test.cpp +++ b/tests/prefill/switch_point_rule_test.cpp @@ -92,6 +92,45 @@ int main() { CHECK(sp::share_limit_for(2048) == 3072); // A4000: measured break-even about 2,900 CHECK(sp::share_limit_for(3840) % sp::kGrid == 0 && sp::share_limit_for(3840) > 3840); + // the class the rule is on for by default: CUDA, discrete, one GPU, link probe ran, compute capability 8.6; STRATA_SWITCH_POINT=0 is the way back, =1 asks for it elsewhere + { + sp::DeviceClass in; + in.cuda = true; in.discrete = true; in.single_gpu = true; in.link_probed = true; in.cc_major = 8; in.cc_minor = 6; + CHECK(sp::in_default_class(in)); + CHECK(sp::enabled(in, -1)); // nothing set: on + CHECK(!sp::enabled(in, 0)); // STRATA_SWITCH_POINT=0 (or any value but 1): the way back + CHECK(sp::enabled(in, 1)); // STRATA_SWITCH_POINT=1: on + // every other compute capability is out of the class with nothing set + const int other[][2] = {{6, 0}, {6, 1}, {7, 0}, {7, 5}, {8, 0}, {8, 7}, {8, 9}, {9, 0}, {10, 0}, {12, 0}, {12, 1}, {0, 0}}; + for (const auto& cc : other) { + sp::DeviceClass d = in; + d.cc_major = cc[0]; d.cc_minor = cc[1]; + CHECK(!sp::in_default_class(d)); + CHECK(!sp::enabled(d, -1)); + CHECK(sp::enabled(d, 1)); // the explicit opt-in still works on another CUDA card + CHECK(!sp::enabled(d, 0)); + } + // each other condition on its own takes a card out of the class + { sp::DeviceClass d = in; d.single_gpu = false; CHECK(!sp::enabled(d, -1)); CHECK(!sp::enabled(d, 0)); } // two cards / a layer split + { sp::DeviceClass d = in; d.link_probed = false; CHECK(!sp::enabled(d, -1)); } // no probe + { sp::DeviceClass d = in; d.discrete = false; CHECK(!sp::enabled(d, -1)); } // integrated / shared memory + { sp::DeviceClass d = in; d.cuda = false; CHECK(!sp::enabled(d, -1)); CHECK(!sp::enabled(d, 1)); CHECK(!sp::enabled(d, 0)); } // HIP: never, whatever the cc says + { sp::DeviceClass d; CHECK(!sp::enabled(d, -1)); CHECK(!sp::enabled(d, 1)); } // nothing known + // the variable: unset or empty = default, exactly "1" = on, anything else = off + CHECK(sp::env_state(nullptr) == -1); + CHECK(sp::env_state("") == -1); + CHECK(sp::env_state("1") == 1); + CHECK(sp::env_state("0") == 0); + CHECK(sp::env_state("off") == 0); + CHECK(sp::env_state("11") == 0); + // the class gives the measured floors: the A6000 and the A4000 are both 8.6 + CHECK(sp::kClassCcMajor == 8 && sp::kClassCcMinor == 6); + CHECK(sp::floor_for_card(13580, total, sp::Card{3.14, 12.2, 84}) == 3584); + CHECK(sp::share_limit_for(3584) == 5632); + CHECK(sp::floor_for_card(7836, total, sp::Card{1.44, 11.0, 48}) == 2048); + CHECK(sp::share_limit_for(2048) == 3072); + } + if (failed) { std::fprintf(stderr, "switch_point_rule_test: %d check(s) failed\n", failed); return 1;