layer split auto: on a tie the balanced placement wins
When every placement holds the whole expert profile the predicted decode window is the same for all of them and the winner was floating-point noise: --trim-stage-weights on four GPUs chose layers 6/30/5/7 and read a 32K prompt at 1,750 tok/s, against 2,790 for 12/12/12/12 with the same decode speed and tokens (4x Radeon AI PRO R9700, IQ3_S). Among placements whose window time agrees to 1e-6 ms the smallest slowest stage is kept.
This commit is contained in:
1 parent
efe7839905
commit
08cdd8bf68
1 file changed
+25
-3
@@ -3232,12 +3232,32 @@ int main(int argc, char** argv) {
|
||||
std::vector<int64_t> best, at((size_t) ns - 1);
|
||||
double best_ms = 1e30, best_mass = 0;
|
||||
int64_t best_held = 0, tried = 0;
|
||||
// TIES GO TO THE BALANCED PLACEMENT. When every placement holds the whole profile (the model fits the cards,
|
||||
// as IQ3_S does on two or more 32 GB cards) the predicted decode window is the same for all of them - the
|
||||
// layers' times just add - and which one "won" was floating-point noise in the sum: 3 layers on the first
|
||||
// card, 30 on the second. A prompt flows through the stages as a pipeline, so its speed is the slowest stage's:
|
||||
// measured on 4x R9700 with --trim-stage-weights, 6,36,41 read a 32K prompt at 1,750 tok/s and 12,24,36 at 2,780,
|
||||
// same decode speed, same tokens. Among placements whose window time agrees to 1e-6 ms the one with the
|
||||
// smallest slowest stage (layers x ms per layer) is kept; an earlier one stays on a second tie.
|
||||
double best_max = 1e30;
|
||||
auto stage_max = [&](const std::vector<int64_t>& cuts) {
|
||||
double m = 0;
|
||||
for (int i = 0; i < ns; ++i) {
|
||||
const int64_t lb = i == 0 ? 0 : cuts[(size_t) i - 1], le = i + 1 < ns ? cuts[(size_t) i] : g.n_layers;
|
||||
m = std::max(m, (double) (le - lb) * layer_ms[(size_t) i]);
|
||||
}
|
||||
return m;
|
||||
};
|
||||
const double tie_eps = 1e-6;
|
||||
auto consider = [&]() {
|
||||
double hm = 0;
|
||||
int64_t held = 0;
|
||||
const double ms = predict(at, hm, held);
|
||||
++tried;
|
||||
if (ms < best_ms) { best = at; best_ms = ms; best_mass = hm; best_held = held; }
|
||||
const double mx = stage_max(at);
|
||||
if (ms < best_ms - tie_eps || (ms <= best_ms + tie_eps && mx < best_max - tie_eps)) {
|
||||
best = at; best_ms = std::min(ms, best_ms); best_mass = hm; best_held = held; best_max = mx;
|
||||
}
|
||||
};
|
||||
const int64_t L = g.n_layers;
|
||||
// share the layers in proportion to speed: the fallback beyond four GPUs, and the only placement a
|
||||
@@ -3313,9 +3333,11 @@ int main(int argc, char** argv) {
|
||||
(double) k1 * layer_ms[0] + (double) (k2 - k1) * layer_ms[1] +
|
||||
(double) (k3 - k2) * layer_ms[2] + (double) (L - k3) * layer_ms[3];
|
||||
++tried;
|
||||
if (ms < best_ms) {
|
||||
const double mx = stage_max({k1, k2, k3});
|
||||
if (ms < best_ms - tie_eps || (ms <= best_ms + tie_eps && mx < best_max - tie_eps)) {
|
||||
best = {k1, k2, k3};
|
||||
best_ms = ms;
|
||||
best_ms = std::min(ms, best_ms);
|
||||
best_max = mx;
|
||||
best_mass = hm / denom;
|
||||
best_held = held_at[a] + held_at[b] + held_at[c] + held_at[d];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user