Skip to content

[Q1] Reject unsupported matching priors consistently (#515) - #577

Merged
ruslan-splynx merged 2 commits into
mainfrom
codex/q1-matching-prior-validation
Oct 16, 2026
Merged

ruslan-splynx merged 2 commits into
mainfrom
codex/q1-matching-prior-validation

Conversation

@ruslan-splynx

@ruslan-splynx ruslan-splynx commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #515

Matching priors above 0.5 previously reached Rust's graph builder as negative-weight edges even though Sparse Blossom cannot handle them and the CUDA-Q adapter rejected them. Probability 1 and non-finite mechanisms could also disappear silently.

All matching constructors now reject non-finite priors and values outside [0, 0.5] with InvalidMatchingPrior { column, prob }. Validation precedes edge dropping and merging, so an invalid source prior cannot hide in an empty column or a parallel-edge combination. Native Python and CUDA-Q share the Rust range validation; inputs are never clamped. Zero and 0.5 remain supported; DEM construction and BP-family priors retain [0, 1]. Split constructors report split-model column indices.

Boundary tests also exposed an infinite log-odds weight for the smallest positive f64. A log-difference fallback handles overflowing ratios while preserving the original expression and tested bit-identical weights for ordinary priors. Decoder algorithms, quantization and tie-breaking are unchanged.

Validation:

  • 65 targeted Rust tests passed on each of macOS and Linux, including all seven new prior regressions in both debug and release, DEM/matching/splitting suites and doctests.
  • 15 native Python tests passed locally; 33 passed on Linux with the actual CUDA-Q QEC SDK, including 18 adapter/registration tests, with no skips. The isolated native overlay's ten source hashes match the committed code.
  • 12,000 real Stim syndrome/decoder cases at distances 3 and 5: zero differences against the existing matrix-roundtrip reference, including syndrome and observable projections. This is a representation/reference comparison, not an independent optimal-matching oracle.
  • Workspace/all-target Clippy, Python-feature Clippy and rustfmt passed locally; QEC/Python all-target Clippy passed on Linux. Full workspace/platform tests are left to PR CI.
  • Manual self-review found no blocking issues. This correctness change makes no throughput claim.

Policy, reproduction commands and recorded evidence. Genuine MWPM retrace ties and infeasible syndromes remain outside this change.

@ruslan-splynx
ruslan-splynx merged commit bb128f7 into main Oct 16, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Define MWPM/Union-Find behaviour for priors > 0.5 (negative edge weights)

1 participant