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 --no-cpp
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
Build the docs
Will be released in the future.
pip
For python 3.8 to 3.10
pip install qpandalite
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 current working directory (cwd).
- Now you can submit task to the online chip!
Step 1.1 (Optional). Use originq_dummy
Dummy server is used to emulate the behavior of an online-avaiable quantum computing server, without really accessing the system but with your local computer to simulate the quantum circuit.
-
Input the necessary information (available_qubits and available_topology) to call create_originq_dummy_config.
-
If you want both mode, use create_originq_config and inputting all needed information.
Step 2. Create the circuits and run
Refer to test/demo
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
Todo.
Circuit build
Refer to test/demo
from qpandalite import Circuit
c = Circuit()
c.rx(1, 0.1)
print(c.circuit)
Circuit simulation
Refer to test/draft_test/originir_simulator_test.py
import qpandalite.simulator as qsim
sim = qsim.OriginIR_Simulator(reverse_key=False)
originir = '''
QINIT 72
CREG 2
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(originir)
print(res)
print(sim.state)
# Expect output:
# [0.23218757036469517, 0.04592184582945769, 0.0, 0.0, 0.6122094271102275, 0.10968115669561962, 0.0, 0.0]
# [(0.4818584546987789+0j), (-0.21429383059121812+0j), (0.7824381298928546+0j), (0.33118145584500897+0j), 0j, 0j, 0j, 0j]
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.7-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7f5f92ecaf1571577c985de242e8619953d4ff2edbaccb40a1403ba3f85adb4 |
|
MD5 | 9893c876681cc4eeaf2b367d7309b7e5 |
|
BLAKE2b-256 | e74c9f8a0424d5502a1d0011b6f311c45e1e55b06288aa7cbd02c8e5941970e0 |
Hashes for qpandalite-0.1.7-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa66eb02a5b508d6752fd0742081e0f1c8766c259dc11f1e05d92cffd22c3fd7 |
|
MD5 | ea14008c0d038331d30effe62a22b21a |
|
BLAKE2b-256 | 1514abeb88e7608dd95d419b5e14b5d585541adc6fa3f5cf71817445518a372c |
Hashes for qpandalite-0.1.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ae275e4df52185b1adc67f1ea8c82607b182f3b3164ec2380f5b5a63b2615b8 |
|
MD5 | 191fef85fe4c2b62e03026d96e6fa96b |
|
BLAKE2b-256 | 1ca4965c19068f631dd236642327575c40bb548ffccd7f547dc67ec6cc6cde0f |
Hashes for qpandalite-0.1.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 075658a87b65bedb14498d518aa4c0253fed1bf817df02e17516860fec3f5d74 |
|
MD5 | 3763494092877d54da494788d36586af |
|
BLAKE2b-256 | 122561a538a463729c1b9b3356789be9bd703ddc1c337400ab71838bd79cc8cc |