Archived
core/place: --draft-expert-placement host and --expert-profile/--expert-pin-top (decode-hot residency)
This commit is contained in:
1 parent
9f707a0f67
commit
6b544e0d39
11 files changed
+566
-10
No files matched your search
+49
-1
@@ -1695,6 +1695,39 @@ int Engine::plan() {
|
||||
for (VramFacts& f : facts) f.held_out = cvec_bytes;
|
||||
RAD_TRY(resolve_table_placement(facts, emb_bytes, wfs, kv_floor, ngram_bytes,
|
||||
ngram_device, ngram_host, ck_store + host_arenas));
|
||||
/* --draft-expert-placement host: the drafter's experts are pinned in the host pool before
|
||||
* the strategy runs, so they are not part of the elastic plane the card must hold and the
|
||||
* pool must have room for them on top of the trunk's spill. Growing the pool here, before
|
||||
* the split, is what lets a drafter fit beside a trunk that already fills the card. */
|
||||
if (cfg_.draft_expert_placement == "host") {
|
||||
const int64_t MiB = (int64_t)1 << 20;
|
||||
int64_t draft_max = 0;
|
||||
for (const WeightFootprint& wf : wfs) draft_max = std::max(draft_max, wf.draft_experts);
|
||||
if (draft_max == 0 && cfg_.draft_expert_placement_given) {
|
||||
RAD_ERR("--draft-expert-placement host: this model declares no draft head with "
|
||||
"routed experts");
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
if (draft_max > 0) {
|
||||
/* The pool must hold the drafter on top of the trunk's own spill, so it grows by
|
||||
* the drafter's bytes and the floor is recomputed against that larger room with
|
||||
* the drafter taken out of the plane the card places. */
|
||||
const int64_t add = (align_up(draft_max, MiB) + MiB - 1) / MiB;
|
||||
cfg_.host_pool_mib += add;
|
||||
for (size_t i = 0; i < facts.size(); ++i) {
|
||||
int64_t room = cfg_.host_pool_mib * MiB;
|
||||
if (cfg_.weights_disk_tier)
|
||||
room -= file_stage_reserve(wfs[i].layer_unit_max, wfs[i].routed);
|
||||
facts[i].expert_floor = expert_vram_floor_draft_hosted(
|
||||
wfs[i], std::max<int64_t>(room - align_up(wfs[i].draft_experts, MiB), 0));
|
||||
facts[i].experts = std::max<int64_t>(wfs[i].experts - wfs[i].draft_experts, 0);
|
||||
}
|
||||
RAD_INFO("placement: --draft-expert-placement host pins %s of drafter experts a "
|
||||
"rank in the host pool; --host-pool-mib grows by %lld to hold them, and "
|
||||
"the card places only the trunk's experts",
|
||||
humanb(draft_max).c_str(), (long long)add);
|
||||
}
|
||||
}
|
||||
/* The n-gram table was counted off the card; on it, every rank holds the whole table. */
|
||||
if (cfg_.ngram_resolved == TablePlacement::Vram)
|
||||
for (VramFacts& f : facts) f.statics += ngram_bytes;
|
||||
@@ -1843,6 +1876,20 @@ int Engine::plan() {
|
||||
in.profile = file_->profile();
|
||||
in.n_profile = (int64_t)file_->header().prof_count;
|
||||
}
|
||||
/* --expert-profile replaces the container's activation profile, which is prefill-heavy:
|
||||
* decode-hot experts differ, and the pin below keeps them resident. Loaded once, before
|
||||
* any rank plans, so every rank ranks the same way. */
|
||||
if (!cfg_.expert_profile.empty()) {
|
||||
if (expert_profile_.empty() && ri == 0) {
|
||||
int32_t trunk = -1;
|
||||
const int pr = xs_profile_load(cfg_.expert_profile, &expert_profile_, &trunk);
|
||||
if (pr < 0) return pr;
|
||||
}
|
||||
if (!expert_profile_.empty()) {
|
||||
in.profile = expert_profile_.data();
|
||||
in.n_profile = (int64_t)expert_profile_.size();
|
||||
}
|
||||
}
|
||||
in.container = file_ != nullptr;
|
||||
in.host_backend = device_is_host();
|
||||
Planner planner(in);
|
||||
@@ -1864,7 +1911,8 @@ int Engine::plan() {
|
||||
humanb(r->plan.totals.bytes[(int)Tier::Mapped]).c_str()),
|
||||
r->plan.forced_host_used > 0
|
||||
? fmt("the host pool holds the %s the placement flags put there (the token "
|
||||
"embedding, the encoder towers) beside the weights placed in it",
|
||||
"embedding, the encoder towers, the drafter's experts) beside the "
|
||||
"weights placed in it",
|
||||
humanb(r->plan.forced_host_used).c_str())
|
||||
: std::string());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user