Skip to content

Record assume_a as an assumption about the solved matrix - #2374

Open
jessegrabowski wants to merge 4 commits into
pymc-devs:mainfrom
jessegrabowski:extract-assumptions-from-assume-a
Open

Record assume_a as an assumption about the solved matrix#2374
jessegrabowski wants to merge 4 commits into
pymc-devs:mainfrom
jessegrabowski:extract-assumptions-from-assume-a

Conversation

@jessegrabowski

Copy link
Copy Markdown
Member

assume_a picked the LAPACK routine and nothing else, so a matrix the caller had already promised was positive definite or diagonal still looked opaque to every other op in the graph. solve now records that promise as an assumption on a, which is the same thing assume() does. Diagonal gains the most, since solve lowers it to a division and the property was otherwise lost outright; a determinant, an inverse, a matmul, or a second solve against that matrix all drop from a dense op to an elementwise one.

Rewrites build new solves too, so the recording can also happen mid-rewrite, after the single pass that resolves assumption markers has already run. Nothing drained those: the fact went nowhere, and the marker stayed in the graph where it blocks any rewrite trying to match across it. The drain is per-node work, so it now also runs as an ordinary local rewrite, with the one-shot pass kept as the fast path for the markers a user built. Two existing tests changed expectations because of that; they rewrite with include=("canonicalize", ...), which never ran the one-shot pass, so markers had been leaking into graphs those tests called rewritten.

The whole-graph pass at 0.8 only sees markers a user built, so it stays as the fast path; the local rewrite covers any a later rewrite introduces.
@ricardoV94

ricardoV94 commented Aug 25, 2026

Copy link
Copy Markdown
Member

Gosh these claude statements are really painful to read. Can you prompt it to use 2 sentences max or something?

Propagate assumption from solve assume_a... nothing else was really said

}


def _normalize_assume_a(assume_a: str) -> str:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate this, why lift stuff out of the Op? attributes and methods are a thing

# _record_assume_a reads the dtype off ``a``, so it has to be a variable first.
a = pt.as_tensor_variable(a)
assume_a = _normalize_assume_a(assume_a)
a = _record_assume_a(a, assume_a)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline it...

@jessegrabowski

Copy link
Copy Markdown
Member Author

Gosh these claude statements are really painful to read. Can you prompt it to use 2 sentences max or something?

It's hard to get it down. I thought this was already a reasonable improvement from the default.

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