Skip to content

xpu: without Sysman (WSL2), free memory falls back to the core total (stacked on #1672) - #1691

Merged
ashhart merged 3 commits into
ashhart:mainfrom
jschmied:xpu-sysman
Nov 1, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
jschmied:xpu-sysman

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Problem

On WSL2, zesInit crashes with SIGSEGV inside Intel's driver (NEO 23.43, libze_intel_gpu.so.1).

  • strace: Sysman init tries /dev/dri/renderD128–191, which are all missing under WSL. It then opens /dev/dxg and faults at si_addr=0x100000000.
  • gdb: the crash is a libc string routine reading a bad pointer, called from the driver.
  • Cause: this NEO's Sysman has no WDDM backend. With ZES_ENABLE_SYSMAN=1 the init fails cleanly instead, but there is still no Sysman.

TensorFold calls zesInit to size a prompt cache from free memory, so a drafted engine (Nemotron with MTP) can't size its cache on WSL.

Change

  • Sysman lists: asked for their count first, and zesInit runs only when a prompt cache needs free memory.
  • ze.Gpu.memory(): calls Sysman only where /dev/dri exists or /dev/dxg does not. Native Linux (xe/i915) is unchanged.
  • Under WDDM: it returns free = size = the core total from zeDeviceGetMemoryProperties, which works on WSL: 7,428,497,408 bytes on an Iris Xe, the same as clinfo.
    • The lane host already takes min(free, size − allocated), so the budget becomes "total minus what TensorFold allocated".
    • On an iGPU the total is shared system memory, so this is an upper bound: other processes' RAM use isn't seen. Sysman wouldn't see it either under WDDM.
  • ZES_ENABLE_SYSMAN is left alone, since setting it changes zeInit on native Linux.

Checks

  • Iris Xe (WSL2):
    • tf-xpu-memory-test reports 6.92 GiB free, and 6.42 GiB after a 512 MiB allocation;
    • a server with an LFM3 prompt cache sizes it through this path: "prompt cache of 3.75 GiB (5.75 GiB free on the device)".
  • bmg: the xpu-native and xpu-tests builds still succeed. Native-Linux Sysman isn't retested; its code is unchanged apart from the count-first lists.
  • Spark: lean reports no new findings; zig build test, the contract, golden, security and fuzz steps pass; git diff --check is clean.

Stacked on #1672: without its count-first enumeration, Context.init itself crashes on this machine.

jschmied and others added 3 commits November 1, 2026 04:02
…a prompt cache needs free memory

Under WSL2 (Intel Iris Xe 0x9a49 over /dev/dxg, compute runtime 23.43.27642, Level Zero loader 1.16)
zesInit(0) segfaults inside libze_intel_gpu.so.1. tensorfold-native died at startup in ze.Gpu.memory(),
which the lane host called for the prompt cache budget even when no cache is made. The lane host now
reads free memory only for drafted engines, the only ones that keep a cache.

zesDriverGet, zesDeviceGet and zesDeviceEnumMemoryModules ask for the count first, clamp it and skip
null handles, as the core enumeration does.
…less what the process allocated

Under WSL2 the GPU is a WDDM adapter (/dev/dxg, no /dev/dri). NEO 23.43's zesInit walks
/dev/dri/renderD128..191, then opens /dev/dxg and faults inside libze_intel_gpu.so.1 (SIGSEGV at
0x100000000, an AVX-512 string compare in libc on a bad pointer), with or without
ZES_ENABLE_SYSMAN. With ZES_ENABLE_SYSMAN=1 set before zeInit, zesInit returns
ZE_RESULT_ERROR_UNINITIALIZED instead; Sysman has no WDDM backend either way.

Gpu.memory() now asks Sysman only where /dev/dri exists (or /dev/dxg does not). Elsewhere free and size
are the core total (zeDeviceGetMemoryProperties, asked with room for 8 modules: NEO answers a count
query with 0), and the lane host's freeMemory subtracts this process's allocations as before, so a
drafted engine's prompt cache is sized on WSL too. tf-xpu-memory-test asks free memory the way the
lane host does, before and after a 512 MiB allocation.
@ashhart
ashhart merged commit 62b0a3f into ashhart:main Nov 1, 2026
9 checks passed
@ashhart

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

ashhart added a commit that referenced this pull request Nov 1, 2026
ashhart added a commit that referenced this pull request Nov 1, 2026
@ashhart

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants