Merge f-028-par
This commit is contained in:
commit
32f0c44f08
29 files changed
+1024
-128
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include "strata/core/remote_experts.hpp"
|
||||
#include "strata/core/peer_experts.hpp"
|
||||
#include "strata/kernels/cpu/expert_layout.hpp"
|
||||
#include "strata/kernels/window_limits.hpp"
|
||||
#include "strata/artifact/gguf_reader.hpp"
|
||||
|
||||
#include "strata/core/pinned.hpp"
|
||||
@@ -4804,10 +4805,10 @@ void expert_pool_dispatch(void* user, const float* x_f, const int32_t* ids, cons
|
||||
|
||||
namespace {
|
||||
// the verify window's per-entry tables in `expert_pool_dispatch_multi` (`kind`, `distinct`, `first_of`)
|
||||
// are fixed arrays of this many entries: MAXT tokens of the model's 10 routed experts must fit, and a larger k is
|
||||
// refused at run time rather than written past them.
|
||||
constexpr int64_t kMaxWindowEntries = 128;
|
||||
static_assert(strata::kernels::cpu::MAXT * 10 <= kMaxWindowEntries, "a verify window's entries overflow the tables");
|
||||
// are fixed arrays of this many entries: a window's rows (kWindowMaxT) of the model's 10 routed experts must fit, and a
|
||||
// larger k is refused at run time rather than written past them. 128 for the 8-row window (as it was), 256 for 16.
|
||||
constexpr int64_t kMaxWindowEntries = strata::kernels::kWindowMaxT <= 8 ? 128 : 256;
|
||||
static_assert(strata::kernels::kWindowMaxT * 10 <= kMaxWindowEntries, "a verify window's entries overflow the tables");
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
@@ -4831,7 +4832,7 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
float* out, strata::kernels::cpu::NativeArithmetic arithmetic) {
|
||||
using namespace strata::kernels::cpu;
|
||||
if (d.failed) return;
|
||||
if (n_tok < 1 || n_tok > MAXT) {
|
||||
if (n_tok < 1 || n_tok > strata::kernels::kWindowMaxT) {
|
||||
d.failed = true;
|
||||
d.fail = "a verify window has more tokens than the multi-token expert kernel takes";
|
||||
d.fail_layer = d.layers;
|
||||
@@ -4850,12 +4851,13 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
d.fail_layer = d.layers;
|
||||
return;
|
||||
}
|
||||
if ((int64_t) d.act_multi.size() < n_tok) d.act_multi.resize((size_t) MAXT);
|
||||
if ((int64_t) d.act_multi.size() < n_tok) d.act_multi.resize((size_t) strata::kernels::kWindowMaxT);
|
||||
const ExpertLayout& lay = expert_layout();
|
||||
const bool native = lay.native;
|
||||
if (native && d.nact_multi.size() < (size_t) MAXT * kNativeActBytes) d.nact_multi.resize((size_t) MAXT * kNativeActBytes);
|
||||
if (native && d.nact_multi.size() < (size_t) strata::kernels::kWindowMaxT * kNativeActBytes)
|
||||
d.nact_multi.resize((size_t) strata::kernels::kWindowMaxT * kNativeActBytes);
|
||||
if (d.job_of.size() != (size_t) d.n_expert) d.job_of.assign((size_t) d.n_expert, (int16_t) -1);
|
||||
if (d.jobs_multi.size() < (size_t) (n_tok * k)) d.jobs_multi.resize((size_t) (MAXT * k));
|
||||
if (d.jobs_multi.size() < (size_t) (n_tok * k)) d.jobs_multi.resize((size_t) (strata::kernels::kWindowMaxT * k));
|
||||
static const bool ptrace = std::getenv("STRATA_POOL_TRACE") != nullptr;
|
||||
auto pt = [&](const char* what, long long a = -1) {
|
||||
if (ptrace) { std::fprintf(stderr, "pool trace: layer %lld %s %lld\n", (long long) d.layers, what, a); std::fflush(stderr); }
|
||||
@@ -5169,6 +5171,17 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
++d.cold_zc;
|
||||
}
|
||||
}
|
||||
if (d.jobs_multi[(size_t) jo].nt == MAXT) {
|
||||
// a window of 9..16 rows routes more than MAXT tokens to this expert: the kernels and the pool's scratch
|
||||
// take MAXT tokens a job, so the rest are a further job over the same blob (each token's rows are its own,
|
||||
// so the split changes no value; the blob is read once more)
|
||||
const int16_t prev = jo;
|
||||
jo = (int16_t) njobs++;
|
||||
ExpertJobMulti& nj = d.jobs_multi[(size_t) jo];
|
||||
nj.blob = d.jobs_multi[(size_t) prev].blob;
|
||||
nj.fmt = d.jobs_multi[(size_t) prev].fmt;
|
||||
nj.nt = 0;
|
||||
}
|
||||
ExpertJobMulti& jb = d.jobs_multi[(size_t) jo];
|
||||
jb.act[jb.nt] = &d.act_multi[(size_t) t];
|
||||
jb.nact[jb.nt] = native ? d.nact_multi.data() + (size_t) t * kNativeActBytes : nullptr;
|
||||
|
||||
Reference in new issue
Block a user