Variational algorithm circuits

oracq.algorithms.optimization.variational

Parameterized quantum circuits, MaxCut QAOA, and Pauli measurement circuits for VQE.

oracq.algorithms.optimization.variational.hardware_efficient_ansatz(width, layers)[source]

Generate a parameterized circuit of Ry/Rz layers with nearest-neighbor CNOTs.

Parameters:
  • width – Width of target.

  • layers – Parameters shaped [layer][qubit][Ry,Rz]; all angles are given in radians.

Returns:

target only. Parameter optimization and repeated execution are organized by the caller.

Return type:

Operation

oracq.algorithms.optimization.variational.qaoa_maxcut(width, edges, gammas, betas)[source]

Generate the QAOA cost/mixer circuit for MaxCut.

Parameters:
  • 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.

Returns:

The QAOA circuit starting from the uniform state. Reading target yields a candidate bit string of a cut.

Return type:

Operation

The cost is Σw(1-ZuZv)/2. This function does not run a classical optimizer.

oracq.algorithms.optimization.variational.pauli_measurement(preparation, word)[source]

Rotate the prepared state into the specified Pauli measurement basis.

Parameters:
  • 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.

Returns:

target/work interface. Reading the Z parity of the non-I positions estimates the expectation of that Pauli word.

Return type:

Operation

oracq.algorithms.optimization.variational.vqe_measurements(preparation, terms)[source]

Generate measurement circuits for each term of the VQE Hamiltonian.

Parameters:
  • preparation – An ansatz with instantiated parameters or another state preparation.

  • terms – List of (real coefficient, Pauli word) pairs.

Returns:

List of (coefficient, measurement Operation) pairs. Energy aggregation and parameter optimization happen on the classical side.

Return type:

tuple