core: optimize remote expert helper decode
Add default-off cache coordination, helper-side weighted reduction and CPU activation quantization on demand. Allow helper cache capacities to be sized automatically at startup. Port the saved v2.2 implementation onto upstream 0.1.38 without changing the separate peer tier. Document the helper-only scope and current validation limits.
This commit is contained in:
1 parent
200c35a8e9
commit
5cc53cddbc
11 files changed
+375
-33
No files matched your search
+12
-2
@@ -1,5 +1,6 @@
|
||||
// src/core/verify.cpp - see include/strata/core/verify.hpp.
|
||||
#include "strata/core/verify.hpp"
|
||||
#include "strata/core/remote_expert_opt.hpp"
|
||||
#if defined(_WIN32)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
@@ -887,7 +888,10 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
m_ids_ + tb * K, m_w_ + tb * K, m_seq_, (uint32_t) ((l - lb_) * G + grp + 1), cs);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (remote_opt_) // #578: the helper GPUs reduce with the routing weights - publish them
|
||||
doorbell_publish(xm, ids_ + tb * K, w_ + tb * K, (int64_t) n * N, (int64_t) n * K, m_x_ + tb * N,
|
||||
m_ids_ + tb * K, m_w_ + tb * K, m_seq_, cs);
|
||||
else {
|
||||
const int32_t* layer_res = hits_.d_res != nullptr ? (hits_.d_res + l * g.n_expert) : nullptr;
|
||||
doorbell_publish_res(xm, ids_ + tb * K, layer_res, (int) g.n_expert, (int64_t) n * N, (int64_t) n * K,
|
||||
m_x_ + tb * N, m_ids_ + tb * K, m_seq_, cs);
|
||||
@@ -999,7 +1003,9 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
} else {
|
||||
wait_flag_ge(m_flag_, ring, cs); // the CPU's share is in the mapped rows
|
||||
stamp(l, 23, grp);
|
||||
if (dec_batch) // only the CPU rows cross PCIe (p_dst[0, counts[1]) = the GPU's own rows)
|
||||
if (remote_opt_) // #578: the helper's rows come back reduced; skip them as well
|
||||
remote_opt_->copy_rows(parts_out, m_ymiss_ + (size_t) tb * K * N, tb, n, p_dst, p_counts + 1, cs);
|
||||
else if (dec_batch) // only the CPU rows cross PCIe (p_dst[0, counts[1]) = the GPU's own rows)
|
||||
copy_rows_from_mapped(parts_out, m_ymiss_ + (size_t) tb * K * N, (int64_t) n * K, N,
|
||||
p_dst, p_counts + 1, cs);
|
||||
else
|
||||
@@ -1020,6 +1026,8 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
mb.weights = w_ + t * K; mb.shared = shared_ + t * N;
|
||||
if (!moe_combine_parts(g, l, K, mb, parts_ + (size_t) t * K * N, bo_ + t * N, cs, err)) return false;
|
||||
}
|
||||
if (remote_opt_) remote_opt_->combine(bo_ + tb * N, y_dummy_ + tb * N, tb, n,
|
||||
device_plan_ ? skip_ + grp : nullptr, ring, cs);
|
||||
stamp(l, 24, grp);
|
||||
if (l == g.n_layers - 1) {
|
||||
if (!fuse_head_gr) {
|
||||
@@ -1379,9 +1387,11 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
|
||||
set_plan_slot(grp);
|
||||
const int tb = gtb[grp], n = gte[grp] - gtb[grp];
|
||||
progress_at("verify window: the CPU experts of layer", l);
|
||||
if (remote_opt_) remote_opt_->begin(h_w_ + (size_t) tb * ss.k, tb, n);
|
||||
if (pool != nullptr)
|
||||
pool(user, h_x_ + (size_t) tb * g.n_embd, h_ids_ + (size_t) tb * ss.k, n, ss.k,
|
||||
h_ymiss_ + (size_t) tb * ss.k * g.n_embd, l);
|
||||
if (remote_opt_) remote_opt_->end();
|
||||
VDBG("layer %lld served\n", (long long) l);
|
||||
if (g_trace) trace_ev(*(volatile uint32_t*) h_flagA_ == want ? "SERVED" : "SERVED-NO-PLAN-YET", k, l,
|
||||
(int64_t) ms_since(b)); // aux: ms the CPU experts took
|
||||
|
||||
Reference in new issue
Block a user