diff --git a/sycl/src/core/expert_cache.cpp b/sycl/src/core/expert_cache.cpp index ed1c8740..1ca0ff49 100644 --- a/sycl/src/core/expert_cache.cpp +++ b/sycl/src/core/expert_cache.cpp @@ -74,7 +74,10 @@ size_t device_free_bytes() try { You may need to adjust the code. */ dpct::get_current_device().get_memory_info(free_b, total_b); - if (const unsigned long long own = own_drm_local_bytes(); own > 0 && total_b > own && total_b - own < free_b) { + // #1440: only where the driver reports the whole card as free (Arc A750/i915). own_drm_local_bytes() sums every DRM + // fd of the process, i.e. both cards on a layer split, and would charge the first card's cache to the second. + if (const unsigned long long own = (free_b + (16ull << 20) >= total_b) ? own_drm_local_bytes() : 0ull; + own > 0 && total_b > own && total_b - own < free_b) { static std::atomic said{false}; if (free_b + (16ull << 20) >= total_b && !said.exchange(true)) std::fprintf(stderr, "strata: the driver reports the whole card as free although this process holds %.2f GiB of it (Arc A750/i915 does this); sizing from the DRM fdinfo instead\n", (double) own / 1073741824.0); diff --git a/sycl/src/program/generate.cpp b/sycl/src/program/generate.cpp index d714f8c9..35c1c431 100644 --- a/sycl/src/program/generate.cpp +++ b/sycl/src/program/generate.cpp @@ -4688,10 +4688,15 @@ int main(int argc, char **argv) try { unsigned long long* mirror_table_d = nullptr; // [n_layers][n_expert] device-readable mirror addresses (0 = none) int64_t unmirrored_misses = 0; if (o.stream_experts && srcp == &gguf_src && o.expert_cache > 0) { + // #1054, #1440: with a layer split the mirror holds only the first GPU's layers. The pinned memory belongs to + // this GPU's context, and the later stages' caches do not exist yet (every later-stage expert would count as a + // miss: 20 GiB of RAM for experts the other card then holds, or one 39 GiB pinned allocation that fails). + const int64_t mirror_end = multi_gpu && !split_at.empty() ? split_at[0] : g.n_layers; std::vector> miss; for (const auto& pr : profile) // the profile's order: the most-routed misses first, if the cap is reached - if (xcache.slot_of(pr.first, pr.second) == strata::core::kNotResident) miss.push_back({pr.first, pr.second}); - for (int64_t l = 0; l < g.n_layers; ++l) // pairs the profile does not list at all + if (pr.first < mirror_end && xcache.slot_of(pr.first, pr.second) == strata::core::kNotResident) + miss.push_back({pr.first, pr.second}); + for (int64_t l = 0; l < mirror_end; ++l) // pairs the profile does not list at all for (int64_t e = 0; e < g.n_expert; ++e) if (xcache.slot_of(l, e) == strata::core::kNotResident && std::find(miss.begin(), miss.end(), std::pair{l, e}) == miss.end())