EconML icon indicating copy to clipboard operation
EconML copied to clipboard

Try to support numpy version 2

Open BlueDrink9 opened this issue 6 months ago • 4 comments

This is well and truly in draft mode, and may never get off the ground without some serious decision making. As such, I'm not really expecting this to have this merged, but perhaps the work that I have done here might be helpful for someone else down the line.

Numpy 2 does not support python 3.8, which straightaway rules out some of the optional dependencies that EconML has (eg pytorch). To get it building and testing, I have just removed them, and so it would probably require some more work if it was desirable to keep those.

I'm not experienced with cython, and a lot of the cython code here was not particularly clear to me from the sparse comments, so most of what I've done is really on a best guess effort to get it to successfully compile and pass tests. I'm still working on getting the remaining warnings fixed, but it would definitely benefit from help from someone who actually understands cython/the numpy API . ~~That being said, some of the tests are failing with segfaults so clearly I have made some mistakes somewhere. I have highlighted where I think these most likely are, but it will need someone who actually understands cython/the numpy API to assess and fix.~~

BlueDrink9 avatar May 08 '25 09:05 BlueDrink9

I'm a bit confused by the lkg.txt files, how do we regenerate those?

BlueDrink9 avatar May 08 '25 11:05 BlueDrink9

git ls-files --eol shows that crlf in this repo is incredibly inconsistent. I would highly recommend, at some point, doing dos2unix or similar on every file, to avoid issues around line endings in the future!

BlueDrink9 avatar May 08 '25 21:05 BlueDrink9

A bunch of the continuous integration steps will need to be updated to use a later version of python rather than 3.8 as part of this

BlueDrink9 avatar May 08 '25 23:05 BlueDrink9

Passing tests with a lot of warnings https://github.com/BlueDrink9/EconML/actions/runs/14917865406/job/41907412454

BlueDrink9 avatar May 08 '25 23:05 BlueDrink9

Thanks, I've cherry-picked one of your commits into another PR (#984) attempting to address this and other issues.

One issue with both your attempt and mine is that several tests run dramatically slower (see, e.g. the ubuntu-latest 3.10 ray tests, which take about 2 hours with these changes vs. 20 minutes without them). If you've got any insights on how to mitigate that performance regression I'm all ears.

kbattocchi avatar Jun 27 '25 15:06 kbattocchi

Thanks, I've cherry-picked one of your commits into another PR (#984) attempting to address this and other issues.

One issue with both your attempt and mine is that several tests run dramatically slower (see, e.g. the ubuntu-latest 3.10 ray tests, which take about 2 hours with these changes vs. 20 minutes without them). If you've got any insights on how to mitigate that performance regression I'm all ears.

Figured it out - needed to make sure noexcept (which was formerly the default) was applied to every nogil function. Closing this PR in favor of #984, but thanks again for contributing.

kbattocchi avatar Jul 07 '25 14:07 kbattocchi