pymc-devs / pymc-devs/pytensor

How to handle `monotonically_increasing/decreasing` attributes on non-unary OPs

Open
#2,267 2 comments 0 reactions 1 assignee View on GitHub

@Dekermanjian is already working on this.

Since Jun 29, 2026.

Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

Recently we added monotonically_increasing and monotonically_decreasing attributes to UnaryScalarOP and this brought about a discussion around non-unary scalar operations that may be monotonic like Add/Max.

The two options that I can think off are:

1). move the attributes up onto ScalarOP and keep default as FALSE

2). Define special cases of non-unary scalar ops to have the attributes

I think that option one has the advantage that all ScalarOPS would be consistent with these attributes and would avoid a potential attribute error when something like op.scalar_op.monotonic_increasing is called on a Mul op. The disadvantage being how we define and use monotonicity, will it be monotonic in every input while holding the others fixed?

Option two I think would simpler, but would still require a definition of monotonicity for a non-unary operation.

Resolution to this topic would facilitate the completion of https://github.com/pymc-devs/pymc/issues/8259

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.