Skip to main content

QPanda-Lite. A python-native version for pyqpanda. Simple, easy, and transparent.

Project description

QPanda-lite

GitHub version Documentation Status PyPI version codecov Build and Test

QPanda: Quantum Programming Architecture for NISQ Device Application

QPanda-lite is a simple, easy-to-use, and transparent Python-native version of QPanda.


Table of Contents


Quick Example

from qpandalite.circuit_builder import Circuit
from qpandalite.simulator import OriginIR_Simulator

# Build a Bell state circuit
circuit = Circuit()
circuit.h(0)           # Hadamard on qubit 0
circuit.cnot(0, 1)     # CNOT from qubit 0 to qubit 1
circuit.measure(0, 1)   # Measure both qubits

# Simulate with 1000 shots
sim = OriginIR_Simulator()
result = sim.simulate_shots(circuit.originir, shots=1000)
print(result)
# Possible output: {0: 497, 3: 503}

Features

QPanda-lite 围绕以下目标设计:

特性 说明
透明 清晰的量子程序组装与执行方式
Python 原生 纯 Python 实现,安装简单,集成方便
多后端 支持 OriginIR Simulator、QASM Simulator、Quafu、OriginQ 等多种执行后端
同步/异步 支持同步和异步两种任务提交模式
可扩展 易于添加新的量子门、操作符和模拟后端

核心概念:

  • Circuit — 量子线路构建器,支持 OriginIR / OpenQASM 格式输出
  • Backend — 量子模拟器或真实量子计算机
  • Result — 测量结果以原生 Python 数据结构返回(dict / list / ndarray)

Installation

Supported Platforms

  • Windows / Linux / macOS

Requirements

  • Python 3.9 – 3.12

pip(推荐)

pip install qpandalite

Build from Source

纯 Python(无 C++ 依赖):

git clone https://github.com/Agony5757/QPanda-lite.git
cd QPanda-lite
pip install . --no-cpp

开发模式:

pip install -e .

含 C++ 模拟器(需 CMake):

git clone --recurse-submodules https://github.com/Agony5757/QPanda-lite.git
cd QPanda-lite
pip install .

Optional Dependencies

功能 安装命令
Quafu 执行后端 pip install pyquafu
Qiskit 执行后端 pip install qiskit qiskit-aer

Project Structure

QPanda-lite/
├── qpandalite/
│   ├── circuit_builder/          # Circuit class and gate definitions
│   ├── simulator/                # Local simulators (OriginIR, QASM, etc.)
│   ├── originir/                 # OriginIR parser
│   ├── qasm/                    # OpenQASM 2.0 parser
│   ├── task/                    # Cloud task submission (OriginQ / Quafu / IBM)
│   ├── transpiler/              # Circuit conversion (Qiskit ↔ OriginIR)
│   └── analyzer/                # Result analysis (expectation values, etc.)
├── QPandaLiteCpp/               # C++ backend (pybind11)
├── docs/                        # Sphinx documentation
└── test/                       # Unit tests

Quick Start

1. Build a Circuit

from qpandalite.circuit_builder import Circuit

c = Circuit()
c.rx(1, 0.1)         # RX rotation on qubit 1
c.cnot(1, 0)         # CNOT with control=1, target=0
c.measure(0, 1)      # Measure qubits 0 and 1


print(c.circuit)
# QINIT 2
# CREG 2
# RX q[1], (0.1)
# CNOT q[1], q[0]
# MEASURE q[0], c[0]
# MEASURE q[1], c[1]

注意:measure 只记录被测量的 qubit,电路中实际使用的 qubit 由门操作决定。

2. Circuit Simulation

import qpandalite.simulator as qsim

sim = qsim.OriginIR_Simulator(reverse_key=False)

originir = '''
QINIT 72
CREG 3
RY q[45],(0.9424777960769379)
RY q[46],(0.9424777960769379)
CZ q[45],q[46]
RY q[45],(-0.25521154)
RY q[46],(0.26327053)
X q[46]
MEASURE q[45],c[0]
MEASURE q[46],c[2]
MEASURE q[52],c[1]
'''

res = sim.simulate_statevector(originir)
print(res)
print(sim.state)

3. Submit to Cloud Hardware

import qpandalite.task.quafu as quafu

# Configure first: see qcloud_config_template/quafu_template.py
# quafu.create_quafu_online_config(...)

taskid = quafu.submit_task(circuit.originir, chip_id='ScQ-P10')
result = quafu.query_by_taskid_sync(taskid)

Examples

📁 examples/ — Runnable demonstrations

Getting Started

Example Description
Circuit Remapping Build a circuit and remap qubits for real hardware
Dummy Server Submit tasks to the local dummy simulator
Result Post-Processing Convert and analyze results

Algorithms

Example Description
Grover Search Unstructured search with quadratic speedup
Quantum Phase Estimation Eigenvalue phase estimation

Documentation

📖 Read the Docs


Status

🚧 Actively developing. API may change.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

qpandalite-0.3.0-cp313-cp313-win_amd64.whl (765.3 kB view details)

