Internal:Quantum Information Science (QIS General): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 10: | Line 10: | ||
== Code == | == Code == | ||
=== Qiskit === | === Qiskit === | ||
==== GPU ==== | |||
Calling a GPU to execute quantum circuits is relatively straight forward. First, choose your backend. This can be ideal, noisy, or a snapshot from a real qiskit quantum device. Once you have your simulator selected, use the *set_options* method to set the device: | |||
<syntaxhighlight lang="python"> | |||
try: | |||
simulator_gpu = Aer.get_backend('aer_simulator') | |||
simulator_gpu.set_options(device='GPU') | |||
except AerError as e: | |||
print('Err:\n',e) | |||
</syntaxhighlight> | |||
When running the script on Wahab, a GPU must be allocated for this. The .sh file should look something like this: | |||
<syntaxhighlight lang="python"> | |||
#!/bin/bash | |||
#SBATCH -p gpu | |||
#SBATCH --gres gpu:1 | |||
enable_lmod | |||
module load container_env python3 | |||
crun -p ~/envs/python3.10 python3 -u ./main.py | |||
</syntaxhighlight> | |||
Revision as of 15:03, 2 May 2023
QIS General
I will use this page to keep a general progression and categorization about QIS ranging from theory to useful code.
Notebooks
QIS General
Custom built QIS notebooks (some modeled after Nielsen's lectures) can be found here[1].
Code
Qiskit
GPU
Calling a GPU to execute quantum circuits is relatively straight forward. First, choose your backend. This can be ideal, noisy, or a snapshot from a real qiskit quantum device. Once you have your simulator selected, use the *set_options* method to set the device:
try:
simulator_gpu = Aer.get_backend('aer_simulator')
simulator_gpu.set_options(device='GPU')
except AerError as e:
print('Err:\n',e)
When running the script on Wahab, a GPU must be allocated for this. The .sh file should look something like this:
#!/bin/bash
#SBATCH -p gpu
#SBATCH --gres gpu:1
enable_lmod
module load container_env python3
crun -p ~/envs/python3.10 python3 -u ./main.py