Changelog¶
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Effort-based versioning.
Unreleased¶
Added¶
Generic QPE circuit construction from arbitrary per-phase-qubit unitaries:
qpe_circuit(with an optionalwith_iqftflag to stop after the controlled unitaries, i.e. the QPE first stage) andqpe_gatesin theestimationmodule. Each powerU^(2^k)is supplied as an independent gate list (possibly lazy), enabling non-squaring implementations such as Shor’s algorithm.exact_evolution_powersandtrotter_evolution_powersto build the controlled unitaries from aHamiltonian, andevolution_powersdispatching between them according ton_trotter_steps.qpe_gate_listto build the QPE gate list without simulation, for resource analysis and serialization; gates are written to disk when itssavefileargument is set.trotter_evolution_gatesto build the gate sequence of a single Trotterized evolutionU(t).add_gate_controlsin thecircuitmodule, lazily yielding the controlled gates.Hamiltonian.to_sparse_matrixreturning the Hamiltonian as a SciPy sparse matrix.transpile_mpo_to_circuit: convenience wrapper chaininginit_cost_tn,find_transfer_structure,build_first_sweepandoptimize_single_gate_updateto fit a brickwall circuit ansatz to a reference MPO in one call.init_cost_tnandtranspile_mpo_to_circuitare now re-exported fromqpe_toolbox.circuit.state_preparation_mpois now re-exported fromqpe_toolbox.tensor.trotter_approx_as_MPOis now re-exported fromqpe_toolbox.hamiltonian.optimize_single_gate_update/transpile_mpo_to_circuit: keyword-onlyoptimizeargument selecting the contraction strategy of each gate’s local environment.measure_rpe_phasesandrefine_rpe_phases, splittingrobust_phase_estimationinto a measurement stage (raw phasesphi_m) and a simulation-free classical retrieval stage (refined phasestheta_m).
Changed¶
Breaking:
controlled_mpono longer takesphys_regandaux_reg: its signature is nowcontrolled_mpo(mpo, k_ctrl, *, ctrl=1). Both registers were redundant, the control site and the MPO length being enough to build the result. The register ordering restriction is gone with them, so the control qubit may now sit anywhere in the MPO rather than below every physical qubit.Breaking:
qpe_sample,qpe_first_stageandqpe_energyno longer accept the output-mode flagsrun_simulation/write_gates; useqpe_gate_listfor the gate-tracking and serialization mode.Breaking: the Trotter discretization is now specified as an integer number of steps
n_trotter_stepsinstead of a step sizedt(computed internally asdt = evolution_time / n_trotter_steps).qpe_sampleandqpe_first_stagereplacedtwithn_trotter_steps;qpe_energyandrobust_phase_estimationrename theirn_stepsargument ton_trotter_steps.Breaking: the Hadamard test (
build_hadamard_test_circuit,run_hadamard_test) is now built onqpe_circuitand takes the unitary in the framework convention (argumentU_gaterenamed tounitary): either a single gate or an iterable of uncontrolled gates on data-register-local qubit indices. Their phase-rotation argumentthetais renamed tophase_gate_angle. Both functions, as well asestimate_overlap_phase, now expose the underlyingCircuitMPStruncation knobscutoffandmax_bond.Breaking:
rpe_get_hadamard_outputis renamedestimate_overlap_phase, since it computes the phase of an overlap and runs no Hadamard test. It now takes a prebuiltunitary(a single gate or an iterable of gates) together withn_shots, instead of building the evolution from the Hamiltonian and an evolution time.Breaking:
Hamiltonian.get_U_exactis renamedHamiltonian.get_exact_unitary. It andHamiltonian.get_trotter_stepnow take the physical register as a keyword-onlyphys_regargument (renamed fromdata_reg), defaulting torange(n_qubits).get_trotter_steptakestrotter_orderbefore the keyword-only arguments (get_trotter_step(dt, trotter_order, *, phys_reg=None)), andget_exact_unitary’scontrolsis now optional (get_exact_unitary(evolution_time, *, phys_reg=None, controls=None)).Breaking:
robust_phase_estimationreplacedepsilonwithn_repetitions, removedsign_E0, added anrngargument for deterministic sampling, added at0argument setting the base evolution time, and changed thetrotter_orderdefault from 2 to 1. The estimated phase is nowE0 * t0, so the energy is recovered astheta / t0. The returned list now has lengthn_repetitions(no leading placeholder).Breaking:
shift_control_gatesreturns a one-shot generator instead of a list, so the controlled copies are built as they are applied rather than all at once. Callers iterating over the result more than once must wrap it inlist.Breaking:
draw_layered_circuit/draw_layered_expvalreplaced thelist_namesargument with three keyword-only argumentsstate_label,labels_1qubitandlabels_2qubit. A label list shorter than the circuit depth now raisesValueErrorinstead of failing with anIndexErrorwhile drawing.Breaking: Trotter-Suzuki MPO functions (
trotter_approx_as_MPO,trotter1_approx_as_MPO,trotter2_approx_as_MPO,trotter4_approx_as_MPO,exp_Pauli_string_as_MPO) moved fromqpe_toolbox.circuit.mpo_circuit_transpilationtoqpe_toolbox.hamiltonian.trotterization, androtation_gatesmoved there fromqpe_toolbox.hamiltonian.hamiltonian.state_preparation_mpomoved toqpe_toolbox.tensor.mpomps_tools. Importing the Trotter functions orstate_preparation_mpofromqpe_toolbox.circuit.mpo_circuit_transpilationnow raisesImportError;rotation_gatescan still be imported from its old module.Breaking:
trotter_approx_as_MPOrenamedordertotrotter_order, consistent withHamiltonian.get_trotter_stepand every QPE/RPE function in the codebase.dtis now positional, andtrotter_order,cutoffandmax_bonddefault to1,1e-10andNone.Breaking:
trotter1_approx_as_MPO/trotter2_approx_as_MPO/trotter4_approx_as_MPOtake aHamiltonianand a positionaldtinstead ofham_terms, n_qubitsand a keyword-onlydt.cutoffandmax_bonddefault to1e-10andNone.Breaking:
exp_Pauli_string_as_MPOsignature changed from(ham_term, n_qubits, *, theta)to(term, dt, n_qubits), and it now buildsexp(-i * dt * coeff * P), matchingrotation_gatesand the Trotter functions: passdt = -thetato recover the oldexp(i * theta * coeff * P). It also raisesValueErrorif a qubit is repeated or out of range.Breaking:
mpo_circuit_transpilationhelpers:update_dict_contr_envsrenamed toupdate_contracted_envs; it andupdate_cost_tntake a single gate tensor instead of a list. Argumentsdict_transf,dict_contr_envsandxrenamed totransfer_structure,contracted_envsandsite_index.Breaking:
tn_fit:tags,steps,tolandcontract_optimizeare now keyword-only. A progress bar is always shown; setTQDM_DISABLE=1before importingtqdmto silence it. RaisesTypeErroron parametrized tensors, andValueErroriftagsselects anything other than whole two-qubit gates (e.g. gates split by quimb’s defaultgate_contract).tags=Noneis no longer supported, as it never worked on a circuit state.run_hadamard_test/estimate_overlap_phase: replacedseedwith anrng(numpy.random.Generator) argument.init_cost_tn: replacedseed(int) with anrng(numpy.random.Generator) argument, consistent with the rest of the codebase.state_preparation_mpo: raisesValueErrorunless the MPS arrays are in'lpr'order (as returned byDMRG2), instead of silently building a wrong MPO.optimize_single_gate_update: now returns(cost_tn, contracted_envs, overlap), whereoverlapis normalized by2**n_qubits.Renamed
rpe_distancetoangular_distance; it is now vectorized.rpe_update_theta: signature changed to(phi_m, theta_ref, m), now returning a single angle.Hamiltonian.to_denseandHamiltonian.get_exact_unitaryare faster for larger systems.optunadependency moved from core dependency to recommended.qpe_toolboxsubpackages are reachable as attributes without an explicit submodule import (import qpe_toolbox; qpe_toolbox.estimation), loaded on first access soimport qpe_toolboxstays cheap.dir(qpe_toolbox)lists only the public API.RPE now measures each phase from a single control-free
CircuitMPSsimulation of the overlap⟨ψ₀|U|ψ₀⟩(no ancilla qubit) instead of two Hadamard-test circuits; finiten_shotsare emulated from the exact expectation via the Bernoulli law rather than by circuit sampling. Without an ancilla to entangle, the simulated state carries less entanglement, so the result is more accurate at a givenmax_bond.robust_phase_estimation:verbosity=1now prints bothphi_mandtheta_m; the per-iteration progress moved toverbosity=2.
Removed¶
rpe_distance(renamed toangular_distance).hyperoptimizationexample and all QAOA-related code:examples/hyperoptimization.py,src/qpe_toolbox/circuit/qaoa.pyandtests/test_qaoa.py. This removesbrute_force_maxcut,compute_qaoa_contraction_costsandstudy_optimization_time_costsfromqpe_toolbox.circuit.tn_fit: theprogbarargument.PRC_loc_cost_tn, inlined into the newoptimize_one_gate.two_qubit_rand_layer: thereverseargument. It only changed the order in which overlapping gates were applied, and never the control direction its documentation claimed.Unused internal helpers with no remaining call site:
count_gates_qft_swapped(estimation.qft),make_fermionic_hamiltonian_auto(hamiltonian.pyscf_converter) andadd_creg_mpo(tensor.mpomps_tools).
Fixed¶
controlled_mpo: the shape and identity checks were applied to the last auxiliary site instead of the control sitek_ctrlthat is actually replaced, and required an interior tensor with four legs. A single-qubit auxiliary register sits at the start of the MPO and has only three, so LCU QPE with one phase qubit (run_qpe_lcu_walk_operatorwithm_ph=1) raisedValueError: Invalid MPO tensor shapeinstead of running.draw_layered_expval: two-qubit layer labels were indexed in the opposite direction to single-qubit ones, so the two label lists disagreed on which layer they were naming.draw_layered_circuit/draw_layered_expval: unlabelled diagrams drew['']next to every qubit instead of nothing.trotter4_approx_as_MPO: the 4th-order Suzuki “triple-jump” composition applied its middle-layer factor twice instead of sandwiching it between two applications of the outer-layer factor, sotrotter_order=4was less accurate thantrotter_order=1. The error of a single step now scales asdt**5.exp_Pauli_string_as_MPO: Pauli letters were assigned in increasing qubit order, so terms listing their qubits unsorted put the letters on the wrong qubits.exp_Pauli_string_as_MPO: the MPO was compressed with a fixedcutoff=1e-6, which dropped Hamiltonian terms withabs(dt * coeff)below about1e-3. It is now only truncated at machine precision.optimize_single_gate_update: optimized gate tensors could end up with their input legs swapped, so reading their data as a gate matrix gave the wrong gate.run_hadamard_test(withn_shots=EXACT) andestimate_overlap_phase: the measured expectation values were not normalized by the state norm, so a truncated MPS (which quimb leaves sub-normalized) gave a biased phase, and apsi0of norm different from 1 an outright wrong one.
1.1.0 - 2026-04-02¶
Changed¶
misc documentation improvement.
qiskit-aerswitched from test group to core dependency.kahyparswitched from core to optional dependency.cotengrustadded as optional dependency.
1.0.0 - 2026-03-18¶
Added¶
Initial public release of
qpe-toolbox.circuitmodule:quimbcircuit construction, parametrized circuits, QAOA, gate counting, serialization, and plotting.hamiltonianmodule:Hamiltonianclass, spin models,pyscfinterface for molecular chemistry, fermionic encodings viaopenfermion.estimationmodule: textbook and robust QPE variants, LCU walk operators, block encoding, QFT, Hadamard test.tensormodule: MPS/MPO utilities beyond whatquimbprovides natively.Sphinx documentation deployed to GitHub Pages.
Full test suite with ≥ 70 % branch coverage.
CI/CD workflows for testing and PyPI publishing.