Nobisuke
Dekisugi
RAG
Privacy policy
2024/08/08 12:35
Hello,
While I was working during the day, I thought I heard a voice saying,
"Use AMD's GPU!"
So, I decided to give it a try.
Shoya Yasuda is managing a solver called TYTAN.
Since pyqubo has not been maintained recently, we decided to create a maintained QUBO solver with volunteers. Additionally, QUBO solvers are quite expensive, so we made it open-source and GPU-compatible to enable large-scale calculations.
This time, I adapted the solver that was previously compatible with NVIDIA GPUs to work with AMD GPUs. Instead of CUDA, we use ROCm.
For this experiment, I used a Ryzen 9 5950X CPU and a consumer-grade RX 7900 XTX GPU.
# Check if ROCm is available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Create a 10000x10000 upper triangular matrix
matrix = torch.triu(torch.rand((10000, 10000), dtype=torch.float32)).to(device)
# Create a binary vector of length 10000
binary_vector = torch.randint(0, 2, (10000,), dtype=torch.float32).to(device)
...
# Display the result
print(result)
tensor(6344590.5000, device='cuda:0')
It was incredibly fast.
print(qubo)
print(x)
tensor([[0.6717, 0.2371, 0.3101, ..., 0.5782, 0.7420, 0.1201],
[0.0000, 0.1776, 0.7430, ..., 0.5994, 0.1445, 0.1131],
[0.0000, 0.0000, 0.4777, ..., 0.9339, 0.5034, 0.7254],
...,
[0.0000, 0.0000, 0.0000, ..., 0.1156, 0.8715, 0.9204],
[0.0000, 0.0000, 0.0000, ..., 0.0000, 0.5723, 0.5254],
[0.0000, 0.0000, 0.0000, ..., 0.0000, 0.0000, 0.6098]],
device='cuda:0')
tensor([0., 0., 0., ..., 0., 0., 1.], device='cuda:0')
It looks like it worked.
print(len(qubo))
print(len(x))
10000
10000
We successfully solved a 10,000-qubit problem.
Similarly, I tried solving a HOBO problem, and although it takes more time due to its complexity, it worked as well:
tensor([[[3.4074e-01, 2.3801e-01, 7.2555e-01, ..., 5.7089e-01,
9.3300e-01, 9.4946e-01],
[4.5312e-01, 6.0727e-02, 6.4917e-01, ..., 9.2022e-01,
4.8904e-01, 7.7863e-01],
[4.8968e-01, 1.3415e-01, 1.3029e-01, ..., 1.3355e-01,
3.1534e-01, 1.4187e-01],
...,
[8.1578e-01, 4.4324e-01, 6.7385e-01, ..., 4.7309e-01,
8.9954e-01, 1.3278e-01],
[3.1411e-01, 6.2912e-01, 3.0486e-01, ..., 7.0183e-01,
2.1883e-01, 4.6304e-01],
[2.8279e-01, 2.7991e-01, 3.7780e-01, ..., 8.6366e-01,
1.0008e-01, 4.9714e-01]],
[[3.6964e-02, 4.8730e-01, 3.2427e-01, ..., 7.9467e-01,
7.8272e-01, 7.5983e-01],
[7.0970e-01, 2.3678e-01, 2.4753e-02, ..., 7.0028e-01,
2.4440e-01, 1.1518e-02],
[6.3244e-01, 8.4304e-01, 9.5919e-01, ..., 6.2282e-01,
4.0956e-01, 4.5244e-01],
...,
[4.4514e-01, 4.7023e-01, 5.3170e-02, ..., 5.9058e-02,
6.1356e-01, 9.7442e-01],
[1.7204e-02, 6.4554e-01, 4.0960e-01, ..., 4.3088e-01,
6.7305e-01, 7.0740e-01],
[5.8251e-01, 4.6846e-01, 7.5960e-01, ..., 7.6140e-01,
8.1435e-01, 1.9587e-01]],
[[1.1972e-01, 1.0914e-01, 4.9694e-01, ..., 9.5165e-01,
4.4203e-01, 3.6698e-01],
[3.1464e-01, 6.1380e-01, 1.2407e-01, ..., 3.7007e-01,
7.6723e-02, 3.5921e-01],
[1.1962e-01, 5.5726e-01, 1.7458e-01, ..., 4.3072e-01,
7.2724e-01, 3.4609e-01],
...,
[7.7374e-01, 7.4722e-02, 3.7408e-01, ..., 2.1651e-01,
4.6314e-01, 7.4453e-02],
[7.3573e-01, 6.9235e-01, 4.4228e-01, ..., 5.4889e-01,
6.1121e-01, 9.5530e-01],
[3.2142e-01, 5.7895e-02, 3.3993e-01, ..., 4.1517e-02,
8.8431e-01, 9.4296e-01]],
...,
[[4.0457e-01, 2.8757e-01, 5.4801e-01, ..., 1.0961e-01,
7.2955e-01, 1.9745e-01],
[8.9825e-01, 1.0816e-01, 6.0176e-01, ..., 3.0971e-01,
7.8467e-01, 4.8715e-01],
[9.9333e-01, 1.5634e-01, 9.9381e-01, ..., 8.3018e-01,
6.3215e-01, 1.2996e-01],
...,
[6.1138e-01, 7.5022e-01, 5.3412e-01, ..., 7.2379e-01,
1.9942e-01, 7.2978e-02],
[6.0287e-01, 7.0418e-01, 2.6854e-01, ..., 7.5977e-02,
1.3940e-01, 2.4227e-01],
[3.3239e-01, 4.3019e-01, 6.400
8e-01, ..., 5.2265e-01,
1.2314e-01, 9.3854e-01]],
[[9.4510e-01, 5.6508e-01, 3.4954e-01, ..., 8.2149e-01,
9.1106e-01, 2.4986e-04],
[9.9170e-01, 2.9942e-01, 5.7906e-01, ..., 4.9604e-01,
2.4864e-01, 2.2348e-01],
[3.3026e-01, 4.4755e-01, 2.5998e-01, ..., 4.6217e-01,
5.0340e-01, 4.0357e-01],
...,
[1.9716e-01, 2.9640e-02, 5.8540e-01, ..., 4.8116e-01,
2.9869e-01, 6.4445e-01],
[3.0518e-01, 2.6747e-01, 6.4220e-02, ..., 9.0268e-01,
7.4376e-02, 8.2438e-01],
[1.4391e-01, 2.9811e-01, 8.7411e-01, ..., 9.6410e-01,
5.4904e-01, 3.1477e-01]],
[[4.7378e-01, 5.8130e-01, 5.5962e-01, ..., 7.8212e-02,
2.1484e-01, 1.6522e-01],
[9.0710e-01, 2.7738e-01, 9.7132e-01, ..., 3.2095e-01,
2.7935e-01, 3.4490e-01],
[6.5868e-02, 3.0124e-01, 3.8631e-01, ..., 8.2379e-01,
8.5930e-01, 9.4988e-01],
...,
[9.0615e-01, 6.0957e-02, 8.0838e-02, ..., 1.1742e-01,
9.3179e-02, 3.6622e-01],
[7.0447e-01, 1.2479e-01, 6.1637e-01, ..., 8.9149e-01,
2.5499e-01, 4.4584e-01],
[7.3772e-01, 3.1814e-01, 6.3537e-01, ..., 1.2058e-01,
1.6863e-01, 1.1854e-01]]], device='cuda:0')
There were no issues using AMD. That’s all.
© 2024, blueqat Inc. All rights reserved