变分算法电路¶
oracq.algorithms.optimization.variational
Parameterized quantum circuits, MaxCut QAOA, and Pauli measurement circuits for VQE.
- oracq.algorithms.optimization.variational.hardware_efficient_ansatz(width, layers)[源代码]¶
Generate a parameterized circuit of Ry/Rz layers with nearest-neighbor CNOTs.
- 参数:
width -- Width of target.
layers -- Parameters shaped [layer][qubit][Ry,Rz]; all angles are given in radians.
- 返回:
target only. Parameter optimization and repeated execution are organized by the caller.
- 返回类型:
- oracq.algorithms.optimization.variational.qaoa_maxcut(width, edges, gammas, betas)[源代码]¶
Generate the QAOA cost/mixer circuit for MaxCut.
- 参数:
width -- Number of graph vertices, also the width of target.
edges -- (u,v,weight) triples with nonnegative weights; self-loops are not accepted.
gammas -- Cost evolution angles per layer.
betas -- Mixer evolution angles per layer, of the same length as gammas.
- 返回:
The QAOA circuit starting from the uniform state. Reading target yields a candidate bit string of a cut.
- 返回类型:
The cost is Σw(1-ZuZv)/2. This function does not run a classical optimizer.
- oracq.algorithms.optimization.variational.pauli_measurement(preparation, word)[源代码]¶
Rotate the prepared state into the specified Pauli measurement basis.
- 参数:
preparation -- A state preparation with zero input and a clean work space.
word -- An I/X/Y/Z string of the same width; the first character corresponds to the least significant bit.
- 返回:
target/work interface. Reading the Z parity of the non-I positions estimates the expectation of that Pauli word.
- 返回类型:
- oracq.algorithms.optimization.variational.vqe_measurements(preparation, terms)[源代码]¶
Generate measurement circuits for each term of the VQE Hamiltonian.
- 参数:
preparation -- An ansatz with instantiated parameters or another state preparation.
terms -- List of (real coefficient, Pauli word) pairs.
- 返回:
List of (coefficient, measurement Operation) pairs. Energy aggregation and parameter optimization happen on the classical side.
- 返回类型:
tuple