qubo_to_spo

qubo_to_spo(qubo, *, hamiltonian_builder='native', quadratization_strength=None)[source]

Convert a QUBO/HUBO directly to its cost-Hamiltonian SparsePauliOp.

The Ising encoding’s additive loss constant is baked into the returned SPO as an identity term, so the expectation value of the SPO on any computational-basis state equals the QUBO’s energy on the corresponding bitstring — no separate offset bookkeeping required at the call site. Downstream consumers that strip identity terms (e.g. VQE, CustomVQA, TrotterSpecStage) will recover the constant automatically; consumers that don’t (e.g. the QAOA cost pipeline) pick it up via the pipeline’s pure-identity expectation-value rule.

The decoder, encoding metadata, and a separately-addressable loss constant are dropped. If you need any of those, call qubo_to_ising() directly.

Parameters:
  • qubo – QUBO dict, HUBO dict, numpy matrix, BQM, or BinaryPolynomial.

  • hamiltonian_builder (Literal['native', 'quadratized']) – "native" or "quadratized".

  • quadratization_strength (float | None) – Penalty for quadratization. None (default) picks an adaptive strength — see QuadratizedIsingConverter. Ignored when hamiltonian_builder="native".

Return type:

SparsePauliOp

Returns:

SparsePauliOp over IsingResult.n_qubits qubits. Includes a single identity term carrying the Ising-encoding loss constant when that constant is non-zero.