Skip to content

Commit

Permalink
!2284 merge to master
Browse files Browse the repository at this point in the history
Merge pull request !2284 from donghufeng/r0.9
  • Loading branch information
donghufeng authored and gitee-org committed Jan 31, 2024
2 parents 1b6cd64 + 02c4215 commit fdbbe97
Show file tree
Hide file tree
Showing 81 changed files with 2,363 additions and 125 deletions.
2 changes: 2 additions & 0 deletions .cppcheck.suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ useStlAlgorithm:ccsrc/include/ops/gates/terms_operator_base.tpp
useInitializationList:ccsrc/include/simulator/cintrin.h

ctuOneDefinitionRuleViolation:tests/core/test_circuit_block.cpp

unusedStructMember:ccsrc/include/simulator/stabilizer/stabilizer.h
1 change: 1 addition & 0 deletions .jenkins/check/config/filter_cmakelint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
"mindquantum/cmake" "whitespace/indent"
"mindquantum/cmake/Modules" "whitespace/indent"
"mindquantum/cmake/Modules/apple" "whitespace/indent"
"mindquantum/ccsrc/lib/simulator/stabilizer/CMakeLists.txt" "whitespace/indent"
1 change: 1 addition & 0 deletions .jenkins/check/config/filter_cppcheck.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@
"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_dot_like.cpp" "syntaxError"
"mindquantum/ccsrc/lib/simulator/vector/detail/cpu_common/cpu_vector_core_gate_expect.cpp" "syntaxError"
"mindquantum/ccsrc/python/mqbackend/lib/binding.cc" "syntaxError"
"mindquantum/ccsrc/include/simulator/stabilizer/stabilizer.h" "unusedStructMember"
1 change: 1 addition & 0 deletions .jenkins/check/config/whitelizard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mindquantum/mindquantum/algorithm/nisq/chem/reference_state.py:get_reference_cir
mindquantum/mindquantum/io/display/circuit_text_drawer.py:rich_circuit
mindquantum/mindquantum/utils/f.py:random_insert_gates

mindquantum/ccsrc/lib/simulator/stabilizer/stabilizer.cpp:mindquantum::stabilizer::StabilizerTableau::Decompose
mindquantum/ccsrc/include/simulator/vector/vector_state.tpp:mindquantum::sim::vector::detail::VectorState<qs_policy_t_>::GetExpectationWithGradParameterShiftOneMulti
mindquantum/ccsrc/include/ops/gates.h:mindquantum::GetGateByName
mindquantum/ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::QubitOperator<coeff_t>::sparse_matrix
Expand Down
1 change: 1 addition & 0 deletions .whitelizard.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mindquantum/algorithm/nisq/chem/reference_state.py:get_reference_circuit
mindquantum/io/display/circuit_text_drawer.py:rich_circuit
mindquantum/utils/f.py:random_insert_gates

