Skip to content
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

"Schur decomposition solver error" on aarch64 #8033

Closed
andyndang opened this issue Jan 24, 2022 · 7 comments
Closed

"Schur decomposition solver error" on aarch64 #8033

andyndang opened this issue Jan 24, 2022 · 7 comments

Comments

@andyndang
Copy link

andyndang commented Jan 24, 2022

Describe the bug

I'm using PmdArima, which uses statsmodels underneath the hood.

However, I'm noticing a difference between running the same code on x64 vs aarch64 architecture

Version of statsmodel: 0.13.1
Version of pmdarima: 1.8.4

Code Sample, a copy-pastable example if possible

import pmdarima as pm
import numpy as np

model = pm.arima.ARIMA(order=(1, 0, 0), seasonal_order=(2, 1, 0, 7))
data = np.array([ 0.0, 0.0, 0.0, 0.0, 0.0, 9.85040379
, 9.54116535, 9.32663155, 9.2234745,  9.565238, 8.71925259, 9.76801205
, 9.69493675, 9.79889011, 9.49398804, 8.66767883, 9.33772945, 8.71925259
, 9.15603161, 8.45924664, 8.7293129,  9.48911667, 10.19035053, 9.22128391
, 9.01288033, 8.12544632, 9.57633972, 8.85050488, 9.03771114, 9.09411049
, 8.72431564, 8.64025211, 8.89891052, 9.55954933, 8.9926033,  8.79051018
, 9.06884098, 8.56023407, 8.63816166, 9.47813416, 10.32632923, 9.49745369], dtype=float)
model.fit(data)

