Commit ae36aabc authored by Gopalakrishnan Meena, Murali's avatar Gopalakrishnan Meena, Murali
Browse files

Major update - for GPU install and full instruction

parent 49607675
Loading
Loading
Loading
Loading
+188 −158
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an

## Step 1: Install packages

1. Create custom conda environment with the Qiskit libraries. Based on steps in [OLCF Docs](https://docs.olcf.ornl.gov/quantum/quantum_software/hybrid_hpc.html#qiskit), but see below for some specific notes for the qiskit versions we use:
Create custom conda environment with the Qiskit libraries. Based on steps in [OLCF Docs](https://docs.olcf.ornl.gov/quantum/quantum_software/hybrid_hpc.html#qiskit), but see below for some specific notes for various machines we use:

<details><summary>Notes for Andes:</summary>

* Make sure to install your custom env in either `/ccs` or `/lustre/orion` (recommended). This is required to seamlessly run the plotting routines on OLCF JupyterLab.
@@ -44,23 +45,22 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
```
</details>

      * Since the QLSA circuit generator ([HHL](https://github.com/anedumla/quantum_linear_solvers)) uses an older qiskit version requiring qiskit-terra, we need to make two envs: (1) to generate the circuit and (2) to run the circuit using qiskit 1.0
      1. Install libraries to generate circuit
            * Make custom conda env
Since the QLSA circuit generator ([HHL](https://github.com/anedumla/quantum_linear_solvers)) uses an older qiskit version requiring qiskit-terra, we need to make two envs: (1) to generate the circuit and (2) to run the circuit using qiskit 1.0

### 1.1 Install libraries to generate the HHL circuit
1. Make custom conda env
      ```
      conda create --name qlsa-circuit python=3.11
      conda activate qlsa-circuit
      ```
            * Install qiskit and [linear solver](https://github.com/anedumla/quantum_linear_solvers) package
2. Install qiskit and [linear solver](https://github.com/anedumla/quantum_linear_solvers) package
      ```
      pip install -r requirements_circuit.txt --no-cache-dir
      ```
            * Test [linear solver package](https://github.com/anedumla/quantum_linear_solvers): [`test_linear_solver.py`](test_linear_solver.py)

3. Test [linear solver package](https://github.com/anedumla/quantum_linear_solvers): [`test_linear_solver.py`](test_linear_solver.py)
      ```
      python test_linear_solver.py -nq 2
      ```
                  
      <details><summary>Sample output from the test code:</summary>
      
      ```
@@ -119,24 +119,55 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
      ===========Data not saved===========
      ```
      </details>
4. Install GPU version of Aer simulator (skip for Frontier):
      ```
      pip install qiskit-aer-gpu==0.14.2 --no-cache-dir
      ```
      <details><summary>Notes for Perlmutter:</summary>

      * Need to manually set `LD_LIBRARY_PATH`
      ```
      source init_perlmutter_circuit.sh
      ```
      Or
      ```
      export LD_LIBRARY_PATH=/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-circuit/lib/python3.11/site-packages/nvidia/cuda_runtime/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-circuit/lib/python3.11/site-packages/cuquantum/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-circuit/lib/python3.11/site-packages/cutensor/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-circuit/lib/python3.11/site-packages/nvidia/nvjitlink/lib:$LD_LIBRARY_PATH
      ```
      </details>

      * **NOTE:** Make sure to test the installation:
      ```
      python -c "from qiskit_aer import AerSimulator; simulator = AerSimulator(); print(simulator.available_devices())"
      ```
      * with the sample code provided: [`test_gpu.py`](test_gpu.py)

      2. Install libraries to run the circuit
            * Make custom conda env
      ```
      python test_gpu.py -nq 2 --gpu
      ```
      <details><summary>Sample output from the test code:</summary>

      ```
      Simulator: aer_simulator_statevector_gpu
      N qubits: 2; GPU: True; multiple-GPU: False;
      Time elapsed 1:  0 min 0.49 sec
      Time elapsed 2:  0 min 0.01 sec
      ```
      </details>

### 1.2 Install libraries for the solver used to run the HHL circuit
1. Make custom conda env
      ```
      conda create --name qlsa-solver python=3.11
      conda activate qlsa-solver
      ```
            * Install qiskit and other packages
2. Install qiskit and other packages
      ```
      pip install -r requirements_solver.txt --no-cache-dir
      ```

            * Test qiskit installation: [`test_qiskit_installation.py`](test_qiskit_installation.py)

3. Test qiskit installation: [`test_qiskit_installation.py`](test_qiskit_installation.py)
      ```
      python test_qiskit_installation.py -backtyp ideal
      ```

      <details><summary>Sample output from the test code:</summary>

      ```
@@ -156,21 +187,19 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
      
      * Change `-backtyp` for different backends.      
      * **NOTE:** To run using IBM Provider, you need to add your IBM Quantum Computing API KEY and instance to the `keys.sh` file and source activate it.

2. Install GPU version of Aer simulator (skip for Frontier):

4. Install GPU version of Aer simulator (skip for Frontier):
      ```
    pip install qiskit-aer-gpu==0.14.2 --no-cache-dir
      pip install qiskit-aer-gpu==0.15.1 --no-cache-dir
      ```
      <details><summary>Notes for Perlmutter:</summary>

      * Need to manually set `LD_LIBRARY_PATH`
      ```
      source init_perlmutter.sh
      source init_perlmutter_solver.sh
      ```
      Or
      ```
      export LD_LIBRARY_PATH=/global/common/software/m4454/env_muraligm/envs/qlsa-solver/lib/python3.11/site-packages/nvidia/cuda_runtime/lib:/global/common/software/m4454/env_muraligm/envs/qlsa-solver/lib/python3.11/site-packages/cuquantum/lib:/global/common/software/m4454/env_muraligm/envs/qlsa-solver/lib/python3.11/site-packages/cutensor/lib:/global/common/software/m4454/env_muraligm/envs/qlsa-solver/lib/python3.11/site-packages/nvidia/nvjitlink/lib:$LD_LIBRARY_PATH
      export LD_LIBRARY_PATH=/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-solver/lib/python3.11/site-packages/nvidia/cuda_runtime/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-solver/lib/python3.11/site-packages/cuquantum/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-solver/lib/python3.11/site-packages/cutensor/lib:/global/cfs/cdirs/m4454/muraligm/QC/OLCF-QCFD/qlsa-scaling/envs/qlsa-solver/lib/python3.11/site-packages/nvidia/nvjitlink/lib:$LD_LIBRARY_PATH
      ```
      </details>

@@ -194,7 +223,6 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
      ```
      </details>


### Step 2: Run Scripts

1. Start interactive job
@@ -267,6 +295,11 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
      ```
      srun -N1 -n1 -c2 python circuit_HHL.py -case [case-name] -casefile [case-var-file] --savedata
      ```

4. Once you have the circuit saved, you can run the solver (make sure to deactivate circuit env and activate solver env)
      ```
      srun -N1 -n1 -c2 python solver.py -case [case-name] -casefile [case-var-file] -s [shots]
      ```
      <details><summary>Sample output for Hele-Shaw flow, solving for pressure:</summary>

      ```
@@ -371,9 +404,6 @@ All developments were done on [OLCF Andes](https://docs.olcf.ornl.gov/systems/an
      ```
      </details>

      * Fidelity: 99.91% (96.8% reported by [Bharadwaj & Srinivasan (2020)](https://www.sto.nato.int/publications/STO%20Educational%20Notes/STO-EN-AVT-377/EN-AVT-377-01.pdf))
      * Takes approximately 140 mins to run this script on Andes batch node.

# Jupyter notebooks for visualizing results

See the following Jupyter notebooks for: