Repository navigation
tensornet-mps backend is slower than tensornet? #3388
Replies: 1 comment
|
This result is actually not as surprising as it looks, and in many CUDA-Q workloads it’s fairly common to see tensornet-mps slower than tensornet, especially for small-to-medium circuit sizes like 17–97 qubits. Let’s break it down. 1. Key misunderstanding: MPS is not always fasterIt’s natural to assume:
But in practice: Tensornet (TN)
Tensornet-MPS
👉 So MPS is not a “free speedup backend” 2. Why MPS is slower in your case (very likely causes)✔ (A) Circuits still too entangledSurface codes are:
For distances 3 → 7:
👉 Result: MPS loses its advantage ✔ (B) Overhead dominates at 17–97 qubitsMPS has fixed costs:
For small-to-mid systems:
✔ (C) GPU utilization mismatchTensorNet:
MPS:
👉 So even on RTX 3090, MPS can underperform 3. Why tuning CUDAQ_MPS_* did nothingYou mentioned: These only affect:
They do NOT fundamentally change:
So:
4. When MPS should be fastertensornet-mps wins when: ✔ deep circuits Typical examples:
5. Why TensorNet wins hereYour workload:
👉 This is actually ideal for TensorNet GPU contraction, not MPS So TensorNet benefits from:
6. Likely conclusionYour observation:
is expected because:
7. Debug steps (if you want to confirm)✔ Check bond dimension growthIf MPS bond dimension grows close to:
→ MPS loses advantage ✔ Profile kernel time (Nsight Systems)Look for:
✔ Compare FLOP vs overhead ratioTensorNet:
MPS:
8. Final answer
If you want, I can also help you:
If this answer helped or pointed you in the right direction, I'd appreciate it if you could mark it as the accepted answer so it's easier for others with the same issue to find. Also, if you found my contribution useful, I'd appreciate it if you could check out my GitHub profile, follow me, and star any repositories you find interesting. GitHub: https://github.com/Advait251206 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
The problem
I have performed some CudaQ tests involving surface codes for quantum error correction using C++ CudaQ frontend. I run kernels for surface code distance 3 codes (17 qubits), code distance 5 (49 qubits) and code distance 7 (97 qubits) using
tensornetandtensornet-mpsbackend, a sample code is attached below. All the backends managed to finish the computation for distances 3 and 5, the fp32 versions were faster than fp64 as expected, but I got surprising results regarding the overall running times:tensornet-mpsbackend worked slower than thetensornetbackend in all tests.And more: I tweaked
CUDAQ_MPS_{MAX_BOND,ABS_CUTOFF,RELATIVE_CUTOFF}parameters specified on the tensornet-mps backend page in a hope to gain some speed for a precision, but saw no improvement.Expected results
I expected the
tensornet-mpsbackend to work faster thantensornetat the cost of a lower simulation precision. Therefore, I suspect that either I made some obvious configuration error, ortensornet-mpsdoes not work properly. What do you think? What next steps are possible to debug the problem?Versions
nvcr.io/nvidia/quantum/cuda-quantum:cu12-0.10.0NVIDIA-SMI 575.64.03 Driver Version: 575.64.03 CUDA Version: 12.9NVIDIA GeForce RTX 3090CUDA-Q Version cu12-0.10.0 (https://github.com/NVIDIA/cuda-quantum 857dd2ce0a783c32416af8fba8664ff30f9ddc47)Sample program
Below I provide the sample program for code distance=5 (file circuit.cpp) and the build instructions (file build.sh).
cudaq-sample-d5.zip
All reactions