Skip to content

fix: smarter GPU detection to prefer Intel XPU over AMD iGPU#345

Draft
Kosinkadink wants to merge 1 commit into
mainfrom
fix/gpu-detection-xpu-amd-igpu
Draft

fix: smarter GPU detection to prefer Intel XPU over AMD iGPU#345
Kosinkadink wants to merge 1 commit into
mainfrom
fix/gpu-detection-xpu-amd-igpu

Conversation

@Kosinkadink

Copy link
Copy Markdown
Member

Problem

When a machine has an AMD CPU with integrated Radeon graphics (vendor 1002) and an Intel Arc discrete GPU (vendor 8086), the old pickGPU() priority (NVIDIA > AMD > Intel) incorrectly selects AMD — even though the AMD device is just an iGPU incapable of ROCm, and the user's actual compute GPU is the Intel Arc XPU.

Fixes #342

Changes

Core logic

  • pickGPU() now accepts rich GpuDevice[] with name, VRAM, and discrete/integrated info
  • New isAmdIgpu() heuristic classifies AMD GPUs using:
    • Device name patterns (e.g. "AMD Radeon(TM) Graphics" = iGPU, "RX 7900 XTX" = discrete)
    • Dedicated VRAM size (<512MB = iGPU, from Windows WMI)
    • Explicit discrete flag when available
  • Priority is now: NVIDIA > discrete AMD > Intel (XPU) > AMD iGPU > CPU

Windows

  • WMI query expanded to fetch Name + AdapterRAM per Win32_VideoController

Linux

  • lspci parser extracts device descriptions for name-based iGPU heuristics
  • sysfs reader simplified (vendor-only; lspci runs first with richer data)

Tests

  • Comprehensive unit tests for isAmdIgpu and pickGPU covering:
    • The exact bug scenario (AMD iGPU + Intel Arc → picks Intel)
    • All single-GPU cases, all multi-GPU priority combinations
    • VRAM boundary conditions, explicit discrete flag, device order independence
  • 533 tests passing, typecheck + lint + build all green

When a machine has both an AMD CPU with integrated Radeon graphics
(vendor 1002) and an Intel Arc discrete GPU (vendor 8086), the old
pickGPU() priority (NVIDIA > AMD > Intel) would incorrectly select
AMD even though the AMD device is just an iGPU incapable of ROCm.

Changes:
- pickGPU() now accepts rich GpuDevice[] with name/VRAM/discrete info
- New isAmdIgpu() heuristic classifies AMD GPUs as integrated vs discrete
  using device name patterns, VRAM size, and sysfs boot_vga attribute
- Priority is now: NVIDIA > discrete AMD > Intel (XPU) > AMD iGPU > CPU
- Windows WMI query expanded to fetch Name + AdapterRAM per controller
- Linux lspci parser extracts device descriptions for name-based heuristics
- Linux sysfs reader uses boot_vga attribute to flag integrated GPUs
- Comprehensive unit tests for isAmdIgpu and pickGPU covering the bug scenario

Fixes #342

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d2dfc-3f03-760c-b05d-f88aae3ea22e
@Kosinkadink Kosinkadink marked this pull request as draft March 28, 2026 04:06
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.

GPU detection bug - when an XPU gpu runs on a machine with an AMD CPU that has GPU cores, AMD is selected as the device

1 participant