Verify profile: time the window routing apart from the plan/doorbell; route_window_parity covers T = 1..6

STRATA_VERIFY_PROFILE: a stamp after the routing (projection + top-k) splits slot 17 into
"router (proj+topk)" and "plan+bell", so a slow router shows up on its own line.
Profile-only: the stamp writes nothing unless the profile or the #649 trace is on.

route_window_parity also checks the window sizes 1 and 5 (the --spec 4 verifier
runs every T from 1 to 5).

(cherry picked from commit 82ff69eb97)
This commit is contained in:
Pablo Ugolini authored and pugolini committed 2026-10-20 15:55:15 +00:00
1 parent 9ae93f7b1f
commit 70813d5b83
3 files changed
+8 -4

No files matched your search

+1 -1
View File
@@ -499,7 +499,7 @@ private:
unsigned long long* trace_h_ = nullptr;
unsigned long long* trace_m_ = nullptr;
size_t trace_n_ = 0;
static constexpr int kProfPer = 33; // stamps per layer (32 left the hc-read second
static constexpr int kProfPer = 34; // stamps per layer (32 left the hc-read second
// half's up-stamp at slot 32 = the next layer's slot 0: D8)
bool prof_on_ = false;
unsigned long long* prof_ = nullptr; // device: n_layers * kProfPer + 4 stamps
+6 -2
View File
@@ -1880,6 +1880,7 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
mb.logits = logits_ + t * NE; mb.ids = ids_ + t * K; mb.weights = w_ + t * K;
if (!moe_route(wt, g, l, K, mb, mixed_ + t * N, cs, err, nullptr)) return false;
}
stamp(l, 33, grp); // the routing (projection + top-k) done; what follows in 17 is the plan / doorbell
// STRATA_ROUTE_PRIOR=lambda (opt-in, changes the output): the top-10 picked again with a logit bonus for the
// resident experts; the weights stay the router's (route_prior.cu)
static const float route_prior = [] { const char* v = std::getenv("STRATA_ROUTE_PRIOR"); return v ? (float) std::atof(v) : 0.0f; }();
@@ -2246,9 +2247,10 @@ std::string Verifier::profile_report() {
if (!prof_on_ || prof_windows_ == 0) return std::string();
static const char* names[kProfPer] = {"-", "hc-read0", "q8+qkv/q-idx gemv", "conv", "ab", "z", "rec", "q8+kv-idx",
"k/v+norm-rope", "kv+idx append", "q+q-idx", "scores+topk", "kv-resolve",
"attention", "gate", "", "out-proj", "router+plan+bell", "shared+quant",
"attention", "gate", "", "out-proj", "plan+bell", "shared+quant",
"waitA", "VRAM hits", "waitB", "PCIe grp", "waitCPU", "copy+combine",
"(gap)", "head", " hc0 norm", " hc0 down", " hc0 up", " hc1 norm", " hc1 down", " hc1 up"};
"(gap)", "head", " hc0 norm", " hc0 down", " hc0 up", " hc1 norm", " hc1 down", " hc1 up",
"router (proj+topk)"};
std::string out;
char b[80];
double total = 0;
@@ -2614,6 +2616,8 @@ void Verifier::accumulate_profile(const unsigned long long* stamps) {
prof_sum_[kind][32] += u1;
prof_sum_[kind][17] -= gap(at(l, 32), at(l, 16));
}
const double rt = gap(at(l, 33), at(l, 32)); // of what is left of 17: the projection + top-k
if (u1 > 0 && rt > 0) { prof_sum_[kind][33] += rt; prof_sum_[kind][17] -= rt; }
}
if (l + 1 < le_) prof_sum_[kind][25] += gap(at(l + 1, 0), at(l, 24));
const double dn = gap(at(l, 27), at(l, 0)), dd = gap(at(l, 28), at(l, 27)), du = gap(at(l, 1), at(l, 28));
+1 -1
View File
@@ -28,7 +28,7 @@ int main() {
std::mt19937 rng(7);
std::normal_distribution<float> nd(0.0f, 1.0f);
for (int n_out : {E, 1}) {
for (int T : {2, 3, 4, 6}) {
for (int T : {1, 2, 3, 4, 5, 6}) {
std::vector<uint16_t> w((size_t) n_out * N);
std::vector<float> x((size_t) T * N);
for (auto& v : w) v = bf16(nd(rng) * 0.05f);