Quingo Simulator Backend QuaLeSim
Project description
Start
The QuaLeSim(Quantum Lego Simulator) is an adapted version of DQCSim. For quantum circuit simulation, you can simulate QUIET-s and QCIS instruction by it. And what's more, now the QuaLeSim is integrated into the backend of Quingo, you can use it directly after installing quingoc and quingo-runtime. More inforemations is available in [[#Install]]
Install
The QuaLeSim now is only for Linux platform.
- 环境准备:
- Linux platform with
python>=3.6
- Rust # if you don't have rust, make sure you have
'curl'
to install rust in the setup.py .
- Linux platform with
- 安装说明:
- You can get the source code from gitee
git clone git@gitee.com:quingo/qualesim.git cd qualesim git checkout task/fix-bugs git submodule update --init --recursive # you must have the limits of authority of quiet-parser, dqcsim-qcis, # dqcsim-quiets, dqcsim-tequila, dqcsim-quantumsim. pip install -r requirements.txt pip install . # the step may be very slow, you can use command below. # python setup.py bdist_wheel # cd <path-to-qualesim>/target/python/build/bdist.linux-x86_64/wheel # pip install xxx.whl # 存在LLVM的情况下会很慢,暂时不清楚原因,正在修改中。
- externs:
# The Simulator is for QCIS and QUIET-s, and now the quingo-0.2.3 can generate QCIS and QUIET-s # so you can install quingoc and quingo-runtime to use it. # quingoc: git clone git@gitee.com:quingo/quingo-compiler.git git checkout enh/I7U2U5/refactor_frontend 1. add eigen mkdir <tmp> cd <tmp> cp /mnt/share/eigen-3.4.0.zip . unzip eigen-3.4.0.zip # then copy Eigen and unsupported to quingo-compiler/extern and like - `quingo-compiler/extern/Eigen/src/SparseCholesky/SimplicialCholesky.h` - SimplicialCholesky& setMode(SimplicialCholeskyMode mode)(around line 545): { switch(mode) { case SimplicialCholeskyLLT: m_LDLT = false; break; case SimplicialCholeskyLDLT: m_LDLT = true; break; default: // delete this line break; // delete this line } } - `quingo-compiler/extern/unsupported/Eigen/MatrixFunctions` 2. cd quingo-compiler/build 3. cmakeninja .. 4. ninja 5. ln -s <path-to-quingo-compiler>/build/bin/quingoc ~/.local/bin/quingoc # 建立软链接 # quingo-runtime and other simulators: git clone git@gitee.com:quingo/quingo-runtime.git cd quingo-runtime git checkout task/backend-result pip install -e . git clone git@gitee.com:quingo/pyqcisim.git cd pyqcisim git checkout bug-fix pip install -e . git clone git@gitee.com:quingo/SymQC.git cd SymQC pip install -e . ``` ^dea5d0
- You can get the source code from gitee
Quick Start
Quick Start is for users use the Simulator directly or use it with quingo-runtime. Some examples are available below.
- For independent users:
- The Simulator can simulate QUIET-s and QCIS instructions, you can use it directly:
from dqcsim.plugin import *
from dqcsim.host import *
sim = Simulator(stderr_verbosity=Loglevel.INFO)
sim.with_frontend("<path-to-qcis-file>", verbosity=Loglevel.INFO)
# sim.with_frontend("<path-to-qi-file>", verbosity=Loglevel.INFO)
# Loglevel is for output information for DEBUG/INFO/OFF
# If you only want the simulation output, please set it OFF
sim.with_backend("quantumsim", verbosity=Loglevel.INFO)
# sim.with_backend("tequila", verbosity=Loglevel.INFO)
# now we have DQCsim-Tequila and DQCsim-QuantumSim backend for Simulator
sim.simulate()
res = sim.run(measure_mod="state_vector", num_shots=10)
# Start the simulation with different exe mod,
# measure_mod="one_shot" and num_shots=int /
# "state_vector"
# the output should be
sim.stop()
final_state = dict()
final_state = res["res"]
print(final_state)
- the output is :
measure_mod="state_vector":
res1(M Q1, M Q2) = {'classical': {'Q1': 1, 'Q2': 1}, 'quantum': (['Q3'], [0j, (1+0j)])}
# classical is qubit measured, quantum is qubit unmeasured with state vector.
res2() = {'classical': {}, 'quantum': (['Q1', 'Q2', 'Q3'], [(0.7071067811865472+0j), 0j, 0j, 0j, 0j, 0j, 0j, (0.7071067811865478+0j)])}
measure_mod="one_shot", num_shots=10:
# classical is classical value, quantum is qubit measured. and they are one to one correspondence
res(measure(q1)->c1, measure(q2)->c2) = {'quantum': [['q1', 'q2'], [[0, 0], [0, 0], [1, 1], [0, 0], [0, 0], [1, 1], [0, 0], [0, 0], [1, 1], [1, 1]]], 'classical': [{'c1': [0], 'c2': [0]}, {'c1': [0], 'c2': [0]}, {'c1': [1], 'c2': [1]}, {'c1': [0], 'c2': [0]}, {'c1': [0], 'c2': [0]}, {'c1': [1], 'c2': [1]}, {'c1': [0], 'c2': [0]}, {'c1': [0], 'c2': [0]}, {'c1': [1], 'c2': [1]}, {'c1': [1], 'c2': [1]}]}
- For Quingo Users
- You should follow the [[#Install|extern: quingoc & quingo-runtime installation]] to install it.
from quingo import *
import qututor.global_config as gc
from quingo.backend.qisa import Qisa
# input quingo file and simulate qu func
qu_file = gc.quingo_dir / "ghz.qu"
circ_name = "GHZ_state"
# set the qisa, and it is the output instructions QUIET,
# you can change to Qisa.QCIS or others.
task = Quingo_task(
qu_file,
circ_name,
qisa=Qisa.QUIET,
)
num_shots = 10
cfg = ExeConfig(ExeMode.SimFinalResult, num_shots)
num_qubits = 3
# now backend BackendType.QUANTUM_SIM, BackendType.DQCSIM_TEQUILA
# BackendType.DQCSIM_QUANTUMSIM, BackendType.SYMQC is available.
# method 1
qasm_fn = compile(task, params=(num_qubits,))
res = execute(qasm_fn, BackendType.QUANTUM_SIM, cfg)
# method 2
# res = call(task, (num_qubits,), BackendType.DQCSIM_TEQUILA, cfg)
print("res: ", res)
- the output is :
measure_mod="state_vector":
res1(M Q1, M Q2) = {'classical': {'Q1': 1, 'Q2': 1}, 'quantum': (['Q3'], [0j, (1+0j)])}
# classical is qubit measured, quantum is qubit unmeasured with state vector.
res2() = {'classical': {}, 'quantum': (['Q1', 'Q2', 'Q3'], [(0.7071067811865472+0j), 0j, 0j, 0j, 0j, 0j, 0j, (0.7071067811865478+0j)])}
measure_mod="one_shot", num_shots=10:
# quingo-runtime only have quantum values.
res(measure(q1)->c1, measure(q2)->c2) =(['q1', 'q2'], [[0, 0], [0, 0], [1, 1], [0, 0], [0, 0], [1, 1], [0, 0], [0, 0], [1, 1], [1, 1]])
FAQ
- for install
- your environment donot have rust?
- you can install rust yourself by the Rust 程序设计语言 (rust-lang.org)
- or just make sure you have command
"curl"
, the setup will help you install it automatic.
- if you have llvm in your platform, the setup install maybe very slow.
- the problem is to be solved.
- install about quingoc
- please refer to docs/DeveloperGuide.md · Quingo/quingo-compiler - Gitee.com
- your environment donot have rust?
- for use
- when you first use it, there would be a problem
核心已转储
- it is the dqcsim's problem and is to be solved.
- when you first use it, there would be a problem
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
Close
Hashes for qualesim-0.0.4-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50c5728df9ae86971ad314b4cca0ae9e4187c251e6a01039906aa8708f5f2353 |
|
MD5 | 66289eaea5e35c417ade19fc8d97396a |
|
BLAKE2b-256 | 137b912da86bace3421681dd05bf80e5f29bbac5eb3d4c554875b4ff1fb5e329 |
Close
Hashes for qualesim-0.0.4-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cb383726012b0dfb9326c2142509beef1feed3dba0e8c465a4ba6b84dbd93f |
|
MD5 | 36fb354c2cb49066f1091c5689fb627e |
|
BLAKE2b-256 | 6ab82137215c27ad25cb2f055465de789014cdc44b079f6a1cf08abf316fc312 |
Close
Hashes for qualesim-0.0.4-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd6232d547f542fe7fc183ada7923ca7af8c7a4d9410d3651bd1eb15a97f587b |
|
MD5 | 1ca82d1027389ccc99c68d34ee7e1720 |
|
BLAKE2b-256 | 58cbfc6059177df02ca45320647a81c36ed742b998ca66abe69a48fcd107c3ae |
Close
Hashes for qualesim-0.0.4-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 458b02cefef4c62da3268ea7cca70014d6450fbfaebc32194f7128e62f95c04a |
|
MD5 | 56e1e075572b7ec8b9e09a65b8985499 |
|
BLAKE2b-256 | f4ffbbe000e428f5520f6ff102a08f7da3c8507224ffafcd4d0804d8c07e2fb0 |
Close
Hashes for qualesim-0.0.4-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b2cf258e2792be0f81804d1ff737b1a2b9cfc927352c37601f7d6392762fc05 |
|
MD5 | 541c5ebfc59b7bb2150b9de63710556e |
|
BLAKE2b-256 | 622da402800c4960f19a77321105d1f58eb369af275d1a86c374d79482735d06 |
Close
Hashes for qualesim-0.0.4-cp37-cp37m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 791a3e29cd3cc25426ef748b870eeb24c37c2a9e34e94ef340f0c3437555aba1 |
|
MD5 | c17d995284948f96b65a12c809e3ae1d |
|
BLAKE2b-256 | a768a0ca9ee2605dc8ad1463440cc88daf8363d57a976044d480a4f0a8c35321 |
Close
Hashes for qualesim-0.0.4-cp36-cp36m-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fb8f0d4094a9ad14413142a1e7a4cea52c4819498e822ff446398442919b34b |
|
MD5 | 084cd821890a8fddf6b917b71b84913d |
|
BLAKE2b-256 | 1956d6dc215fae422a5bca69d508c97f771793e536574032199d498f64fde649 |