| 6 | namespace strata::spec { |
| 7 | |
| 8 | double CostModel::step_ms(int k, bool mtp) const { |
| 9 | const int n = std::clamp(k + 1, 1, K_MAX + 1); |
| 10 | const double dense = dense_ms * dense_ratio[n - 1]; |
| 11 | // CPU misses: distinct experts grow as U(n); each extra token routed to a missed expert adds a fraction of a |
| 12 | // read. Tokens per distinct expert = n / U(n)-ratio (U measured in units of one token's 10 experts). |
| 13 | const double u = distinct_ratio[n - 1]; |
| 14 | const double uses_per_expert = (double) n / u; |
| 15 | const double cpu = (1.0 - hit_rate) * cpu_all_miss_ms * u * (1.0 + extra_use_cost * (uses_per_expert - 1.0)); |
| 16 | const double draft = k * (mtp ? mtp_draft_ms : lookup_draft_ms); |
| 17 | return dense + cpu + sync_ms + draft; |
| 18 | } |
| 19 | |
| 20 | Controller::Controller(CostModel cost, double min_gain, double ema) : cost_(cost), min_gain_(min_gain), ema_(ema) { |
| 21 | // Priors: MTP per-position acceptance from flyweight's measurement on this model (0.86 per draft); lookup by |