pymc-devs / pymc-devs/pytensor

Reconsider `local_sum_prod_all_to_none`

Open
#1,580 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

First, why is this restricted to Sum/Prod instead of all CAReduce?

https://github.com/pymc-devs/pytensor/blob/79444a3110a5e17ac88006c71dae5360666c4487/pytensor/tensor/rewriting/math.py#L1813-L1827

Second not sure about using None as canonical. If we don't allow None at the Op level we never risk duplication, since there's only one way to create such an Op (i.e., list all axes). If code can be made more efficient later on, it should also be done for all axis, and therefore the distinction is never needed. str representation can still choose to omit axis if all are reduced for readability

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.

Research direction

Start in pytensor/tensor/rewriting/math.py around lines 1813-1827 and inspect local_sum_prod_all_to_none alongside CAReduce. Compare the Sum/Prod restriction with the broader CAReduce behavior, and evaluate whether None should remain canonical or only be used for display. The work is done when the canonical axis policy and its scope are decided and reflected consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.