Multi-GPU visibility causes overhead in single-GPU workloads
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 456
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 165
Description
Required prerequisites
- Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
- If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug
State Vector, Tensor Network and MPS backends have a delay proportional to the number of available GPUs, even when running CUDA-Q code on a single GPU.
Steps to reproduce the bug
Run a new container, assigning 1 GPU:
docker run -it --gpus 1 --rm nvcr.io/nvidia/nightly/cuda-quantum:cu12-0.11.0
Create ghz.cpp:
#include <cudaq.h>
struct ghz {
auto operator()(const int N) __qpu__ {
cudaq::qvector q(N);
h(q[0]);
for (int i = 0; i < N - 1; i++) {
x<cudaq::ctrl>(q[i], q[i + 1]);
}
mz(q);
}
};
int main(int argc, char *argv[]) {
int qubits_count = 2;
if (argc > 1) {
qubits_count = atoi(argv[1]);
}
auto counts = cudaq::sample(1000, ghz{}, qubits_count);
counts.dump();
return 0;
}
Compile it with:
nvq++ ghz.cpp --target nvidia -o nvidia.out
nvq++ ghz.cpp --target tensornet -o tensornet.out
nvq++ ghz.cpp --target tensornet-mps -o tensornet-mps.out
Observe the execution times with time ./nvidia.out and so on.
Rerun the previous steps inside a container with more GPUs available:
docker run -it --gpus 8 --rm nvcr.io/nvidia/nightly/cuda-quantum:cu12-0.11.0
On a DGX B200 node, I get around 0.9s when assigning 1 GPU to the container and 8s when assigning all 8 GPUs. The issue also occurs when assigning a different number of GPUs to the container, with the delay increasing as the number of GPUs increases.
Expected behavior
The presence of multiple GPUs should not cause delays when emulating quantum code on a single GPU. Ideally, this delay should be shorter even during multi-GPU execution (8s are not negligible in a 8 GPUs GHZ emulation that takes 16s to finish).
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA-Q version: nvcr.io/nvidia/nightly/cuda-quantum:cu12-0.11.0
- Operating system: Ubuntu 24.04.2 LTS
- Driver version: 570.124.06
Suggestions
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the delay with the provided ghz.cpp, nvq++ commands, and Docker GPU assignments, then inspect initialization and GPU-discovery paths for the State Vector, Tensor Network, and MPS backends. Done means single-GPU execution time is not proportional to the number of visible GPUs, with the supplied workload and timing commands providing the comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, docker
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100