question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TEST/BUG: Tolerance violation in test_solvers::test_solve_discrete_are

See original GitHub issue

From https://github.com/conda-forge/scipy-feedstock/pull/210 on linux, using openblas 0.3.21, both with & without skylake**

=========================== short test summary info ============================
FAILED linalg/tests/test_solvers.py::test_solve_discrete_are - AssertionError: 
= 1 failed, 49466 passed, 2839 skipped, 253 xfailed, 9 xpassed, 236 warnings in 780.89s (0:13:00) =
E   AssertionError: 
E   Arrays are not almost equal to 5 decimals
E   
E   Mismatched elements: 1 / 9 (11.1%)
E   Max absolute difference: 1.78702176e-05
E   Max relative difference: inf
E    x: array([[ 1.78702e-05,  1.10194e-05, -2.05636e-06],
E          [ 1.10194e-05,  6.89924e-06, -1.35228e-06],
E          [-2.05636e-06, -1.35601e-06,  2.92435e-07]])
E    y: array([[0., 0., 0.],
E          [0., 0., 0.],
E          [0., 0., 0.]])
**

The respective machines have:

Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2,AVX512F,AVX512CD,AVX512_SKX
    not found = AVX512_KNL,AVX512_KNM,AVX512_CLX,AVX512_CNL,AVX512_ICL

as well as

Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2
    not found = AVX512F,AVX512CD,AVX512_KNL,AVX512_KNM,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Sep 20, 2022

This is also happening in CI (example log):

___________________________ test_solve_discrete_are ____________________________
[gw0] linux -- Python 3.9.14 /opt/hostedtoolcache/Python/3.9.14/x64/bin/python
scipy/linalg/tests/test_solvers.py:528: in test_solve_discrete_are
    _test_factory(case, min_decimal[ind])
        _test_factory = <function test_solve_discrete_are.<locals>._test_factory at 0x7fb76d5a8b80>
        case       = (array([[ 1.77777778,  1.11111111, -0.22222222],
       [ 1.11111111,  1.44444444, -0.88888889],
       [-0.22222222, ...([[1000000.,       0.,       0.],
       [      0., 1000000.,       0.],
       [      0.,       0., 1000000.]]), None)
        cases      = [(array([[ 2.+0.j,  1.-2.j],
       [ 0.+0.j, -0.-3.j]]), array([[0],
       [1]]), array([[1, 0],
       [0, 2]]), ar...0.005, 0.   ],
       [0.   , 0.02 ]]), array([[0.33333333, 0.        ],
       [0.        , 3.        ]]), None), ...]
        ind        = 16
        min_decimal = (12, 14, 13, 14, 13, 16, ...)
scipy/linalg/tests/test_solvers.py:525: in _test_factory
    assert_array_almost_equal(res, np.zeros_like(res), decimal=dec)
