Fix integration test non-determinism#9
Open
robtaylor wants to merge 5 commits into
Open
Conversation
robtaylor
commented
Nov 25, 2025
Owner
- Fix order-dependency in small-signal analysis from IndexSet::remove deprecation
- CI: Enable integration tests
- Fix non-deterministic compilation causing random CI test failures
…eprecation The deprecated IndexSet::remove() method was replaced with swap_remove() in the small-signal network analysis. However, this exposed a latent order- dependency bug where the analysis results differed based on iteration order. Root Cause: The algorithm had a circular dependency where analyze_value() checks if values are in small_signal_vals, but membership in that set depends on the analysis results. With platform-specific hash ordering (ahash::RandomState), this caused reactive/resistive contribution counts to swap on Windows MSYS2. Solution: Implemented an order-independent fixed-point algorithm with four phases: 1. Speculatively add ALL candidate nodes to small_signal_vals 2. Evaluate all candidates against this consistent set state 3. Remove speculative nodes that weren't confirmed 4. Add confirmed flows and remove resolved candidates This ensures all candidates see the same set state during evaluation, making the analysis deterministic regardless of iteration order while still supporting circular dependencies (e.g., noise nodes). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The compiler was producing non-deterministic output due to use of ahash's RandomState, which uses random seeding for its hash function. This caused iteration order of hash-based collections to vary between runs, leading to different compilation results and sporadic CI failures. Root cause: GVN (Global Value Numbering) used ahash::RandomState for hashing expressions. Different hash values across runs caused different equivalence class assignments and leader selections, which cascaded: 1. GVN picks different instruction leaders non-deterministically 2. Values get replaced differently via replace_uses() 3. op_dependent_insts BitSet gets populated differently 4. determine_evaluation() makes different linearization decisions 5. Noise sources/implicit equations are created vs. linearized differently This manifested as entire noise sources or implicit equations appearing or disappearing between runs - not just ordering differences. Changes: - Replace ahash::RandomState with BuildHasherDefault<FxHasher> in GVN - Replace AHashMap/AHashSet with IndexMap/IndexSet (with FxHasher) or HashMap/HashSet (with FxHasher) throughout the codebase - Use FxHasher consistently for deterministic hashing - Remove unused ahash dependencies from several crates Affected crates: mir_opt, mir_autodiff, sim_back, osdi, hir_def, hir_lower, basedb, mir, vfs, typed_indexmap, sourcegen 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Árpád Bűrmen <arpad.buermen@fe.uni-lj.si>
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.