Skip to content

refactor: re-run eliminate_perfect_aliases! after alias_elimination! #4537

Draft
AayushSabharwal wants to merge 3 commits into
masterfrom
as/perfect-aliases
Draft

refactor: re-run eliminate_perfect_aliases! after alias_elimination! #4537
AayushSabharwal wants to merge 3 commits into
masterfrom
as/perfect-aliases

Conversation

@AayushSabharwal
Copy link
Copy Markdown
Member

We run eliminate_perfect_aliases! before alias_elimination! to (significantly) reduce the number of equations the latter pass has to process. However, alias_elimination! identifies additional x ~ y equations which can easily be removed by eliminate_perfect_aliases!. This has resulted in better simplification on some models.

@oscardssmith
Copy link
Copy Markdown
Member

Why doesn't alias_elimination! eleminate these perfect aliases?

@AayushSabharwal
Copy link
Copy Markdown
Member Author

alias_elimination!, contrary to its name, doesn't actually "eliminate" anything. It just runs bariess on the equations.

@oscardssmith
Copy link
Copy Markdown
Member

oscardssmith commented May 15, 2026

but it does have a function that runs after it to actually eliminate the aliases, right?

Also, wouldn't all of these be aliases found by adding support for the fast path detecting x~-y?

@AayushSabharwal
Copy link
Copy Markdown
Member Author

but it does have a function that runs after it to actually eliminate the aliases, right?

Nope. This PR adds that.

Also, wouldn't all of these be aliases found by adding support for the fast path detecting x~-y?

I'm not sure. It's technically possible they wouldn't, but I don't know how much that would happen in practice. Once I get JuliaComputing/StateSelection.jl#81 working, I'll check if keeping this change around is worth it, since the main win from this is smaller linsolves.

@oscardssmith
Copy link
Copy Markdown
Member

IMO the order we should go is

  1. recognize x ~ -y in trivial alias detection
  2. (if still useful) refactor: reduce size of inline linear solves JuliaComputing/StateSelection.jl#81
  3. (if still useful) this (and if not, delete alias_elimination! if possible).

I would really like the passes we do to feel grounded and obviously correct/necessary.

@AayushSabharwal
Copy link
Copy Markdown
Member Author

AayushSabharwal commented May 15, 2026

Yep, agreed. However, we can't delete alias_elimination! since it removes duplicate equations, which we get frequently because we allow duplicate connects (and iirc have presented MTK's ability to do so at a conference somewhere)

@oscardssmith
Copy link
Copy Markdown
Member

I think there probably is a much simpler way to remove duplicate equations.

@AayushSabharwal AayushSabharwal marked this pull request as draft May 18, 2026 07:03
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.

2 participants