-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ ARIMA fixes and refactoring #939
base: main
Are you sure you want to change the base?
Conversation
Thanks a lot! Just a small question, do you know if using C++20 would cause problems for users on old MacOS systems? We publish wheels for MacOS 10.13, which is fairly old and I'm not sure if there could be runtime crashes due to something not being in the system's libc++ |
According to https://en.cppreference.com/w/cpp/compiler_support/20, It's not used in the library interface, if it was there could be ABI issues if the library and calling code were compiled with different versions of clang and stdc++ (program loads the dynamic library and calls a function that has std::span as one of its arguments). I have no way to test it on MacOS 10.13, but I strongly doubt any issues could happen at runtime. With optimization, the entire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Just some small comments.
int p = mp + ns * msp; | ||
int q = mq + ns * msq; | ||
auto params = std::vector<double>(params_in, params_in + params_inv.size()); | ||
const py::array_t<uint32_t> armav, bool trans) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an int array on the python side:
statsforecast/python/statsforecast/arima.py
Lines 308 to 317 in 665e9b1
arma = np.array( | |
[ | |
*order[::2], | |
*seasonal["order"][::2], | |
seasonal["period"], | |
order[1], | |
seasonal["order"][1], | |
], | |
dtype=np.intc, | |
) |
I'm ok with changing it to np.uint32 there, but we should make them match so that no copy is made when passing that to the cpp side. Let me know if you want to make that change, if not I can push that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to np.uint32, did it together with the ssize_t fix :)
src/arima.cpp
Outdated
double phij = j < p ? phi[j] : 0.0; | ||
|
||
size_t ind = 0; | ||
ssize_t ind1 = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like windows doesn't like this
ssize_t ind1 = -1; | |
py::ssize_t ind1 = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't realize it was a posix type, fixed.
Fixes #937. The code no longer segfaults in that scenario, but tries to allocate ~194 GB of memory and gets killed by oomkiller instead, would be probably nice to add an available memory check.
I had to bump cpp version to 20 in order to use
std::span
.All i did was change types to size_t/uint32 where it made sense, added const where it was possible and I also added some
assert
s on preconditions.I didn't find any tests, but i ran it before/after on the following configurations:
and got the exact same results.