mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 15:28:40 +00:00
A stage with one layer holds a handful of expert slots (a 12 GB 3060: 512), and the prompt chunk of every card in the pipeline is clamped to what that cache can lend. When the pick has such a stage, search again among placements that give every stage at least three layers; keep the new pick and print both and why. With none startable the first pick stays. Identical cards pick balanced stages and never reach the second search.
39 lines
1.6 KiB
C++
39 lines
1.6 KiB
C++
// include/strata/program/split_rules.hpp - rules for the automatic layer split that do not need a GPU to check.
|
|
//
|
|
// A stage that owns one or two layers holds a handful of expert slots (a 12 GB 3060 with one layer held 512), and
|
|
// the prompt chunk of the whole pipeline is clamped to what the smallest cache can lend (#448): 576 -> 347 tok/s in
|
|
// #1616. So the search first looks for a placement in which every stage owns at least kMinStageLayers layers, and
|
|
// only falls back to the unrestricted best when no such placement can start the prompt path.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
namespace strata::program::split_rules {
|
|
|
|
constexpr int64_t kMinStageLayers = 3;
|
|
|
|
/// The restriction only makes sense when the model has the layers for it.
|
|
inline bool restriction_possible(int64_t n_layers, int stages) {
|
|
return stages >= 2 && n_layers >= kMinStageLayers * stages;
|
|
}
|
|
|
|
/// cuts: the first layer of each later stage (stages - 1 of them); n_layers: the model's layers.
|
|
/// Returns the size of the smallest stage.
|
|
inline int64_t smallest_stage(const std::vector<int64_t>& cuts, int64_t n_layers) {
|
|
int64_t lo = n_layers, prev = 0;
|
|
for (const int64_t c : cuts) {
|
|
if (c - prev < lo) lo = c - prev;
|
|
prev = c;
|
|
}
|
|
if (n_layers - prev < lo) lo = n_layers - prev;
|
|
return lo;
|
|
}
|
|
|
|
/// True when some stage owns fewer than kMinStageLayers layers.
|
|
inline bool has_tiny_stage(const std::vector<int64_t>& cuts, int64_t n_layers) {
|
|
return smallest_stage(cuts, n_layers) < kMinStageLayers;
|
|
}
|
|
|
|
} // namespace strata::program::split_rules
|