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 — seeQuadratizedIsingConverter. Ignored whenhamiltonian_builder="native".
- Return type:
- Returns:
SparsePauliOpoverIsingResult.n_qubitsqubits. Includes a single identity term carrying the Ising-encoding loss constant when that constant is non-zero.