Add multi-outcome factor-model input to the trellis engine - #587
Open
ciaranra wants to merge 8 commits into
Open
Add multi-outcome factor-model input to the trellis engine#587ciaranra wants to merge 8 commits into
ciaranra wants to merge 8 commits into
Conversation
…tored outcome probabilities
…d close review round-2 findings
…output byte-identical)
This was referenced Aug 24, 2026
Member
Author
|
Review-panel follow-up pushed: the binary-delegation gate now accepts pairs whose induced baseline log-mass error is within the engine's 1e-9 acceptance bar (the previous 1e-12-relative bound was unreachable for small baselines, demoting exact-complement factors like (1e-6, 0.999999) off the binary kernel). New tests: the repro in both listing orders (bitwise vs the DEM build, BP enabled), a tiny-baseline case documenting why sub-2e-7 baselines correctly stay on the faithful N-ary kernel, and a seeded classification sweep. Gate mutation-tested in both directions. |
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 an N-ary (multi-outcome) factor-model input to
exp/pecos-trellis, closing the largest capability gap versus the upstream Frontier decoder's choice engine: a factor with arbitrarily many mutually exclusive outcomes, each carrying its own probability, detector toggles, and observable toggles. This also provides the public model-construction API (FactorModel/Factor/Outcome) that previously existed only upstream.FactorModel::newvalidates outcomes (probabilities in range and summing to 1 within 1e-10, indices in range, no duplicates per outcome);TryFrom<&SparseDem>maps each binary mechanism to a two-outcome factor.TrellisDecoder::from_factor_modelclassifies the model: binary-shaped models delegate tofrom_sparse_demand are bitwise-identical to the equivalent DEM build (BP scoring and indistinguishable-merging fully supported); genuinely multi-outcome models run a new N-ary DP kernel.deadline_column_order_for_factors/backward_deadline_column_order_for_factorsorder factors by the union of their outcomes' detector supports.Binary path unchanged
The binary kernel is under a byte-identical external parity contract. Every existing fixture (
upstream_fixtures.json,upstream_order_fixtures.json,bitwise_snapshot.json) passes unmodified; the refactors on the shared path (kernel enum wrapping, mask-slice plumbing inmerge_branch, integer-only ordering refactor) move zero float operations, verified by an independent mechanical diff of the decode functions.Verification
upstream_nary_fixtures.json): 7 N-ary models decoded per-shot against the upstream choice engine, cross-checked against the upstream pure-Python reference on unpruned decodes, hand-verified on the degeneracy case. PECOS matches status, predicted label, every terminal log mass, and log evidence within 1e-9, unpruned and pruned (pruned rows also pin the retained-label set, validating the generalized suffix scoring).cargo test -p pecos-trellis -p pecos-frontier -p pecos-bp-trellis, coldcargo clippy --all-targets -- -D warnings, andcargo fmt --checkall pass.Follow-ups (separate PRs): integer max-log metric mode, Python bindings and user-facing docs.