engine-gpu: fix multi-GPU detection on hybrid (discrete + integrated) systems#1
Closed
adamtpang wants to merge 1 commit into
Closed
engine-gpu: fix multi-GPU detection on hybrid (discrete + integrated) systems#1adamtpang wants to merge 1 commit into
adamtpang wants to merge 1 commit into
Conversation
On Windows, wgpu's enumerate_adapters(Backends::PRIMARY) returns every
physical GPU twice (DX12 and Vulkan), and hybrid laptops also expose the
integrated GPU. The engine previously created a context for every entry
and round-robined worker threads across them, so a miner with a discrete
NVIDIA + integrated Intel could end up doing all its work on the slow
integrated GPU.
Also, --gpu-devices N was only capping worker threads, not the number of
adapters opened, so the engine still kept handles to GPUs it didn't use.
New behavior:
* Drop DeviceType::Cpu software adapters (llvmpipe, WARP).
* Deduplicate physical GPUs across backends, keeping the most native
backend per (vendor, device, name).
* Sort by device-type rank (discrete > virtual > integrated > other).
* Auto-detect prefers discrete GPUs exclusively when any exist, and
falls back to the single best non-discrete adapter otherwise.
* --gpu-devices N now actually caps adapter initialization.
Selection logic is split into select_adapter_indices so it can be
unit-tested with synthetic AdapterInfo; 6 tests cover the hybrid-laptop,
multi-discrete, integrated-only, software-adapter, and explicit-cap
cases.
https://claude.ai/code/session_01M8TsvfAHfST4D8zTDevK4x
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.
Closing — this duplicates the core fix already in flight at Quantus-Network/quantus-miner#62 (filter
Cpuadapters, dedupe across backends, sort discrete-first).The genuinely additive bits over Quantus-Network#62 are kept on the branch
claude/nicholas-engineering-problem-rfI4rfor later cherry-picking onto the upstream branch:--gpu-devices Nnow actually caps adapter initialization (fix(gpu): filter CPU-emulated adapters and dedupe per physical GPU Quantus-Network/quantus-miner#62 marked this as a future follow-up). Requires changingGpuEngine::try_newsignature to takemax_devices: Option<usize>.select_adapter_indicesinto a pure function so the policy is unit-testable with syntheticwgpu::AdapterInfo(realwgpu::Adaptercan't be constructed without a GPU).cargo check --workspace --all-targetsandcargo clippy -- -D warningspass.https://claude.ai/code/session_01M8TsvfAHfST4D8zTDevK4x