Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accelerate MPS simulator by using cuQuantum #2112

Open
doichanj opened this issue May 1, 2024 · 6 comments · May be fixed by #2168
Open

Accelerate MPS simulator by using cuQuantum #2112

doichanj opened this issue May 1, 2024 · 6 comments · May be fixed by #2168
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@doichanj
Copy link
Collaborator

doichanj commented May 1, 2024

What is the expected behavior?

MPS
simulation method (https://github.com/Qiskit/qiskit-aer/tree/main/src/simulators/matrix_product_state) becomes important to simulate circuits with large number of qubits. Currently MPS simulation method only supports device=CPU and it takes long time to simulate circuits with large number of qubits.

cuQuantum (https://developer.nvidia.com/cuquantum-sdk) is a SDK for Quantum computing that accelerates simulation on NVIDIA's GPUs. cuQuantum has APIs for statevector simulation (cuStateVec) and tensor network simulation (cuTensorNet) on GPUs, and Aer currently supports cuQuantum in method=statevector and method=tensor_network but we do not have for MPS method.

MPS method can be accelerated by using cuTensorNet and there are some code examples here https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/examples.html

@doichanj doichanj added enhancement New feature or request good first issue Good for newcomers labels May 1, 2024
@MozammilQ
Copy link

anyone trying this one? :)

@Randl
Copy link

Randl commented Jun 1, 2024

So if I understand correctly, what is required is to implement additional set of MPS_Tensor methods


that utilize cuQuantum, similarly to, for example, tensor network contractor? I think it could be nice to discuss the details of architecture and design before starting tackling this issue.

For cuQuantum side, this example that uses cutensornetStateApplyTensorOperator and cutensornetStateFinalizeMPS probably should be a good place to start building the relevant routines.

@doichanj
Copy link
Collaborator Author

doichanj commented Jun 3, 2024

I think Decompose is one of the most time consuming kernel that can be accelerated by cuTensornet.

double MPS_Tensor::Decompose(MPS_Tensor &temp, MPS_Tensor &left_gamma,
rvector_t &lambda, MPS_Tensor &right_gamma,
bool mps_lapack) {
cmatrix_t C;
C = reshape_before_SVD(temp.data_);
cmatrix_t U, V;
rvector_t S(std::min(C.GetRows(), C.GetColumns()));
csvd_wrapper(C, U, S, V, mps_lapack);
double discarded_value = 0.0;
discarded_value = reduce_zeros(U, S, V, max_bond_dimension_,
truncation_threshold_, mps_lapack);
left_gamma.data_ = reshape_U_after_SVD(U);
lambda = S;
if (mps_lapack) { // When using Lapack V is V dagger
right_gamma.data_ = reshape_VH_after_SVD(V);
} else {
right_gamma.data_ = reshape_V_after_SVD(V);
}
return discarded_value;
}

There is a wrapper implementation of SVD by using LAPACK in svd.cpp I think we can add wrapper for GPU

@MozammilQ
Copy link

@Randl , I was working on this issue., and svd is my target thing since last night.
But, its true that I have to learn cuQuantum, and your previous comment shows you have a better idea of cuQuantum.
Now, who's going to do the PR.
Waiting for you comment :)
I will do as you say :)

@Randl
Copy link

Randl commented Jun 3, 2024

Go on, feel free to work on it if you're already in progress.

@MozammilQ MozammilQ linked a pull request Jun 6, 2024 that will close this issue
@MozammilQ
Copy link

There are some issues in MacOS CI test.
and, my PR is having some performance issues,
So, It would be good if my PR is not merged now.
Anyways, I will continue to work on the PR, until the performance issue is solved! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants