Giter VIP home page Giter VIP logo

quantum's Introduction

English | 简体中文

Paddle Quantum (量桨)

Paddle Quantum (量桨) is the world's first cloud-integrated quantum machine learning platform based on Baidu PaddlePaddle. It supports the building and training of quantum neural networks, making PaddlePaddle the first deep learning framework in China. Paddle Quantum is feature-rich and easy to use. It provides comprehensive API documentation and tutorials help users get started right away.

Paddle Quantum aims at establishing a bridge between artificial intelligence (AI) and quantum computing (QC). It has been utilized for developing several quantum machine learning applications. With the PaddlePaddle deep learning platform empowering QC, Paddle Quantum provides strong support for scientific research community and developers in the field to easily develop QML applications. Moreover, it provides a learning platform for quantum computing enthusiasts.

Features

  • Easy-to-use
    • Many online learning resources (Nearly 50 tutorials)
    • High efficiency in building QNN with various QNN templates
    • Automatic differentiation
  • Versatile
    • Multiple optimization tools and GPU mode
    • Simulation with 25+ qubits
    • Flexible noise models
  • Featured Toolkits
    • Toolboxes for Chemistry & Optimization
    • LOCCNet for distributed quantum information processing
    • Self-developed QML algorithms

Install

Install PaddlePaddle

This dependency will be automatically satisfied when users install Paddle Quantum. Please refer to PaddlePaddle's official installation and configuration page. This project requires PaddlePaddle 2.2.0 to 2.3.0.

Install Paddle Quantum

We recommend the following way of installing Paddle Quantum with pip,

pip install paddle-quantum

or download all the files and finish the installation locally,

git clone https://github.com/PaddlePaddle/quantum
cd quantum
pip install -e .

Environment setup for Quantum Chemistry module

Currently, our qchem module uses PySCF as its backend to compute molecular integrals, so before executing quantum chemistry, we have to install this Python package.

It is recommended that PySCF is installed in a Python environment whose Python version >=3.6.

We highly recommend you to install PySCF via conda. MacOS/Linux user can use the command:

conda install -c pyscf pyscf

NOTE: For Windows user, if your operating system is Windows10, you can install PySCF in Ubuntu subsystem provided by Windows 10's App Store. PySCF can't run directly in Windows, so we are working hard to develop more quantum chemistry backends. Our support for Windows will be improved in the coming release of Paddle Quantum.

Note: Please refer to PySCF for more download options.

Run example

Now, you can try to run a program to verify whether Paddle Quantum has been installed successfully. Here we take quantum approximate optimization algorithm (QAOA) as an example.

cd paddle_quantum/QAOA/example
python main.py

For the introduction of QAOA, please refer to our QAOA tutorial.

Breaking Change

In version 2.2.0 of Paddle Quantum, we have made an incompatible upgrade to the code architecture, and the new version's structure and usage can be found in our tutorials, API documentation, and the source code. Also, we support connecting to a real quantum computer via QuLeaf, using paddle_quantum.set_backend('quleaf') to select QuLeaf as the backend.

Introduction and developments

Quick start

Paddle Quantum Quick Start Manual is probably the best place to get started with Paddle Quantum. Currently, we support online reading and running the Jupyter Notebook locally. The manual includes the following contents:

  • Detailed installation tutorials for Paddle Quantum
  • Introduction to quantum computing and quantum neural networks (QNNs)
  • Introduction to Variational Quantum Algorithms (VQAs)
  • Introduction to Paddle Quantum
  • PaddlePaddle optimizer tutorial
  • Introduction to the quantum chemistry module in Paddle Quantum
  • How to train QNN with GPU

Tutorials

We provide tutorials covering quantum simulation, machine learning, combinatorial optimization, local operations and classical communication (LOCC), and other popular QML research topics. Each tutorial currently supports reading on our website and running Jupyter Notebooks locally. For interested developers, we recommend them to download Jupyter Notebooks and play around with it. Here is the tutorial list,

