Skip to content

Commit 326d45a

Browse files
committed
optimize: SEQUANT_SELROOT_DEBUG print for the perf-first ceiling branch
The [selroot] diagnostic previously fired only on the peak-first (!perf_first) branch. Mirror it in the perf-first branch so a dense_time_space run can print each term's chosen_peak_gb and calibrate peak_threshold. Adds `fit` (whether a schedule met the ceiling; 0 => fell back to global min-flops). Gated on the same env var; no effect when unset.
1 parent 87e6250 commit 326d45a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

SeQuant/core/optimize/cost_model.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,9 +1031,23 @@ struct PeakBatchedModel {
10311031
if (peak_bytes(rootf[i].peak) <= peak_threshold &&
10321032
(pbest < 0 || better(i, pbest)))
10331033
pbest = i;
1034-
if (pbest < 0) // nothing fits the budget: perf-first best effort
1034+
bool const fit = pbest >= 0; // a schedule met the ceiling
1035+
if (!fit) // nothing fits the budget: perf-first best effort
10351036
for (int i = 0; i < static_cast<int>(rootf.size()); ++i)
10361037
if (pbest < 0 || better(i, pbest)) pbest = i;
1038+
// DIAGNOSTIC (gated): same fields as the peak-first branch below, plus
1039+
// `fit` = whether the ceiling was met (0 => the budget was below even the
1040+
// min-peak schedule, so this fell back to global min-flops). Use the
1041+
// per-term chosen_peak_gb to calibrate peak_threshold under a perf-first
1042+
// (dense_time_space) objective.
1043+
if (pbest >= 0 && std::getenv("SEQUANT_SELROOT_DEBUG")) {
1044+
double gmin = std::numeric_limits<double>::max();
1045+
for (auto const& p : rootf) gmin = std::min(gmin, p.flops);
1046+
std::cerr << "[selroot] chosen_flops=" << rootf[pbest].flops
1047+
<< " chosen_peak_gb=" << (peak_bytes(rootf[pbest].peak) / 1e9)
1048+
<< " fit=" << (fit ? 1 : 0) << " nfront=" << rootf.size()
1049+
<< " global_min_flops=" << gmin << "\n";
1050+
}
10371051
return pbest;
10381052
}
10391053
int best = -1;

0 commit comments

Comments
 (0)