ccsrc/lib/simulator/stabilizer/stabilizer.cpp:mindquantum::stabilizer::StabilizerTableau::Decompose
ccsrc/include/simulator/vector/vector_state.tpp:mindquantum::sim::vector::detail::VectorState<qs_policy_t_>::GetExpectationWithGradParameterShiftOneMulti
ccsrc/include/ops/gates.h:mindquantum::GetGateByName
ccsrc/include/ops/gates/qubit_operator.tpp:mindquantum::ops::QubitOperator<coeff_t>::sparse_matrix
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![PyPI](https://img.shields.io/badge/pypi_package-0.9.0-limegreend.svg)](https://gitee.com/mindspore/mindquantum/tree/r0.9/)
[![Downloads](https://static.pepy.tech/badge/mindquantum)](https://pepy.tech/project/mindquantum)
[![API](https://img.shields.io/badge/API-MindQuantum-red.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/overview.html)
[![Tutorial](https://img.shields.io/badge/Tutorial-MindQuantum-limegreend.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/parameterized_quantum_circuit.html)
[![Tutorial](https://img.shields.io/badge/Tutorial-MindQuantum-limegreend.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/beginner/parameterized_quantum_circuit.html)
[![Issues](https://img.shields.io/badge/Issues-MindQuantum-limegreend.svg)](https://gitee.com/mindspore/mindquantum/issues)
[![Release](https://img.shields.io/badge/Release-MindQuantum-limegreend.svg)](https://gitee.com/mindspore/mindquantum/releases)
[![LICENSE](https://img.shields.io/badge/license-Apache_2.0-green.svg)](https://gitee.com/mindspore/mindquantum/blob/master/LICENSE)
Expand Down Expand Up @@ -119,26 +119,26 @@ The trained parameters are,

1. Basic usage

- [Variational Quantum Circuit](https://mindspore.cn/mindquantum/docs/en/master/parameterized_quantum_circuit.html)
- [Quantum simulator](https://www.mindspore.cn/mindquantum/docs/en/master/quantum_simulator.html)
- [Initial experience of quantum neural network](https://www.mindspore.cn/mindquantum/docs/en/master/initial_experience_of_quantum_neural_network.html)
- [Advanced gradient calculation of variational quantum circuits](https://www.mindspore.cn/mindquantum/docs/en/master/get_gradient_of_PQC_with_mindquantum.html)
- [Advanced operations of quantum circuit](https://www.mindspore.cn/mindquantum/docs/en/master/advanced_operations_of_quantum_circuit.html)
- [Quantum Measurement](https://www.mindspore.cn/mindquantum/docs/en/master/quantum_measurement.html)
- [Noisy Quantum Circuit](https://www.mindspore.cn/mindquantum/docs/en/master/noise.html)
- [Noise simulator](https://www.mindspore.cn/mindquantum/docs/en/master/noise_simulator.html)
- [Qubit Mapping](https://www.mindspore.cn/mindquantum/docs/en/master/qubit_mapping.html)
- [Bloch Sphere](https://www.mindspore.cn/mindquantum/docs/en/master/bloch_sphere.html)
- [Variational Quantum Circuit](https://mindspore.cn/mindquantum/docs/en/master/beginner/parameterized_quantum_circuit.html)
- [Quantum simulator](https://www.mindspore.cn/mindquantum/docs/en/master/beginner/quantum_simulator.html)
- [Initial experience of quantum neural network](https://www.mindspore.cn/mindquantum/docs/en/master/advanced/initial_experience_of_quantum_neural_network.html)
- [Advanced gradient calculation of variational quantum circuits](https://www.mindspore.cn/mindquantum/docs/en/master/advanced/get_gradient_of_PQC_with_mindquantum.html)
- [Advanced operations of quantum circuit](https://www.mindspore.cn/mindquantum/docs/en/master/beginner/advanced_operations_of_quantum_circuit.html)
- [Quantum Measurement](https://www.mindspore.cn/mindquantum/docs/en/master/beginner/quantum_measurement.html)
- [Noisy Quantum Circuit](https://www.mindspore.cn/mindquantum/docs/en/master/middle_level/noise.html)
- [Noise simulator](https://www.mindspore.cn/mindquantum/docs/en/master/middle_level/noise_simulator.html)
- [Qubit Mapping](https://www.mindspore.cn/mindquantum/docs/en/master/middle_level/qubit_mapping.html)
- [Bloch Sphere](https://www.mindspore.cn/mindquantum/docs/en/master/beginner/bloch_sphere.html)
2. Variational quantum algorithm
- [Classification of iris by quantum neural network](https://www.mindspore.cn/mindquantum/docs/en/master/classification_of_iris_by_qnn.html)
- [Quantum Approximate Optimization Algorithm](https://mindspore.cn/mindquantum/docs/en/master/quantum_approximate_optimization_algorithm.html)
- [The Application of Quantum Neural Network in NLP](https://mindspore.cn/mindquantum/docs/en/master/qnn_for_nlp.html)
- [VQE Application in Quantum Chemistry Computing](https://mindspore.cn/mindquantum/docs/en/master/vqe_for_quantum_chemistry.html)
- [Equivalence Checking of Parameterized Quantum Circuits](https://www.mindspore.cn/mindquantum/docs/en/master/equivalence_checking_of_PQC.html)
- [Classification of iris by quantum neural network](https://www.mindspore.cn/mindquantum/docs/en/master/case_library/classification_of_iris_by_qnn.html)
- [Quantum Approximate Optimization Algorithm](https://mindspore.cn/mindquantum/docs/en/master/case_library/quantum_approximate_optimization_algorithm.html)
- [The Application of Quantum Neural Network in NLP](https://mindspore.cn/mindquantum/docs/en/master/case_library/qnn_for_nlp.html)
- [VQE Application in Quantum Chemistry Computing](https://mindspore.cn/mindquantum/docs/en/master/case_library/vqe_for_quantum_chemistry.html)
- [Equivalence Checking of Parameterized Quantum Circuits](https://www.mindspore.cn/mindquantum/docs/en/master/advanced/equivalence_checking_of_PQC.html)
3. GENERAL QUANTUM ALGORITHM
- [Quantum Phase Estimation algorithm](https://www.mindspore.cn/mindquantum/docs/en/master/quantum_phase_estimation.html)
- [Grover search and long algorithms based on MindQuantum](https://www.mindspore.cn/mindquantum/docs/en/master/grover_search_algorithm.html)
- [Shor’s algorithm based on MindQuantum](https://www.mindspore.cn/mindquantum/docs/en/master/shor_algorithm.html)
- [Quantum Phase Estimation algorithm](https://www.mindspore.cn/mindquantum/docs/en/master/case_library/quantum_phase_estimation.html)
- [Grover search and long algorithms based on MindQuantum](https://www.mindspore.cn/mindquantum/docs/en/master/case_library/grover_search_algorithm.html)
- [Shor’s algorithm based on MindQuantum](https://www.mindspore.cn/mindquantum/docs/en/master/case_library/shor_algorithm.html)

## API

Expand Down
42 changes: 21 additions & 21 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![PyPI](https://img.shields.io/badge/pypi_package-0.9.0-limegreend.svg)](https://gitee.com/mindspore/mindquantum/tree/r0.9/)
[![Downloads](https://static.pepy.tech/badge/mindquantum)](https://pepy.tech/project/mindquantum)
[![API](https://img.shields.io/badge/API-MindQuantum-red.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/overview.html)
[![Tutorial](https://img.shields.io/badge/Tutorial-MindQuantum-limegreend.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/parameterized_quantum_circuit.html)
[![Tutorial](https://img.shields.io/badge/Tutorial-MindQuantum-limegreend.svg)](https://mindspore.cn/mindquantum/docs/zh-CN/master/beginner/parameterized_quantum_circuit.html)
[![Issues](https://img.shields.io/badge/Issues-MindQuantum-limegreend.svg)](https://gitee.com/mindspore/mindquantum/issues)
[![Release](https://img.shields.io/badge/Release-MindQuantum-limegreend.svg)](https://gitee.com/mindspore/mindquantum/releases)
[![LICENSE](https://img.shields.io/badge/license-Apache_2.0-green.svg)](https://gitee.com/mindspore/mindquantum/blob/master/LICENSE)
Expand Down Expand Up @@ -120,31 +120,31 @@ print(dict(zip(ansatz.params_name, net.trainable_params()[0].asnumpy())))

1. 基础使用指南

- [变分量子线路](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/parameterized_quantum_circuit.html)
- [量子模拟器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/quantum_simulator.html)
- [量子神经网络初体验](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/initial_experience_of_quantum_neural_network.html)
- [变分量子线路梯度计算进阶](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/get_gradient_of_PQC_with_mindquantum.html)
- [量子线路高阶操作](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/advanced_operations_of_quantum_circuit.html)
- [量子测量](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/quantum_measurement.html)
- [含噪声量子线路](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/noise.html)
- [噪声模拟器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/noise_simulator.html)
- [比特映射](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/qubit_mapping.html)
- [布洛赫球](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/bloch_sphere.html)
- [变分量子线路](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/beginner/parameterized_quantum_circuit.html)
- [量子模拟器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/beginner/quantum_simulator.html)
- [量子神经网络初体验](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/advanced/initial_experience_of_quantum_neural_network.html)
- [变分量子线路梯度计算进阶](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/advanced/get_gradient_of_PQC_with_mindquantum.html)
- [量子线路高阶操作](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/beginner/advanced_operations_of_quantum_circuit.html)
- [量子测量](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/beginner/quantum_measurement.html)
- [含噪声量子线路](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/middle_level/noise.html)
- [噪声模拟器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/middle_level/noise_simulator.html)
- [比特映射](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/middle_level/qubit_mapping.html)
- [布洛赫球](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/beginner/bloch_sphere.html)

2. 变分量子算法

- [通过量子神经网络对鸢尾花进行分类](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/classification_of_iris_by_qnn.html)
- [量子近似优化算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/quantum_approximate_optimization_algorithm.html)
- [量子神经网络在自然语言处理中的应用](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/qnn_for_nlp.html)
- [在量子化学计算中应用量子变分求解器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/vqe_for_quantum_chemistry.html)
- [含参量子线路的等价性检查](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/equivalence_checking_of_PQC.html)
- [通过量子神经网络对鸢尾花进行分类](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/classification_of_iris_by_qnn.html)
- [量子近似优化算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/quantum_approximate_optimization_algorithm.html)
- [量子神经网络在自然语言处理中的应用](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/qnn_for_nlp.html)
- [在量子化学计算中应用量子变分求解器](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/vqe_for_quantum_chemistry.html)
- [含参量子线路的等价性检查](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/advanced/equivalence_checking_of_PQC.html)

3. 通用量子算法

- [量子相位估计算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/quantum_phase_estimation.html)
- [基于MindQuantum的Grover搜索算法和龙算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/grover_search_algorithm.html)
- [基于MindQuantum的Shor算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/shor_algorithm.html)
- [HHL算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/hhl_algorithm.html)
- [量子相位估计算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/quantum_phase_estimation.html)
- [基于MindQuantum的Grover搜索算法和龙算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/grover_search_algorithm.html)
- [基于MindQuantum的Shor算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/shor_algorithm.html)
- [HHL算法](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/case_library/hhl_algorithm.html)

## API

Expand Down Expand Up @@ -235,7 +235,7 @@ export OMP_NUM_THREADS=4

对于大型服务器,请根据模型规模合理设置并行内核数以达到最优效果。

更多注意事项请查看[FAQ页面](https://gitee.com/mindspore/mindquantum/blob/master/tutorials/0.frequently_asked_questions.ipynb)。
更多注意事项请查看[FAQ页面](https://gitee.com/mindspore/mindquantum/blob/r0.8/tutorials/0.frequently_asked_questions.ipynb)。

## 构建二进制whl包

Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- [STABLE] [`GroupedPauli`](https://www.mindspore.cn/mindquantum/docs/en/master/core/gates/mindquantum.core.gates.GroupedPauli.html#mindquantum.core.gates.GroupedPauli): Add Pauli combination gate. This gate allows for faster execution compared to individually applying single Pauli gates.
- [STABLE] [`GroupedPauliChannel`](https://www.mindspore.cn/mindquantum/docs/en/master/core/gates/mindquantum.core.gates.GroupedPauliChannel.html#mindquantum.core.gates.GroupedPauliChannel): Add Pauli combination channel. This channel allows for faster execution compared to applying Pauli channels individually.
- [STABLE] [`SX`](https://www.mindspore.cn/mindquantum/docs/en/master/core/gates/mindquantum.core.gates.SXGate.html#mindquantum.core.gates.SXGate): Add sqrt X gate.
- [STABLE] [Givens]: Add Givens rotation gate.
- [STABLE] [`Givens`](https://www.mindspore.cn/mindquantum/docs/en/master/core/gates/mindquantum.core.gates.Givens.html): Add Givens rotation gate.

#### Circuit

Expand Down
4 changes: 2 additions & 2 deletions RELEASE_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- [STABLE] [`GroupedPauli`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/gates/mindquantum.core.gates.GroupedPauli.html#mindquantum.core.gates.GroupedPauli): 新增泡利组合门,该门比逐个执行单个泡利门会更加快速。
- [STABLE] [`GroupedPauliChannel`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/gates/mindquantum.core.gates.GroupedPauliChannel.html#mindquantum.core.gates.GroupedPauliChannel): 新增泡利信道组合信道,该组合信道比逐一执行泡利信道更快。
- [STABLE] [`SX`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/gates/mindquantum.core.gates.SXGate.html): 新增根号X门。
- [STABLE] [Givens]: 新增Givens旋转门。
- [STABLE] [`Givens`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/core/gates/mindquantum.core.gates.Givens.html): 新增Givens旋转门。

#### Circuit

Expand All @@ -43,7 +43,7 @@
#### utils

- [STABLE] [`进度条`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/mindquantum.utils.html#progress-bar): 新增两个基于rich构建的简单易用的进度条,分别为支持单层循环的[`SingleLoopProgress`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/utils/mindquantum.utils.SingleLoopProgress.html#mindquantum.utils.SingleLoopProgress)和支持两层循环的[`TwoLoopsProgress`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/utils/mindquantum.utils.TwoLoopsProgress.html#mindquantum.utils.TwoLoopsProgress)
- [Alpha] [random_insert_gates]: 支持在量子线路中随机插入量子门。
- [Alpha] [`random_insert_gates`](https://www.mindspore.cn/mindquantum/docs/zh-CN/master/utils/mindquantum.utils.random_insert_gates.html): 支持在量子线路中随机插入量子门。

#### Algorithm

Expand Down
79 changes: 79 additions & 0 deletions ccsrc/include/math/longbits/longbits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* Copyright (c) Huawei Technologies Co., Ltd. 2024. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef MATH_LONGBITS_LONGBITS_H_
#define MATH_LONGBITS_LONGBITS_H_
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>

#include <fmt/core.h>
namespace mindquantum {
class LongBits {
using ele_t = uint64_t;

public:
LongBits() = default;
explicit LongBits(size_t n_bits);

// -----------------------------------------------------------------------------

void operator^=(const LongBits& other);
void operator&=(const LongBits& other);
LongBits operator^(const LongBits& other) const;
LongBits operator&(const LongBits& other) const;
bool operator==(const LongBits& other) const;

// -----------------------------------------------------------------------------

void SetBit(size_t poi, bool val);

size_t GetBit(size_t poi) const;

std::string ToString() const;

void InplaceFlip();
LongBits Flip();

bool Any(size_t start, size_t end);

bool Any(size_t start);

private:
LongBits(size_t n_bits, const std::vector<ele_t>& data);

private:
size_t n_bits = 1;
std::vector<ele_t> data = {0};
};
} // namespace mindquantum

// -----------------------------------------------------------------------------

template <>
struct fmt::formatter<mindquantum::LongBits> {
constexpr auto parse(format_parse_context& ctx) { // NOLINT(runtime/references)
return ctx.begin();
}
template <typename FormatContext>
auto format(const mindquantum::LongBits& obj, FormatContext& ctx) { // NOLINT(runtime/references)
return format_to(ctx.out(), obj.ToString());
}
};
#endif
Loading

0 comments on commit fdbbe97

Please sign in to comment.