With the latest LOCCNet module, Paddle Quantum can efficiently simulate distributed quantum information processing tasks. Interested readers can start with this tutorial on LOCCNet. In addition, Paddle Quantum supports QNN training on GPU. For users who want to get into more details, please check out the tutorial Use Paddle Quantum on GPU. Moreover, Paddle Quantum could design robust quantum algorithms under noise. For more information, please see Noise tutorial.

In a recent update, the measurement-based quantum computation (MBQC) module has been added to Paddle Quantum. Unlike the conventional quantum circuit model, MBQC has its unique way of computing. Interested readers are welcomed to read our tutorials on how to use the MBQC module and its use cases.

API documentation

For those who are looking for explanation on the python class and functions provided in Paddle Quantum, we refer to our API documentation page.

We, in particular, denote that the current docstring specified in source code is written in simplified Chinese, this will be updated in later versions.

Feedbacks

Users are encouraged to contact us through GitHub Issues or email [email protected] with general questions, unfixed bugs, and potential improvements. We hope to make Paddle Quantum better together with the community!

Research based on Paddle Quantum

We also highly encourage developers to use Paddle Quantum as a research tool to develop novel QML algorithms. If your work uses Paddle Quantum, feel free to send us a notice via [email protected]. We are always excited to hear that! Cite us with the following BibTeX:

