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

Releasing qsim_mgpu source on GitHub instead of only binaries the Docker container #106

Open
basnijholt opened this issue Dec 7, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@basnijholt
Copy link

basnijholt commented Dec 7, 2023

Dear cuQuantum developers,

After long struggles in trying to get qsim to compile with multi-GPU support, I found out that one cannot accomplish this using stock qsim. IMO this wasn't very clear from the documentation.

Ultimately, I found out by running the NVIDIA cuQuantum Appliance Docker container and checking the git diff --no-index between the original qsim_simulator.py and the ~/conda/envs/cuquantum-23.10/lib/python3.10/site-packages/qsimcirq/qsim_circuit.py file in the Docker container.

It turns out that this changed version uses a module qsim_mgpu which appears to be unavailable outside the said Docker container.

Unfortunately, my current software stack cannot integrate Docker containers (we need full control over the entire environment), yet the multi-GPU support offered by qsim_mgpu is essential for our work. We would greatly benefit from the ability to compile qsim_mgpu independently.

Could you please consider releasing the modified qsim code/fork with qsim_mgpu for standalone use? This would be immensely beneficial for us and potentially for others in the community facing similar challenges.

If there are reasons for keeping this code exclusive to the Docker environment, understanding them could help us explore alternative solutions.

Tagging the core maintainers: @leofang @ahehn-nv @mtjrider @Takuma-Yamaguchi

@basnijholt basnijholt changed the title Releasing qsim_mgpu on GitHub instead of only via the Docker container Releasing qsim_mgpu source on GitHub instead of only binaries the Docker container Dec 7, 2023
@mtjrider
Copy link
Collaborator

Unfortunately, my current software stack cannot integrate Docker containers (we need full control over the entire environment), yet the multi-GPU support offered by qsim_mgpu is essential for our work. We would greatly benefit from the ability to compile qsim_mgpu independently.

@basnijholt can you clarify your needs/requirements surrounding the following statement?
... my current software stack cannot integrate Docker containers (we need full control over the entire environment) ...

The default user within the container is a member of the sudo group. It should be possible to configure the environment however you want (or to build an entirely new image).

From the software section of the NGC landing page:


Default user environment

The default user in the container is cuquantum with user ID 1000. The cuquantum user is a member of the sudo group. By default, executing commands with sudo using the cuquantum user requires a password which can be obtained by reading the file located at /home/cuquantum/.README formatted as {user}:{password}.

To acquire new packages, we recommend using conda install -c conda-forge ... in the default environment (cuquantum-23.10). You may clone this environment and change the name using conda create --name {new_name} --clone cuquantum-23.10. This may be useful in isolating your changes from the default environment.

CUDA is available under /usr/local/cuda, a symbolic directory managed by update-alternatives. To query configuration information, use update-alternatives --config cuda.

@mtjrider mtjrider self-assigned this Feb 12, 2024
@mtjrider mtjrider added enhancement New feature or request question Further information is requested labels Feb 12, 2024
@basnijholt
Copy link
Author

basnijholt commented Feb 12, 2024

Thanks for your reply @mtjrider!

The main problem is that I would like to install a fully locked environment from a conda-lock.yml file and this is just not possible.

Installing the precise versions of the packages we require, requires surgical interventions like removing all packages except qsim and any packages it's built with (like numpy). Then we need to maintain a requirements file that hard pins exactly the numpy and Python versions (perhaps other hard linked packages?) used in the cuQuantum Appliance.

I just tried to download nvcr.io/nvidia/cuquantum-appliance to count the number of dependencies but the repo is down currently (another reason why separate distribution would be great).

Other reasons why this Docker route is suboptimal:

  • We require a different Python version
  • We require a different numpy version (which cannot be changed because qsim is compiled wrt the numpy in the image)
  • We prefer to use micromamba over conda
  • We would like to use our own base images when building Docker images
  • It is not possible to test wrt different Python versions

Finally, another problem is that the Qiskit version that is shipped inside the cuQuantum Appliance 23.10 is broken and does not run noisy simulations correctly.

Verify with the following snippet. (Click to expand)
import qiskit
import qiskit_aer

# Build circuit
qc = qiskit.QuantumCircuit(1)
qc.x(0)
qc.measure_all()

# Build noise model
noise_model = qiskit_aer.noise.NoiseModel()
noise_model.add_all_qubit_quantum_error(qiskit_aer.noise.depolarizing_error(1.0, 1), ['x'])

# Simulate circuit with noise
sim = qiskit_aer.AerSimulator(method='statevector', device='GPU')
job = sim.run(qc, shots=1024, noise_model=noise_model)
counts = job.result().get_counts()
print(f"Measured counts {counts}.\nExpected result is a roughly even mixture between 0 and 1.")

which, in the cuQuantum container, yields

Measured counts {'1': 1024}.
Expected result is a roughly even mixture between 0 and 1.

All of the above described issues are easily resolved when just publishing NVIDIA's fork of qsim, which allows installing it like any other package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants