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;