Loading examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/README.md 0 → 100644 +64 −0 Original line number Diff line number Diff line # TNQVM Random Circuit Run - Platform: Andes Cluster: 2 AMD EPYC 7302 16Core Processor 3.0 GHz, 16 cores (total 32 cores per node) - Modules ``` module load gcc/10.3.0 cmake/3.18.4 python/3.7-anaconda3 git/2.29.0 openblas/0.3.12-omp ``` - ExaTN build (MPI enabled) ``` CC=gcc CXX=g++ FC=gfortran cmake .. -DCMAKE_BUILD_TYPE=Release -DEXATN_BUILD_TESTS=TRUE -DBLAS_LIB=OPENBLAS -DBLAS_PATH=/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-10.3.0/openblas-0.3.12-lvqlwh4l3ywjy3fmrfcusmh2ooyt2r4b/lib -DMPI_LIB=OPENMPI -DMPI_ROOT_DIR=/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-10.3.0/openmpi-4.0.4-4gclv46mxmuq3kriamaxinzezppb7vyi -DCMAKE_INSTALL_PREFIX=/ccs/proj/phy149/Thien/.exatn ``` - XACC and TNQVM build: ``` cmake .. -DCMAKE_INSTALL_PREFIX=/ccs/proj/phy149/Thien/.xacc ``` ``` CC=gcc CXX=g++ FC=gfortran cmake .. -DCMAKE_BUILD_TYPE=Release -DXACC_DIR=/ccs/proj/phy149/Thien/.xacc -DEXATN_DIR=/ccs/proj/phy149/Thien/.exatn -DTNQVM_BUILD_TESTS=TRUE -DTNQVM_BUILD_EXAMPLES=TRUE ``` - QCOR build ``` CC=gcc CXX=g++ cmake .. -DXACC_DIR=/ccs/proj/phy149/Thien/.xacc -DLLVM_ROOT=/ccs/proj/phy149/Thien/.llvm -DMLIR_DIR=/ccs/proj/phy149/Thien/.llvm/lib/cmake/mlir -DQCOR_BUILD_TESTS=TRUE -DQCOR_EXTRA_HEADERS="/sw/andes/gcc/10.3.0/include/c++/10.3.0/x86_64-pc-linux-gnu/;/sw/andes/gcc/10.3.0/include/c++/10.3.0/" ``` - Export PATH (for qcor command-line tools) ``` export PATH=/ccs/proj/phy149/Thien/.xacc/bin:$PATH ``` - Interactive session request (2 full node for 1 hour): ``` salloc -A PHYXXX -N 2 -t 1:00:00 ``` - Run MPI: 4 tasks on 2 nodes, each uses 16 cores. ``` srun -n4 -N2 -c16 --cpu-bind=threads ./a.out -qrt nisq -qpu tnqvm -qpu-config tnqvm.ini ``` # DM-SIM Adder Circuit (GPU) - Platform: Summit. Login node: (2) 16-core Power9 CPUs and (4) V100 GPUs. Compute nodes have (2) 22-core Power9 CPUs and (6) V100 GPUs. Note: on login node, we can only use **one** GPU for testing. - Request an interactive session: ``` bsub -Is -W 1:00 -nnodes 1 -P PHYXXX $SHELL ``` Note: small jobs (e.g., single node) is low priority (w.r.t. Summit job scheduling), hence we may not be able to request an allocation for the live session. No newline at end of file examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/adder_dm_sim.qasm 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * quantum ripple-carry adder * Cuccaro et al, quant-ph/0410184 */ // Install DM-SIM plugin: // qcor -install-plugin https://github.com/ORNL-QCI/DM-Sim.git // Using DM-Sim: // qcor -linker g++ -qrt nisq adder.qasm -shots 1024 -qpu dm-sim[gpus:1] // Note: on a login node, GPU-GPU comm is disabled, hence can only run with 1 GPU. // Multi-GPU on compute node: e.g, see the bsub example: OPENQASM 3; gate ccx a,b,c { h c; cx b,c; tdg c; cx a,c; t c; cx b,c; tdg c; cx a,c; t b; t c; h c; cx a,b; t a; tdg b; cx a,b; } gate majority a, b, c { cx c, b; cx c, a; ccx a, b, c; } gate unmaj a, b, c { ccx a, b, c; cx c, a; cx a, b; } qubit cin; qubit a[4]; qubit b[4]; qubit cout; bit ans[5]; // Input values: uint[4] a_in = 1; uint[4] b_in = 15; for i in [0:4] { if (bool(a_in[i])) { x a[i]; } if (bool(b_in[i])) { x b[i]; } } // add a to b, storing result in b majority cin, b[0], a[0]; for i in [0: 3] { majority a[i], b[i + 1], a[i + 1]; } cx a[3], cout; for i in [2: -1: -1] { unmaj a[i], b[i+1], a[i+1]; } unmaj cin, b[0], a[0]; measure b[0:3] -> ans[0:3]; measure cout[0] -> ans[4]; No newline at end of file examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/random_circuit.qasm 0 → 100644 +26 −0 Original line number Diff line number Diff line OPENQASM 3; include "stdgates.inc"; const n_qubits = 50; const n_layers = 12; qubit q[n_qubits]; // Compile: qcor random_circuit.qasm // Run by: mpiexec -n <N> ./a.out -qrt nisq -qpu tnqvm -qpu-config tnqvm.ini // Loop over layers float[64] theta = 1.234; for i in [0:n_layers] { // Single qubit layers: for j in [0:n_qubits] { rx(theta) q[j]; } // For demonstration purposes, just change the // angle in each layer by adding 1.0. theta += 1.0; // Entanglement layers: for j in [0:n_qubits - 1] { cx q[j], q[j+1]; } } examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/summit_job.lsf 0 → 100644 +11 −0 Original line number Diff line number Diff line #!/bin/bash #BSUB -P <PROJECT_ID> #BSUB -W 1 #BSUB -nnodes 1 #BSUB -o out_cc.txt -e err_cc.txt module load python/3.8.10 gcc/9.3.0 cuda/11.4.0 openblas/0.3.15-omp ## "--smpiargs=-gpu" is for enabling GPU-Direct RDMA ## 4 GPUs jsrun -n4 -a1 -g1 -c1 --smpiargs="-gpu" ./a.out No newline at end of file examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/tnqvm.ini 0 → 100644 +3 −0 Original line number Diff line number Diff line tnqvm-visitor=exatn:float exatn-buffer-size-gb=2 bitstring=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] No newline at end of file Loading
examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/README.md 0 → 100644 +64 −0 Original line number Diff line number Diff line # TNQVM Random Circuit Run - Platform: Andes Cluster: 2 AMD EPYC 7302 16Core Processor 3.0 GHz, 16 cores (total 32 cores per node) - Modules ``` module load gcc/10.3.0 cmake/3.18.4 python/3.7-anaconda3 git/2.29.0 openblas/0.3.12-omp ``` - ExaTN build (MPI enabled) ``` CC=gcc CXX=g++ FC=gfortran cmake .. -DCMAKE_BUILD_TYPE=Release -DEXATN_BUILD_TESTS=TRUE -DBLAS_LIB=OPENBLAS -DBLAS_PATH=/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-10.3.0/openblas-0.3.12-lvqlwh4l3ywjy3fmrfcusmh2ooyt2r4b/lib -DMPI_LIB=OPENMPI -DMPI_ROOT_DIR=/sw/andes/spack-envs/base/opt/linux-rhel8-x86_64/gcc-10.3.0/openmpi-4.0.4-4gclv46mxmuq3kriamaxinzezppb7vyi -DCMAKE_INSTALL_PREFIX=/ccs/proj/phy149/Thien/.exatn ``` - XACC and TNQVM build: ``` cmake .. -DCMAKE_INSTALL_PREFIX=/ccs/proj/phy149/Thien/.xacc ``` ``` CC=gcc CXX=g++ FC=gfortran cmake .. -DCMAKE_BUILD_TYPE=Release -DXACC_DIR=/ccs/proj/phy149/Thien/.xacc -DEXATN_DIR=/ccs/proj/phy149/Thien/.exatn -DTNQVM_BUILD_TESTS=TRUE -DTNQVM_BUILD_EXAMPLES=TRUE ``` - QCOR build ``` CC=gcc CXX=g++ cmake .. -DXACC_DIR=/ccs/proj/phy149/Thien/.xacc -DLLVM_ROOT=/ccs/proj/phy149/Thien/.llvm -DMLIR_DIR=/ccs/proj/phy149/Thien/.llvm/lib/cmake/mlir -DQCOR_BUILD_TESTS=TRUE -DQCOR_EXTRA_HEADERS="/sw/andes/gcc/10.3.0/include/c++/10.3.0/x86_64-pc-linux-gnu/;/sw/andes/gcc/10.3.0/include/c++/10.3.0/" ``` - Export PATH (for qcor command-line tools) ``` export PATH=/ccs/proj/phy149/Thien/.xacc/bin:$PATH ``` - Interactive session request (2 full node for 1 hour): ``` salloc -A PHYXXX -N 2 -t 1:00:00 ``` - Run MPI: 4 tasks on 2 nodes, each uses 16 cores. ``` srun -n4 -N2 -c16 --cpu-bind=threads ./a.out -qrt nisq -qpu tnqvm -qpu-config tnqvm.ini ``` # DM-SIM Adder Circuit (GPU) - Platform: Summit. Login node: (2) 16-core Power9 CPUs and (4) V100 GPUs. Compute nodes have (2) 22-core Power9 CPUs and (6) V100 GPUs. Note: on login node, we can only use **one** GPU for testing. - Request an interactive session: ``` bsub -Is -W 1:00 -nnodes 1 -P PHYXXX $SHELL ``` Note: small jobs (e.g., single node) is low priority (w.r.t. Summit job scheduling), hence we may not be able to request an allocation for the live session. No newline at end of file
examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/adder_dm_sim.qasm 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * quantum ripple-carry adder * Cuccaro et al, quant-ph/0410184 */ // Install DM-SIM plugin: // qcor -install-plugin https://github.com/ORNL-QCI/DM-Sim.git // Using DM-Sim: // qcor -linker g++ -qrt nisq adder.qasm -shots 1024 -qpu dm-sim[gpus:1] // Note: on a login node, GPU-GPU comm is disabled, hence can only run with 1 GPU. // Multi-GPU on compute node: e.g, see the bsub example: OPENQASM 3; gate ccx a,b,c { h c; cx b,c; tdg c; cx a,c; t c; cx b,c; tdg c; cx a,c; t b; t c; h c; cx a,b; t a; tdg b; cx a,b; } gate majority a, b, c { cx c, b; cx c, a; ccx a, b, c; } gate unmaj a, b, c { ccx a, b, c; cx c, a; cx a, b; } qubit cin; qubit a[4]; qubit b[4]; qubit cout; bit ans[5]; // Input values: uint[4] a_in = 1; uint[4] b_in = 15; for i in [0:4] { if (bool(a_in[i])) { x a[i]; } if (bool(b_in[i])) { x b[i]; } } // add a to b, storing result in b majority cin, b[0], a[0]; for i in [0: 3] { majority a[i], b[i + 1], a[i + 1]; } cx a[3], cout; for i in [2: -1: -1] { unmaj a[i], b[i+1], a[i+1]; } unmaj cin, b[0], a[0]; measure b[0:3] -> ans[0:3]; measure cout[0] -> ans[4]; No newline at end of file
examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/random_circuit.qasm 0 → 100644 +26 −0 Original line number Diff line number Diff line OPENQASM 3; include "stdgates.inc"; const n_qubits = 50; const n_layers = 12; qubit q[n_qubits]; // Compile: qcor random_circuit.qasm // Run by: mpiexec -n <N> ./a.out -qrt nisq -qpu tnqvm -qpu-config tnqvm.ini // Loop over layers float[64] theta = 1.234; for i in [0:n_layers] { // Single qubit layers: for j in [0:n_qubits] { rx(theta) q[j]; } // For demonstration purposes, just change the // angle in each layer by adding 1.0. theta += 1.0; // Entanglement layers: for j in [0:n_qubits - 1] { cx q[j], q[j+1]; } }
examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/summit_job.lsf 0 → 100644 +11 −0 Original line number Diff line number Diff line #!/bin/bash #BSUB -P <PROJECT_ID> #BSUB -W 1 #BSUB -nnodes 1 #BSUB -o out_cc.txt -e err_cc.txt module load python/3.8.10 gcc/9.3.0 cuda/11.4.0 openblas/0.3.15-omp ## "--smpiargs=-gpu" is for enabling GPU-Direct RDMA ## 4 GPUs jsrun -n4 -a1 -g1 -c1 --smpiargs="-gpu" ./a.out No newline at end of file
examples/qcor_demos/ibm_qasm3_demo_092021/qasm3-gpu-sim/tnqvm.ini 0 → 100644 +3 −0 Original line number Diff line number Diff line tnqvm-visitor=exatn:float exatn-buffer-size-gb=2 bitstring=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] No newline at end of file