@misc{Paddlequantum, title = {{Paddle Quantum}}, year = {2020}, url = {https://github.com/PaddlePaddle/Quantum}, }

So far, we have done several projects with the help of Paddle Quantum as a powerful QML development platform.

[1] Wang, Youle, Guangxi Li, and Xin Wang. "Variational quantum Gibbs state preparation with a truncated Taylor series." Physical Review Applied 16.5 (2021): 054035. [pdf]

[2] Wang, Xin, Zhixin Song, and Youle Wang. "Variational quantum singular value decomposition." Quantum 5 (2021): 483. [pdf]

[3] Li, Guangxi, Zhixin Song, and Xin Wang. "VSQL: Variational Shadow Quantum Learning for Classification." Proceedings of the AAAI Conference on Artificial Intelligence. Vol. 35. No. 9. 2021. [pdf]

[4] Chen, Ranyiliu, et al. "Variational quantum algorithms for trace distance and fidelity estimation." Quantum Science and Technology (2021). [pdf]

[5] Wang, Kun, et al. "Detecting and quantifying entanglement on near-term quantum devices." arXiv preprint arXiv:2012.14311 (2020). [pdf]

[6] Zhao, Xuanqiang, et al. "Practical distributed quantum information processing with LOCCNet." npj Quantum Information 7.1 (2021): 1-7. [pdf]

[7] Cao, Chenfeng, and Xin Wang. "Noise-Assisted Quantum Autoencoder." Physical Review Applied 15.5 (2021): 054012. [pdf]

Frequently Asked Questions

  1. Question: What is quantum machine learning? What are the applications?

    Answer: Quantum machine learning (QML) is an interdisciplinary subject that combines quantum computing (QC) and machine learning (ML). On the one hand, QML utilizes existing artificial intelligence technology to break through the bottleneck of quantum computing research. On the other hand, QML uses the information processing advantages of quantum computing to promote the development of traditional artificial intelligence. QML is not only suitable for quantum chemical simulations (with Variational Quantum Eigensolver) and other quantum problems. It also help researchers to solve classical optimization problems including knapsack problem, traveling salesman problem, and Max-Cut problem through the Quantum Approximate Optimization Algorithm.

  2. Question: I want to study QML, but I don't know much about quantum computing. Where should I start?

    Answer: Quantum Computation and Quantum Information by Nielsen & Chuang is the classic introductory textbook to QC. We recommend readers to study Chapter 1, 2, and 4 of this book first. These chapters introduce the basic concepts, provide solid mathematical and physical foundations, and discuss the quantum circuit model widely used in QC. Readers can also go through Paddle Quantum's quick start guide, which contains a brief introduction to QC and interactive examples. After building a general understanding of QC, readers can try some cutting-edge QML applications provided as tutorials in Paddle Quantum.

  3. Question: Currently, there is no fault-tolerant large-scale quantum hardware. How can we develop quantum applications?

    Answer: The development of useful algorithms does not necessarily require a perfect hardware. The latter is more of an engineering problem. With Paddle Quantum, one can develop, simulate, and verify the validity of self-innovated quantum algorithms. Then, researchers can choose to implement these tested quantum algorithms in a small scale hardware and see the actual performance of it. Following this line of reasoning, we can prepare ourselves with many candidates of useful quantum algorithms before the age of matured quantum hardware.

  4. Question: What are the advantages of Paddle Quantum?

    Answer: Paddle Quantum is an open-source QML toolkit based on Baidu PaddlePaddle. As the first open-source and industrial level deep learning platform in China, PaddlePaddle has the leading ML technology and rich functionality. With the support of PaddlePaddle, especially its dynamic computational graph mechanism, Paddle Quantum could easily train a QNN and with GPU acceleration. In addition, based on the high-performance quantum simulator developed by Institute for Quantum Computing (IQC) at Baidu, Paddle Quantum can simulate more than 20 qubits on personal laptops. Finally, Paddle Quantum provides many open-source QML tutorials for readers from different backgrounds.

Copyright and License

Paddle Quantum uses Apache-2.0 license.

References

[1] Quantum Computing - Wikipedia

[2] Nielsen, M. A. & Chuang, I. L. Quantum computation and quantum information. (2010).

[3] Phillip Kaye, Laflamme, R. & Mosca, M. An Introduction to Quantum Computing. (2007).

[4] Biamonte, J. et al. Quantum machine learning. Nature 549, 195–202 (2017).

[5] Schuld, M., Sinayskiy, I. & Petruccione, F. An introduction to quantum machine learning. Contemp. Phys. 56, 172–185 (2015).

[6] Benedetti, M., Lloyd, E., Sack, S. & Fiorentini, M. Parameterized quantum circuits as machine learning models. Quantum Sci. Technol. 4, 043001 (2019).

quantum's People

Contributors

eltociear avatar gsq7474741 avatar imppresser avatar quleaf avatar xiaoguanghu01 avatar yangguohao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quantum's Issues

【PaddlePaddle Hackathon】82 基于量子卷积神经网络的图片分类

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见 PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:基于量子卷积神经网络 (QCNN) 的图片分类
  • 技术标签:量子卷积神经网络
  • 任务难度:困难
  • 详细描述:

众所周知,卷积神经网络 (CNN) 在图像识别等问题上表现十分出色,受到 CNN 的启发 QCNN 被提出(参考 1)。CNN 核心的操作是卷积和池化,对于 QCNN 可以考虑利用参数化量子电路或者随机电路代替卷积和池化操作。关于 QCNN 的形式有很多(参考 2),目前还处于探索阶段。在这个任务中,你需要尝试实现基于量子卷积神经网络的图片分类。

任务要求:根据参考文献 3 和其它参考文献,形成一篇 QCNN 的教程,教程包括背景知识、方法介绍和代码实验等,具体形式可参考量桨已有的教程(参考资料 4)。

参考资料

  1. Cong, I., Choi, S. & Lukin, M.D. Quantum convolutional neural networks. Nat. Phys. 15, 1273–1278. (2019) https://doi.org/10.1038/s41567-019-0648-8
  2. Maxwell Henderson, Samriddhi Shakya, Shashindra Pradhan, Tristan Cook. “Quanvolutional Neural Networks: Powering Image Recognition with Quantum Circuits.”(2019) arXiv:1904.04767
  3. Yanxuan Lü, Qing Gao, Jinhu Lü, Maciej Ogorzałek, Jin Zheng.A Quantum Convolutional Neural Network for Image Classification.(2021) arxiv:2107.03630
  4. https://qml.baidu.com/tutorials/overview.html

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对量子计算有一定了解
  • 对计算机视觉有一定了解
  • 对量桨平台的运用有一定了解

【PaddlePaddle Hackathon】78 实现密度矩阵可视化

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:实现密度矩阵可视化
  • 技术标签:量子计算、密度矩阵
  • 任务难度:简单
  • 详细描述:

获取到某个量子态的密度矩阵就意味着我们获取到了这个量子态的基本信息。在这个任务中,你要实现用可视化的方式来进一步展示这个密度矩阵里所蕴含的信息。具体来说,对于一个 n x n 维的密度矩阵,其矩阵内的元素有 n^2 个,每一个元素都是复数,有实部和虚部,你可以用两个 3D 直方图来分别展示其实部和虚部。第一张图展示实部,x 和 y 坐标对应密度矩阵的 x 行和 y 列,相应位置元素实部的值对应了 z 坐标值的大小,第二张图展示虚部,其规则与实部相同。

任务要求

  1. 实现对 n>=1 个量子比特产生的密度矩阵,都可以展示其可视化功能
  2. 应使用 matplotlib 库的子图功能产生左右两个子图
  3. 输入应可以兼容量桨的数据类型 paddle.Tensor

功能定位:对 paddle_quantum.utils 库进行功能扩展

函数输入:多量子比特的量子态的状态向量或者密度矩阵(类型为 paddle.Tensornp.ndarray

函数输出:对应的密度矩阵可视化图(类型为 matplotlib.Figure

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  1. 对量桨平台的运用有一定了解
  2. 对密度矩阵的实现有一定了解
  3. matplotlib 画图库有一定了解

ImportError: DLL load failed while importing core: 动态链接库(DLL)初始化例程失败。

paddlepaddle: 2.1.2
paddle-quantum: 2.1.2
system: win10

报错:
Traceback (most recent call last):
File "D:\anaconda\envs\paddle21\lib\site-packages\psi4_init_.py", line 55, in
from . import core
ImportError: DLL load failed while importing core: 动态链接库(DLL)初始化例程失败。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "E:/Base_project/neural-network-base/quantum_computing/quantum_simulation/structure_of_hamiltonian.py", line 15, in
from paddle_quantum.qchem import geometry, get_molecular_data
File "D:\anaconda\envs\paddle21\lib\site-packages\paddle_quantum\qchem.py", line 22, in
import psi4
File "D:\anaconda\envs\paddle21\lib\site-packages\psi4_init_.py", line 60, in
raise ImportError("{0}".format(err))
ImportError: DLL load failed while importing core: 动态链接库(DLL)初始化例程失败。

相关数学推导咨询

首先表达对相关 Contributor 的感谢。在学习量桨的过程中,无法理解为何如下电路对应的矩阵如教程所写,请问能否提供进一步解释?
image
image

【PaddlePaddle Hackathon】80 多量子比特独立系统的 Bloch 球展示

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:多量子比特独立系统的 Bloch 球展示
  • 技术标签:量子计算、量子态
  • 任务难度:中等
  • 详细描述:

Bloch 球是一个可以直观地展示单量子比特状态的工具。对于单比特量子态,若其是纯态,则对应了 Bloch 球面上的点,若其是混合态,则对应了 Bloch 球内部的点。对于多个比特的量子态,则不能直接套用单比特量子的 Bloch 球功能,而是需要借助密度矩阵求偏迹等知识来结合实现。这个任务中,你需要实现多比特量子态的 Bloch 球展现。

任务要求

  1. 实现输入多量子比特的态矢量或者密度矩阵,输出对应的多量子比特的 Bloch 球展示的函数
  2. 子图个数应该能够根据输入而改变
  3. 求偏迹过程可以使用量桨内置的函数

功能定位:对 paddle_quantum.utils.plot_state_in_bloch_sphere 函数进行功能扩展。

函数输入:多量子比特的量子态的状态向量或者密度矩阵(类型为 paddle.Tensornumpy.ndarray);要绘制的量子比特序号以及顺序,默认为 None,表示全部绘制。

函数输出:对应的 Bloch 球示意图。

实现内容:应支持 n (n>=1) 个量子比特的输入。若输入为单量子比特,其效果应与传统 Bloch 球相符合。若输入为多量子比特,其效果应该与总系统对应于某个量子比特的子系统相符合。

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对量子计算有一定了解
  • 对量子态有一定了解
  • 了解 matplotlib 包的使用

Many of the examples dont work

For instance:
QGAN_EN.iynb

RuntimeError: (NotFound) There are no kernels which are registered in the einsum operator.
  [Hint: Expected kernels_iter != all_op_kernels.end(), but received kernels_iter == all_op_kernels.end().] (at /paddle/paddle/fluid/imperative/prepared_operator.cc:341)
  [operator < einsum > error]

image

QAutoencoder_CN.ipynb:

ValueError: (InvalidArgument) conj(): argument 'X' (position 0) must be Tensor, but got numpy.ndarray (at /paddle/paddle/fluid/pybind/op_function_common.cc:737)

image

Can you help?

【PaddlePaddle Hackathon】77 为哈密顿量矩阵实现指定量子比特数

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:为哈密顿量矩阵实现指定量子比特数
  • 技术标签:量子计算、哈密顿量、量子比特数
  • 任务难度:简单
  • 详细描述:

在量子力学中,哈密顿量是描述系统能量的算符。目前量桨中的 Hamiltonian 类可以通过方法 Hamiltonian.construct_h_matrix() 来生成其对应的矩阵形式。目前,该方法自动根据哈密顿量的表达式来决定系统**有几个量子比特。例如对于哈密顿量 '1 Z0, Z2' 会生成对应三个量子比特的矩阵(对应的泡利单词为 'ZIZ')。在这个任务中,你需要完成对这个方法的修改,使得其可以生成对应用户指定输入量子比特数的矩阵,例如对于刚刚提到的哈密顿量,若用户指定生成五个量子比特的矩阵,则生成对应泡利单词为 'ZIZII' 的矩阵。

任务要求:使得 Hamiltonian.construct_h_matrix() 方法支持传入参数 n_qubit 来指定生成矩阵对应的量子比特数(该参数应该不小于哈密顿量表达式中所对应的量子比特数)。

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对量桨平台的运用有一定了解
  • 对哈密顿量有一定了解

Importing `paddle_quantum` generates warnings that can't be silenced

I have a file test.py that contains

import warnings
warnings.filterwarnings("ignore")

import sys
print(sys.version)
from importlib.metadata import version
print(f"PaddlePaddle version {version('paddlepaddle')}") 
print(f"Paddle quantum version {version('paddle_quantum')}")

import paddle

Running python test.py outputs

3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
PaddlePaddle version 2.4.0rc0
Paddle quantum version 2.3.0
/home/victory/paddle_quantum_venv/lib/python3.10/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
  warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
/home/victory/paddle_quantum_venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
/home/victory/paddle_quantum_venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google.logging')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
/home/victory/paddle_quantum_venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2349: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(parent)
/home/victory/paddle_quantum_venv/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)

These warnings should not be here.

咨询项目内图片是否可以自由使用

在项目的Quantum/introduction/figures 目录下,有这张图片:intro-fig-IBMQ.png
大约是一台ibm原型机的图片。

请问这张图片来源是哪里,我准备放入一篇介绍量桨的文章里,做插图,可以吗 ?

另外在量桨的一些学习项目中,用到的一些图片都注明了来源(大多来自wiki),这样的图片在注明来源的情况下可以在文章中使用吧?

【PaddlePaddle Hackathon】79 图片编码为量子态

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:图片编码为量子态
  • 技术标签:量子计算、密度矩阵
  • 任务难度:简单
  • 详细描述:

一张图片的信息可以由一个矩阵来表示。而在量子计算中,一个量子态也可以用一个密度矩阵来进行表示。因此,一张图片的信息是可以使用密度矩阵来进行编码表示的。在该任务中,你可以考虑将一个图片编码为量子态的密度矩阵,应该要注意的是,密度矩阵需要满足三个条件。首先,密度矩阵是 Hermitian 矩阵;其次,密度矩阵的迹(trace)为 1,最后密度矩阵是半正定矩阵。一个可供参考的思路是,将图片转换为由其灰度值构成的矩阵,再转换成 2^n x 2^n 的矩阵,再将其转换为符合条件的密度矩阵。对于其它合理的方式,我们也可以酌情采纳。

任务要求

  1. 实现输入任意一张图片,都能转化为方阵的形式来表示。
  2. 实现图片与密度矩阵一一对应,即不同的图片产生的密度矩阵应该不同。

功能定位:对paddle_quantum.utils库进行功能扩展

函数输入:图片文件

函数输出:图片对应的密度矩阵(类型为 numpy.ndarray

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对密度矩阵的实现有一定了解
  • numpy包有一定的了解

【PaddlePaddle Hackathon】81 时间演化电路的性能优化

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:时间演化电路的性能优化
  • 技术标签:量子计算、哈密顿量
  • 任务难度:中等
  • 详细描述:

哈密顿量模拟,指的是模拟一个量子系统随时间演化的过程。根据量子力学的基本公理,对于不含时的哈密顿量而言,系统的时间演化过程可以由算符 exp(-iHt) 进行描述。目前,量桨中实现了基于 product formula 的数字化哈密顿量模拟,可以根据泡利哈密顿量来创建相应的模拟时间演化电路。在这个任务中,你需要实现对时间演化电路的性能优化。目前,该模块的实现方法是对于泡利哈密顿量中的每一项分别搭建一个旋转电路,其具体方法可以参考 1 中的 4.7.3 节。实际上,对于一些特殊的两量子比特项而言,文献 2 提出了更加高效的电路。因此,你可以将该文献中描述的 special case 进行单独的实现,并将相关代码合入 paddle_quantum.trotter.construct_trotter_circuit() 函数中。

注:对于哈密顿量模拟更加详细的介绍,可以参考量桨官网上的教程:利用 Product Formula 模拟时间演化模拟一维海森堡链的自旋动力学

任务要求

  1. 编写单独的函数,使其可以实现文献 2 中提到的量子电路
  2. 在搭建时间演化电路时,检测出哈密顿量中可以高效模拟的项并进行单独处理
  3. 利用实际系统的哈密顿量对该功能进行验证,确保结果正确

参考资料

  1. Nielsen, Michael A., and Isaac L. Chuang. "Quantum computing and quantum information." (2000).
  2. Vatan, Farrokh, and Colin Williams. "Optimal quantum circuits for general two-qubit gates." Physical Review A 69.3 (2004): 032315.

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对量子计算有一定了解
  • 对哈密顿量模拟有一定了解
  • 对量桨平台的运用有一定了解

Medical image classification

Hi,
I wanted to inquire about the availability of the code for training models in Paddle-quantum, specifically related to medical image classification as found in this link: https://github.com/PaddlePaddle/Quantum/blob/master/applications/medical_image_classification/introduction_en.ipynb.

I was wondering if Paddle-quantum has a similar code implementation to Qiskit's quantum convolutional neural network as seen in this link: https://github.com/Qiskit/qiskit-machine-learning/blob/main/docs/tutorials/11_quantum_convolutional_neural_networks.ipynb.

Additionally, I am curious if it's possible to utilize quantum encoding for 256x256 medical images using Paddle-quantum on a 12GB GPU.?

Assuming I extract features using a classical CNN such as VGG12 and create a classical feature vector of 128 features, what would be the best quantum encoding method to use in Paddle-quantum? How many qubits would I need?

Thanks!

经典分类器与量子分类器求梯度的问题

对比了一下 Tutorial 里的 QUANTUM CLASSIFIER 和 飞桨提供的手写字体识别网络,发现这两者求梯度的方式都一样,那 quantum circuit learning 里关于 Optimization procedure 的讨论有什么意义呢?既然都是用到反向传播算法求解梯度,那可不可理解为$U(\theta)$ 对应于经典网络部分的一个仿射层?都是一个向量(假设输入数据只有一笔)乘以一个矩阵。

Expectation values of Pauli strings?

Hello,
For a tutorial, I am trying to do something very simple, calculating the expectation value of:
image
Instead of:

hamiltonian = random_pauli_str_generator(N, terms=1)

How can i specify my own Hamiltonian to compare the value with the theoretical one?
Thanks

Is it possible to use ProcessPoolExecutor to accelerate the for loop in the forward method in QApproximating_EN.ipynb

Since the forward method in the example Quantum Neural Network Approximating Functions uses a for loop, it's quite slow when the depth of the circuit is large. I want to use ProcessPoolExecutor to replace the for loop.

While using ProcessPoolExecutor with paddle, this error cannot pickle 'Tensor' object always occurs. I also meet another error cannot pickle 'ParamBase' object. I'm wondering whether it's possible to accelerate the for loop. Can anyone provide a parallelized version of the example Quantum Neural Network Approximating Functions?

量子表达能力的例子报错

import numpy as np
import paddle
import paddle_quantum as pq
from paddle_quantum.ansatz.circuit import Circuit
from paddle_quantum.visual import plot_state_in_bloch_sphere

num_qubit = 1 # 设定量子比特数
num_sample = 2000 # 设定采样次数
outputs_yz = list() # 储存采样电路输出
for _ in range(num_sample):
# 初始化量子神经网络
cir = Circuit(num_qubit)
cir.ry(0)
cir.rz(0)
# 输出态的密度矩阵
rho = cir(pq.state.zero_state(num_qubit))
outputs_yz.append(rho)

plot_state_in_bloch_sphere(outputs_yz, save_gif=True, filename='figures/bloch_yz.gif')

报错如下:

ValueError Traceback (most recent call last)
[e:](file:///E:/)代码\Variational Algorithm\work_1\VQLS\1-1Revision\Expressibility测试2.py in line 9
39 cir.rz(0)
40 # 输出态的密度矩阵
----> 41 rho = cir(pq.state.zero_state(num_qubit))
42 outputs_yz.append(rho)
44 # plot_state_in_bloch_sphere(outputs_yz, save_gif=True, filename='figures/bloch_yz.gif')

File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle\nn\layer\layers.py:1254, in Layer.call(self, *inputs, **kwargs)
1245 if (
1246 (not in_declarative_mode())
1247 and (not self._forward_pre_hooks)
(...)
1251 and (not in_profiler_mode())
1252 ):
1253 self._build_once(*inputs, **kwargs)
-> 1254 return self.forward(*inputs, **kwargs)
1255 else:
1256 return self._dygraph_call_func(*inputs, **kwargs)

File d:\Software\Anaconda3\anaconda3\envs\Qpaddle\lib\site-packages\paddle_quantum\ansatz\circuit.py:1696, in Circuit.forward(self, state)
1694 state = state.clone()
1695 state.is_swap_back = False
-> 1696 state = super().forward(state)
...
1123 check_type(input, 'input', (list, tuple, Variable), 'concat')

ValueError: (InvalidArgument) The shape of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1], input[1]'s shape = [].
[Hint: Expected inputs_dims[i].size() == out_dims.size(), but received inputs_dims[i].size():0 != out_dims.size():1.] (at ..\paddle/phi/kernels/funcs/concat_funcs.h:55)

paddle-quantum == 2.4.0
将circ.rz(0)改为ry和rx都是正常运行

【PaddlePaddle Hackathon】76 量子电路的量子比特数扩展

(此 ISSUE 为 PaddlePaddle Hackathon 活动的任务 ISSUE,更多详见PaddlePaddle Hackathon

Paddle Quantum(量桨)是基于百度飞桨开发的量子机器学习工具集,支持量子神经网络的搭建与训练,提供易用的量子机器学习开发套件与量子优化、量子化学等前沿量子应用工具集,使得百度飞桨也因此成为国内首个支持量子机器学习的深度学习框架。

【任务说明】

  • 任务标题:量子电路的量子比特数扩展
  • 技术标签:量子计算、量子电路、量子比特数
  • 任务难度:简单
  • 详细描述:

用量桨创建了一个量子电路之后,在运行的过程中,有时可能需要去拓展该量子电路的量子比特数,如增加辅助量子比特等。而量桨目前没有这个功能,因此目前只能重新建立一个新的量子电路去计算。因此,拓展当前量子电路的量子比特数这一功能就显得尤为重要。在这个任务中,你需要为量桨实现量子电路的量子比特数扩展。

任务要求:实现对 n>=1 个量子比特的线路进行比特数的扩展

功能定位: 在 paddle_quantum 中的 UAnstaz 类中增加新的成员函数

函数输入: 扩展后的量子比特数

函数输出: 无

【提交内容】

  1. 项目PR到 Quantum
  2. 相关技术文档
  3. 项目单测文件

【技术要求】

  • 对量桨平台的运用有一定了解
  • 了解量桨中对量子线路的管理方式

【PaddlePaddle Hackathon】Paddle Quantum 任务合集

hi,大家好,非常高兴的告诉大家,首届 PaddlePaddle Hackathon 开始啦。PaddlePaddle Hackathon 是面向全球开发者的深度学习领域编程活动,鼓励开发者了解与参与 PaddlePaddle。本次共有四大方向(PaddlePaddle、Paddle Family、Paddle Friends、Paddle Anything)四大方向,共计100个任务共大家完成。详细信息可以参考 PaddlePaddle Hackathon 说明。大家是否已经迫不及待了呢~

本 ISSUE 是 Paddle Family 专区 Paddle Quantum 方向任务合集。具体任务列表如下:

序号 难度 任务ISSUE
76 ⭐️ 【PaddlePaddle Hackathon】76 量子电路的量子比特数扩展
77 ⭐️ 【PaddlePaddle Hackathon】77 为哈密顿量矩阵实现指定量子比特数
78 ⭐️ 【PaddlePaddle Hackathon】78 实现密度矩阵可视化
79 ⭐️ 【PaddlePaddle Hackathon】79 图片编码为量子态
80 ⭐️⭐️ 【PaddlePaddle Hackathon】80 多量子比特独立系统的 Bloch 球展示
81 ⭐️⭐️ 【PaddlePaddle Hackathon】81 时间演化电路的性能优化
82 ⭐️⭐️⭐️ 【PaddlePaddle Hackathon】82 基于量子卷积神经网络的图片分类

若想要认领本次活动任务,请至 PaddlePaddle Hackathon Pinned ISSUE 完成活动报名以及任务认领。

活动官网:PaddlePaddle Hackathon

量桨2.1.3版本导入化学分子库报错

pip 安装量桨 pip install paddle_quantum

导入化学分子库报错

from paddle_quantum import qchem

---------------------------------------------------------------------------ImportError                               Traceback (most recent call last)/tmp/ipykernel_119/2965734494.py in <module>
----> 1 from paddle_quantum import qchem
ImportError: cannot import name 'qchem' from 'paddle_quantum' (/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle_quantum/__init__.py)

还有这个:
----> 5 from paddle_quantum.qchem import geometry
      6 # dir(paddle_quantum)
      7 from paddle_quantum.circuit import UAnsatz

ModuleNotFoundError: No module named 'paddle_quantum.qchem'

发现安装目录里没有相应目录

aistudio@jupyter-209599-1708798:/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle_quantum$ ls
circuit.py   expecval.py  gradtool.py   locc.py    __pycache__  simulator.py  trotter.py  VQSD
clifford.py  finance.py   __init__.py   mbqc       QAOA         SSVQE         utils.py
dataset.py   GIBBS        intrinsic.py  optimizer  shadow.py    state.py      VQE

发现github源代码里有相应目录

[Quantum](https://github.com/PaddlePaddle/Quantum)/[paddle_quantum](https://github.com/PaddlePaddle/Quantum/tree/master/paddle_quantum)/qchem/

大胆猜测,是不是pip编译上传的时候,忘记把那个目录编译进去了?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.