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

Universal CPU Build Support for Qiskit Aer with CUDA and ROCm #2029

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

basnijholt
Copy link

@basnijholt basnijholt commented Jan 12, 2024

This PR introduces an update to the qiskit_aer build process, ensuring that the CPU variant of controller_wrappers is always built, alongside CUDA and ROCm variants. This ensures that builds targeting CUDA or ROCm can still operate on systems that only have CPU capabilities.

Key Changes:

  1. CPU Build as a Default: The CPU backend (controller_wrappers_cpu) is now always built. This is independent of whether CUDA (controller_wrappers_cuda) or ROCm (controller_wrappers_rocm) backends are being built.

  2. Conditional CUDA and ROCm Builds: Compilation of CUDA and ROCm backends remains conditional based on the AER_THRUST_BACKEND setting. This ensures that these backends are built only when specified, without affecting the CPU build.

  3. Organized Build Process: The build process in CMakeLists.txt is organized to handle CPU, CUDA, and ROCm backends separately. Each backend has its specific compiler flags, definitions, and dependencies, ensuring a clean and manageable build process.

This update significantly improves the flexibility and applicability of Qiskit Aer, enabling it to run on a broader range of systems, from specialized CUDA and ROCm environments to general-purpose CPU-only machines.

I my case this is useful because we distribute a single environment / container that run both on CPU and GPU machines. ATM qiskit-aer is our only dependency that doesn't allow this mode of operation.

@CLAassistant
Copy link

CLAassistant commented Jan 12, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@basnijholt basnijholt marked this pull request as ready for review January 13, 2024 03:22
IMPORTED_BACKEND = None
BACKENDS = ["cuda", "rocm", "cpu"]

for backend_suffix in BACKENDS:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could also add an environment variable to for example force the CPU implementation.

But that can be done in a followup PR.

@basnijholt
Copy link
Author

@doichanj, thanks a lot for looking at this PR!

This problem is still very annoying for us because we're maintaining 2 locked environments for CUDA and non-CUDA now. It would be awesome to be able to use one installation that works both on CPU and CUDA.

@doichanj
Copy link
Collaborator

I could not build with this PR when setting -DAER_THRUST_BACKEND=CUDA, it seems CPU build is not correctly configured and failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants