Compute trellis transcendentals with libm so the bitwise snapshot holds on every platform - #536
Merged
Merged
Conversation
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.
Problem
The dev Rust lane has been red on macOS and Windows since #504 merged:
decode_outputs_match_bitwise_snapshotpins raw f64 bit patterns, but the committed snapshot was generated on Linux. The platform math libraries roundln/exp/ln_1pdifferently by one ULP, so tworandom_seed23scenarios diverged in theirlog_evidence/log_massbits on the other platforms. PR CI runs the test matrix on ubuntu only, which is how the mismatch reached dev unseen.Fix
Route the trellis engine's transcendentals (
log_odds, suffix-compatibility log-probabilities,bp_score_probability,logaddexp) through thelibmcrate, which is pure Rust and returns identical bits on every platform. This follows the precedent already set inpecos-num::special, which useslibm::lgammafor the same reason. The committed snapshot is regenerated once against the libm values.The brute-force enumeration oracle in the trellis tests deliberately stays on std math: it is tolerance-compared, and an independent oracle is more useful when it does not share the engine's implementation.
Verification
log_evidence/log_masshex values; everypredictedlabel is unchanged, so decode decisions are identical before and after.cargo fmt --check, coldcargo clippy --locked --workspace --all-targets -- -D warnings, and the fullpecos-trellis+pecos-frontiertest suites are green.workflow_dispatchto prove the fix cross-platform before merge; see the linked run on the branch.