Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
xuxusheng 0b53cfea02 | 2 years ago | |
---|---|---|
.jenkins/check/config | 2 years ago | |
cmake | 2 years ago | |
docs | 3 years ago | |
mindquantum | 2 years ago | |
tests | 2 years ago | |
third_party/patch | 2 years ago | |
tutorials | 2 years ago | |
.clang-format | 2 years ago | |
.cmake-format.yaml | 2 years ago | |
.codespell.allow | 2 years ago | |
.cppcheck.suppressions | 2 years ago | |
.gitignore | 2 years ago | |
.pre-commit-config.yaml | 2 years ago | |
CMakeLists.txt | 2 years ago | |
LICENSE | 3 years ago | |
NOTICE | 2 years ago | |
README.md | 2 years ago | |
README_CN.md | 2 years ago | |
RELEASE.md | 2 years ago | |
VERSION.txt | 2 years ago | |
build.bat | 2 years ago | |
build.sh | 2 years ago | |
install_with_docker.md | 2 years ago | |
install_with_docker_en.md | 2 years ago | |
pyproject.toml | 2 years ago | |
requirements.txt | 2 years ago | |
setup.cfg | 2 years ago | |
setup.py | 2 years ago |
MindQuantum is a general quantum computing framework developed by MindSpore and HiQ, that can be used to build and train different quantum neural networks. Thanks to the powerful algorithm of quantum software group of Huawei and High-performance automatic differentiation ability of MindSpore, MindQuantum can efficiently handle problems such as quantum machine learning, quantum chemistry simulation, and quantum optimization, which provides an efficient platform for researchers, teachers and students to quickly design and verify quantum machine learning algorithms.
The below example shows how to build a parameterized quantum circuit.
from mindquantum import *
import numpy as np
encoder = Circuit().h(0).rx({'a0': 2}, 0).ry('a1', 1)
print(encoder)
print(encoder.get_qs(pr={'a0': np.pi/2, 'a1': np.pi/2}, ket=True))
Then you will get,
q0: ────H───────RX(2*a0)──
q1: ──RY(a1)──────────────
-1/2j¦00⟩
-1/2j¦01⟩
-1/2j¦10⟩
-1/2j¦11⟩
ansatz = CPN(encoder.hermitian(), {'a0': 'b0', 'a1': 'b1'})
sim = Simulator('projectq', 2)
ham = Hamiltonian(-QubitOperator('Z0 Z1'))
grad_ops = sim.get_expectation_with_grad(ham,
encoder + ansatz,
encoder_params_name=encoder.params_name,
ansatz_params_name=ansatz.params_name)
import mindspore as ms
ms.context.set_context(mode=ms.context.PYNATIVE_MODE, device_target="CPU")
net = MQLayer(grad_ops)
encoder_data = ms.Tensor(np.array([[np.pi/2, np.pi/2]]))
opti = ms.nn.Adam(net.trainable_params(), learning_rate=0.1)
train_net = ms.nn.TrainOneStepCell(net, opti)
for i in range(100):
train_net(encoder_data)
print(dict(zip(ansatz.params_name, net.trainable_params()[0].asnumpy())))
The trained parameters are,
{'b1': 1.5720831, 'b0': 0.006396801}
For more API, please refers to MindQuantum API
1.Download Source Code from Gitee
cd ~
git clone https://gitee.com/mindspore/mindquantum.git
2.Compiling MindQuantum
cd ~/mindquantum
bash build.sh
cd output
pip install mindquantum-*.whl
pip install https://hiq.huaweicloud.com/download/mindspore/cpu/x86_64/mindspore-1.3.0-cp38-cp38-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install https://hiq.huaweicloud.com/download/mindquantum/newest/linux/mindquantum-master-cp37-cp37m-linux_x86_64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install https://hiq.huaweicloud.com/download/mindquantum/newest/windows/mindquantum-master-cp37-cp37m-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple
- Change
cp37-cp37m
tocp38-cp38
orcp39-cp39
according to your python version.- When the network is connected, dependency items are automatically downloaded during .whl package installation. (For details about other dependency items, see setup.py). In other cases, you need to manually install dependency items.
Successfully installed, if there is no error message such as No module named 'mindquantum' when execute the following command:
python -c 'import mindquantum'
Mac or Windows users can install MindQuantum through Docker. Please refer to Docker installation guide
Please set the parallel core number before running MindQuantum scripts. For example, if you want to set the parallel core number to 4, please run the command below:
export OMP_NUM_THREADS=4
For large servers, please set the number of parallel kernels appropriately according to the size of the model to achieve optimal results.
For more details about how to build a parameterized quantum circuit and a quantum neural network and how to train these models, see the MindQuantum Tutorial.
More details about installation guide, tutorials and APIs, please see the User Documentation.
Check out how MindSpore Open Governance works.
Welcome contributions. See our Contributor Wiki for more details.
MindQuantum is a general software library supporting the development of applications for quantum computation.
Python C++ CMake Text Cuda other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》