Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index 4e03dc8..48f5cf8 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -1969,6 +1969,19 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
const core::ModelGeometry& g = *m.g;
core::SessionState& ss = *m.ss;
const auto t_start = Clock::now();
+ const bool roofline = std::getenv("STRATA_PREFILL_ROOFLINE") != nullptr;
+ uint64_t roof_bytes = 0, roof_unique_bytes = 0, roof_copies = 0, roof_unique = 0;
+ std::vector<uint32_t> roof_counts(roofline ? (size_t) (g.n_layers * g.n_expert) : 0);
+ // The serial issuer or the joined issuer thread owns this counter; peer copies are excluded.
+ auto roof_copy = [&](int64_t l, int64_t e, size_t bytes) {
+ if (!roofline) return;
+ roof_bytes += bytes;
+ ++roof_copies;
+ if (roof_counts[(size_t) (l * g.n_expert + e)]++ == 0) {
+ roof_unique_bytes += bytes;
+ ++roof_unique;
+ }
+ };
const int64_t LB = stage_lb_, LE = stage_le_;
// The direct successor's future lives on the Prefill object. Intermediate
// stages therefore do not drain the complete remaining GPU chain here.
@@ -2306,6 +2319,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
m.stage_live[sl] = true;
stats_.ms_experts_host += ms_since(th);
++stats_.experts_streamed;
+ roof_copy(en.l, en.e, bytes);
++issued;
}
};
@@ -2353,6 +2367,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
m.stage_live[sl] = true;
iss_ms += ms_since(th);
++iss_streamed;
+ roof_copy(en.l, en.e, bytes);
a_issued.store(idx + 1, std::memory_order_release);
}
});
@@ -3580,6 +3595,7 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
stage_of[j] = sl;
stats_.ms_experts_host += ms_since(th);
++stats_.experts_streamed;
+ roof_copy(l, e, (size_t) lay.blob_bytes(l));
return true;
};
// In the streamed walk an MMQ group is gathered in ONE launch, after ONE wait on its last
@@ -4001,6 +4017,11 @@ bool Prefill::run_impl(const int64_t* tokens, int64_t n, int64_t pos0, std::stri
(long long) kv_prefetches);
}
stats_.ms_total += ms_since(t_start);
+ if (roofline) {
+ std::fprintf(stderr, "strata prefill roofline: tokens %lld H2D_bytes %llu copies %llu unique_bytes %llu unique_experts %llu\n",
+ (long long) n, (unsigned long long) roof_bytes, (unsigned long long) roof_copies,
+ (unsigned long long) roof_unique_bytes, (unsigned long long) roof_unique);
+ }
if (pt.on) {
pt.fold();
double total = 0.0;