E   AssertionError: 
E   Arrays are not almost equal to 5 decimals
E   
E   Mismatched elements: 1 / 9 (11.1%)
E   Max absolute difference: 1.78702176e-05
E   Max relative difference: inf
E    x: array([[ 1.78702e-05,  1.10194e-05, -2.05636e-06],
E          [ 1.10194e-05,  6.89924e-06, -1.35228e-06],
E          [-2.05636e-06, -1.35601e-06,  2.92435e-07]])
E    y: array([[0., 0., 0.],
E          [0., 0., 0.],
E          [0., 0., 0.]])
        a          = array([[ 1.77777778,  1.11111111, -0.22222222],
       [ 1.11111111,  1.44444444, -0.88888889],
       [-0.22222222, -0.88888889,  0.77777778]])
        b          = array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])
        case       = (array([[ 1.77777778,  1.11111111, -0.22222222],
       [ 1.11111111,  1.44444444, -0.88888889],
       [-0.22222222, ...([[1000000.,       0.,       0.],
       [      0., 1000000.,       0.],
       [      0.,       0., 1000000.]]), None)
        dec        = 5
        knownfailure = None
        q          = array([[1000000.,       0.,       0.],
       [      0., 1000000.,       0.],
       [      0.,       0., 1000000.]])
        r          = array([[1000000.,       0.,       0.],
       [      0., 1000000.,       0.],
       [      0.,       0., 1000000.]])
        res        = array([[ 1.78702176e-05,  1.10194087e-05, -2.05636024e-06],
       [ 1.10194087e-05,  6.89923763e-06, -1.35228038e-06],
       [-2.05636024e-06, -1.35600567e-06,  2.92435288e-07]])
        x          = array([[ 4879024.98548958,  3467002.3263308 , -1527489.83358603],
       [ 3467002.3263308 ,  4673013.65591872, -1939512.49275335],
       [-1527489.83358603, -1939512.49275335,  2175767.57596036]])

That is with OpenBLAS 0.3.20 from Ubuntu.

I cannot reproduce it locally on Linux with either openblas 0.3.20 or 0.3.21 from conda-forge:

  - libopenblas   0.3.20  pthreads_h78a6416_0  conda-forge                    
  + libopenblas   0.3.21  pthreads_h78a6416_3  conda-forge/linux-64     Cached
  - openblas      0.3.20  pthreads_h320a7e8_0  conda-forge                    
  + openblas      0.3.21  pthreads_h320a7e8_3  conda-forge/linux-64 

I will note that internally solve_discrete_are uses ordqz, which leads us back to the same gges routine as in gh-16949. That one shows up on macOS and this one on Linux, but they’re probably symptoms of the same underlying issue.

0reactions
danigmcommented, Dec 2, 2022

I’ve a similar issue building for i586:

[  695s] =================================== FAILURES ===================================
[  695s] _____________________ test_solve_generalized_discrete_are ______________________
[  695s] [gw0] linux -- Python 3.8.15 /usr/bin/python3.8
[  695s] 
[  695s]     def test_solve_generalized_discrete_are():
[  695s]         mat20170120 = _load_data('gendare_20170120_data.npz')
[  695s]     
[  695s]         cases = [
[  695s]             # Two random examples differ by s term
[  695s]             # in the absence of any literature for demanding examples.
[  695s]             (np.array([[2.769230e-01, 8.234578e-01, 9.502220e-01],
[  695s]                        [4.617139e-02, 6.948286e-01, 3.444608e-02],
[  695s]                        [9.713178e-02, 3.170995e-01, 4.387444e-01]]),
[  695s]              np.array([[3.815585e-01, 1.868726e-01],
[  695s]                        [7.655168e-01, 4.897644e-01],
[  695s]                        [7.951999e-01, 4.455862e-01]]),
[  695s]              np.eye(3),
[  695s]              np.eye(2),
[  695s]              np.array([[6.463130e-01, 2.760251e-01, 1.626117e-01],
[  695s]                        [7.093648e-01, 6.797027e-01, 1.189977e-01],
[  695s]                        [7.546867e-01, 6.550980e-01, 4.983641e-01]]),
[  695s]              np.zeros((3, 2)),
[  695s]              None),
[  695s]             (np.array([[2.769230e-01, 8.234578e-01, 9.502220e-01],
[  695s]                        [4.617139e-02, 6.948286e-01, 3.444608e-02],
[  695s]                        [9.713178e-02, 3.170995e-01, 4.387444e-01]]),
[  695s]              np.array([[3.815585e-01, 1.868726e-01],
[  695s]                        [7.655168e-01, 4.897644e-01],
[  695s]                        [7.951999e-01, 4.455862e-01]]),
[  695s]              np.eye(3),
[  695s]              np.eye(2),
[  695s]              np.array([[6.463130e-01, 2.760251e-01, 1.626117e-01],
[  695s]                        [7.093648e-01, 6.797027e-01, 1.189977e-01],
[  695s]                        [7.546867e-01, 6.550980e-01, 4.983641e-01]]),
[  695s]              np.ones((3, 2)),
[  695s]              None),
[  695s]             # user-reported (under PR-6616) 20-Jan-2017
[  695s]             # tests against the case where E is None but S is provided
[  695s]             (mat20170120['A'],
[  695s]              mat20170120['B'],
[  695s]              mat20170120['Q'],
[  695s]              mat20170120['R'],
[  695s]              None,
[  695s]              mat20170120['S'],
[  695s]              None),
[  695s]             ]
[  695s]     
[  695s]         min_decimal = (11, 11, 16)
[  695s]     
[  695s]         def _test_factory(case, dec):
[  695s]             """Checks if X = A'XA-(A'XB)(R+B'XB)^-1(B'XA)+Q) is true"""
[  695s]             a, b, q, r, e, s, knownfailure = case
[  695s]             if knownfailure:
[  695s]                 pytest.xfail(reason=knownfailure)
[  695s]     
[  695s]             x = solve_discrete_are(a, b, q, r, e, s)
[  695s]             if e is None:
[  695s]                 e = np.eye(a.shape[0])
[  695s]             if s is None:
[  695s]                 s = np.zeros_like(b)
[  695s]             res = a.conj().T.dot(x.dot(a)) - e.conj().T.dot(x.dot(e)) + q
[  695s]             res -= (a.conj().T.dot(x.dot(b)) + s).dot(
[  695s]                         solve(r+b.conj().T.dot(x.dot(b)),
[  695s]                               (b.conj().T.dot(x.dot(a)) + s.conj().T)
[  695s]                               )
[  695s]                     )
[  695s]             assert_array_almost_equal(res, np.zeros_like(res), decimal=dec)
[  695s]     
[  695s]         for ind, case in enumerate(cases):
[  695s] >           _test_factory(case, min_decimal[ind])
[  695s] 
[  695s] _test_factory = <function test_solve_generalized_discrete_are.<locals>._test_factory at 0xde728220>
[  695s] case       = (array([[ 0.97905961,  0.15428665, -0.03994193,  0.00391164, -0.01180311,
[  695s]         -0.02494093, -0.00892079,  0.0143359...891e-06,  2.94712339e-08],
[  695s]        [ 2.40952333e-08,  4.30614350e-07],
[  695s]        [ 1.23662598e-08, -6.06921957e-07]]), ...)
[  695s] cases      = [(array([[0.276923  , 0.8234578 , 0.950222  ],
[  695s]        [0.04617139, 0.6948286 , 0.03444608],
[  695s]        [0.09713178, 0.3170...91e-06,  2.94712339e-08],
[  695s]        [ 2.40952333e-08,  4.30614350e-07],
[  695s]        [ 1.23662598e-08, -6.06921957e-07]]), ...)]
[  695s] ind        = 2
[  695s] mat20170120 = {'A': array([[ 0.97905961,  0.15428665, -0.03994193,  0.00391164, -0.01180311,
[  695s]         -0.02494093, -0.00892079,  0.01...,  2.58702432e-06]]), 'R': array([[ 6.86199839e-07, -1.42279806e-08],
[  695s]        [-1.42279806e-08,  1.81130866e-07]]), ...}
[  695s] min_decimal = (11, 11, 16)
[  695s] 
[  695s] /usr/lib/python3.8/site-packages/scipy/linalg/tests/test_solvers.py:654: 
[  695s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  695s] 
[  695s] case = (array([[ 0.97905961,  0.15428665, -0.03994193,  0.00391164, -0.01180311,
[  695s]         -0.02494093, -0.00892079,  0.0143359...891e-06,  2.94712339e-08],
[  695s]        [ 2.40952333e-08,  4.30614350e-07],
[  695s]        [ 1.23662598e-08, -6.06921957e-07]]), ...)
[  695s] dec = 16
[  695s] 
[  695s]     def _test_factory(case, dec):
[  695s]         """Checks if X = A'XA-(A'XB)(R+B'XB)^-1(B'XA)+Q) is true"""
[  695s]         a, b, q, r, e, s, knownfailure = case
[  695s]         if knownfailure:
[  695s]             pytest.xfail(reason=knownfailure)
[  695s]     
[  695s]         x = solve_discrete_are(a, b, q, r, e, s)
[  695s]         if e is None:
[  695s]             e = np.eye(a.shape[0])
[  695s]         if s is None:
[  695s]             s = np.zeros_like(b)
[  695s]         res = a.conj().T.dot(x.dot(a)) - e.conj().T.dot(x.dot(e)) + q
[  695s]         res -= (a.conj().T.dot(x.dot(b)) + s).dot(
[  695s]                     solve(r+b.conj().T.dot(x.dot(b)),
[  695s]                           (b.conj().T.dot(x.dot(a)) + s.conj().T)
[  695s]                           )
[  695s]                 )
[  695s] >       assert_array_almost_equal(res, np.zeros_like(res), decimal=dec)
[  695s] E       AssertionError: 
[  695s] E       Arrays are not almost equal to 16 decimals
[  695s] E       
[  695s] E       Mismatched elements: 2 / 64 (3.12%)
[  695s] E       Max absolute difference: 2.41539492e-16
[  695s] E       Max relative difference: inf
[  695s] E        x: array([[-9.3156683539027951e-18, -3.8725552255078561e-18,
[  695s] E               -1.4044229781949927e-17, -5.9924192886452732e-17,
[  695s] E               -6.5613289676686240e-17,  2.9395801978427663e-17,...
[  695s] E        y: array([[0., 0., 0., 0., 0., 0., 0., 0.],
[  695s] E              [0., 0., 0., 0., 0., 0., 0., 0.],
[  695s] E              [0., 0., 0., 0., 0., 0., 0., 0.],...
[  695s] 
[  695s] a          = array([[ 0.97905961,  0.15428665, -0.03994193,  0.00391164, -0.01180311,
[  695s]         -0.02494093, -0.00892079,  0.01433595...     [-0.02851398, -0.00156313, -0.01257725, -0.05334177, -0.03769227,
[  695s]         -0.00788838, -0.62801576,  0.34907   ]])
[  695s] b          = array([[-1.04368719,  1.09316659],
[  695s]        [ 0.51336209, -0.15143908],
[  695s]        [ 0.78618282,  0.3888125 ],
[  695s]        [ 0.90... 0.12416864],
[  695s]        [ 0.90485159, -0.0090001 ],
[  695s]        [-0.00863767,  0.55645316],
[  695s]        [ 0.00708354,  0.6553915 ]])
[  695s] case       = (array([[ 0.97905961,  0.15428665, -0.03994193,  0.00391164, -0.01180311,
[  695s]         -0.02494093, -0.00892079,  0.0143359...891e-06,  2.94712339e-08],
[  695s]        [ 2.40952333e-08,  4.30614350e-07],
[  695s]        [ 1.23662598e-08, -6.06921957e-07]]), ...)
[  695s] dec        = 16
[  695s] e          = array([[1., 0., 0., 0., 0., 0., 0., 0.],
[  695s]        [0., 1., 0., 0., 0., 0., 0., 0.],
[  695s]        [0., 0., 1., 0., 0., 0., 0., ...   [0., 0., 0., 0., 0., 1., 0., 0.],
[  695s]        [0., 0., 0., 0., 0., 0., 1., 0.],
[  695s]        [0., 0., 0., 0., 0., 0., 0., 1.]])
[  695s] knownfailure = None
[  695s] q          = array([[ 1.75512507e-06, -4.27225221e-07, -9.34790486e-07,
[  695s]         -6.10641258e-07,  1.62839572e-06,  2.22620136e-06,
[  695s] ...-7.58710361e-07,
[  695s]         -9.08221173e-07, -2.90720260e-07, -6.17890194e-08,
[  695s]         -2.00190655e-06,  2.58702432e-06]])
[  695s] r          = array([[ 6.86199839e-07, -1.42279806e-08],
[  695s]        [-1.42279806e-08,  1.81130866e-07]])
[  695s] res        = array([[-9.31566835e-18, -3.87255523e-18, -1.40442298e-17,
[  695s]         -5.99241929e-17, -6.56132897e-17,  2.93958020e-17,
[  695s] ...-2.32497044e-17,
[  695s]         -4.66493602e-17,  2.28475491e-17, -5.35590182e-18,
[  695s]          9.16049192e-17,  3.31817878e-17]])
[  695s] s          = array([[-6.27256153e-07,  2.80554657e-07],
[  695s]        [ 4.27827567e-07,  8.54401686e-08],
[  695s]        [ 8.76221935e-07,  1.5285....68302891e-06,  2.94712339e-08],
[  695s]        [ 2.40952333e-08,  4.30614350e-07],
[  695s]        [ 1.23662598e-08, -6.06921957e-07]])
[  695s] x          = array([[ 1.88357055e-06, -3.98902725e-07, -8.97987558e-07,
[  695s]         -7.18984081e-07,  1.95043873e-06,  2.15596656e-06,
[  695s] ...-7.62588561e-07,
[  695s]         -8.85735630e-07, -2.59621085e-07, -7.62321103e-08,
[  695s]         -1.79447605e-06,  3.08567024e-06]])
[  695s] 
[  695s] /usr/lib/python3.8/site-packages/scipy/linalg/tests/test_solvers.py:651: AssertionError
[  695s] =========================== short test summary info ============================
[  695s] FAILED linalg/tests/test_solvers.py::test_solve_generalized_discrete_are - As...
[  695s] = 1 failed, 37442 passed, 2429 skipped, 145 xfailed, 13 xpassed in 667.09s (0:11:07) =
Read more comments on GitHub >

github_iconTop Results From Across the Web

TILA-RESPA Integrated Disclosure rule
Creditors can cure tolerance violations in many ways. For example, a cure for a tolerance violation can be provided by: ▫ Providing a...
Read more >
Correcting TRID Errors Evaluating Errors and Risk - NAFCU
How can a tolerance violation be cured? • If consumer pays amount that exceeds tolerances, no violation if no later than 60 days...
Read more >
What must creditors do when the amounts paid at closing ...
For example, a cure for a tolerance violation can be provided by: Providing a refund directly to the consumer;. Providing a principal reduction;....
Read more >
[video] CFPB Rule Provides Tighter Fee Tolerances - MyTicor
The new forms group charges together making it impossible for the settlement agent to determine if there is a tolerance violation. There is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found