layer split auto: a two-GPU rig whose first pick has a tiny stage tries each card's share of the room before the three-layer rule (#2644)

On RTX 4060 Ti 16 GB + RTX 3060 12 GB (48 layers, IQ3_S) the first pick was K=2 and the #1616 retry
(every stage at least 3 layers) landed on its own edge, K=3: the 3060 ran 3 layers, 12 GB idle, 452 tok/s of
prefill against 802 at 28 layers (the prompt flows through the stages as a pipeline). For two GPUs the retry
now first asks for a placement in which each stage owns at least floor(layers x its room / all rooms) layers
(split_rules::share_floors, at least 3, trimmed to fit); the three-layer rule stays the second try and the
first pick the last, and the log says which one was taken. Nothing changes where the first pick has no
one- or two-layer stage (equal cards), and three or more GPUs keep the #1616 rule alone.

Reported by @Tworks25 on #2644, with the sweep of layer_split 12..32 (PR #2643). split_rules_test gets the
reporter's rooms (14.2 GiB and 5.50 GiB) and the identical-card and degenerate cases.
This commit is contained in:
Niko1221 committed 2026-10-15 16:31:45 +02:00
1 parent 8101a8903b
commit 3b848837fa
3 files changed
+151 -17

No files matched your search

+49
View File
@@ -91,6 +91,55 @@ int main() {
CHECK(big[0] == 1.0 && big[1] > 4.3 && big[1] < 4.4 && big[2] == 64.0 && big[3] == 1.0);
CHECK(link_miss_scale({-1.0, -1.0})[1] == 1.0);
}
// #2644: RTX 4060 Ti 16 GB + RTX 3060 12 GB, 48 layers. The reporter's numbers: CUDA1 5.50 GiB free of 11.63 (the
// 3060 side), CUDA0 the 16 GB card with ~14.2 GiB room. The #1616 retry alone took K=3 (3 layers on the second card)
// although the first pick K=2 was the same problem; the share of the room gives it 13 layers of 48.
{
const int64_t MiB = 1 << 20, L = 48;
const std::vector<int64_t> room{14500 * MiB, 5632 * MiB};
const std::vector<int64_t> f = share_floors(room, L);
CHECK(f.size() == 2 && f[0] == 34 && f[1] == 13);
CHECK(floors_exceed_minimum(f));
// the cut K = the second stage's first layer. With the big card first, the old rule's edge is K=45 (the second card
// with 3 layers): below its floor.
CHECK(below_floors({45}, L, f));
CHECK(below_floors({47}, L, f));
CHECK(!below_floors({35}, L, f)); // second card: 13 layers
CHECK(!below_floors({34}, L, f)); // 14 layers
CHECK(below_floors({36}, L, f)); // 12 layers: under its share
CHECK(below_floors({33}, L, f)); // the big card under its share
// the same pair the other way round: the small card first
const std::vector<int64_t> r = share_floors({room[1], room[0]}, L);
CHECK(r[0] == 13 && r[1] == 34);
CHECK(below_floors({3}, L, r)); // the old retry's K=3 starves the small card
CHECK(!below_floors({13}, L, r));
CHECK(!below_floors({14}, L, r));
// a predicted-time pick under the floors sits at the edge of the floor, not at the three-layer edge
// (layer ms 0.82 on the 4060 Ti, 1.45 on the 3060 as the engine prices them: fewer layers on the 3060 predict faster)
auto pick = [&](const std::vector<int64_t>& fl) {
int64_t best_k = -1;
double best = 1e30;
for (int64_t k = 2; k < L; ++k) {
if (!fl.empty() && below_floors({k}, L, fl)) continue;
if (smallest_stage({k}, L) < (fl.empty() ? kMinStageLayers : 0)) continue;
const double ms = (double) k * 1.45 + (double) (L - k) * 0.82; // card 0 = the 3060 here
if (ms < best) { best = ms; best_k = k; }
}
return best_k;
};
CHECK(pick({}) == 3); // today: the 3060 gets 3 layers
CHECK(pick(r) == 13); // with the floors: its share
std::printf("split_rules_test: #2644 floors %lld,%lld; 3060 first: old retry K=%lld, share retry K=%lld\n",
(long long) f[0], (long long) f[1], (long long) pick({}), (long long) pick(r));
// identical cards: the even split, and the floors never exceed the layers
const std::vector<int64_t> eq = share_floors({10000 * MiB, 10000 * MiB}, L);
CHECK(eq[0] == 24 && eq[1] == 24);
const std::vector<int64_t> three = share_floors({1 * MiB, 1 * MiB, 30000 * MiB}, 12);
CHECK(three[0] == 3 && three[1] == 3 && three[2] == 6); // lifted to 3, the big one trimmed to fit 12
CHECK(share_floors({0, 0}, L)[0] == kMinStageLayers && share_floors({-5, 0}, L)[1] == kMinStageLayers);
CHECK(!floors_exceed_minimum(share_floors({0, 0}, L)));
CHECK(!below_floors({}, 48, {}));
}
if (failed == 0) std::printf("split_rules_test: ok\n");
return failed ? 1 : 0;
}