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:
zhedang authored and Niko1221 committed 2026-10-03 23:33:07 +02:00
1 parent 200c35a8e9
commit 5cc53cddbc
11 files changed
+375 -33

No files matched your search

+10 -6
View File
@@ -2106,13 +2106,17 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
if (kind[i] < 0) { any_cpu = true; break; }
const auto c1 = std::chrono::steady_clock::now();
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)
// #578 --remote-expert-opt: a token whose experts all run on a GPU (CUDA0 or a helper) needs no CPU activation
const bool ep = d.remote_count > 0 && d.remote[0]->optimized_decode();
for (int64_t t = 0; t < n_tok; ++t) {
if (ep && std::all_of(kind + t * k, kind + (t + 1) * k, [](int32_t v) { return v >= 0; })) continue;
if (native && lay.fmt[(size_t) d.layers].gu_type == 42) // a native Q2_0 pack: the Q2_0 kernels' activations
act_quant_any(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
else if (native)
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]);
else
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();
if (any_cpu) { // CS-T: the experts the CPU computes, fetched together (the GGUF in place reads them on several threads)