Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

DRAFT: Analyze macos-15-intel problems of issue 23710#23728

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

DietBru
Copy link
Contributor

@DietBruDietBru commentedOct 3, 2025
edited
Loading

DO NOT MERGE!

Issue#23713 shows that only on "macos-15-intel" hardware,signal.closest_STFT_dual_window does not produce identical results though, it should. Here, additional tests are added to investigate that behavior.

This PR is needed due to lack of having local macos-15-intel hardware. Consult also PR#23713.

DO NOT MERGE!Issue 2370 shows that only on "macos-15-intel" hardware, `signal.closest_STFT_dual_window` does not produce identical results though, it should.Here, additional tests are added to investigate that behavior.This PR is needed due to lack of having local macos-15-intel hardware.Consult also PR 23713.
@DietBruDietBru added the CIItems related to the CI tools such as CircleCI, GitHub Actions or Azure labelOct 3, 2025
DO NOT MERGE! Continuing analysis on Issue 2370.
DO NOT MERGE! Continuing analysis on Issue 2370 (1).[skip circle]
DO NOT MERGE! Continuing analysis on Issue 2370 (2).[skip circle]
@DietBru
Copy link
ContributorAuthor

DietBru commentedOct 3, 2025
edited
Loading

Thistest shows that matrix multiplication and addition does not produce identical results (or I'm blind), i.e.:

xp_assert_equal(qd2,qd1)assertqd1isnotqd2# ensure mutating qd1 is not the problem# Taken from closest_STFT_dual_window (qd1 == qd2):denominator1=qd1.T.real @qd1.real+qd1.T.imag @qd1.imag# always >= 0denominator2=qd2.T.real @qd2.real+qd2.T.imag @qd2.imag# always >= 0xp_assert_equal(denominator2,denominator1)# fails only on macos15-intel

Do you have any ideas,@andyfaff?

The corresponding log output:

2025-10-03T22:05:39.3230950Z ________________________ test_issue2370[hann-17-8-True] ________________________2025-10-03T22:05:39.3231510Z 2025-10-03T22:05:39.3231780Z win_name = 'hann', m = 17, hop = 8, sym_win = True, scaled = True2025-10-03T22:05:39.3232260Z 2025-10-03T22:05:39.3232510Z     @pytest.mark.parametrize('sym_win', (False, True))2025-10-03T22:05:39.3233130Z     @pytest.mark.parametrize('hop', (8, 9))2025-10-03T22:05:39.3233700Z     @pytest.mark.parametrize('m', (16, 17))2025-10-03T22:05:39.3234350Z     @pytest.mark.parametrize('win_name', ('hann', 'hamming'))2025-10-03T22:05:39.3235120Z     def test_issue2370(win_name, m, hop, sym_win, scaled=True):2025-10-03T22:05:39.3235830Z         """Analyze macos15-intel problems (issue 23710) """2025-10-03T22:05:39.3236970Z         win = get_window(win_name, m, not sym_win)2025-10-03T22:05:39.3237570Z         d_win = np.ones_like(win)2025-10-03T22:05:39.3238220Z         d1, s1, qd1, wd1 = _closest_STFT_dual_window2(win, hop, d_win, scaled=scaled)2025-10-03T22:05:39.3239120Z         d2, s2, qd2, wd2 = _closest_STFT_dual_window2(win, hop, d_win, scaled=scaled)2025-10-03T22:05:39.3239790Z     2025-10-03T22:05:39.3240270Z         # Identical function calls should produce identical results:2025-10-03T22:05:39.3240950Z         xp_assert_equal(wd2, wd1)2025-10-03T22:05:39.3241420Z         xp_assert_equal(qd2, qd1)2025-10-03T22:05:39.3242010Z         assert qd1 is not qd2  # ensure mutating qd1 is not the problem2025-10-03T22:05:39.3242640Z     2025-10-03T22:05:39.3243020Z         # Taken from closest_STFT_dual_window (qd1 == qd2):2025-10-03T22:05:39.3243840Z         denominator1 = qd1.T.real @ qd1.real + qd1.T.imag @ qd1.imag  # always >= 02025-10-03T22:05:39.3245050Z         denominator2 = qd2.T.real @ qd2.real + qd2.T.imag @ qd2.imag  # always >= 02025-10-03T22:05:39.3246130Z >       xp_assert_equal(denominator2, denominator1)  # fails on macos15-intel2025-10-03T22:05:39.3246860Z         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^2025-10-03T22:05:39.3247950Z E       AssertionError: 2025-10-03T22:05:39.3248450Z E       Arrays are not equal2025-10-03T22:05:39.3248860Z E       2025-10-03T22:05:39.3249460Z E       Mismatched elements: 1 / 1 (100%)2025-10-03T22:05:39.3250130Z E       Max absolute difference among violations: 1.77635684e-152025-10-03T22:05:39.3250870Z E       Max relative difference among violations: 1.5700901e-162025-10-03T22:05:39.3251500Z E        ACTUAL: array(11.313725)2025-10-03T22:05:39.3251960Z E        DESIRED: array(11.313725)2025-10-03T22:05:39.3252270Z 2025-10-03T22:05:39.3252520Z d1         = array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])2025-10-03T22:05:39.3253240Z d2         = array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])2025-10-03T22:05:39.3253950Z d_win      = array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])2025-10-03T22:05:39.3254620Z denominator1 = np.float64(11.313725490196077)2025-10-03T22:05:39.3255200Z denominator2 = np.float64(11.313725490196079)2025-10-03T22:05:39.3256230Z hop        = 82025-10-03T22:05:39.3256650Z m          = 172025-10-03T22:05:39.3257100Z qd1        = array([0.        , 0.04106732, 0.19526215, 0.53846081, 1.        ,2025-10-03T22:05:39.3257800Z        1.20606003, 1.13807119, 1.03794126, 1.        , 1.03794126,2025-10-03T22:05:39.3258460Z        1.13807119, 1.20606003, 1.        , 0.53846081, 0.19526215,2025-10-03T22:05:39.3259030Z        0.04106732, 0.        ])2025-10-03T22:05:39.3259540Z qd2        = array([0.        , 0.04106732, 0.19526215, 0.53846081, 1.        ,2025-10-03T22:05:39.3260220Z        1.20606003, 1.13807119, 1.03794126, 1.        , 1.03794126,2025-10-03T22:05:39.3260890Z        1.13807119, 1.20606003, 1.

@andyfaff
Copy link
Contributor

Sorry, this isn't my area of expertise. I just discovered the issue ¯_(ツ)_/¯.

I would naively expect it to be equal. Same size arrays, same dtype, identical contents. The difference looks to be an ULP.

Perhaps we can just skip the test? How important is it that the calculation is identical in this case?

import sys, platform@pytest.mark.skipif(sys.platform == 'darwin' and platform.uname().machine=='x86_64' and platform.mac_ver()[0] > "15", reason="MacOS specific test")

Can you boil it down to a standalone example (just numpy)? That calculation doesn't involve any scipy code, that check is purely a numpy calculation. We should find out more about the numpy configuration.

DO NOT MERGE! Continuing analysis on Issue 2370 (3).Attempt at creating self-contained test.[skip circle]
@DietBru
Copy link
ContributorAuthor

Thanks for reporting this issue to NumPy,@andyfaff.
The test only uses the short functions_closest_STFT_dual_window2 and_calc_dual_canonical_window, which only utilize basic NumPy operations. Isolating it further (withtest_macos15_intel_repeatability) failed. Without being able to debug what's going on, I feel I am out of productive options here.

Perhaps we can just skip the test? How important is it that the calculation is identical in this case?

It would be nice to have some sort of confirmation that the deviations are always in the least significant mantissa bits. My hunch is that some uninitialized memory area is assumed to be zeroed (perhaps caused by using imaginary parts of an real-valued array), which could potentially lead to large deviations...

DO NOT MERGE! Continuing analysis on Issue 2370 (4).Improve failing test.[skip circle]
DO NOT MERGE! Continuing analysis on Issue 2370 (5).New test to check if matrix multiplication is the problem.[skip circle]
DO NOT MERGE! Continuing analysis on Issue 2370 (6).Attempt to isolate the problem a little more.[skip circle]
DO NOT MERGE! Continuing analysis on Issue 2370 (7).Attempt to isolate the problem a little more.[skip circle]
DietBru added a commit to DietBru/scipy that referenced this pull requestOct 13, 2025
…acos-15-intel backendAs discussed in NumPy issue 29873, utilizing the inner product does not always guarantee identical results. This commit changes the equality test to a testing approximate equality in `test_closest_STFT_dual_window_roundtrip`.Introduced with PRscipy#23713. Investigations can be found in the draft PRscipy#23728.Closesscipy#23710.
@DietBru
Copy link
ContributorAuthor

Discussion can be found inNumPy issue 29873. PR#23767 fixes the test by testing for approximate equality.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@larsonerlarsonerAwaiting requested review from larsonerlarsoner is a code owner

@ilaynilaynAwaiting requested review from ilaynilayn is a code owner

Assignees

No one assigned

Labels

CIItems related to the CI tools such as CircleCI, GitHub Actions or Azurescipy.signal

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@DietBru@andyfaff

[8]ページ先頭

©2009-2025 Movatter.jp