GithubHelp home page GithubHelp logo

Comments (3)

aseyboldt avatar aseyboldt commented on September 27, 2024

Consider me intrigued...
Sounds like somewhere there is a conversion to float64, because that exact number is one bigger than the largest integer a float64 can represent exactly:
np.float64(9223372036854775).astype(np.int64) is our magic 9223372036854776.

from pytensor.

aseyboldt avatar aseyboldt commented on September 27, 2024

This seems to have been around for a long time.
The maximum and minimum are implemented as CAReduction (pytensor.scalar.basic.ScalarMaximum). There seem to be two problems with this implementation: Both scalar Ops specify inf and -inf as identity element, but if we are working with integer types, those do not even have an identity.
But the direct source of the bug seems to be this generated C-Code:

        return f"{z} = (({y})>({x})? ({y}): " f'(({x})>=({y})? ({x}): nan("")));'

It tries to ignore nans, but by doing so it implicitly converts the intermediate values to floats.

I guess it might make sense to split the ScalarOps: One for floats (where we have an identity) and one for ints (where we don't). And then use the nan-check only for floats.

edit

This was introduced here: aesara-devs/aesara#297

from pytensor.

ricardoV94 avatar ricardoV94 commented on September 27, 2024

The conversion story makes sense. Regarding infty, the code actually initializes those to zero when it's (u)integers.

The number thing was not a hard cutoff. It starts working with larger values and then fails again. In case that helps.

And yes this bug is likely there for a while but was hidden when the max/min could be constant folded, triggering the C implementation of MaxAndArgmax instead which just calls numpy C code and handles it correctly.

from pytensor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.