Uploaded CPython 3.13Windows x86-64

qpandalite-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (844.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

qpandalite-0.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (855.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

qpandalite-0.3.0-cp312-cp312-win_amd64.whl (765.3 kB view details)

Uploaded CPython 3.12Windows x86-64

qpandalite-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (844.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

qpandalite-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (855.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

qpandalite-0.3.0-cp311-cp311-win_amd64.whl (765.3 kB view details)

Uploaded CPython 3.11Windows x86-64

qpandalite-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (844.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

qpandalite-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (855.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ i686

qpandalite-0.3.0-cp310-cp310-win_amd64.whl (765.3 kB view details)

Uploaded CPython 3.10Windows x86-64

qpandalite-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (844.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

qpandalite-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (855.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ i686

File details

Details for the file qpandalite-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: qpandalite-0.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 765.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qpandalite-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0631f9bdd241dc52fcaf1983ddb34c275dcdb2df1e32eede27e9e4daf7b123bd
MD5 7ffe736e2954489ab4023a96cc23982e
BLAKE2b-256 0a4d3680d3814afdf5bafcf0f58b9a2b92efed054dbee3ef4547d9c5e2bc2583

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp313-cp313-win_amd64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 346e765683017500888948e85b39399c19f373bb7ff26574d4cdc2740036ba47
MD5 84f5caae47f87c34c7bf9bf0bb47c440
BLAKE2b-256 7cab0ef266a9de06bbe9362a25df506bc4ceaef74dedf5308a5e31f6785f7f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1df8cb2ad7fd3c0138e831da2a6b92e10e0def5a4fa647d833591fe6c8267e03
MD5 1089decb61302b06a0e9dec5bc250381
BLAKE2b-256 391c4cd562be56123f27a03564b1fc886b48cfc54bfd02e703342e8e245f7526

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: qpandalite-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 765.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qpandalite-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 38226ec9a4882d7e9911da4f213b980c4b4bff6b2b07b87b8632a1eed40405c9
MD5 b59c931f445355084904b2487694184f
BLAKE2b-256 8c93ae747257b7b01eb064ffd8e350b103e7f9fadffcda8bd41e4ca53ba84a1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp312-cp312-win_amd64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e30e24a5648496c1990a280db18576b12d7a6bdd886e57595fbf761d3d5a145
MD5 1c723fb3f0948d1c043528daef2239d2
BLAKE2b-256 feb4f891ccbe6b810926ff6ed1cd4e2eaf662e2265ad826754b4e996aa47f2bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4c29525f7eab3039b1f093d2f73157bc617d7c80b7a75a0cb56a039b78ac4305
MD5 d7e711da8c1e8706b7a079a68da2d161
BLAKE2b-256 6d37cd2379b860d5afab41df7179ec7353cba3882a98e0ce056db5db46508217

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: qpandalite-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 765.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qpandalite-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ffd6d7c25bc28180be9432c2b466fe8644aa77f942887a5ff04f344374870d73
MD5 279cfaabf79f981377f9a5ed09cdcd75
BLAKE2b-256 a8be63f67fbeb1f7653b83c51684f5c9e5488c5a556c97b8e1623ea3b7cc8eda

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp311-cp311-win_amd64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 188489fb51c5e529b0ed339be0f82068b5960243c7e4e33e25913efd1a8142fb
MD5 80eeb57d6255b374d00c49f5728c6d94
BLAKE2b-256 6a6c2ada852b867f28c5c82e1a8365640ee8c9c2d397fbf36d6de9bd974dcc99

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 716109a570adf453431673be6f60bbbbc4cc4da80113823621df6341bcb84156
MD5 043e92264f6b9b4af00321ae4f80209b
BLAKE2b-256 b6a37e372f20eabc3d03d1fcd720e1c1d846f0b26a7013e39a059bac71ce37b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: qpandalite-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 765.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qpandalite-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 43d197b83027cdb11ef95aed0a816739de3cdeda45e0c205bdf1486be71e3e01
MD5 49c7ab84b6127bd73dc7495d1ebaf399
BLAKE2b-256 08cb7ab300a5e929cc0b8c3a278e1c608df6943717ff7b4e4da5cfda199e5893

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp310-cp310-win_amd64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03282574c9bfd2e7f5ca24b09b7ec7c4198468f0c99417e438f77d6ad1477d0c
MD5 a6db35c8fa18b7aa82de51bb0806d4fc
BLAKE2b-256 cb35f91627acbfa4c7dee4f6a60aec11578b58d3b644984c4d6897ec3a319895

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qpandalite-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for qpandalite-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2ba9cf5905ec1dde71846340c071023f86c89a5577631ec3952d4cf21da029ec
MD5 3041e44dc0740849389f8423b71a1f85
BLAKE2b-256 a58206bd3ca2ae840a0e60b31beb9c212d33a7090a9b868762e8b8cc5bd9af82

See more details on using hashes here.

Provenance

The following attestation bundles were made for qpandalite-0.3.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: pypi-publish.yml on Agony5757/QPanda-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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