Excepton on aarch64:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/env/lib/python3.9/site-packages/pmdarima/arima/arima.py", line 597, in fit
    self._fit(y, X, **fit_args)
  File "/env/lib/python3.9/site-packages/pmdarima/arima/arima.py", line 520, in _fit
    fit, self.arima_res_ = _fit_wrapper()
  File "/env/lib/python3.9/site-packages/pmdarima/arima/arima.py", line 508, in _fit_wrapper
    return arima, arima.fit(start_params=start_params,
  File "/env/lib/python3.9/site-packages/statsmodels/tsa/statespace/mlemodel.py", line 704, in fit
    mlefit = super(MLEModel, self).fit(start_params, method=method,
  File "/env/lib/python3.9/site-packages/statsmodels/base/model.py", line 563, in fit
    xopt, retvals, optim_settings = optimizer._fit(f, score, start_params,
  File "/env/lib/python3.9/site-packages/statsmodels/base/optimizer.py", line 241, in _fit
    xopt, retvals = func(objective, gradient, start_params, fargs, kwargs,
  File "/env/lib/python3.9/site-packages/statsmodels/base/optimizer.py", line 651, in _fit_lbfgs
    retvals = optimize.fmin_l_bfgs_b(func, start_params, maxiter=maxiter,
  File "/env/lib/python3.9/site-packages/scipy/optimize/lbfgsb.py", line 197, in fmin_l_bfgs_b
    res = _minimize_lbfgsb(fun, x0, args=args, jac=jac, bounds=bounds,
  File "/env/lib/python3.9/site-packages/scipy/optimize/lbfgsb.py", line 360, in _minimize_lbfgsb
    f, g = func_and_grad(x)
  File "/env/lib/python3.9/site-packages/scipy/optimize/_differentiable_functions.py", line 260, in fun_and_grad
    self._update_fun()
  File "/env/lib/python3.9/site-packages/scipy/optimize/_differentiable_functions.py", line 226, in _update_fun
    self._update_fun_impl()
  File "/env/lib/python3.9/site-packages/scipy/optimize/_differentiable_functions.py", line 133, in update_fun
    self.f = fun_wrapped(self.x)
  File "/env/lib/python3.9/site-packages/scipy/optimize/_differentiable_functions.py", line 130, in fun_wrapped
    return fun(x, *args)
  File "/env/lib/python3.9/site-packages/statsmodels/base/model.py", line 531, in f
    return -self.loglike(params, *args) / nobs
  File "/env/lib/python3.9/site-packages/statsmodels/tsa/statespace/mlemodel.py", line 939, in loglike
    loglike = self.ssm.loglike(complex_step=complex_step, **kwargs)
  File "/env/lib/python3.9/site-packages/statsmodels/tsa/statespace/kalman_filter.py", line 983, in loglike
    kfilter = self._filter(**kwargs)
  File "/env/lib/python3.9/site-packages/statsmodels/tsa/statespace/kalman_filter.py", line 903, in _filter
    self._initialize_state(prefix=prefix, complex_step=complex_step)
  File "/env/lib/python3.9/site-packages/statsmodels/tsa/statespace/representation.py", line 983, in _initialize_state
    self._statespaces[prefix].initialize(self.initialization,
  File "statsmodels/tsa/statespace/_representation.pyx", line 1373, in statsmodels.tsa.statespace._representation.dStatespace.initialize
  File "statsmodels/tsa/statespace/_representation.pyx", line 1362, in statsmodels.tsa.statespace._representation.dStatespace.initialize
  File "statsmodels/tsa/statespace/_initialization.pyx", line 288, in statsmodels.tsa.statespace._initialization.dInitialization.initialize
  File "statsmodels/tsa/statespace/_initialization.pyx", line 406, in statsmodels.tsa.statespace._initialization.dInitialization.initialize_stationary_stationary_cov
  File "statsmodels/tsa/statespace/_tools.pyx", line 1284, in statsmodels.tsa.statespace._tools._dsolve_discrete_lyapunov
numpy.linalg.LinAlgError: Schur decomposition solver error.

If the issue has not been resolved, please file it in the issue tracker.

Expected Output

No error. Intel version doesn't cause the issue

Output of import statsmodels.api as sm; sm.show_versions()

import statsmodels.api as sm; sm.show_versions()

INSTALLED VERSIONS

Python: 3.9.7.final.0
OS: Linux 4.14.232-177.418.amzn2.aarch64 #1 SMP Tue Jun 15 20:58:11 UTC 2021 aarch64
byteorder: little
LC_ALL: None
LANG: C.UTF-8

statsmodels

Installed: 0.13.1 (/env/lib/python3.9/site-packages/statsmodels)

Required Dependencies

cython: Not installed
numpy: 1.22.0 (/env/lib/python3.9/site-packages/numpy)
scipy: 1.6.1 (/env/lib/python3.9/site-packages/scipy)
pandas: 1.3.5 (/env/lib/python3.9/site-packages/pandas)
dateutil: 2.8.2 (/env/lib/python3.9/site-packages/dateutil)
patsy: 0.5.2 (/env/lib/python3.9/site-packages/patsy)

Optional Dependencies

matplotlib: Not installed
cvxopt: Not installed
joblib: 1.1.0 (/env/lib/python3.9/site-packages/joblib)

Developer Tools

IPython: Not installed
jinja2: Not installed
sphinx: Not installed
pygments: Not installed
pytest: Not installed
virtualenv: Not installed

@bashtage
Copy link
Member

I suspect there are bugs in OpenBLAS that are percolating up on aarch64. The test suite doesn't actually pass with the failure occurring in the state space modes.

@bashtage
Copy link
Member

Does latest scipy help?

@AGSaidi
Copy link

AGSaidi commented Jan 24, 2022

The last bug I know of in OpenBLAS was fixed about a year ago in OpenMathLib/OpenBLAS#3052

@andyndang
Copy link
Author

@bashtage good catch. Upgraded to scipy 1.7.3 fixed the issue :)

@bashtage
Copy link
Member

This is good to hear. Could be OpenBLAS, or could be a change in the optimizer avoids a problematic value. Closing since sounds like no issue.

@snadampal
Copy link

scipy version 1.7.2 is the first version with this bug fixed.
Looks like very few fixes went into v1.7.2, but the OpenBLAS version was upgraded from v0.3.9 to v0.3.17.
I believe it is the newer openBLAS version fixing this particular issue. There have been multiple precision/data correctness fixes went into OpenBLAS from v0.3.9 to v0.3.17.

@bashtage bashtage added this to the 0.13.2 milestone Feb 8, 2022
@bashtage bashtage modified the milestones: 0.13.2, 0.14 Apr 14, 2023
@ZumelzuR
Copy link

ZumelzuR commented Feb 9, 2024

In my case I solved only scaling the data with MinMaxScaler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants