Skip to content

xpu: ask Level Zero for the driver and device counts before the lists - #1672

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jschmied:xpu-enum
Nov 1, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jschmied:xpu-enum

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

Problem

context.enumerate and ze.Gpu.open called zeDriverGet and zeDeviceGet once, with the count preset to the array size (8). On WSL2 with an Iris Xe (Level Zero loader 1.16, NEO 23.43), the loader returned that count unchanged and filled the slots past the real devices with null handles. zeDeviceGetProperties on the first null handle then crashed tensorfold-xpu devices and every test that opens a device.

Change

Both enumerations now follow the Level Zero pattern:

  • ask for the count with a null list;
  • clamp it to the array;
  • fetch the list;
  • skip any null handle.

No other behaviour changes.

Checks

  • Iris Xe, WSL2: before, tensorfold-xpu devices crashed; after, it lists the one device. The SPIR-V build for tgllp still stops at nem_attn_dec.cl (DPAS); the follow-up PR handles that.
  • Spark, no Intel GPU: lean check reports no new findings; zig build test, the contract, golden, security and fuzz steps pass; git diff --check is clean.

jschmied and others added 2 commits November 1, 2026 02:33
zeDriverGet and zeDeviceGet were called once with a preset count of 8. On WSL2 with an Iris Xe (loader 1.16, NEO 23.43) the loader left the count as asked and filled the rest with null handles, and zeDeviceGetProperties on a null handle crashed. Both enumerations (context.enumerate and Gpu.open) now query the count first, clamp it to the array, and skip null handles.
@ashhart
ashhart merged commit d08c759 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

ashhart commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Thanks @jschmied! The Level Zero device listing fix, so tensorfold-xpu devices no longer crashes on WSL2 with an Iris Xe, is in 1.2.1: https://github.com/ashhart/TensorFold/releases/tag/v1.2.1

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