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

+1
View File
@@ -197,6 +197,7 @@ private:
/* init() for every surviving instance, after the whole graph has resolved, so a failing init
* cannot abort declare before the miss report is assembled. */
void finish_instances();
void fill_tune_instances();
int32_t find_kv_consumer(rad_kvgroup g);
void finish_layouts();
void finish_kv_groups();
+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();
+1
View File
@@ -535,6 +535,7 @@ int dev_code_runs(size_t from, size_t to, int device, std::string* why) {
extern "C" {
int rad_dev_peer_access(int self, int peer) { return rad::dev_peer_access(self, peer); }
int rad_event_create_as(RadEvent* out, unsigned flags) {
const int s = dev()->event_create(out, flags);
+7
View File
@@ -504,6 +504,13 @@ public:
Geometry geom;
std::string geom_key;
const RadKernelInfo* info = nullptr;
/* The instance init() produced for this instantiation, null for a kernel with no init.
* A collective's launch cannot be formed without it: the peer bundle -- the scratch, the
* flags and the sequence counters, published to every rank and made peer-accessible at
* init -- is what makes the exchange addressable, and RadArgs carries no other route to
* it. The instance belongs to the rank this Program was declared for (Program::ctx), and
* the Registry that made it must outlive the launch (spec §1, §15). */
void* instance = nullptr;
};
std::vector<TuneRequest> tune_requests;