Add pecos-frontier: native Frontier approximate logical-ML decoder - #421
Draft
ciaranra wants to merge 10 commits into
Draft
Add pecos-frontier: native Frontier approximate logical-ML decoder#421ciaranra wants to merge 10 commits into
ciaranra wants to merge 10 commits into
Conversation
…ig validation, and upstream golden-fixture parity tests
…es, support p=1 forced mechanisms, disclose prefix-mass-only pruning
…xture pruned parity
…te registration for now
…ing with upstream parity fixtures
…p; lint-conform fixture generators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
pecos-frontier, a native Rust implementation of the Frontier decoder(Leverrier & Urbanke, arXiv:2606.20513): pruned ordered dynamic programming that
approximates the logical maximum-likelihood rule by accumulating posterior mass per
logical class (merging degenerate error configurations) rather than searching for a
single most-likely error. This targets qLDPC/DEM decoding problems; the paper reports
state-of-the-art accuracy on the gross code [[144,12,12]] under circuit-level noise
with small retained frontier sizes.
Decision record: the upstream project is a Python package whose engine is a single raw
CPython extension with no standalone C++ target or C API, and its performance-critical
model preparation lives in Python — so this is a native port with the upstream package
used as a verification oracle, not an FFI wrap (unlike Tesseract/PyMatching, which
build standalone C++ from pinned sources).
What's included (v1, binary model)
FrontierDecoder::{from_sparse_dem, from_dem_str}building columns directly fromSparseDemmechanisms; explicitFrontierConfig { k, delta, column_order }withfail-fast validation (provisional defaults pending benchmarking). Duplicate indices
within a mechanism are rejected;
p == 1mechanisms are supported by exact foldinginto the decode start state.
log-sum-exp merging, completed-detector consistency checks, deterministic K/Delta
pruning (no map-iteration-order dependence; total-order tie-breaks).
ObservableDecoderimplementation returning wideObsMask(no 64-observable cap;decode_to_observablesfails loud past 64).FrontierResultreports per-labelretained log masses, total
log_evidence(upstream semantics), runner-up gap, andfrontier-size stats.
exp/pecos-frontier(experimental,publish = false): the algorithm core isoracle-verified, but the crate graduates to
crates/and thepecos-decodersmeta-crate only after broader validation with real users.
Verification
enumeration over all fault subsets (per-label log masses to 1e-9 and argmax) on 33
seeded random hyperedge DEMs, including reversed column orders.
tests/fixtures/upstream_fixtures.jsonis generatedby the committed script against the upstream Python+C++ package; unpruned per-label
masses, predicted labels, and log evidence match to 1e-9 across 5 models x 46
syndromes (including a >64-observable model and a degeneracy case where logical-ML
disagrees with most-likely-error).
K truncation each break tests when altered).
determinism including ties, fail-loud unexplainable/overpruned syndromes, config and
DEM validation, trait-object use.
Accuracy vs upstream (measured)
score_alphasuffix-compatibility pruning is now ported (the paper's S = P + alpha*Cscoring; default alpha 0.8 matching upstream), so pruned decoding uses upstream's rule,
not a prefix-mass-only approximation. Golden-fixture parity is enforced for BOTH
unpruned and pruned regimes at 1e-9. A head-to-head on an identical d3 rotated-surface
circuit-noise model (identical deadline-reorder column order, identical 2000 sampled
shots, forward-only, K in {2,4,8,16}) matches upstream's per-shot predictions exactly
in the alpha=0.8 lane at every K; the alpha=0 lane differs on 3-4 shots per 2000 from
equal-score tie ordering only. Runtime is ~1.3-1.5x upstream's C++ per shot. The
bridge_abexample is the committed cross-implementation harness.Review
Two independent adversarial Codex arms (diff review + fresh-session semantics attack
against the paper and upstream implementation) ran before marking ready; confirmed
findings (wide-label tie-break word order, duplicate-index semantics, p == 1 support,
pruning-rule disclosure, mass-naming precision) are fixed in the final commits.
Ordering, committee, and Python API (added after the initial review rounds)
deadline_column_order/backward_deadline_column_order: native generation ofupstream's ordering heuristics, permutation-exact against upstream on golden fixtures.
FrontierCommittee: forward/backward two-leg decoding with upstream's selection rule,parity-tested (status, label, direction, evidence) including fixtures where the
backward leg wins.
pecos_rslib_exp:FrontierDecoder/FrontierCommitteeDecoderwith the
pecos_rslib.decodersAPI shape (from_dem+ kwargs, sparsedecode,dense
decode_syndrome,decode_batch),column_orderpresets matching upstreamvocabulary, and arbitrary-precision
observables_mask(works past 64 observables).Verified by maturin-built extension + pytest (6 tests), reproduced independently.
Out of scope (follow-ups tracked in the design note)
metric mode, and performance work (incremental suffix-score deltas); tracked in the
design note with reasons.