tune: measure collectives as the exchange -- per-rank operands and instances, device.p2p measured before declare, tune requests carrying their instance

This commit is contained in:
Dustin Ewan authored and StillDeadcode committed 2026-10-25 10:30:52 +01:00
1 parent d0c44cf5a3
commit e9555d2bc1
7 files changed
+339 -101

No files matched your search

+25
View File
@@ -487,6 +487,7 @@ void Builder::record_tune_request(const Resolved& r) {
req.geom = r.geom;
req.geom_key = r.geom_key;
req.info = r.row->info;
req.instance = r.instance;
prog_.tune_requests.push_back(std::move(req));
}
@@ -597,6 +598,29 @@ void Builder::finish_instances() {
}
}
}
/* The instances are made in finish_instances(), after record_tune_request ran, so the requests
* now carry the instance their kernel will launch with. A collective's launch cannot be formed
* without it -- the peer bundle (scratch, flags, sequence counters) is what init() builds and
* RadArgs reaches the exchange through nothing else -- so the tuner forms its launches from this.
* Keyed exactly as record_tune_request keyed. */
void Builder::fill_tune_instances() {
for (size_t i = 1; i < prog_.ops.size(); ++i) {
const OpInfo& oi = prog_.ops[i];
for (const Band& b : oi.bands)
for (int d = 0; d < RAD_N_DOMAINS; ++d) {
const Resolved& r = b.dom[d];
if (!r || !r.row || !r.row->info) continue;
const std::string key = r.row->info->name + std::string("\x1f") + r.row->plugin +
std::string("\x1f") + r.geom_key;
for (auto& t : prog_.tune_requests)
if (t.kernel + std::string("\x1f") + t.plugin + std::string("\x1f") +
t.geom_key == key)
t.instance = r.instance;
}
}
}
rad_op Builder::decl_op(const char* opname, const RadParam* p, int n_p,
const rad_weight* w, int n_w) {
if (finished_) return err(RAD_E_STATE, "decl_op('%s') after declare finished", opname ? opname : "");
@@ -2380,6 +2404,7 @@ int Builder::finish() {
}
if (instances_) finish_instances();
fill_tune_instances();
finish_weight_uses();
finish_layouts();
finish_kv_groups();