-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add support for AMD GPUs #619
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@jakurzak Can you please add a PR description ? @sergeisakov Can you take a look at this PR? |
Yes, I'll take a look at this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding support for AMD GPUs. I can't really test if it works or not. Nevertheless the PR looks good to me. Could you fix a few formatting issues? Could you also add some doc?
lib/vectorspace_cuda.h
Outdated
sizeof(fp_type) * Impl::MinSize(dest.num_qubits()), | ||
cudaMemcpyHostToDevice); | ||
ErrorCheck( | ||
cudaMemcpy(dest.get(), src, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a four space indent if the line breaks after (
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Thank you for taking the time to look at the PR! |
I fixed the style issues and commented on the use of HIPCC for CPU code when compiling Python bindings. |
I added basic documentation for AMD GPU support. |
Thank you. Could you replace Qsim with qsim in |
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Looks like it's getting hung up on the kokoro test. |
The cuQuantum test failed during bringup: Logs
From the logs, it's possible this was a network error. I'll re-trigger the test, but in the meantime check the logs to see if this PR could have caused the issue. |
Hmm. Doesn't look like I can re-trigger the kokoro test specifically. Could you push a commit so Github picks up on it? |
No cuQuantum support in the AMD port, BTW, as there's no AMD equivalent. |
@sergeisakov, @95-martin-orion, can you help move this forward? |
Overview
This pull request adds support for AMD Instinct GPUs.
Changes
CMakeLists.txt
Makefile
HIPCC=hipcc
andHIPCCFLAGS = -O3
variables, similarly to the existingNVCC=nvcc
andHIPCCFLAGS = -O3
variables..PHONY: qsim-hip
,.PHONY: hip-tests
, and.PHONY: run-hip-tests
sections, similarly to the existing.PHONY: qsim-cuda
,.PHONY: cuda-tests
, and.PHONY: run-cuda-tests
sections.apps/Makefile
HIP_TARGETS
wih the.hip.x
suffix from all files with the.cuda.cu
suffix, similarly to how the list ofCUDA_TARGETS
is generated..PHONY: qsim-hip
and the%hip.x: %cuda.cu
section, similarly to the existing.PHONY: qsim-cuda
and%cuda.x: %cuda.cu
sections.apps/make.sh
docs/_book.yaml
docs/tutorials/amd_gpu.md
lib/cuda2hip.h
__shfl_down_sync()
, as a wrapper around HIP's__shfl_down()
function, since the former is not currently available in HIP.lib/fuser_mqubit.h
lib/simulator_cuda_kernels.h
lib/statespace_cuda.h
cudaMemset()
.lib/statespace_cuda_kernels.h
lib/util_cuda.h
lib/vectorspace_cuda.h
cudaFree()
,cudaMemcpy()
, andcudaDeviceSynchronize()
.pybind_interface/Makefile
QSIMLIB_HIP
, similar to the existingQSIMLIB_CUDA
.pybind-gpu
anddecide-gpu
topybind-cuda
anddecide-cuda
.pybind-hip
anddecide-hip
.clean
section.pybind_interface/decide/CMakeLists.txt
HIP
as one of the project languages. The CMake file then adjusts the build process to use HIP-specific commands (hip_add_library
) and properties for compiling the relevant source files. It also includes the necessary directories and sets the module properties for creating a Python extension module with HIP support, allowing the same build system to work across both CUDA and HIP platforms depending on the available compiler.pybind_interface/decide/decide.cpp
HIP = 2
toenum GPUCapabilities
.GPUCapabilities gpu = HIP
if HIP compiler is detected.pybind_interface/hip/CMakeLists.txt
pybind_interface/hip/pybind_main_hip.cpp
pybind_interface/hip/pybind_main_hip.h
qsim_hip
using Pybind11.pybind_interface/pybind_main.cpp
circuit
,ncircuit
, andstate_space
.qsimcirq/__init__.py
qsim_decide.detect_gpu()
returns 2, import the HIP-compatible moduleqsimcirq.qsim_hip
.setup.py
import shutil
.cmake_args
list to specify hipcc as the C and C++ compiler.qsim_hip
directory contains a CMake project to be built as a Python extension with support for HIP.tests/Makefile
tests/make.sh
Building
Testing
Simulator
or
Python bindings
or