Native Windows Intel GPU detection - #17
Draft
offbyonebit wants to merge 1 commit into
Draft
Conversation
detect_gpus() previously walked /sys/bus/pci/devices, so on Windows it returned an empty list and `arc-llama init` dead-ended with "Windows auto-detection is not supported yet". PR #11 made paths, the launcher and the CLI Windows-safe but never touched hardware discovery, so Windows users could install the package and then had nowhere to go. detect_gpus() now dispatches by platform. The Windows path enumerates Intel display adapters from the registry, reads bus/device/function from cfgmgr32 numeric device-node properties, and takes VRAM from the display-class HardwareInformation.qwMemorySize value, falling back to the existing device-ID table. Device IDs are parsed out of PNP instance strings so the arch_for_device_id() table keeps working unchanged. Two deliberate choices worth calling out: pci_slot is a config key that has to survive reboots, so it is synthesised as the same 0000:bb:dd.f string the Linux path produces rather than any enumeration index. Configs stay readable and portable across platforms. Bus/device/function come from the numeric cfgmgr32 properties, not from parsing the LocationInformation string. That string is written by the PCI bus driver and can be localized, so an English-only parse would silently find zero GPUs on a German or Japanese install. The string parse is kept only as a last-resort fallback and notes when it is used. No COM: VRAM is not read through DXGI. Hand-rolled COM vtable dispatch via ctypes turns a wrong offset into an access violation that no try/except can catch, which would break this module's rule that detection degrades rather than raises. sycl_index remains best-effort. Level Zero enumeration order on Windows is not documented to follow PCI order, so it is probed from sycl-ls when available and otherwise guessed from PCI order with a note telling the user to override. This is the known-weak spot for multiple identical cards and needs hardware confirmation. Tests are fixture-driven with the Windows calls monkeypatched so they run on Linux and on GitHub's windows-latest runners, neither of which has an Intel GPU. Linux detection is unchanged and still covered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
detect_gpus()walked/sys/bus/pci/devices, so on Windows it returned[]andarc-llama initexited with "Windows auto-detection is not supported yet". #11 made paths, the launcher and the CLI Windows-safe but never touched hardware discovery, so a Windows user couldpip install arc-llamaand then had nowhere to go.The Intel Arc community skews heavily Windows, so the people most likely to adopt this currently cannot run it.
What
detect_gpus()now dispatches by platform. The Windows path:HardwareInformation.qwMemorySize, falling back to the existing device-ID tablearch_for_device_id()works unchangedLinux detection is untouched.
Design notes
pci_slotis synthesised as the same0000:bb:dd.fstring Linux produces, not an enumeration index. It is a config key that has to survive reboots, and this keeps configs portable across platforms.Location comes from numeric properties, not the
LocationInformationstring. That string is written by the PCI bus driver and can be localized, so an English-only parse would silently find zero GPUs on a German or Japanese install. It is kept only as a last-resort fallback, and notes when used.No COM. VRAM is deliberately not read via DXGI. Hand-rolled COM vtable dispatch through
ctypesturns a wrong offset into an access violation that notry/exceptcan catch, which would break this module's rule that detection degrades rather than raises.Known weak spot:
sycl_indexLevel Zero enumeration order on Windows is not documented to follow PCI order. It is probed from
sycl-lswhen present, otherwise guessed from PCI order with a note telling the user to override. For two identical cards this is the thing most likely to be wrong, and a wrong mapping silently sends work to the wrong GPU.Needs confirmation on real hardware
Neither maintainer machine nor CI has an Intel GPU on Windows, so these are unverified:
CM_DRP_ADDRESSpacks device in the high 16 bits and function in the low 16. Confirm the synthesised slot matches the physical slot in Device Manager / GPU-Z (detect.py:157){hw_id}\{inst_id}device-instance ID format is whatCM_Locate_DevNodeWexpects (detect.py:282)sycl-lsbracket format across oneAPI versions (detect.py:502)sycl_indexactually match the Level Zero ordinal? See Test multi-GPU swap policy on a 2+ Arc system #2Testing
Fixture-driven with the Windows calls monkeypatched, so they run on Linux and on
windows-latest, neither of which has an Intel GPU. 24 detect tests pass, ruff clean.Draft until someone with a Windows Arc box confirms the checklist above.
🤖 Generated with Claude Code