pymc-devs / pymc-devs/pytensor
BUG: <```uint64 dtype``` is broken for ```Max```>
Open
Nobody has claimed this yet.
bug
C-backend
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Describe the issue:
The Max op which is a subclass of CAReduce fails for 64 bit unsigned integers. This is also evident in the PR 731 and its test. The exact number where uint64 starts failing for is 9223372036854775.
Error can also be reproduced with the following example:
Reproducable code example:
import pytensor.tensor as pt
import numpy as np
dtype="uint64"
n = pt.vector("n", shape=(None,), dtype=dtype)
test_n = np.array([0, 9223372036854775], dtype)
assert pt.max(n).dtype == dtype
print(pt.max(n).eval({n: test_n})) # 9223372036854776
print(test_n.max()) # 9223372036854775
assert pt.max(n).eval({n: test_n}) == test_n.max() # Fails, returns 1 larger
Error message:
No response
PyTensor version information:
Python 3.11.8
Pytensor 2.20.0
Context for the issue:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Max operation and its CAReduce base, then inspect the uint64 case and the test referenced from PR 731. Reproduce the supplied Python/NumPy example; done when pt.max(n) returns the same uint64 maximum as test_n.max() for the failing value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100