Skip to main content

Q-Gear

Project description

qgear

paper link: https://arxiv.org/pdf/2504.03967

image.png

Preliminary

  • Let’s assume you already have a computational GPU node allocated on HPC
  • Checking the NVIDIA GPU
    • nvidia-smi
  • Create a env (we do not recommend using default such .local / HOME)
  • Note that more than one GPU support need to enable MPI > the way we choose is high performance lustre file system

1. Install ENV

clone repo

git clone git@github.com:gzquse/qgear.git`

cd qgear
module load conda
conda create --prefix=/pscratch/sd/{location}/{username}/qgear -y python=3.11 pip
conda activate $SCRATCH/qgear
pip install -u qgear 
pip install -u ipykernel
python -m ipykernel install --user --name qgear --display-name qgear

test qgear install successfully

qgear

   ___     ____ _____    _    ____                                                      
  / _ \   / ___| ____|  / \  |  _ \                                                     
 | | | | | |  _|  _|   / _ \ | |_) |                                                    
 | |_| | | |_| | |___ / ___ \|  _ <                                                     
  \__\_\  \____|_____/_/   \_\_| \_\                                                    


Installation successful!

Welcome to QGEAR. Run 'qgear.run_cudaq()' to speed up.
Fun fact: We love to use Emacs! 🐧

2. Open Jupyter Notebook

NERSC jupyter

https://jupyter.nersc.gov/

Select the kernel image.png

go to nbs/example.ipynb; run example image-2.png

Pypi

https://pypi.org/project/qgear/

Demos

1. simple speed up with random circuit and QFT

https://gzquse.github.io/qgear/examples.html

2. quantum image encoding

see appendix F in the paper https://gzquse.github.io/qgear/apps.html

image.png

local development

. ./pm_martin.dev.source

# make sure qgear package is installed in development mode
https://nbdev.fast.ai/tutorials/tutorial.html
pip3 install -e '.[dev]'
pip3 install qgear

# compile to have changes apply to qgear
nbdev_prepare

Supported Quantum Gates

This is the list of quantum gates currently supported by the implementation, based on the gateId mapping.

Gate ID Gate Name Description Parameters Example Usage
1 H (Hadamard) Creates superposition by mapping ( 0) and ( 1).
2 RY rotation Rotation around the Y-axis by a given angle. angle (in radians), target qubit q0 ry(angles[j], q0)
3 RZ rotation Rotation around the Z-axis by a given angle. angle (in radians), target qubit q0 rz(angles[j], q0)
4 CX (CNOT) Controlled-X gate; flips target qubit if control qubit is ( 1). Control qubit q0, target qubit q1
5 Measure Measures the qubit in the computational basis. Target qubit q0 mz(q0) (example)
6 CP (Controlled-Phase) Applies a phase shift to the target qubit if control qubit is ( 1). angle (phase in radians), control qubit q0, target qubit q1
7 SWAP Swaps the quantum states of two qubits. Qubit q0, qubit q1 swap(q0, q1)
8 U (U3 gate) General single-qubit rotation parameterized by three Euler angles. theta, phi, lambda_ (all in radians), target qubit q0 u3(theta, phi, lambda_, q0)

Notes

  • q0 is the primary target qubit.
  • q1 is an additional target or control qubit (depending on the gate).
  • angles is an array of rotation parameters in radians.
  • gate_type and qvector are used to determine qubit mapping for multi-qubit gates.
  • The U3 gate is the most general single-qubit gate and can represent any rotation.

Example Gate Sequence

```python # Apply Hadamard to qubit 0 h(q0)

Rotate qubit 0 around Y-axis by pi/4

ry(math.pi/4, q0)

Apply CNOT from qubit 0 to qubit 1

x.ctrl(q0, q1)

Apply a controlled-phase gate

r1.ctrl(math.pi/2, q0, q1)

Swap qubits 0 and 1

swap(q0, q1)

Apply a general U3 rotation

u3(theta, phi, lambda_, q0)

Goal

build the versatile all-in-one quantum accelerator for HPC-QPU hybrid regime that supports all the mainstream quantum frameworks.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qgear-1.1.2.tar.gz (405.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qgear-1.1.2-py3-none-any.whl (442.9 kB view details)

Uploaded Python 3

File details

Details for the file qgear-1.1.2.tar.gz.

File metadata

  • Download URL: qgear-1.1.2.tar.gz
  • Upload date:
  • Size: 405.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for qgear-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0df328aa1d33710a912b8af004dbbbf5d3be5bf0b841be48d3214dc7af422a91
MD5 9a208912d86dd2a6585d67c2c05571bb
BLAKE2b-256 1baa1585c494ca9c3d2c3b543ad914d9bebbcdf8bf841bdee18b8543917c9011

See more details on using hashes here.

File details

Details for the file qgear-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: qgear-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 442.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for qgear-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd1246e027d2457fb109526ae6e30e50bed89c97f6e89d335c92892ea3a22b59
MD5 bb5dfc46e391bebce48b3b646519b464
BLAKE2b-256 d44dcc71eec6a0b76780193ffb26a5bde2478e636876ff4f4328922e6df95948

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page