expert plan: a helper GPU's experts are not part of the PCIe share
The verify window's GPU plan counted a layer's misses and moved the last pcie_num/256 of them to the primary over PCIe, leaving out the primary's resident experts and the peer tier's but not those a helper GPU (RemoteExperts) holds. The plan runs before RemoteExperts::begin(), which only claims rows the plan left at kind -1, so a PCIe share above 0 read part of the helper's experts over the primary's link while the helper idled for them. RemoteExperts::holds(layer, expert) (the helper cache's slot_of), and the plan treats such an expert as it treats the peer tier's: not a miss, never in the PCIe share; its rows stay at kind -1 for begin(). No default changes. 2x RX 6900 XT, IQ3_S, --remote-expert-opt with the probed share 0.39: 59.6 / 58.5 -> 37.2 / 33.8 ms per window, PCIe entries per layer-window 4.00 -> 0.26 / 0.06, decode 40.6 / 39.3 -> 65.6 / 67.7 tok/s (--pcie-frac 0: 66.9 / 67.1).
This commit is contained in:
1 parent
affb999c63
commit
abe8919c06
2 files changed
+14
-1
No files matched your search
@@ -37,6 +37,8 @@ public:
|
||||
int64_t k, const int32_t* kind, const int32_t* primary_res,
|
||||
std::string& err);
|
||||
bool owns(int64_t index) const { return owned_[(size_t) index] != 0; }
|
||||
/// This helper's cache holds (layer, expert): begin() will take its rows unless the plan gave them away.
|
||||
bool holds(int64_t layer, int32_t expert) const { return cache_.slot_of(layer, expert) >= 0; }
|
||||
bool optimized_decode() const { return remote_opt_ != nullptr; }
|
||||
bool finish(float* out, std::string& err);
|
||||
int64_t resident() const { return cache_.resident(); }
|
||||
|
||||
@@ -2020,6 +2020,15 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
if (d.plan != nullptr && n <= kMaxWindowEntries && n <= d.plan->cap) {
|
||||
int64_t distinct[kMaxWindowEntries], first_of[kMaxWindowEntries];
|
||||
int nd = 0, nmiss = 0;
|
||||
// a helper GPU (RemoteExperts) holding the expert computes it in its own VRAM once begin() claims the row: like
|
||||
// the peer tier's, such an expert is no miss of this plan and never part of the PCIe share, which would read it
|
||||
// over the primary's link instead (2x RX 6900 XT, IQ3_S, --remote-expert-opt with the probed share 0.39: ~4
|
||||
// helper experts per layer-window moved to PCIe, 59 ms per window against 34 ms)
|
||||
auto helper_holds = [&](int32_t e) {
|
||||
for (int r = 0; r < d.remote_count; ++r)
|
||||
if (d.remote[r]->holds(d.layers, e)) return true;
|
||||
return false;
|
||||
};
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
first_of[i] = i;
|
||||
for (int64_t j = 0; j < i; ++j)
|
||||
@@ -2028,7 +2037,7 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
distinct[nd++] = i;
|
||||
const int32_t e = ids[i];
|
||||
if (e >= 0 && e < d.n_expert && d.host_res[(size_t) d.layers * (size_t) d.n_expert + (size_t) e] < 0 &&
|
||||
!(d.peer != nullptr && d.peer->has(d.layers, e))) ++nmiss;
|
||||
!(d.peer != nullptr && d.peer->has(d.layers, e)) && !helper_holds(e)) ++nmiss;
|
||||
}
|
||||
}
|
||||
const bool pcie_ok = d.pcie_num > 0 && d.src->pcie_layer(d.layers);
|
||||
@@ -2050,6 +2059,8 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
|
||||
: (size_t) slot * (size_t) d.cache_blob));
|
||||
} else if (d.peer != nullptr && d.peer->has(d.layers, e)) {
|
||||
kd = 2; // multi-GPU: the second GPU computes it
|
||||
} else if (helper_holds(e)) {
|
||||
// left to the helper: kind -1 until RemoteExperts::begin() claims the row (see above)
|
||||
} else {
|
||||
if (miss_rank >= nmiss - m && fetches < P.staging_cap && fetches < 64) {
|
||||
const uint8_t* src = d.src->pinned(d.layers, e) ? d.src->blob(d.layers, e) : nullptr;
|
||||
|
||||
Reference in new issue
Block a user