perf(cuda,decode): zero-doorbell verify graph, sub-warp expert packing, shared-mem staging, and batched PLE/MTP
This commit is contained in:
1 parent
586367cb00
commit
a36be1db29
21 files changed
+1197
-322
No files matched your search
+23
-12
@@ -2099,16 +2099,23 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
for (int64_t i = 0; i < n; ++i) if (d.remote[r]->owns(i)) kind[i] = 2;
|
||||
}
|
||||
}
|
||||
static const bool dec_batch = [] { const char* v = std::getenv("STRATA_DEC_BATCH"); return v == nullptr || std::atoi(v) != 0; }();
|
||||
const bool gpu_zeroes_hits = (d.plan != nullptr && n <= kMaxWindowEntries && n <= d.plan->cap && dec_batch);
|
||||
bool any_cpu = false;
|
||||
for (int64_t i = 0; i < n; ++i)
|
||||
if (kind[i] < 0) { any_cpu = true; break; }
|
||||
const auto c1 = std::chrono::steady_clock::now();
|
||||
if (native && lay.fmt[(size_t) d.layers].gu_type == 42) // a native Q2_0 pack: the Q2_0 kernels' activations
|
||||
for (int64_t t = 0; t < n_tok; ++t) act_quant_any(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
|
||||
else if (native)
|
||||
for (int64_t t = 0; t < n_tok; ++t)
|
||||
native_quant_act(lay.fmt[(size_t) d.layers], x_f + (size_t) t * H, d.nact_multi.data() + (size_t) t * kNativeActBytes);
|
||||
else
|
||||
for (int64_t t = 0; t < n_tok; ++t) act_quant_q8_1(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
|
||||
if (any_cpu) {
|
||||
if (native && lay.fmt[(size_t) d.layers].gu_type == 42) // a native Q2_0 pack: the Q2_0 kernels' activations
|
||||
for (int64_t t = 0; t < n_tok; ++t) act_quant_any(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
|
||||
else if (native)
|
||||
for (int64_t t = 0; t < n_tok; ++t)
|
||||
native_quant_act(lay.fmt[(size_t) d.layers], x_f + (size_t) t * H, d.nact_multi.data() + (size_t) t * kNativeActBytes);
|
||||
else
|
||||
for (int64_t t = 0; t < n_tok; ++t) act_quant_q8_1(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
|
||||
}
|
||||
const auto c2 = std::chrono::steady_clock::now();
|
||||
{ // CS-T: the experts the CPU computes, fetched together (the GGUF in place reads them on several threads)
|
||||
if (any_cpu) { // CS-T: the experts the CPU computes, fetched together (the GGUF in place reads them on several threads)
|
||||
static thread_local std::vector<int64_t> miss;
|
||||
miss.clear();
|
||||
for (int64_t i = 0; i < n_tok * k; ++i)
|
||||
@@ -2134,8 +2141,10 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
if (kind[i] == 0) ++d.cache_hits;
|
||||
else ++d.offload_entries; // #588: PCIe or another GPU
|
||||
if (kind[i] == 2 && d.peer != nullptr) ++d.peer_entries;
|
||||
// multi-GPU: a direct peer launch is writing this row right now - zeroing it would race it
|
||||
if (!(kind[i] == 2 && d.peer != nullptr && d.peer->launched_direct()))
|
||||
// multi-GPU: a direct peer launch is writing this row right now - zeroing it would race it;
|
||||
// dec_batch: copy_rows_from_mapped_kernel already zeroes kind 0/1 rows on the GPU
|
||||
if (!((kind[i] == 2 && d.peer != nullptr && d.peer->launched_direct()) ||
|
||||
(gpu_zeroes_hits && (kind[i] == 0 || kind[i] == 1))))
|
||||
std::memset(row, 0, (size_t) H * sizeof(float));
|
||||
continue;
|
||||
}
|
||||
@@ -2165,8 +2174,10 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
}
|
||||
const auto c3 = std::chrono::steady_clock::now();
|
||||
pt("run", njobs);
|
||||
if (native) d.pool->run_split_multi_native(lay.fmt[(size_t) d.layers], d.jobs_multi.data(), njobs);
|
||||
else d.pool->run_split_multi(d.jobs_multi.data(), njobs);
|
||||
if (njobs > 0) {
|
||||
if (native) d.pool->run_split_multi_native(lay.fmt[(size_t) d.layers], d.jobs_multi.data(), njobs);
|
||||
else d.pool->run_split_multi(d.jobs_multi.data(), njobs);
|
||||
}
|
||||
if (d.remote_count > 0) {
|
||||
static thread_local std::string remote_error;
|
||||
for (int r = 0; r < d.remote_count; ++r)
|
||||
|
||||
Reference in new issue
Block a user