Skip to content

Changelog

All notable changes to Polypus are documented here. The format follows Keep a Changelog and the project uses Semantic Versioning. While the version is 0.x, a minor release may contain breaking changes; they are marked BREAKING below (Conventional Commits !).

Entries were curated from the Conventional Commits history. Releases before 0.6.0 predate the convention and are summarised by hand.

Unreleased

0.9.0 - 2026-11-30

Upgrading from 0.8

Breaking changes are marked BREAKING under Changed, Removed and Fixed. Where to look first:

  • Python users. The native QML API is stricter: a bool or NumPy bool_ where it takes a count or an execution integer (num_qubits, reps, shots, seed, batch_size, ...) is a TypeError (#571, #607); a complex x, y or y_train is a TypeError instead of losing its imaginary part (#602); a model is limited to 1 000 000 qubits and 4 000 000 gates (#572); and Ansatz.conv(..., pairing="odd_pairs") below three active qubits is a ValueError (#631). qml.load refuses saved models that break these rules. An explicit seed of 2**63 or more with backend="aer" or infrastructure="cunqa" raises polypus.ConfigurationError: pass seed & (2**63 - 1) to replay such a run (#393). On Linux, a native circuit of 31 to 40 qubits runs when the memory budget holds it and raises polypus.InsufficientMemoryError otherwise (#428). The internal polypus_python package drops test_connection and the unread Local(num_qpus=...) arguments (#419).
  • Rust users. polypus-physics: PauliAxis, PauliTerm and PauliSum moved to hamiltonians::pauli and became multi-qubit, PauliSum is built with PauliSum::new, photon_polarization_hamiltonian returns a Result, and PhysicsError is #[non_exhaustive] with new variants (#529, #535). polypus-qml: QmlError, ValidationError and Layer have new variants (#501, #504, #505, #513, #570, #572, #631). OptimizationOutcome has a stop_reason field (#431), TrainFlow and RunCircuitFlow a trace field (None keeps the old behaviour), and polypus_sim::MAX_QUBITS is 40 (#428).
  • Build. The qmio feature needs Rust 1.89 (zeromq 0.7, #383); the default features still build with Rust 1.85.
  • Third-party backend authors. Depend on "0.9". polypus-backend has only additions, such as shot_groups (#419) and the memory-budget helpers of #428.

Added

  • polypus_backend::shot_groups is public: it splits a per-replica shot list into runs of equal shot counts, as (first replica, shots, replicas), the grouping the default QuantumBackend::run_shots_distributed and the CUNQA backend submit by, for a backend that overrides that method (#419).
  • The native simulator now goes beyond 30 qubits where the memory budget allows it (#428). Up to polypus_sim::MAX_QUBITS = 40, a known budget (POLYPUS_MEM_BUDGET, or the RAM/cgroup limit detected on Linux) decides: a statevector that fits runs, one that does not is refused with polypus.InsufficientMemoryError before anything is allocated. Where no memory limit is detected (macOS, Windows) statevectors still stop at 30 qubits with the same error as before, whose message now names POLYPUS_MEM_BUDGET as the way to lift it. A direct polypus-sim caller gets the new SimError::AllocationFailed instead of an abort when the system refuses a statevector's memory. Calibration still reports 31 for never (so caches keep their meaning), and the new CalibrationResult::parallel_threshold() and CalibrationOutcome::parallel_threshold() give the value to set as a simulator's parallel_threshold, with never as usize::MAX, now that 31-qubit circuits exist.
  • TrainResult.stop_reason and TrainResult.n_evaluations on train, qml.train and Model.fit. stop_reason names what ended the optimizer's loop: "iteration_budget", "evaluation_budget" (L-SHADE's schedule, External's max_evaluations), "fitness_tolerance", "parameter_tolerance" (PSO), "degenerate" (CMA-ES), "optimizer_finished" (External's empty ask()) or "callback". n_evaluations counts the candidates scored as a fitness, as TrainProgress.evaluations does, plus the re-score of best_params on the whole training set when a gradient-free optimizer trains on minibatches; the shifted circuits of an exact gradient (Adam in qml.Model.fit) and the final batch are not counted. In Rust: polypus_optimizers::StopReason, OptimizationOutcome::stop_reason and TrainOutcome::n_evaluations. Seeded results are unchanged (#431).
  • Typed execution targets: polypus.Aer, Native, Cunqa, Qmio and Registered, each checking its own fields when built (except sim_method, which Aer checks when the run starts), and a target= keyword on run_quantum_circuit, train, qml.train and qml.predict that replaces infrastructure, backend and their provider arguments (passing one of those next to it is a ConfigurationError, except backend or sim_method left at its default). Strings stay as shorthand; every accepted infrastructure/backend spelling now resolves through one alias table with unchanged errors. infrastructure (and, for train/qml.train, nodes, cores_per_qpu and id) now defaults to None so a call with target= can omit them; without target= they are still required (#434).
  • polypus.log_to_python() forwards the Rust core's log records to Python's logging, as an alternative to polypus.init_logger() (only one of the two can be installed per process). Each record goes to the logger named after the Rust module that emitted it under polypus (polypus_optimizers::util to polypus.optimizers.util), so logging.getLogger("polypus") sets the level, handlers and format of everything Polypus logs. Records carry the Rust file and line, the levels are read from Python at the start of each call, a disabled record never takes the GIL, and an ERROR or WARNING record emitted while the interpreter is shutting down goes to stderr as one fixed line instead of being lost (#458).
  • polypus.qml.Model.num_observables, the readout's observables (the columns of qml.expval), and pickling of Model, so copy.deepcopy works: it travels as the JSON of its spec, rebuilt through the checks of qml.load (#502).
  • polypus.torch.QuantumLayer(model, *, initial_params=None, seed=None, ...), a torch.nn.Module over a native qml.Model for hybrid quantum-classical networks: forward = qml.expval over the batch, backward = one qml.vjp call with the incoming gradient (parameters, inputs or both; #559), so it trains with any torch.optim optimizer; float32 networks work as is (the computation is float64 on the CPU; a complex input is a TypeError, #602), and a seed derives one per backend call so a training replays. polypus.torch.from_trained(trained, ...) starts one from a TrainedModel. PyTorch is the new optional extra pip install "polypus-quantum[torch]" (torch>=2.14.1,<3); import polypus does not import it (#502). See examples/qml_torch_hybrid.py.
  • Exact gradients of native QML by adjoint differentiation (#503): with exact=True on the native backend, Model.fit's Adam gradient, qml.jacobian and polypus.torch.QuantumLayer's backward pass take about three simulations per row (and observable) whatever the number of parameters, instead of two circuits per trainable gate; no API changes. The result is the parameter-shift gradient to rounding; shots keep the parameter shift, and so does exact mode when the memory budget holds one statevector of the model's width but not the two the adjoint needs (logged at info once per fit or qml.jacobian call). A Ctrl+C now also stops an exact qml.jacobian inside a block. In polypus-sim: StatevectorSimulator::adjoint_gradient, AdjointGradient, ADJOINT_STATEVECTORS and four SimError variants (GateIndexOutOfRange, NotDifferentiable, PartialMeasurement, NonFiniteWeight). In polypus-qml: QmlProblem::adjoint_runs/gradient_from_adjoint, JacobianBlock::adjoint_runs/num_adjoint_runs/jacobian_from_adjoint (and ExpectationJacobian's), AdjointRun and DiagonalObservable. In polypus-infrastructure: NativeStatevectorBackend::adjoint_fits/ run_adjoint and AdjointTask. benchmarks/bench_adjoint.py measures it.
  • polypus.qml.kernel_matrix(encoder, x1, x2=None, *, ...), the fidelity quantum kernel K[i, j] = |⟨φ(x1_i)|φ(x2_j)⟩|² of a native Encoder as a float64 NumPy array, ready for scikit-learn's SVC(kernel="precomputed"). With exact=True it takes the inner products of the native simulator's statevectors, each state simulated once when they fit in the memory budget; with shots, the 0…0 frequency of one compute-uncompute circuit (U(x1_i) then U(x2_j)†) per entry. Without x2 only the upper triangle, diagonal included, runs (N(N+1)/2 circuits) and the matrix is symmetric bit for bit; the diagonal is executed, not set to 1. It takes qml.expval's execution arguments and rules, checks everything before a backend exists (a complex value in x1 or x2 is the TypeError qml.expval raises for it, #602), and runs the pairs in blocks over one backend per call. In polypus-circuit: ConcreteCircuit::inverse, CircuitError::NotInvertible, and GateInstruction::push_inverse, public: the one inverse table of the workspace, which the native simulator's adjoint gradient now steps back through too (csx, rc3x and c3sqrtx are inverted through their decomposition). In polypus-qml: FeatureMap, FeatureStates and FidelityKernel, and the variants ValidationError::TrainableLayerInFeatureMap, QmlError::KernelTooLarge and QmlError::StateWidthMismatch. In polypus-infrastructure: NativeStatevectorBackend::fidelity_matrix, which counts its matrix against the memory budget and, with room for one statevector beside it but not two, computes each entry from one statevector instead of refusing. In polypus-backend: InsufficientMemoryForResult and the BackendError::InsufficientMemoryForResult variant (BackendError is #[non_exhaustive]), raised in Python as polypus.InsufficientMemoryError when a result leaves no room for its statevectors. See examples/qml_kernel_svc.py (#504).
  • polypus.qml.Ansatz.strongly_entangling(reps, ranges=None, entangler="cx"), PennyLane's StronglyEntanglingLayers: per layer, a general rotation on every qubit, emitted as Rz(φ), Ry(θ), Rz(ω), in that order, so the exact parameter-shift gradient still applies, then an entangler ("cx" or "cz") from each qubit i to (i + r) mod n, with PennyLane's default ranges or one per layer; 3·n·reps parameters. A range outside 1..=n−1 for the qubits active at that point is a ValueError at the call, and the layer saves and loads with TrainedModel.save/qml.load (format version still 1). In polypus-qml: StronglyEntanglingAnsatz, Layer::StronglyEntangling, QuantumModel::strongly_entangling and the ValidationError variants StronglyEntanglingRangesLength and StronglyEntanglingRangeOutOfBounds. The QML guide shows how EfficientSU2 and BasicEntanglerLayers map onto hardware_efficient (#505).
  • Multi-qubit Pauli sums and an exact H₂ Hamiltonian in polypus-physics (#529), the reference for molecular simulation (#528). In hamiltonians: PauliString (text form "X0 X1 Y2 Y3", product with a Phase), PauliSum::new/simplified/chop; PauliSum::to_dense_real, eigenvalues and ground_energy (little-endian basis, up to MAX_DENSE_QUBITS = 10, real matrices only; symmetric to within SYMMETRY_TOLERANCE relative to the largest entry); FermionOperator and FermionHamiltonian from spatial integrals (spin-orbitals in block order; integral symmetries checked to INTEGRAL_SYMMETRY_TOLERANCE and symmetrized); FermionOperator::to_qubits with QubitMapping::JordanWigner or Parity (Hermitian to within HERMITICITY_TOLERANCE times the sum of the operator's |coefficients|); PauliSum::taper and parity_reduction_qubits, which fix the parities of N↑ and N, not their values (exact for H₂; sector diagonalization for larger molecules is #535). A new chemistry module: STO-3G integrals over normalized s-type contracted Gaussians and H2Molecule in H2Encoding::JordanWigner (4 qubits) or ParityTapered (2 qubits), which implements PhysicsHamiltonian. Validated against PySCF/OpenFermion data in reference-data/h2-sto3g/ (FCI at 0.7414 Å: −1.1372701747 Ha). constants::BOHR_RADIUS_ANGSTROM. New dependency: libm (erf for the Boys function).
  • Measuring a sum of multi-qubit Pauli strings from counts, in polypus_observable: Pauli and PauliMask (a Pauli string as two u64 bitmasks, up to MAX_QUBITS = 64 qubits); group_qubit_wise, a greedy qubit-wise-commuting grouping into a Grouping of MeasurementGroups, each with its basis rotations (BasisRotation::H or BasisRotation::SdgThenH) and its reducer, while identity terms go to Grouping::constant; and ParityObservable, a CostObservable for Z strings of any weight evaluated by bit parity, with expectation_from_probabilities for exact statevector probabilities. A Σ|c|·|scale| above MAX_WEIGHT_BOUND is rejected, so no result can overflow, and counts whose total overflows u64 are an error (#530).
  • Training a cost given as a sum of multi-qubit Pauli strings, such as a molecular Hamiltonian, in polypus-evaluation (Rust; Python bindings follow in #532): PauliSumOracleFactory::new(template, terms) checks a native, measurement-free template and the (coefficient, PauliMask) terms, groups them into qubit-wise-commuting groups, and builds a PauliSumOracle that measures each candidate once per group (the template, the group's basis rotations, a full measurement) with the run's shots, or final_shots, and returns the energy with its sign flipped, since the optimizers maximise. A candidate therefore costs one circuit and the run's shots per group. Invalid input is a PauliSumOracleError. The design is ADR 0009 (#531).
  • Generic Z₂-symmetry tapering in polypus-physics: PauliSum::z_symmetries finds every Z-type symmetry of a qubit Hamiltonian, and Tapering turns each into a single Z with CNOTs and removes that qubit, with the values ±1 of a reference basis state or given explicitly; Tapering::for_sector does it for a molecule's FermionHamiltonian in the Jordan–Wigner or parity encoding with the Hartree–Fock determinant's values (H₂, LiH and BeH₂ in STO-3G go from 4, 12 and 14 qubits to 1, 8 and 9). Tapering::apply tapers any operator that commutes with the symmetries, tapered_basis_state maps a basis state (e.g. a VQE initial state) into the tapered space, and PauliSum::restricted_eigenvalues over Tapering::sector_basis gives the exact energy of an electron sector after tapering (#535).
  • Molecules beyond H₂ in polypus-physics: chemistry::Fcidump reads the integrals of an FCIDUMP file (as PySCF, Molpro or Psi4 write it; restricted, real integrals) into a FermionHamiltonian, with the electron sector (N↑, N↓) that its NELEC and MS2 give; and FermionHamiltonian::sector_eigenvalues / sector_ground_energy compute the exact energies of one electron sector, the FCI energy of a molecule with given charge and spin projection (MS2; any total spin and spatial symmetry), from a matrix of C(K, N↑)·C(K, N↓) determinants (up to MAX_SECTOR_DIMENSION = 2500) instead of the whole 4^K space. Reference FCIDUMP files and FCI energies of H₂, LiH and BeH₂ in STO-3G, generated with PySCF, are in reference-data/fcidump-sto3g/ (#535).
  • Adjoint differentiation of the gates the parameter shift has no rule for (#561): polypus-sim's StatevectorSimulator::adjoint_gradient also differentiates Crx, Cry, Crz, Cp, Cu1, P, U1, U, UGate, U2, Cu3 and Cu (each of their angles, through its generator, the phase of Cu/Cu3 relative to the control included) and U0 (derivative 0), with a new reduction kernel that gives the same bits with and without the parallel feature. In polypus-qml a model with such gates is built like any other and gets its exact gradient, Jacobian and vector-Jacobian product by the adjoint (adjoint_runs, gradient_from_adjoint, jacobian_from_adjoint, vjp_runs), while the parameter-shift methods fail with QmlError::NoExactGradient, which names the instruction and points at exact mode; when exact mode cannot fit the adjoint's two statevectors it has no shift to fall back to, and the error says so (QmlProblem::check_shift_fallback, ExpectationJacobian::check_shift_fallback). No layer emits these gates yet, so nothing changes for a model built from Python. New: AngleRef in polypus-circuit (re-exported by polypus-sim), the SimError variant AngleIndexOutOfRange, and polypus-qml's test-support feature (hidden constructors for the tests of the crates downstream; never enabled in a library or wheel build).
  • polypus.qml.Ansatz.simplified_two_design(reps), PennyLane's SimplifiedTwoDesign: an Ry on every qubit, then reps blocks that apply CZ and an Ry on both qubits of each even pair and then each odd pair; n + 2·(n−1)·reps parameters for the n qubits active at that point, in PennyLane's order (initial weights, then (reps, n−1, 2)). Only Ry and CZ, so the exact parameter-shift gradient still applies; one active qubit is the initial layer alone, whatever reps. The layer saves and loads with TrainedModel.save/qml.load (format version still 1). In polypus-qml: SimplifiedTwoDesignAnsatz, Layer::SimplifiedTwoDesign and QuantumModel::simplified_two_design (#505, #570).
  • polypus-circuit's GateInstruction::angles and GateInstruction::angles_mut list a built-in gate's angles in AngleRef order (none for a call of a declared gate) (#600). This order is now written in one place: polypus-sim's adjoint gradient and polypus-qml's untying take it from there instead of listing it themselves. Their results do not change.
  • For Rust users, the workspace's seeded generator is public in polypus_circuit::rng: SplitMix64 with new, next_u64, next_f64, the increment SplitMix64::GAMMA and the finaliser SplitMix64::mix. The shot sampler, the per-call seeds of contract C-7, the polypus-qml dataset splits and minibatches and the probe for colliding expression checksums all draw from this one definition, and polypus_sim::SplitMix64 is now a re-export of the same type. No seeded stream changes (#614).
  • For Rust users: NativeStatevectorBackend::run_circuits_exact_on_states hands a reader each circuit's amplitudes and key width instead of a map of its probabilities, and polypus_qml::ExactState reads them as that map, bit for bit, through QmlProblem::read_state, CompiledModel::expectations_from_state and CompiledModel::predict_from_state; no map is built (#628).
  • For Rust users: NativeStatevectorBackend::run_circuits_exact_with reads each circuit's exact probabilities as soon as they are computed and keeps only what the reader returns; QmlProblem::read_probabilities, fitness_from_expectations, gradient_from_expectations and adjoint_runs_from_expectations, ExpectationJacobian::jacobian_from_expectations and JacobianBlock::jacobian_from_expectations take those readings instead of the probability maps, with the same results bit for bit; ExpectationJacobian::model returns the model it differentiates (#645).
  • A call trace for polypus.train and polypus.run_quantum_circuit (contract C-12): the keyword-only trace= (a path to a new file) or POLYPUS_CALL_TRACE=<directory> writes one JSON Lines line per planner batch, backend wave, optimizer iteration and QNG metric call, with sizes and times only, capped by POLYPUS_CALL_TRACE_MAX_MB (512 MiB by default). It never changes a result.
  • The call trace in Rust: the trace module of polypus-orchestration, with CallTracer, which writes, caps and closes a trace, the types of its lines (TraceHeader, TraceEvent, RunStatus, …), DEFAULT_MAX_BYTES, and four decorators, TracingPlanner, TracingBackend, TracingObserver and TracingVariance, which record the calls they forward; and Method::name(), the optimizer's name that a trace's header records.
  • polypus.qml.expval(model, x, params, *, ...) and polypus.qml.jacobian(model, x, params, *, wrt="params", ...) for a training loop of your own over a native Model: the expectation of every readout observable per row as a float64 NumPy array (rows, observables), and its exact parameter-shift Jacobian with respect to the parameters ((rows, observables, num_params)), the inputs of angle and IQP encoders ((rows, observables, features)) or both (wrt="both", a tuple). They take TrainedModel.run's execution arguments, check everything before a backend exists (a complex value in x, Python's or NumPy's, is a TypeError naming its position, never cut to its real part; #602), and run the rows in blocks over one backend per call. In polypus-qml: CompiledModel::jacobian with ExpectationJacobian, JacobianBlock, Jacobian and JacobianWrt, CompiledModel::expectations_from_counts/expectations_from_probabilities and num_observables, and QmlError::NoInputGradient. In polypus-evaluation: window_size and candidate_window_size, the QmlOracle's window policy, now public, which also sizes the primitives' blocks. See examples/qml_expval_jacobian_loop.py.
  • polypus.qml.vjp(model, x, params, cotangent, *, wrt="params", ...), the vector-Jacobian product of qml.jacobian with a (rows, observables) cotangent, what a reverse-mode backward pass needs: (num_params,) summed over the rows for wrt="params", (rows, features) for "inputs", the tuple for "both". With exact=True it takes one adjoint run per row whatever the number of observables (qml.jacobian takes one per row and observable), so the exact backward pass of polypus.torch.QuantumLayer, which now calls it, is up to K times cheaper for a K-observable readout; with shots it runs qml.jacobian's circuits and gives its contraction for the same seed. The layer's gradients move in the last bits, no more: exactly, they come from one combined observable instead of one run per observable, and with shots the parameter product is summed in row order. The cotangent's shape is checked right after params (a polypus.ConfigurationError) and its values are read as x's are (a string, None or a complex value is the same TypeError); a NaN or an infinity in it propagates as through the contraction, and changes only its own row's route. qml.jacobian does not change. In polypus-qml: Jacobian::vjp, JacobianBlock::vjp_runs/num_vjp_runs/ vjp_weight_bounds/vjp_from_adjoint (and ExpectationJacobian's), Vjp and DiagonalObservable::weight_bound. benchmarks/bench_vjp.py measures it (#559, ADR 0008).

Changed

  • BREAKING (build): the qmio feature needs Rust 1.89: zeromq goes from 0.6 to 0.7, which raised its MSRV. Default features keep Rust 1.85. The QMIO reply-size cap is still checked after the reply is received; 0.7 has no receive size limit yet (#383).
  • BREAKING: an explicit seed (the seed argument, or the seed of an optimizer such as DE(seed=...) passed to train or qml.train) of 2**63 or more with backend="aer" or infrastructure="cunqa" now raises polypus.ConfigurationError (a ValueError) instead of reaching Qiskit Aer masked to 63 bits, which gave two seeds differing only in bit 63 the same counts; pass seed & (2**63 - 1) to replay a run made with such a seed. The native backend still takes any 64-bit seed. polypus.torch.QuantumLayer(seed=...) masks the seed it derives for each call to 63 bits, so a seeded layer gives the same values as before on Aer and CUNQA; on the native backend the calls whose derived seed had bit 63 set now sample differently (#393).
  • For contributors: every workspace crate inherits a [workspace.lints] table from the root Cargo.toml that denies unsafe_code and clippy::undocumented_unsafe_blocks, so the three unsafe sites docs/ENGINEERING.md §5 authorises are the only ones that compile, each with its own block-scoped allow. missing_docs is on in the crates that are already fully documented, and cargo deny keeps pyo3 out of the pure crates (#408).
  • CI reports how well the tests check the code, not only what they run: the SonarQube Cloud workflow's coverage jobs write Rust line coverage per crate in their summary, and a weekly mutation.yml runs cargo mutants over the pure-Rust crates (report only) and comments the score per crate on a tracking issue. New tests catch the mutants that survived in polypus-observable, CMA-ES and SHADE, and polypus-backend's memory guard and planner, and property tests check the OpenQASM round trip and that the parallel kernels match the sequential ones on random circuits (#409).
  • BREAKING: on Linux, a native circuit of 31 to 40 qubits is no longer refused with the qubit ceiling's ValueError / polypus.NativeCircuitError: it runs if the memory budget holds it and raises polypus.InsufficientMemoryError (not a ValueError) otherwise. Above 40 qubits, and above 30 where no memory limit is detected, the ceiling error is unchanged. For Rust users, polypus_sim::MAX_QUBITS is 40 instead of 30, so StatevectorSimulator::default() and Statevector::new accept up to 40 qubits; the 30-qubit fallback ceiling is polypus_backend::mem_budget::FALLBACK_MAX_QUBITS (#428). The parallelism calibration cache keeps reading existing files as before.
  • BREAKING (Rust): polypus_optimizers::OptimizationOutcome has a new public field, stop_reason, so a struct literal of it outside its crate must set it (#431).
  • CUNQA: the seal looks up a family's QPUs with get_QPUs once instead of once per wave, and looks them up again after qdrop or a failed wave (#437).
  • BREAKING (Rust): polypus_qml::QmlError has two new variants, KernelTooLarge and StateWidthMismatch, so an exhaustive match on it outside its crate must handle them (#504).
  • BREAKING (Rust): polypus_qml::ValidationError has a new variant, TrainableLayerInFeatureMap, so an exhaustive match on it outside its crate must handle it (#504).
  • BREAKING (Rust): polypus_qml::ValidationError has two new variants, StronglyEntanglingRangesLength and StronglyEntanglingRangeOutOfBounds, so an exhaustive match on it outside its crate must handle them (#505).
  • BREAKING (Rust): polypus_qml::Layer has a new variant, StronglyEntangling, so an exhaustive match on it outside its crate must handle it (#505).
  • BREAKING (Rust): polypus_qml::QmlError has a new variant, NoInputGradient, so an exhaustive match on it outside its crate must handle it (#501).
  • BREAKING (Rust): polypus_qml::ValidationError has a new variant, NoFeatures, so an exhaustive match on it outside its crate must handle it (#513).
  • BREAKING (Rust): PauliAxis, PauliTerm and PauliSum moved from hamiltonians::photon_polarization to hamiltonians::pauli; the old paths hamiltonians::photon_polarization::{PauliAxis, PauliTerm, PauliSum} no longer exist. Import them from polypus_physics::hamiltonians (#529).
  • BREAKING (Rust): polypus_physics::hamiltonians::PauliTerm is { coefficient, string: PauliString } instead of a single Pauli on one qubit (qubit, axis), and PauliSum's fields are private: build it with PauliSum::new, which validates, and read it with num_qubits() and terms() (#529).
  • BREAKING (Rust): photon_polarization_hamiltonian returns Result<PauliSum, PhysicsError>, rejecting non-finite parameters (#529).
  • BREAKING (Rust): polypus_physics::error::PhysicsError has new variants, InvalidPauliSum, UnsupportedOperation, InvalidFermionOperator and InvalidIntegrals, so an exhaustive match on it outside its crate must handle them (#529).
  • BREAKING (Rust): polypus_physics::error::PhysicsError is #[non_exhaustive], so a match on it outside its crate needs a wildcard arm, and has two new variants, InvalidFcidump and InvalidSector. Later variants will no longer be breaking changes (#535).
  • Exact native QML gradients are faster where a batch of them used to take the parallel gate kernels (from 12 qubits on, on the 16-thread node measured): a batch of two or more adjoint runs (NativeStatevectorBackend::run_adjoint) now runs each one on the sequential gate kernels and leaves the cores to the runs themselves. Forking every short pass of a run onto the shared pool cost more than it saved, and that made the adjoint's cost jump from 10 to 12 qubits. On 16 threads with 8 rows, qml.jacobian(..., exact=True) is 2.3–6.6× faster at 12 qubits and 2.5–3.9× faster at 14, and an exact Model.fit epoch is 1.3–2.0× faster (benchmarks/bench_adjoint.py). From about 18 qubits on, a batch of two runs can be up to ~1.4× slower than before on the 12–16 threads measured, and on wider nodes a batch smaller than the thread count may lose more (#593). The results are the same bit for bit (#560).
  • The message of QmlError::NoExactGradient, which reaches Python as polypus.EvaluationError (from Model.fit) or ValueError (from qml.jacobian), starts no exact gradient for this model: instead of no exact parameter-shift gradient for this model: (#561).
  • An adjoint derivative is named by an AngleRef (position, angle) instead of a gate position, so a gate with several angles can have one derivative per angle (#561). The adjoint API is new in this release (#503), so code written against 0.8 is not affected: StatevectorSimulator::adjoint_gradient's wrt, AdjointTask::wrt in polypus-infrastructure and AdjointRun::wrt in polypus-qml are &[AngleRef]/Vec<AngleRef>. A Pauli rotation's angle is AngleRef::new(position, 0); its derivative is unchanged, bit for bit. SimError has the new variant AngleIndexOutOfRange, and NotDifferentiable now means a gate without angles or the call of a declared gate.
  • BREAKING (Rust): polypus_qml::Layer has a new variant, SimplifiedTwoDesign, so an exhaustive match on it outside its crate must handle it (#570).
  • BREAKING: a bool is no longer accepted as a count of the native QML API (num_qubits, reps, ranges, a Pauli position, batch_size): Z(True), Encoder(True) or fit(batch_size=True) were read as 1 (and False as 0); they are now a TypeError, as final_shots already was (#571).
  • BREAKING: a native QML model is now bounded in size before its circuit is built. polypus.qml.Encoder/Ansatz refuse more than 1 000 000 qubits, and a layer that takes the model's gates past 4 000 000 is a ValueError where it is added (or, for an encoder that meets more features than at construction, the error of the call that brings the data: a polypus.ConfigurationError in fit, predict and run). Models over those limits that were accepted before, such as hardware_efficient(2**40) or an amplitude encoder over more than 20 qubits, are now refused, by qml.load too. A count too large to fit in 64 bits now reads layer N needs more gates than fit in a usize. In Rust, polypus_qml exports MAX_MODEL_GATES, MAX_MODEL_QUBITS and the SizeLimit enum, and ValidationError has two new variants, ModelTooLarge and TooManyQubits, so an exhaustive match on it outside its crate must handle them (#572).
  • Building Polypus from source needs maturin 1.9.4 or later (it was 1.9.2), the first release that exports PYO3_BUILD_EXTENSION_MODULE to the build (#599).
  • BREAKING: a bool is no longer accepted as an execution integer of the native QML API (shots, n_qpus, nodes, cores_per_qpu or seed of Model.fit, TrainedModel.predict/run, qml.expval, qml.jacobian, qml.vjp and qml.kernel_matrix, and the seed of Dataset.train_test_split): shots=True was read as 1 (and False as 0); it is now a TypeError, before any backend exists, as the counts of the native API and final_shots already were. A NumPy bool_, which NumPy 2.0 still reads as 1/0, is now a TypeError too, there and in the counts of the native API (#607).
  • polypus-logger uses jiff instead of the unmaintained chrono (RUSTSEC-2026-0543) for its local timestamps; the log line prefix, the JSON "timestamp" field and the default log file name keep their format. For Rust users, the minimum supported versions rise to log 0.4.21 (every workspace crate) and serde 1.0.221 (the crates that use it), the floors jiff's optional dependencies need (#618).
  • BREAKING: polypus.qml.Ansatz.conv(..., pairing="odd_pairs") below three active qubits is now a ValueError at the call: there is no odd pair to act on, so no gate read the parameters it reserved. qml.load and unpickling refuse a saved model with such a layer. To keep using one, delete the layer from its spec and, for a saved trained model, also delete its 4 ("basic") or 3 ("cartan") entries from params, the ones right after the parameters of the layers before it: left in, load fails on the parameter count, and deleting others shifts the values every later layer reads. Those entries were never read, so the model computes what it computed before. A convolution below two active qubits keeps raising ValueError, with a message that now names the convolution and its pairing (#631).
  • BREAKING (Rust): polypus_qml::ValidationError has a new variant, ConvNeedsQubits, which ConvLayer's planning returns for every qubit shortfall (including fewer than two active qubits, formerly NotEnoughQubits), so an exhaustive match on it outside its crate must handle it (#631).
  • PauliSumOracle (#531) now runs a batch in windows of whole candidates, sized by candidate_window_size as the QML oracle's are, so at most window × groups bound circuits are alive at once however large the population or the Hamiltonian; the expected values are unchanged, and a seeded run on the native backend gives the same values bit for bit (a backend seeded per call, such as Aer, now draws one stream per window). An empty batch no longer calls the planner, and a group whose counts do not total the shots asked for (contract C-3), an empty map included, is an EvaluationError naming the group and the candidate under any planner, not only the built-in ones, which already reject such counts; before, a planner of one's own could bias the energy silently. group_qubit_wise leaves terms whose coefficient is exactly zero out of every group, as it does identity terms, so they no longer cost circuits; a Hamiltonian with nothing else to measure is PauliSumOracleError::NothingToMeasure (#667).
  • BREAKING: for Rust users, TrainFlow and RunCircuitFlow (polypus-orchestration) have a new public field, trace: Option<Arc<CallTracer>>, so a struct literal must set it; trace: None keeps today's behaviour.
  • For contributors: changelog entries go in changelog.d/, one file per change, and the release pull request assembles them into CHANGELOG.md with towncrier, so pull requests no longer conflict on CHANGELOG.md. See Changelog entries in docs/CONTRIBUTING.md.
  • For contributors: the CI, Hygiene and SonarQube Cloud workflows also run on GitHub merge-queue groups, a prerequisite for enabling the queue on main. Hygiene checks the queue's candidate commit against main with the public rules; SonarQube Cloud skips its jobs there, since the quality gate already ran on the pull request and the push to main reports on the merged commit.
  • For contributors: the Hygiene check also scans the messages of the commits it analyses (merge base to head on pull requests, base to head on merge-queue groups and pushes to main) with the same public rules as file content, plus the private patterns on main, and flags internal bahia<N> host names alongside login-node names. Commit messages admit no allow-list exceptions.
  • For contributors: the Hygiene check rejects a change to CHANGELOG.md while Cargo.toml carries an X.Y.Z-dev version; entries go in changelog.d/, and only the release pull request assembles them into CHANGELOG.md.

Removed

  • BREAKING (polypus_python): the internal polypus_python package no longer exports test_connection, a placeholder that only printed a message, and its infrastructure classes no longer take or store num_qpus, qubits_per_qpu and qpu_types, which nothing read: build Local() instead of Local(num_qpus=..., ...). polypus itself is unchanged (#419).

Fixed

  • A seed drawn from OS entropy is now below 2**63, the range of Aer's seed_simulator, so on a run's first call Aer receives the seed the run reports and a one-call run replays with AerSimulator(seed_simulator=seed); about half of the drawn seeds used to be above it (#393).
  • On Windows the gate-parallel calibration is now cached under %LOCALAPPDATA%\polypus\ when XDG_CACHE_HOME is not set. PowerShell and cmd define neither XDG_CACHE_HOME nor HOME, so the first native simulation of every process measured the threshold again and never saved it. XDG_CACHE_HOME still wins on every platform, and macOS and Linux are unchanged. A Windows user who has HOME set and an existing cache in %HOME%\.cache\polypus\ measures once more, in under a second; calibrate_parallel_threshold()["cache_path"] shows the new location (#416).
  • polypus.qml.Ansatz.hardware_efficient and real_amplitudes with a negative reps raised OverflowError, and with a reps whose parameter count does not fit in 64 bits a PanicException (which except Exception does not catch); both, and any integer too large for a count, are now a ValueError at the call that leaves the Ansatz as it was. A saved file edited to such a count fails the same way. In polypus-qml, QuantumModel::compile returns a ValidationError instead of panicking (#505).
  • The native QML API now rejects samples with zero features. qml.Dataset, Model.fit, TrainedModel.predict / run, Model.circuit / TrainedModel.circuit, qml.expval / qml.jacobian / qml.vjp and qml.kernel_matrix raise a ValueError (a polypus.ConfigurationError where the entry point already raised one) saying that every sample needs at least one feature, where they used to run a model that never saw the data and predicted a constant. The amplitude encoder gets that message too, instead of the zero-norm one. Fewer features than qubits stays accepted (contract C-11, #513).
  • The OpenQASM 2.0 export of a barrier on every qubit in order and of the measurements q[k] -> c[k] of every qubit in order is now written as barrier q; and measure q -> c;, the form the importer reads them back in, as the OpenQASM 3 export already did. So to_qasm2(from_qasm2(to_qasm2(c))) is byte-identical to to_qasm2(c) for these circuits too (contract C-2), and the exported text of those two shapes changes for the same program (#568).
  • The rest of the native QML API's integer arguments followed: a negative or oversized num_qubits of polypus.qml.Encoder/Ansatz, or position of Z/X/Y, raised OverflowError, and the same position in a [(pauli, position), …] list (a Readout observable or an Observable term) a TypeError that did not name it; all are now a ValueError, the list form naming the term or observable and the factor. Model.fit with a negative or oversized batch_size raised OverflowError; it is now the polypus.ConfigurationError that 0 already raised, before any backend exists. An object with __index__ (a NumPy integer) is read as the integer it returns, which an out-of-range message shows. Another type is still a TypeError (#571).
  • A native QML model whose size fit in 64 bits but no circuit could hold was accepted by its builder and only failed later, out of memory or time, in circuit, bind or fit: Ansatz(2).hardware_efficient(2**40) built, and so did a hardware_efficient(reps, rotations=[]) on two or more qubits, with no parameters but reps blocks of entanglers. Ansatz(2**40).real_amplitudes(0) aborted the process on a failed allocation, Ansatz(2**62).real_amplitudes(0) raised a PanicException, and so did Encoder(64).amplitude_encoder(). All are now a ValueError at the call, which leaves the object as it was, and so is a saved file edited to such a model. On a single active qubit, where it emits no gate at all, a hardware_efficient(reps, rotations=[]) is still accepted, and building its circuit no longer takes time in reps (#572).
  • BREAKING: the native QML entry points of 0.8.0 refuse a complex value instead of dropping its imaginary part: a complex x (Model.fit, TrainedModel.predict/run, qml.Dataset, Model.circuit/TrainedModel.circuit), y (Model.fit, qml.Dataset) or y_train (train, qml.train) is a TypeError naming the value's position, whatever its imaginary part and whatever holds it. A NumPy complex array, or a NumPy complex scalar in a list, was accepted cut to its real part with a ComplexWarning, while the same value as a Python complex was already a TypeError (#602).
  • A negative or oversized shots, n_qpus, nodes or cores_per_qpu (more than 4294967295) or seed (more than 18446744073709551615) of Model.fit, TrainedModel.predict/run, qml.expval, qml.jacobian, qml.vjp and qml.kernel_matrix raised OverflowError; it is now a polypus.ConfigurationError naming the argument and the value, before any backend exists, on every infrastructure; a negative shots/n_qpus (and nodes/cores_per_qpu on cunqa) gets the message of 0. The same seed of Dataset.train_test_split is now a ValueError. An out-of-range object with __index__ (a NumPy integer) is shown as the integer it returns (#607).
  • run_quantum_circuit, train, qml.train and qml.predict with infrastructure="qmio" and a native backend name ("polypus") now reject a Qiskit circuit with QMIO's message instead of the native backend's, whose advice to use backend="aer" does not apply on QMIO (#617).
  • QuboObservable and IsingObservable (polypus.Qubo and polypus.Ising) panicked when the shot counts of one candidate added up to more than u64::MAX; they now return ObservableError::Invalid, as ParityObservable does, and a total of exactly u64::MAX is still evaluated. They also evaluated to inf when finite coefficients added up past f64::MAX (two linear terms of 1e308); a QUBO whose (|constant| + Σ|linear| + Σ|quadratic|)·|scale| exceeds MAX_WEIGHT_BOUND (about 4.9e288) is now rejected at construction, a ValueError from Python, and an Ising cost is checked on its QUBO form, whose coefficients add up to as much as 9 times the Ising ones. Results of every accepted cost are unchanged (#625).
  • An exact run on the native backend (exact=True) checked only its statevector against the memory budget, while it also held a vector of 2^n probabilities and a map of up to 2^n results per circuit: a dense 34-qubit run on a 512 GiB host passed the check and was then killed by the out-of-memory killer, with no Python exception. The probabilities vector is gone. TrainedModel.run(exact=True), which returns those maps, now counts them against the budget beside the statevectors in flight: one that would not fit raises polypus.InsufficientMemoryError before it is allocated, after the run has dropped to one circuit at a time, while a sparse output stays cheap at any width; each map is freed as its Python dictionary is built, though those dictionaries (1.1 to 1.2 times the maps) are not counted. Exact training and gradients, qml.expval, qml.jacobian, qml.vjp and TrainedModel.predict(exact=True) build no map at all: they read each circuit's expectation values straight from its statevector, bit for bit what the map would give, so they need only the statevector budget, and the parameter-shift fallback of the exact gradient needs one statevector where the adjoint needs two. Under the fallback budget (no memory limit detected) nothing is refused, as before (#628).
  • The exact native path (exact=True) kept the map of probabilities of circuits it only reads for a few expectation values: an exact gradient of qml.train or Model.fit held one map per circuit of the gradient until the step ended (one per shifted circuit for the parameter-shift fallback, so on a dense output it needed far more memory than the adjoint gradient it replaces), the exact fitness one per circuit of a candidate window, the exact qml.expval, qml.jacobian and qml.vjp one per circuit of a block, and TrainedModel.predict(exact=True) one per row. Each circuit is now read as soon as its probabilities are computed and only its expectation values are kept, which also makes exact training faster; every result is unchanged, bit for bit. TrainedModel.run(exact=True) and the exact kernel, which return or read the probabilities themselves, are unchanged (#645).
  • IsingObservable (polypus.Ising) reported the errors of its expanded QUBO as if they were about the caller's input. A finite field or coupling whose expanded coefficients overflow f64 (-2h, or 4J for a coupling near f64::MAX) was reported as a QUBO "linear" or "quadratic coefficient … is not finite", and a sum above MAX_WEIGHT_BOUND as a bare Σ|c|·|scale|, which can be up to 9 times the caller's own. The error now names the field or coupling (or the constant they fold into) that overflows and says the expanded QUBO cannot be built, and it reports the bound as the expanded QUBO's sum, saying how much each field and coupling adds to it. A variable whose expanded linear coefficient overflows while the -2h and -2J on it are added up is named too. A Σ|c| that overflows f64 is reported as such, before the scale multiplies it, instead of as inf or NaN "exceeding" the bound (with scale = 0 the product was NaN); this also changes the message of QuboObservable, ParityObservable and group_qubit_wise. The error type (ObservableError::Invalid, a ValueError from Python) is unchanged.

Documentation

  • The documentation link of the polypus crate, and the site's and README's Rust API links, point at docs.rs, which keeps the API of each release; the rustdoc on the site under /rust/, built from main, is linked as the unreleased API. For contributors, a root justfile holds every check CI runs and CI calls its recipes, so just ci reproduces them locally (just ci-all adds the MSRV, dependency-floor, packaging, semver, fuzz and Miri jobs); optional pre-commit hooks run rustfmt, ruff and nbstripout. ADR 0006 is marked accepted (#421).
  • The ValueErrors of polypus.Qubo, polypus.Qubo.from_matrix and polypus.Ising are now in the docstrings Python shows: they were written on the constructors, whose doc comments PyO3 does not expose, so help() never listed them. They now include the coefficient bound (sys.float_info.max / 2**65, about 4.9e288; checked on the expanded QUBO for Ising), and the polypus.EvaluationError raised when one candidate's counts add up to more than 2**64 - 1. The training guide states the bound.
  • The Qiskit Aer example of examples/python-backend-template/worker.py passed each request's seed to AerSimulator(seed_simulator=...) as is, though a registered backend receives any 64-bit seed and Aer rejects one of 2**63 or more, so a provider copying it would have failed on about half of a run's requests. It now masks the seed to 63 bits (seed & (2**63 - 1), keeping None), and the protocol description in the worker, in worker_template.py and in the backends guide says when to mask (#642).
  • The documentation site (MkDocs Material) is published at the Pages root, with the rustdoc of every crate under /rust/. Only the crate index pages of the old rustdoc URLs (.../polypus/<crate>/) redirect to .../polypus/rust/<crate>/; deeper rustdoc links change.
  • The site takes the Polypus cyan and octopus mark, Inter and JetBrains Mono served from the site itself (no third-party font requests), and a new landing page with a tabbed quickstart.

0.8.0 - 2026-10-30

Upgrading from 0.7

Breaking changes are marked BREAKING under Changed and Fixed. Where to look first:

  • Python users. Python 3.10 or newer (#360), qiskit<3 and qiskit-aer<0.18 (#362), CUNQA 2.4 or newer (#204). Seeded results differ from 0.7 on every backend (#348, #401, #410, #411, rand 0.10): re-run stored baselines instead of expecting them to replay. Arguments that were ignored now raise: noise_model, sim_method and backend where they do not apply (#332, #334), patience=0 in polypus.DE and polypus.CMAES (#467), and counts that sum to zero in expectation_value (#227). Configuration errors are polypus.ConfigurationError, still a ValueError (#418), and Qiskit and Aer exceptions are raised as polypus.BackendError or polypus.EvaluationError (#218). QMIO needs ZMQ_SERVER or options={"endpoint": ...}, and run_qc_in_qpu, run_qcs_in_qpu and run_worker_qpu.py are gone.
  • Rust users. The polypus crate has no default features (#414); the circuit types' fields are private (#349); GateInstruction, CircuitError, SimError, BackendError, OptimizerError and polypus_orchestration::Method are #[non_exhaustive], and EvaluationError has new variants; the DE, PSO and QNG argument structs, DeConfig and TrainFlow have new fields and dispatch_optimizer a new argument (#395, #397, #410, #500); an Optimizer implemented outside polypus-optimizers implements optimize_observed instead of optimize (#500); OracleFactory::build, templates::qft, Statevector::expectation_z and polypus_sim::sample_projected changed their return types; BackendConfig::Local and Cunqa have no backend field (#230); the polypus-physics samplers take rand 0.10's Rng (#273).
  • Third-party backend authors. polypus-backend, polypus-backend-conformance and polypus-subprocess-backend are on crates.io from this release; depend on "0.8". Registry options are typed (#293, migration in docs/backends.md), a backend gives each call of a run its own seed (#411, contract C-7), BackendError is #[non_exhaustive] and circuits::as_qasm2 returns a Result (#350).

Added

  • Native QML models in polypus.qml: Model(encoder, ansatz, readout) built from an Encoder and an Ansatz (layer builders that check each call without the data, with data re-uploading inside the ansatz) and a Readout(observables, decision="raw", threshold=None), with the readout helpers Z/X/Y, PauliTerm (Z(0) @ Z(1)) and Observable (weighted sums). Model.fit(x, y=None, *, method, loss=None, ...) trains it on rows or a Dataset(x, y=None) (an unlabeled dataset stays marked as such across a split) and returns a TrainResult: supervised with a named loss, or unsupervised maximising the readout; Adam gets the exact parameter-shift gradient; polypus.Rotosolve is accepted with loss="expectation" on a model whose trainable parameters each sit in one rotation, and is otherwise a polypus.ConfigurationError before anything runs, as in train (#398); exact=True uses exact probabilities on the local native simulator; batch_size trains on minibatches. Model.bind(params) gives an immutable TrainedModel whose predict returns the readout's decisions (int for sign, threshold and argmax, float for raw) and whose run returns the counts per row, or an ExactResult of probabilities with exact=True. TrainedModel.save(path) writes it as versioned JSON (read back bit for bit) and polypus.qml.load(path) reads it, revalidating the model and its parameters; loading never runs code. Execution arguments have defaults, and backend=None is the native simulator on local. Options are strings from closed sets. qml.train and qml.predict, which run Qiskit circuits, reject an Encoder or Ansatz with TypeError.
  • polypus_backend::CallSeeds, which hands out the seed of each call a backend receives (the run's on the first, then one derived from it and the call's index), and polypus_backend::stream_seed, the SplitMix64 map behind it and behind the native backend's per-circuit seeds (#411).
  • polypus.DE(mutation_factor=None, crossover_rate=None): DE/rand/1/bin's F, in (0, 2], and CR, in [0, 1]; None keeps 0.8 and 0.7. A value out of range, or any value with strategy="shade" or "lshade", which adapt both, raises polypus.ConfigurationError when the object is built or the attribute set. Rust: AlgorithmDifferentialEvolution::check_rates and the DEFAULT_MUTATION_FACTOR and DEFAULT_CROSSOVER_RATE constants (#410).
  • polypus.External(optimizer, max_evaluations), accepted by train and qml.train: runs an optimizer from outside Polypus, a library such as Optuna, Nevergrad or pycma or an object of your own, through Polypus's scheduler. The optimizer has ask(), which returns the next batch of rows (None or an empty batch when it is done), and tell(candidates, values), which receives that batch and its fitness, to maximise. Each ask() is one batch, spread over the QPUs. The run stops at an empty ask() (converged=True) or before a batch that would take it past max_evaluations, which is neither evaluated nor told, so the budget is never exceeded. A row that is not dimensions finite real numbers (a bool or a complex number is not one) raises ValueError naming its batch and row; a batch and a row are read only up to one row or value too many, so an endless iterator cannot hang the run. An exception from ask() or tell(), KeyboardInterrupt included, is raised as itself. External takes part in garbage collection, so an optimizer that refers back to it is freed. best_params is the best candidate Polypus measured, iterations_run counts the batches, and final_shots re-evaluates five candidates. The library owns its seed and its start: External has no seed (the run's seed fixes the shot sampling) and initial_point raises ValueError before anything runs (#399).
  • polypus.ask_tell, pure-Python adapters for polypus.External: from_optuna(study, dimensions, batch_size, bounds=(0, 2π), initial_point=None), for example with Optuna's TPE sampler, from_nevergrad(optimizer, batch_size=None, initial_point=None) and from_pycma(es), which call each library's public ask/tell methods only and negate the values for a library that minimises; and AskTell, the protocol as a typing.Protocol. None of the three libraries is a dependency of Polypus, and the module imports none of them (#399); the pip extras optuna, nevergrad and cma (pip install "polypus-quantum[optuna]") install one, from the version CI tests the adapters with up to the next major. An adapter's tell raises ValueError for other candidates than the batch it handed out, or the same in another order, before the library is told anything. The Optuna adapter, an OptunaAskTell, has close(), which marks the trials of a batch handed out and never told TrialState.FAIL, so that a budget that cuts a batch leaves no trial RUNNING (#467).
  • External optimizers in training runs (Rust, polypus-orchestration): Method::External with ExternalConfig. The CUNQA walltime warning projects max_evaluations / n batches after a first batch of n candidates; final_shots re-evaluates five candidates (#399).
  • The ask/tell bridge in polypus-optimizers: the AskTell trait, with AskTellError, and AlgorithmExternal with AlgorithmExternalArgs, which run any optimizer that implements it against an EvaluationOracle, one oracle batch per ask (#399).
  • polypus.Rotosolve(sweeps=10, reevaluate_every=5, tolerance=0.01, patience=2, seed=None), accepted by train and qml.train: the Rotosolve of Ostaszewski, Grant and Benedetti (Quantum, 2021), with the value reuse of the NFT method of Nakanishi, Fujii and Todo (Phys. Rev. Research, 2020). When every trainable parameter is the angle of exactly one single-Pauli rotation (any angle of u, u2 or u3 included, which are rz·ry·rz, and in a Qiskit circuit the angle θ of r) and the cost is an average over the shots, the fitness is a sinusoid of each parameter, and Rotosolve moves one parameter at a time to its maximum, in closed form. Each step is one batch of two circuits, plus the current parameters on the first step and every reevaluate_every steps, and after the last step the parameters it reached are measured alone; best_params is the best of the points measured. The run stops after patience sweeps that improve the best by less than tolerance, or after sweeps sweeps. train and qml.train check the circuit before anything runs (a polypus.Circuit or a Qiskit circuit; in qml.train the ansatz only) and raise ValueError naming the first gate or parameter that does not qualify; qml.train also rejects a polypus.SampleCost. An initial_point is the first point measured. A seeded run reproduces on the same platform only, as with CMA-ES. Invalid settings raise ValueError before any circuit runs (#398).
  • Rotosolve in training runs (Rust, polypus-orchestration): Method::Rotosolve with RotosolveConfig. The CUNQA walltime warning counts sweeps × dimensions steps and the final point as one more; final_shots re-evaluates best_params alone (#398).
  • Rotosolve in polypus-optimizers: AlgorithmRotosolve and AlgorithmRotosolveArgs, with an initial_point like every optimizer; and in polypus-circuit, ParameterizedCircuit::check_single_frequency with SingleFrequencyError and AngleForm, which say whether a circuit qualifies; tests/python/test_rotosolve.py checks that it and the Python check of a Qiskit circuit take the same angles and gates (#398).
  • callback in train, qml.train and qml.Model.fit (keyword-only): called once per iteration of the optimizer with a read-only polypus.TrainProgress (iteration, best_fitness, best_params, evaluations), so a run can report its progress, write checkpoints or stop on a criterion of its own. Returning True stops the run, which returns the TrainResult it has reached (converged=False; the final_shots batch is still sent); None or False go on, and any other value raises TypeError. An exception in the callback propagates as itself, with no result. Ctrl+C keeps working as before, and a seeded run with a callback that never stops returns the same result as without one. A callback that is not callable raises TypeError before anything runs (#500).
  • Watching a run in Rust: IterationObserver, IterationReport and Optimizer::optimize_observed (with optimize now its default, an observer that never stops), and AlgorithmDifferentialEvolution::optimize_with_strategy_observed (polypus-optimizers); TrainObserver, TrainProgress, TrainFlow::observer and dispatch_optimizer_observed, which counts the evaluations (polypus-orchestration). Adam, SPSA and Rotosolve now measure the point their last step reached inside their last iteration, with the same oracle calls and outcome (#500).
  • final_shots in train and qml.train (keyword-only in qml.train): once the optimizer has stopped, its best candidates are re-evaluated in one more batch with that many shots per circuit, best_params and, for DE, PSO and CMA-ES, the four best other distinct candidates they scored. The new TrainResult.final_params is the one with the highest value and final_fitness that value; both are None without it. This reduces the winner's curse of best_fitness, the best of many noisy estimates: final_fitness is a fresh estimate, without bias when best_params is re-evaluated alone, and slightly optimistic still as the highest of five. best_fitness keeps its meaning: best_params, best_fitness and fitness_history are the optimizer's, and a seeded run sends the same batches with and without final_shots. The final batch has shot noise of its own (#411), so it does not repeat the training's counts for a candidate. best_params and best_fitness are logged before it, and as a warning if it fails. A value that is not an integer >= 1 raises ValueError before anything runs. The batch is not part of the CUNQA walltime projection (#397).
  • initial_point and final_shots in a native model's Model.fit (keyword-only), with train's checks: a model read back with polypus.qml.load keeps training from its params, and the final re-evaluation scores every training sample, also with batch_size; final_shots with exact=True is a polypus.ConfigurationError. fit now checks the optimizer's configuration before any backend exists, as train does (#498).
  • Model.circuit(x, params=None) and TrainedModel.circuit(x) return the circuit a native model runs for one sample as a polypus.Circuit, measured in the readout's basis; without params the trainable angles stay free, named theta_0, theta_1, ... (#497).
  • The final batch in Rust: EvaluationOracle::evaluate_batch_with_shots (polypus-optimizers), a provided method that VqcOracle and QmlOracle implement by putting the shots in every task; TrainFlow::final_shots, TrainOutcome, FinalEvaluation and Method::final_candidates (polypus-orchestration) (#397).
  • polypus.SPSA(max_iters=300, resamplings=1, perturbation=0.1, target_step=0.63, alpha=0.602, gamma=0.101, eval_interval=20, seed=None), accepted by train and qml.train: Spall's simultaneous perturbation stochastic approximation (1992), with his gains a/k^alpha and c/k^gamma and practical exponents (1998). It estimates the gradient from two circuits per random perturbation whatever the number of parameters, so it suits many parameters and few QPUs. A calibration batch of 50 circuits around the starting point sets the gain so that, with resamplings=1, the first step moves each parameter by about target_step, as Qiskit's SPSA.calibrate does; with more perturbations the first step is usually shorter. Each iteration is one batch of 2·resamplings circuits, so resamplings fills more QPUs and averages that many estimates; the parameters are measured in the same batch on the first iteration and every eval_interval iterations, and after the last step one circuit measures the parameters it reached, so every step is measured; best_params is the best of them. The run makes max_iters iterations and reports converged=False. An initial_point is the centre of the calibration and the first point measured. A seeded run reproduces on the same platform only, as with CMA-ES. Invalid settings raise ValueError before any circuit runs. See the training guide for when to prefer it and its sensitivity to target_step and perturbation (#396).
  • SPSA in training runs (Rust, polypus-orchestration): Method::Spsa with SpsaConfig. The CUNQA walltime warning leaves the calibration batch out of the timing and adds its circuits at the first iteration's pace, and counts the final parameters as one more iteration (#396).
  • SPSA in polypus-optimizers: AlgorithmSPSA and AlgorithmSPSAArgs, with an initial_point like every optimizer (#396).
  • polypus.Adam(max_iters=100, learning_rate=0.1, beta1=0.9, beta2=0.999, epsilon=1e-8, bounds=(-math.pi, math.pi), tolerance=0.01, patience=20, finite_difference_step=0.2, rule="adam", seed=None), accepted by train and qml.train: gradient ascent, built on Kevin Pérez González's Adam (#394). Each iteration is one batch of 2·dimensions + 1 circuits, the current parameters and the central finite difference around them, so no QPU waits on a one-circuit batch, and one step. After the last step one circuit measures the parameters it reached, so every step is measured, and best_params is the best of the parameters measured. max_iters and patience are at least 1. rule="adam" is Kingma and Ba's Adam, whose step does not depend on the scale of the cost; rule="momentum" is Polyak's heavy-ball momentum, whose learning rate does. A seeded run over a backend whose results do not depend on the platform reproduces on every platform (C-7). Invalid settings, an unknown rule included, raise ValueError before any circuit runs. See the training guide for the finite-difference step and for starting from a global search (#395).
  • Adam in training runs (Rust, polypus-orchestration): Method::Adam with AdamConfig. A factory now builds the run's Oracles (evaluation, and an exact gradient when it has one); Adam uses the exact gradient or a finite difference of the evaluation, and the CUNQA walltime warning counts one batch per iteration, plus the call to an exact gradient, and the final parameters as one more iteration (#394, #395).
  • Adam in polypus-optimizers: AlgorithmAdam, AlgorithmAdamArgs and AdamRule, driven by a new GradientOracle contract (the fitness gradient, uphill), with the same fitness-stagnation stop as DE and CMA-ES. A gradient of the wrong length, or with a non-finite component (the new OptimizerError::NonFiniteGradient), is an error. FiniteDifferenceGradient turns any EvaluationOracle into a GradientOracle by central differences, in one batch per gradient, and through GradientOracle::value_and_gradient scores the parameters in the same batch (#394, #395).
  • polypus.backend_compatibility(circuit, *, resources=False) lists, for each backend, why it would reject a circuit, without running it (#218). It also reports "cunqa" and "qmio" next to "aer" and "polypus" (#254). The CUNQA entry prepares the circuit as a run does and converts it with CUNQA's own converter, without raising QPUs; the QMIO entry reports a build without the qmio feature, a Qiskit circuit and a program that is not a terminal-measurement circuit. The keyword-only resources=True also checks the native qubit ceiling and memory budget, with the message of the error the run raises.
  • The QML oracle (QmlOracle, Rust) trains a native polypus-qml problem as well as Qiskit circuits (QmlSource), sampled or exact, with optional per-call minibatches (MinibatchConfig, evaluate_full) and, for the native source, the exact parameter-shift gradient, which QmlOracleFactory hands to Adam through the run's Oracles. Without a minibatch the gradient also returns the parameters' fitness from its own batch (GradientOracle::value_and_gradient), so an Adam iteration on a native model is one call. Both sources share the candidate windows. With a minibatch the Oracles also carry a full-dataset view (Oracles::full_evaluation): Adam scores its parameters on it and takes only the gradient from the minibatch, and the other optimizers' best_fitness is re-scored on it at the end.
  • NativeStatevectorBackend::run_circuits_exact (Rust): the exact basis-state probabilities of each circuit, keyed like its counts, with no sampling and the same memory budget and windows as run_circuits. Only for a full-register read-out.
  • polypus-qml, a pure-Rust crate for quantum machine learning: validated datasets with deterministic splits and feature scaling; layered variational models (angle, amplitude, IQP and basis encoders, a hardware-efficient ansatz, QCNN convolution and pooling); Pauli readout with sign, threshold, argmax or raw decisions; squared-error, binary and categorical cross-entropy and hinge losses, and an unsupervised Expectation loss that maximises the readout itself (no labels). It builds polypus-circuit circuits and turns measurement counts into a fitness, and into an exact parameter-shift gradient that stays exact when convolution and pooling reuse a parameter across gates, but never runs them. A TrainedModel (model plus trained parameters) saves as versioned JSON under the serde feature. Python reaches it through polypus.qml.Model.
  • polypus.CMAES(generations=100, population_size=None, sigma0=math.pi / 2, tolerance=0.01, patience=20, restarts=0, seed=None), accepted by train and qml.train: Hansen's (μ/μ_w, λ)-CMA-ES for periodic parameters, with optional IPOP restarts that double the population. In Rust it is AlgorithmCmaEs, with AlgorithmCmaEsArgs and CmaEsBatchSchedule, in polypus-optimizers, with its own symmetric eigensolver (no new dependency). A seeded run reproduces on the same platform only. With restarts, the CUNQA walltime warning assumes a restart after every generation. The spread of each angle is capped at max(sigma0, π/2), so the step size cannot grow past the 2π period and stall the run (#382). See the training guide for when to prefer it over DE.
  • CUNQA run-flow tests against a fake CUNQA SDK (qraise, run, gather, qdrop, C-3 counts, C-7 per-QPU seeds), and an opt-in test for a real CUNQA family, POLYPUS_CUNQA_REAL=1 pytest tests/python/test_cunqa_real.py (#357).
  • OpenQASM 3 profile: Circuit.from_qasm3, to_qasm3, param_names; the importer records the declared classical width.
  • walltime kwarg for the SLURM walltime of CUNQA virtual QPUs.
  • polypus.__version__, PEP 561 typing stubs and py.typed.
  • qaoa_params_to_dict helper, with the real QAOA parameter order documented.
  • Angle expressions from polypus.Param in Python (2 * Param(0), polypus.sin, pi, ...), stored as circuit expressions.
  • Circuit.clbits_width: the classical width an imported program declares.
  • A warning when training on CUNQA is projected to outlive the walltime.
  • Native circuit drawings: Circuit.draw() (Unicode or ASCII text, or SVG), print(circuit) and SVG display in Jupyter; draw_text/draw_svg and Display in Rust. No new dependencies.
  • Adaptive Differential Evolution: polypus.DE(strategy="shade") (SHADE) and strategy="lshade" (L-SHADE, whose population shrinks linearly towards 4). For "lshade", generations sets the evaluation budget, population_size × (generations + 1) as for the classic DE, and the run spends it in more, smaller generations: more sequential rounds on several QPUs, where "shade" suits better. The default, strategy="rand1bin", is the classic DE, unchanged; an unknown name raises ValueError. In Rust, DeStrategy (with max_generations) and AlgorithmDifferentialEvolution::optimize_with_strategy.
  • initial_point in train and qml.train (keyword-only in qml.train) starts the search from a given point, such as an earlier run's best_params: dimensions finite numbers as a list, tuple or NumPy array, otherwise ValueError before anything runs. DE (every strategy) evaluates it, wrapped into [0, 2π), as the first member of its initial population; PSO as its first particle, which must lie within bounds; QNG starts from it and Adam evaluates it first; CMA-ES centres its first run on it and keeps its sigma0, so a refinement wants a smaller one. Without it every optimizer behaves as before, seeded runs included (#395). In Rust, each optimizer's check_preconditions checks its configuration and then the point without running anything, and polypus_orchestration::Method::check_preconditions calls the one the method names.
  • polypus.ConfigurationError, a polypus.PolypusError that is also a ValueError. Every argument and configuration check of run_quantum_circuit, train, qml.train, qml.predict and a native model's Model.fit, TrainedModel.predict and TrainedModel.run raises it (an unknown infrastructure, a bad walltime, an optimizer setting, options on local/cunqa, a loss without labels, …), as do polypus.DE(strategy=...), polypus.Adam(rule=...) and the argument checks of the polypus.ask_tell adapters, so except polypus.PolypusError catches them and except ValueError still does (#418, #507). Building a native model (qml.Encoder, qml.Ansatz, qml.Readout, qml.Dataset, qml.load) raises a plain ValueError, as building a polypus.Circuit does.
  • polypus.SPSA(stability_constant=0.0): Spall's stability constant A of the step gain a/(k + A)^alpha, finite and >= 0. The calibration keeps the first step at target_step whatever A, so a larger A makes the early steps shrink more slowly; 0 keeps the previous gains, and seeded runs are unchanged. It comes after seed in the positional order. Rust: AlgorithmSPSAArgs::stability_constant and polypus_orchestration::SpsaConfig::stability_constant (#467).
  • Circuit.compose(other, qubits=None) / ParameterizedCircuit::compose (and try_compose) place a circuit onto chosen qubits of another: qubit i of other lands on qubits[i], free parameters are shared by index, and classical bits are not renumbered. Every instruction is checked as its gate method checks it (contract C-4) before any is appended, so a failed call leaves the circuit unchanged; the errors are the new CircuitError::InvalidQubitMap and CircuitError::ConflictingParamNames (ValueError in Python) and those of the gate methods.
  • shor_order_finding template: Beauregard's order-finding circuit for Shor's algorithm, moduli up to 24 bits. polypus.circuits.templates.shor_order_finding(a, modulus, counting_qubits=None) / polypus_circuit::templates::shor_order_finding returns the circuit (2n counting qubits by default, no measurements) whose counting register estimates the order of a modulo modulus; MAX_SHOR_MODULUS_BITS is the 24-bit limit, the largest circuit the OpenQASM importers read back. The arithmetic blocks it is built from are public in Rust under templates::arithmetic: phase_adder, modular_phase_adder, controlled_modular_multiplier and controlled_modular_multiplication. Their invalid arguments are the new CircuitError::InvalidTemplateArgument (ValueError in Python). qft and shor_order_finding build without holding the GIL.
  • polypus.shor.factor: Shor's algorithm end to end, from the classical shortcuts to the order-finding circuit. factor(n, infrastructure=..., shots=1024, a=None, counting_qubits=None, max_attempts=10, seed=None, **run_kwargs) splits a composite n below 2**24 on any backend and returns a ShorResult (factors, method, base, order, attempts, peak_share, uniform_peak_share, counts). method="quantum" says where the order was read, not that the circuit worked: to judge the circuit, compare peak_share, the share of the shots on the peaks of the order (all but the one at 0), with the level of an ideal circuit and with uniform_peak_share, the share uniformly random outcomes would put there. order_from_measurement and factors_from_order, its classical post-processing, are public in the same module.

Changed

  • polypus-quantum requires qiskit>=2.0,<3 and qiskit-aer>=0.17,<0.18, the releases the execution seam is tested on (contract C-10); 0.7.2 set no upper bound (#362).
  • Argument and configuration errors are now polypus.ConfigurationError, a polypus.PolypusError, so an except polypus.PolypusError placed before an except ValueError now catches them (#418).
  • BREAKING: a seed means the same across the calls of one run on every backend: each call gets its own sampling stream. Aer, CUNQA and the subprocess bridge received the run's seed on every call, so batch slot i got the same random numbers in every generation; they now receive it on the first call and a seed derived from it and the call's index on the next ones, as the native backend already did per circuit. A run_quantum_circuit that is one call is unchanged; seeded train, qml.train and multi-call runs on those backends change. Contract C-7 states it, and docs/backends.md says what a third-party backend must do (#411).
  • BREAKING: polypus.Qubo, polypus.Ising and a Python cost function sum each candidate's count-weighted cost in ascending bitstring order instead of HashMap iteration order, which differs between processes, and the cost function is called in that order. The cost sums no longer depend on the process, so a seeded native train replays bit for bit in another process (contract C-7); fitness values of costs with inexact sums can move in the last bit (#401).
  • BREAKING: polypus.DE treats the parameters as angles: every strategy takes a difference between two members as the shorter arc, in (−π, π], so an optimum near 0 converges as well as one at π. "rand1bin" always takes one coordinate of a trial from the mutant, so no trial is a plain copy of its parent. Seeded DE results change (#410).
  • BREAKING (Rust): AlgorithmDifferentialEvolutionArgs and polypus_orchestration::DeConfig have the fields mutation_factor and crossover_rate (#410).
  • BREAKING (Rust): polypus_orchestration::Method has a new variant, External, so an exhaustive match on it outside its crate must handle it (#399).
  • BREAKING (Rust): polypus_orchestration::Method has a new variant, Rotosolve, so an exhaustive match on it outside the crate must handle it (#398).
  • BREAKING (Rust): an Optimizer implemented outside polypus-optimizers now implements optimize_observed, which shows an IterationObserver each iteration, instead of optimize, now its default with an observer that never stops (#500).
  • BREAKING (Rust): polypus_orchestration::TrainFlow has an observer field (None keeps the previous behaviour) (#500).
  • BREAKING: with infrastructure="qmio" or a registered backend ("subprocess" or a third-party one), a noise_model or a sim_method other than "automatic" raises ValueError instead of being ignored, and so does a backend other than "aer" on a registered backend. This applies to run_quantum_circuit, train, qml.train and qml.predict (#334).
  • BREAKING: the native backend (backend="polypus", "statevector" or "polypus_statevector") raises ValueError for a sim_method other than "automatic" instead of ignoring it, in run_quantum_circuit and train (#334).
  • BREAKING (Rust): polypus_backend_conformance::circuits::as_qasm2 returns a Result instead of panicking on an unexportable circuit (#350).
  • BREAKING (Rust): registry options carry a string or a list of strings: BackendBuildContext::option is removed and options is HashMap<String, OptionValue>; read them with option_str or option_list. The subprocess backend's command takes a list as the exact argv; Python callers passing strings need no change (#293, ADR 0005).
  • BREAKING: the native backend derives each circuit's seed from the base seed and the circuit's index with SplitMix64 instead of seed + index, so neighbouring seeds no longer share streams shifted by one circuit (circuit k of seed s equalled circuit k-1 of seed s+1). The same seed and batch still reproduce bit-for-bit (C-7), but counts and backend="polypus" training trajectories for a fixed seed differ from earlier releases (#348).
  • import polypus no longer calibrates the gate-parallel threshold or writes the cache: the first native statevector run of a process does it (polypus.statevector, or run_quantum_circuit/train with backend="polypus"). The cache, POLYPUS_NO_AUTOCALIBRATE and the SLURM/OpenMPI rank check are unchanged (#351).
  • BREAKING: Python 3.9 (end of life) is no longer supported; requires-python is >=3.10 and wheels are built for CPython 3.10–3.13. Every wheel is installed and smoke-tested on its platform before it is published (#360).
  • BREAKING (Rust): ParameterizedCircuit and ConcreteCircuit fields are private; read them with num_qubits(), num_params(), gates() and ConcreteCircuit::into_gates(). ConcreteCircuit::new validates its gates like the builder and panics on invalid ones; try_new and try_with_gates (for transpilers) return the error instead (#349).
  • BREAKING (Rust): GateInstruction, CircuitError, BackendError and SimError are #[non_exhaustive]; a match on them needs a wildcard arm. The simulator reports an instruction it does not know as SimError::UnsupportedInstruction (#349).
  • BREAKING: the declared classical width is kept through circuit binding and export (fix(circuit)!).
  • BREAKING: migrated to the rand 0.10 API; seeded streams may differ from earlier releases, and the public polypus-physics samplers (EnergySpectrum::sample_energy_mev, BeamSource::sample_state, DivergentBeam/ParallelBeam::sample, sample_step_length, MonteCarloEngine::run*, interactions::*) take rand 0.10's rand::Rng (#273).
  • BREAKING: an exception Qiskit or Aer raises during a run is raised as polypus.BackendError, or as polypus.EvaluationError while composing or binding circuits, with the original as __cause__; except QiskitError no longer catches it. In Rust, polypus_evaluation::EvaluationError has the variants Qiskit and Qml, and Python carries a DisplaySafePyErr (#218).
  • Native, Aer and CUNQA backends lower gates outside the target's basis before running; the Aer lowering of a repeated OpenQASM program is cached.
  • BREAKING: templates::qft and qft_with_options return a Result: above MAX_QFT_QUBITS (2827) qubits, whose gates would exceed what the OpenQASM importers read back, they fail with CircuitError::TemplateTooLarge (ValueError in Python) instead of exhausting memory (#356).
  • BREAKING: QMIO has no default endpoint; set ZMQ_SERVER or pass options={"endpoint": ...}. The transport threat model is documented.
  • BREAKING: QMIO reports a Qiskit circuit as UnsupportedCircuit instead of a generic QmioError.
  • BREAKING: run_qc_in_qpu, run_qcs_in_qpu and run_worker_qpu.py are removed; they could not run against any supported CUNQA version.
  • The QIR export declares the circuit's classical width in required_num_results, as the OpenQASM exports do.
  • BREAKING: expectation_value and expectation_values raise ValueError for counts that sum to zero instead of returning 0.0.
  • BREAKING (Rust): Rust no longer sends the backend and id kwargs that run_qcs never read (contract C-1): BackendConfig::Local and BackendConfig::Cunqa have no backend field, and LocalBackend::new and CunqaBackend::new no longer take one (#230).
  • The QML candidate window also follows the backend's concurrency, within the memory bound.
  • BREAKING (Rust): polypus_orchestration::DeConfig has a strategy field; DeStrategy::Rand1Bin keeps the previous behaviour.
  • train and qml.train check the optimizer's configuration (a DE population_size below 4, empty PSO or QNG bounds, an invalid CMA-ES sigma0, ...) before any backend or CUNQA allocation exists, and before initial_point, as the optimizer does. These ValueErrors used to come once the backend existed (#395).
  • BREAKING (Rust): AlgorithmDifferentialEvolutionArgs, AlgorithmPSOArgs, AlgorithmQNGArgs and AlgorithmCmaEsArgs have an initial_point field, polypus_orchestration::dispatch_optimizer takes initial_point as its last argument and TrainFlow has an initial_point field; None keeps the previous behaviour (#395).
  • BREAKING (Rust): the polypus crate has no default features, so it no longer enables log/max_level_info for every dependent; choose a level with info-logs or debug-logs. The wheel is built with debug-logs, so init_logger(level="debug") shows the optimizers' progress without a rebuild. The log-level aliases in .cargo/config.toml are removed (#414).
  • BREAKING (Rust): polypus_orchestration::OracleFactory::build returns Oracles; a factory with only an evaluation oracle returns it .into(). dispatch_optimizer takes impl Into<Oracles>, so a boxed oracle still works, and Method has an Adam variant.
  • BREAKING (Rust): polypus_optimizers::OptimizerError has new variants, NonFiniteGradient (#394), InvalidCandidate and ExternalOptimizer (#399), and is #[non_exhaustive]; a match on it outside its crate needs a wildcard arm, and later variants are not breaking.
  • BREAKING (Rust): polypus_orchestration::Method has a Spsa variant, so an exhaustive match on it needs an arm for it (#396).
  • BREAKING (Rust): polypus_orchestration::TrainFlow has a final_shots field (None keeps the previous behaviour), and its Flow::Output is TrainOutcome, whose optimization field is the OptimizationOutcome it returned before (#397).
  • rust-toolchain.toml pins the Rust that CI and the release builds use (1.99.1), and that rustup selects in a checkout; a new Rust release can no longer turn CI red under -D warnings. The MSRV stays 1.85, and the sdist does not include the file. Fuzzing and Miri use a dated nightly, and the docs, release and tutorial-sync jobs have a timeout (#415).
  • BREAKING: polypus.DE, with every strategy, and polypus.CMAES refuse patience=0 with polypus.ConfigurationError when train starts, as polypus.Adam and polypus.Rotosolve already did: it compared a generation's best fitness with itself, so any tolerance > 0 ended the run at once (#467).
  • A final_shots (train, qml.train), a max_evaluations (polypus.External) or an adapter's dimensions or batch_size (polypus.ask_tell) that is not an integer, such as 4096.0, True or a str, raises TypeError instead of ValueError, as shots and every other integer argument do. An integer below 1 still raises polypus.ConfigurationError (#467).
  • repr(TrainResult) shows final_params after best_params when the run had final_shots (#467).
  • BREAKING (Rust): polypus_orchestration::Method is #[non_exhaustive]: a match on it outside its crate needs a wildcard arm, and a new optimizer is no longer a breaking change (#467).
  • With polypus.External on CUNQA, the walltime warning times the first batch until the second starts, so the library's own time in tell() and the next ask() is in the projection; it left that time out, which for a model-based library can be much of the run. The warning comes when the second batch starts, and a run of one batch gets none (#467).
  • AlgorithmSPSAArgs and polypus_orchestration::SpsaConfig have a stability_constant field (#467).

Deprecated

  • Rust: ConcreteCircuit::to_qasm2 and to_qir, which panic on circuits they cannot export; use try_to_qasm2 and the new try_to_qir. No internal caller uses the panicking exports any more (#350).

Fixed

  • backend="aer" reads a circuit without measurements on the full register (num_qubits-wide keys, C-3), as the native backend does, instead of raising QiskitError (#218).
  • The polypus_python helpers no longer set their logger to DEBUG or write log files to the working directory; serialize_quantum_circuit writes to a private per-user temporary directory (or directory=) instead of <cwd>/temp, and the helpers validate run ids as the Rust entry points do (C-9, #219).
  • With infrastructure="subprocess", a worker started from a short-lived thread (a pool worker or a threading.Thread) is no longer killed when that thread exits (#220).
  • The native backend refuses a measured circuit whose classical width exceeds its counts key (creg c[65536]) with polypus.NativeCircuitError instead of panicking (#346).
  • Sampling shots no longer builds a 2^n cumulative table next to the statevector, memory the budget did not count; the samples are unchanged (#215).
  • A process waiting for the calibration cache lock behind other writers no longer writes without it after a fixed 5 s and loses an entry: only a lock with no write for the timeout counts as stale (#281).
  • A missing optional library is logged with its own message instead of the generic Qiskit error (#256).
  • With infrastructure="subprocess", a worker that answers with a frame that is no protocol message (an unknown op, a field of the wrong type, a payload that is not JSON) fails the call at once with a protocol error, and the worker is killed. The bridge waited for the live worker to exit, so the call hung forever, past recv_timeout_ms (#492).
  • train and qml.train convert expectation_function before creating the backend, so an invalid one no longer requests a CUNQA allocation (qraise) before failing; the optimizer configuration was already checked first. qml.train rejects infrastructure="qmio" before anything runs, like qml.predict. The stubs type options as a dict of str or list/tuple of str values, which the runtime accepts, so mypy accepts options={"command": [...]} (#418).
  • Runs on the local Aer backend or on CUNQA from several threads at once no longer panic with Already mutably borrowed: PyBorrowError on Qiskit 2.0. The circuit lowering shares Qiskit's session equivalence library between threads, and Qiskit 2.0's BasisTranslator cannot share it; Polypus now lowers one circuit at a time, which costs no parallelism since the passes hold the GIL (#468).
  • The examples run as shipped. polypus_cunqa_basic.py passed infraestructure= (a TypeError) and sent its CUNQA steps to "qmio", the teleportation examples called .values() on a RunResult, qft.py needed pandas and max_cut_qaoa.py required --method (it now defaults to polypus_local). The examples that need CESGA's CUNQA or QMIO are in examples/hpc/, and a personal run script is gone. The new examples.yml workflow type-checks every example against the typing stubs and runs the local ones (#406).
  • max_cut_qaoa.py reads every counts key with qubit 0 rightmost: the mean cut behind the approximation ratio and the plotted cut read it reversed, which showed only on graphs that are not symmetric under node reversal (from --qubits 5). The script now checks the mapping against Qiskit's key order before it trains (#445).
  • infraestructures.py compares Aer and the native backend on the Hamming-weight distribution, against a total-variation bound derived from the shot count, and exits with an error on a mismatch. The full 4096-outcome distribution with a fixed 0.05 threshold reported a mismatch on every run, since two samples of 8192 shots differ by about 0.23 (#446).
  • The README quickstart runs on the native backend (backend="polypus"), so it no longer loads Qiskit Aer, which failed to import on the python:3.10-slim to python:3.12-slim images with Qiskit 2.6.0 (cannot allocate memory in static TLS block; fixed in Qiskit 2.6.1). The running guide has a new Troubleshooting section for the error (#392).
  • The polypus-physics tests cover the POLYPUS_ENDF_DATA_DIR override without setting the variable, which raced the tests that read it and cache what they read, and write their files to per-process scratch directories instead of fixed paths in the temp directory. The crate no longer contains unsafe (#420).
  • With infrastructure="cunqa", a circuit without measurements is read out on the full quantum register (num_qubits-wide keys, contract C-3) instead of failing with CUNQA's key 'counts' not found (#253), and a circuit with several classical registers gets one flat bitstring key instead of CUNQA's space-separated one (#304). Checked on a real CUNQA 3.0.0 family; the opt-in test_cunqa_real.py now honours POLYPUS_CUNQA_PATH when deciding to skip.
  • With infrastructure="cunqa", a shot split that is uneven across the QPUs (e.g. 10 shots on 3 QPUs) gives every replica its own QPU and seed: the calls per batch size restarted at QPU 0 and the base seed, so two replicas shared both and one QPU idled. CUNQA's run_qcs takes a qpu_offset kwarg (C-1) (#370).
  • An expression id (ExprId) is a 64-bit checksum of the expression, resolved through the circuit and trusted only after the stored nodes compare equal; with the 32-bit checksum it had, a circuit could take a foreign id for a different expression it held at the same position. A circuit stores each distinct expression once, and accepts an id of an identical expression wherever it stored it (#354).
  • The OpenQASM 2.0 export renames a gate declaration named q or c (c_1), which clashed with the registers it declares and made Qiskit's qasm2.loads reject the program; its callers are printed with the new name (#352).
  • BREAKING (Rust): the native simulator rejects a gate that names one qubit twice (Cx(0, 0) in a hand-built ConcreteCircuit) with the new SimError::RepeatedQubit instead of writing out of bounds; the kernels' operand checks are now assert!s (#342).
  • BREAKING (Rust): a measurement's classical bit index is bounded instead of overflowing: try_push rejects a cbit from MAX_REGISTER_BITS up with the new CircuitError::ClbitOutOfRange, and polypus_sim::sample_projected returns a Result, with SimError::ClbitOutOfRange for a bit beyond the counts key (#345).
  • BREAKING (Rust): Statevector::expectation_z returns Result<f64, SimError> and rejects a qubit outside the register instead of returning a wrong value or overflowing; a repeated qubit cancels (Z·Z = I). An out-of-range parallel_threshold in the calibration cache (e.g. 0) is ignored as a cache miss (#353).
  • OpenQASM 2.0 export keeps angles at full round-trip precision.
  • With infrastructure="cunqa", a non-Aer backend or a noise_model raises ValueError instead of being silently ignored.
  • A Qiskit circuit with free parameters is rejected before any backend, and backend_compatibility reports it.
  • Backends report circuits OpenQASM 2.0 cannot express instead of panicking.
  • QMIO: reply bitstrings are validated and malformed QMIO_* tuning variables are rejected.
  • QMIO: the QmioBackend, run_quantum_circuit, train and qml.train docs state that the endpoint must be trusted, since the 64 MiB reply cap is checked only after the reply is received and does not bound memory (#78).
  • Subprocess backend bounds the worker frame length.
  • The OpenQASM 2.0 importer enforces the OpenQASM 3 importer's size budgets (source, tokens, declarations, instructions after broadcasting, barrier operands, expression nodes) and no longer tokenizes the whole source up front: a few hundred bytes could take gigabytes (#343).
  • The OpenQASM 3 importer bounds the qubits all barriers list: a full-register barrier q; counted as one instruction however large q was (#344).
  • The OpenQASM importers normalise the instructions in place instead of copying them; QIR bitcode export stops llvm-as after 120 s and always reaps it (#356).
  • BREAKING: CUNQA receives cores_per_qpu under the name CUNQA 2.4 and later expect; CUNQA 2.3 is no longer supported (supported range >=2.4,<4, #204).
  • Python errors and OS-entropy failures surface as typed errors, not panics.
  • Memory budget honours K/M/G suffixes and detects the cgroup/RAM limit.
  • CI runs every push to main to completion: the next push cancelled it, and the release gate needs a successful push run for the commit it publishes (#403).
  • CI tests the whole workspace (cargo test --workspace), so a crate added to it is tested without editing the workflow, which listed the crates by hand (#412).
  • CI runs tests it skipped without notice: the pinned-fixture test of the OpenQASM 3 interop with Qiskit (contract C-10), in a leg with the Qiskit that wrote the fixtures; the QIR checks with llvm-as; and the conformance battery against Aer. There a missing tool fails those tests instead of skipping them, and pytest lists every skip with its reason (#407).
  • An oracle failure that the optimizer detects, a batch answered with the wrong number of values or a gradient with a NaN or an infinity, raises polypus.EvaluationError instead of polypus.ConfigurationError (#467).
  • polypus.SPSA refuses a resamplings above 2147483647 with polypus.ConfigurationError, so that an iteration's batch fits in 32 bits; resamplings=4294967295 aborted the process when it allocated the batch (#467).
  • The stubs type final_shots and External's max_evaluations as SupportsIndex, which the runtime accepts, so mypy accepts a NumPy integer (#467).
  • Rust: dispatch_optimizer checks Adam's finite_difference_step with an exact gradient too, as Method::check_preconditions does, so the two agree whatever oracles the run has (#467).
  • A Python test that CI skips now fails the run unless the leg's POLYPUS_ALLOWED_SKIPS lists it (tests/python/skip_guard.py), so a test that backs a contract cannot stop running unnoticed. The floors leg installs LLVM too, and every leg replays the seeded native trainings of the C-7 determinism baseline in a second process and compares them byte for byte (#407).

0.7.2 - 2026-09-30

Added

  • Third-party backends can be registered without touching this repository; conformance battery and reference templates.
  • OpenQASM 2.0 coverage: gate declarations, the rest of qelib1.inc, angle expressions over free parameters, and named free parameters.
  • Supervised QML: y_train in polypus.qml.train and batched inference with polypus.qml.predict.
  • RunResult.merged_counts; RunResult.counts is now a list[dict] (C-3).
  • QuantumBackend extracted into the pyo3-free polypus-backend crate.

Changed

  • BREAKING: CompoundResult::mass_fractions iterates in symbol order (fix(physics)!).
  • Counts dicts are returned in ascending bitstring order.

Fixed

  • Last-write-wins for repeated measurements into one classical bit.
  • Calibration cache is keyed by hardware fingerprint and its writes are locked.
  • Aer counts keys no longer contain per-register spaces.

0.7.1 - 2026-09-23

Added

  • Gate-parallel threshold calibrated per machine at import and cached by thread count; a warning is emitted when it is uncalibrated.
  • polypus-physics reads ENDF-6 data from local reference-data, never downloading it.

Fixed

  • Planner respects backend concurrency caps and bases wave splitting on the memory limit.
  • QmioBackend no longer holds its socket lock across await points.
  • CancelToken handle exposed from Scheduler::run.
  • PSO rejects non-finite bounds.

0.7.0 - 2026-09-14

Added

  • Native GIL-free cost observables (QUBO/Ising) with a callback fallback.
  • Optional gate fusion in the simulator (fusion, on by default).
  • Statevector simulation can be interrupted mid-run.
  • Polyenergetic beams, coherent scattering and ENDF-6 data in polypus-physics.
  • QFT circuit template and native swap gate.
  • Seeds exposed for run_quantum_circuit and train (C-7).

Changed

  • BREAKING: statevector() returns a NumPy array (feat(bindings)!).
  • Core refactor: the Planner, polypus-infrastructure, polypus-orchestration and polypus-evaluation crates; the Python edge is a thin layer over Scheduler/Flow.
  • Native backend parallelises the DE population across circuits.

Fixed

  • Training and run_quantum_circuit release the GIL and honour Ctrl+C.
  • Unique auto-generated run ids; validated qml.train inputs.
  • Backend counts, expectation values and gate parameters are validated (C-3, C-5); out-of-range qubit indices are rejected.
  • Native and Aer concurrency bounded by a memory budget.
  • QMIO distinguishes a send failure from an unknown result.

0.6.0 - 2026-07-03

Added

  • QMIO backend, native statevector simulator for local tests, and QIR support.
  • Pure-Rust circuit crate (polypus-circuit) with OpenQASM 2.0 import/export.
  • polypus-optimizers extracted as a pure-Rust crate; Cargo workspace.
  • Structured JSON logger with a logs/ directory.
  • polypus-physics crate (photon interaction, geometry and voxels).

0.5.0 - 2026-06-10

Added

  • Oracle abstraction and the polypus.qml module.
  • install.sh installer and compilation tests.

(The tag is spelled v.0.5.0.)

0.4.0 - 2026-05-22

Changed

  • Python bindings split into modules; documentation rebuilt for 0.4.

0.3.0 - 2026-05-05

Added

  • Quantum Natural Gradient (QNG) and Particle Swarm (PSO) optimizers.
  • CUNQA 2.x support.

0.2.0 - 2025-11-04

Added

  • Modular infrastructures (local, CUNQA, QMIO) and differential evolution with batch processing and shot distribution.
  • run_quantum_circuit for single runs and multiple expectation values.

0.1.0 - 2025-05-26

Initial release.