Skip to content

Conversation

@robtaylor
Copy link
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

robtaylor and others added 5 commits November 25, 2025 13:51
…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>
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.

3 participants