QPanda-Lite. A python-native version for pyqpanda. Simple, easy, and transparent.
Project description
QPanda-lite
QPanda: Quantum Programming Architecture for NISQ Device Application
QPanda-lite should be a simple, easy, and transparent python-native version for QPanda.
Status
Developing. Unstable.
Design principles
- A clear, and tranparent way to assemble/execute a quantum program
- Support sync/async modes for execution on a quantum hardware
- Clear error hints
- Full, and better documentations
- Visualization of the quantum program
- Be able to migrate to different quantum backends
Install
OS
- Windows
- Linux (not fully tested)
- MacOS (not fully tested)
Requirements
- Python >= 3.7
Optional for quafu execution
manually install via pip :
- pyquafu (pip install pyquafu)
Optional for qiskit execution
manually install via pip :
- qiskit (pip install qiskit) and
- qiskit-ibm-provider (pip install qiskit-ibm-provider) and
- qiskit-ibmq-provider (pip install qiskit-ibmq-provider)
Optional for C++ simulator
- CMake >= 3.1
- C++ compiler (with C++ 14 support), including MSVC, gcc, clang, etc...
Build from source
A minimum version
# Clone the code
git clone https://github.com/Agony5757/QPanda-lite.git
cd QPanda-lite
# install
python setup.py install
For development
git clone https://github.com/Agony5757/QPanda-lite.git
cd QPanda-lite
# install
python setup.py develop
With C++ enabled (quantum circuit simulator written in C++)
git clone https://github.com/Agony5757/QPanda-lite.git
cd QPanda-lite
# install
python setup.py install --has-cpp
Build the docs
Will be released in the future.
pip
Will be supported in the future.
Examples
There are several ways to use QPanda-lite now.
- Circuit building (not supported now)
- Circuit simulation (not supported now)
- Run circuit on several backends
Circuit run on OriginQ Device
Step 1. Create online config
Refer to qcloud_config_template/originq_template.py
- Input the necessary information (token, urls, group_size) to call create_originq_online_config
- You will have the originq_online_config.json in your cwd.
- Now you can submit task to the online chip!
- (Note: if you fail to submit task, replace the token with the newest in json or this template and rerun.)
Step 2. Create the circuit and run
Refer to test/verify_real_chip_bitsequence_origin
- Step 0: Create the online config and import the originq module like this: from qpandalite.task.originq import *
- Step 1.1: Prepare circuits written in OriginIR format (as List[str])
- Step 1.2: Call submit_task_group and you will find the taskid is recorded to the savepath (Note: the upper limit count for quantum circuits is default_task_group_size)
- Step 2.1: Use load_all_online_info to load all taskids (as well as your taskname)
- Step 2.2: Use query_all_task to fetch the data from the platform. If not finished, it will not be fetched and return without waiting.
- Step 2.3: Use query_by_taskid is also available for fetching a single task result. It will return without waiting if the task is not finished.
- Step 3: Delete / move the online_info(savepath) folder to restore everything.
Circuit run on Quafu Device
Step 1. Create online config
Refer to qcloud_config_template/quafu_template.py
- Input the necessary information (token, urls, group_size) to call create_quafu_online_config
- You will have the quafu_online_config.json in your cwd.
- Now you can submit task to the online chip!
Step 2. Create the circuit and run
Refer to test/verify_real_chip_bitsequence_quafu
Circuit build (unfinished)
Refer to test/draft_test/circuit_builder_test.py
from qpandalite import Circuit
c = Circuit('hello')
c.rx(1, angle = 0.1)
print(c)
Circuit simulation (unfinished)
Refer to test/draft_test/simulator_test.py
import qpandalite.simulator as qsim
sim = qsim.Simulator()
sim.init_n_qubit(6)
print(len(sim.state))
print(sim.state)
sim.hadamard(0)
sim.cnot(0,1)
sim.cnot(1,3)
sim.cnot(0,2)
sim.cnot(1,4)
sim.cnot(3,5)
print(sim.state)
# Expect output: 32
Note: Have ImportError? ImportError:qpandalite is not install with QPandaLiteCpp.
You should install with QPandaLiteCpp before importing qpandalite.simulator
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for qpandalite-0.1.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 321b06aade1143b1603f6d46397ac1d7c4b702fac0f332defe3cf3f8daf7bccb |
|
MD5 | 675c6812302a42bb10c2c9239ef06a4b |
|
BLAKE2b-256 | 5658b88919f3c942eec569850f22210553e89d021f59316449dac89e4b123667 |
Hashes for qpandalite-0.1.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 689a6fb346c5f5f90589a47f290799346b0a3515d166c5317a1b3d5d50d58cb2 |
|
MD5 | 74f77e95b0ac476fc4a5bf94376f6acf |
|
BLAKE2b-256 | f173d0bfdd0aad02383c2a93bb4403f74220fa348626cbd8c45297aa9888acd7 |
Hashes for qpandalite-0.1.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4372dfd2c78c28e26aa6ec14c6e1bbcc2b1a60a06e465eb2be03099344d3ca80 |
|
MD5 | f04039953278059974d7775ebb6cad76 |
|
BLAKE2b-256 | 9843b921ec5d3e4b51f4e1e849c12569db939d72a19f1a07bb38681f5bf5d521 |