SYCL layer split (#1440): the host mirror keeps to the first stage's layers; the fdinfo free-memory fallback only where the driver reports the whole card free

- generate.cpp: with a layer split the host mirror walked the later stages' layers too (#1054, fixed in #1111 but
  lost in the re-migration): 20 GiB of pinned RAM for experts the other card holds, or one 39 GiB pinned allocation
  that fails. Both loops stop at the first stage's last layer.
- expert_cache.cpp: device_free_bytes() subtracted the DRM bytes of every card of the process from the card it asked
  about, so on a layer split the second card was charged the first one's cache and its expert cache would not open.
  The fallback is for drivers that report the whole card as free (Arc A750/i915); it now runs only then.

Reported by crobe201 with both diffs; MaineTim confirmed the second on 2x B60.

Co-authored-by: crobe201 <273473305+crobe201@users.noreply.github.com>
This commit is contained in:
Niko1221andcrobe201 committed 2026-10-08 03:07:50 +02:00
1 parent ccd657a296
commit a85347811a
2 files changed
+11 -3

No files matched your search

+4 -1
View File
@@ -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<bool> 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);
+7 -2
View File
@@ -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<std::pair<int64_t, int64_t>> 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<int64_t, int64_t>{l, e}) == miss.end())