Archived
place: --expert-pin-top cuts fractional profile shares correctly
pin_hot() set the pin threshold to the share at the cut minus 1.0, which assumes integer gaps between shares. A profile's per-layer shares are fractions in [0, 1] (xs_profile_load divides by the layer's total), so the threshold went negative and every resident expert counted as pinned at any --expert-pin-top, leaving the heat engine no slab slots (decode -4..9% on Qwen3.8-Flash-Next IQR-V4 against the same run without pinning). The threshold is now the share just below the hot set (-1 when the hot set is every expert, so everything pins). A test with fractional shares pins the hottest quarter and fails without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f2e511fcc
commit
8dcd8fdcd7
2 files changed
+38
-1
No files matched your search
@@ -1146,7 +1146,7 @@ void Planner::pin_hot(const Config& cfg, Plan* p) const {
|
||||
const double keep = (double)cfg.expert_pin_top * (double)shares.size();
|
||||
const size_t hot = keep <= 0.0 ? 0 : std::min(shares.size(), (size_t)std::ceil(keep));
|
||||
const float threshold = hot == 0 ? shares.back() + 1.0f
|
||||
: shares[shares.size() - hot] - 1.0f;
|
||||
: (hot < shares.size() ? shares[shares.size() - hot - 1] : -1.0f);
|
||||
p->pin_threshold = threshold;
|
||||
p->profile_units = (int64_t)shares.size();
|
||||
int64_t pinned = 0, left = 0;
|
||||
|
||||
@@ -4635,6 +4635,43 @@ TEST(expert_pin_top_keeps_the_hottest_resident) {
|
||||
CHECK(p.report(f.prog).find("pinned hot") != std::string::npos);
|
||||
}
|
||||
|
||||
/* Real profiles carry per-layer shares in [0, 1] (xs_profile_load divides by the layer's total), so
|
||||
* the cut must not assume integer gaps between shares: F = 0.25 pins the hottest quarter, not every
|
||||
* resident expert. */
|
||||
TEST(expert_pin_top_cuts_fractional_shares) {
|
||||
Fixture f;
|
||||
build_moe_layers(f, 2, 8, 1 * MiB, 0);
|
||||
|
||||
std::vector<RadFileProfile> prof;
|
||||
for (int l = 0; l < 2; ++l)
|
||||
for (int e = 0; e < 8; ++e) {
|
||||
RadFileProfile r{};
|
||||
r.layer = l;
|
||||
r.expert = e;
|
||||
r.share = (float)(e + 1) / 36.0f;
|
||||
prof.push_back(r);
|
||||
}
|
||||
|
||||
Config c = base_config();
|
||||
c.placement = "expert_tiered";
|
||||
c.vram_weights_mib = 1024;
|
||||
c.host_pool_mib = 1024;
|
||||
c.expert_pin_top = 0.25f;
|
||||
|
||||
PlannerInput in{&f.prog, &c, 0, 1, prof.data(), (int64_t)prof.size()};
|
||||
Plan p;
|
||||
CHECK_OK(Planner(in).plan(&p));
|
||||
|
||||
int pinned = 0, hot_pinned = 0;
|
||||
for (const MoveUnit& mu : p.units) {
|
||||
if (mu.expert < 0 || !mu.pinned) continue;
|
||||
++pinned;
|
||||
if (mu.expert >= 6) ++hot_pinned;
|
||||
}
|
||||
CHECK_EQ(pinned, 4);
|
||||
CHECK_EQ(hot_pinned, 4);
|
||||
}
|
||||
|
||||
TEST(expert_pin_top_zero_pins_nothing) {
|
||||
Fixture f;
|
||||
build_moe_layers(f, 1, 4, 1 * MiB, 0);
|
||||
|
||||
Reference in new issue
Block a user