Comfy-Org / Comfy-Org/Comfy-Desktop
selectPrimaryGpu: prefer discrete over integrated GPU on same-vendor systems
- Dominant language
- TypeScript
- Stars
- 458
- Forks
- 59
- Avg merge
- 22h 18m
- Merged PRs (30d)
- 45
Description
## Background
`selectPrimaryGpu()` (in `src/main/lib/gpu.ts`) picks the promoted "primary" GPU for `system_info` telemetry by: dropping virtual adapters, filtering to the PCI-detected vendor, then **breaking ties on VRAM (highest wins)**.
This is correct for the common case (e.g. NVIDIA dGPU + Intel iGPU) because vendor filtering removes the iGPU from the pool. But there is an edge case where it could mis-select an integrated GPU over a dedicated one:
- **Same-vendor dGPU + iGPU** — e.g. an AMD APU (integrated) alongside an AMD discrete GPU, or an Intel Arc discrete GPU alongside an Intel iGPU. Both controllers match the detected vendor, so selection falls to the VRAM tie-break.
- **No detected vendor / no vendor match** — falls back to "highest-VRAM non-virtual", which could be the iGPU.
If `systeminformation` ever reports an iGPU's shared system memory as larger than the dGPU's dedicated VRAM, the tie-break would pick the iGPU.
## Why this is low priority
- iGPU VRAM via `systeminformation` is usually the small BIOS UMA carveout (128MB–2GB), not the full shared memory, so a dGPU normally still wins.
- On Windows, `Win32_VideoController.AdapterRAM` is a uint32 capped at 4GB, so VRAM values are unreliable anyway.
- **The authoritative signal is already covered**: `comfyui_gpu_model` / `comfyui_gpu_vram_gb` (from the ComfyUI log scraper in `hardwareTap.ts`) report the device PyTorch actually selected — CUDA/ROCm target the dGPU — so the compute GPU person properties are immune to this. `system_info.gpu_model` is best-effort.
## Proposed work
Add a "prefer discrete over integrated" tie-break to `selectPrimaryGpu()` so same-vendor dGPU+iGPU systems favor the dGPU. Open questions to resolve first:
- A reliable iGPU-detection heuristic is non-trivial. Naive model-name matching (`UHD Graphics`, `Iris`, `Radeon Graphics`/APU naming, `Vega ... Graphics`) is fragile and risks false positives/negatives, especially as new products ship. **We are not yet confident the heuristic would be valid**, which is why this is deferred.
- Consider alternative signals: PCI device class, presence in `lspci` as VGA vs 3D controller, or cross-referencing the ComfyUI-reported compute device.
## Acceptance criteria
- `selectPrimaryGpu()` prefers a discrete GPU over an integrated one when both share the detected vendor.
- Unit tests cover the AMD APU + AMD dGPU and Intel iGPU + Intel Arc cases.
- No regression for the common NVIDIA-dGPU-plus-iGPU case.
Follow-up from #1165.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/main/lib/gpu.ts at selectPrimaryGpu() and trace how vendor filtering and VRAM tie-breaking currently work. Resolve which reliable signal distinguishes discrete from integrated GPUs, then add coverage for AMD APU plus AMD discrete, Intel iGPU plus Intel Arc, and the existing NVIDIA case; done means the acceptance criteria hold without regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100