Skip to content

Fixes test_fitting_with_initial_values[DogBoxLSQFitter] convergence failure on arm64#17958

Merged
pllim merged 3 commits into
astropy:mainfrom
casparvl:fix_test_fitting_with_initial_values_failure_on_arm
Aug 29, 2025
Merged

Fixes test_fitting_with_initial_values[DogBoxLSQFitter] convergence failure on arm64#17958
pllim merged 3 commits into
astropy:mainfrom
casparvl:fix_test_fitting_with_initial_values_failure_on_arm

Conversation

@casparvl

Copy link
Copy Markdown
Contributor

Description

On ARM64, when using an optimized OpenBLAS (i.e. configured with -march=native), the unit test test_fitting_with_initial_values[DogBoxLSQFitter] fails to converge. This is because due to the optimization, numerical behavior may alter ever-so-slightly, and apparently the initial starting conditions for this fit we're poorly conditioned. See #15650 for a more extensive description of the issue.

After doing an extensive search for various initial conditions here, this PR changes the initial conditions to values that appear to be more robust. I myself have build this on a wide range of CPU architectures (zen2, zen3, zen4, skylake, haswell, sapphire_rapids, x86_64/generic, aarch64/generic, neoverse_v1, neoverse_n1) to check if the test now passes on all of them. For each of those builds, the underlying OpenBLAS was optimized with -march=native (with the exception of the 'generic' builds), build natively on a machine of one of those architectures. This makes me as sure as I can be that the change in initial condition doesn't fix things for ARM, while reintroducing similar problems elsewhere.

Fixes #15650

@casparvl casparvl requested a review from a team as a code owner March 31, 2025 14:31
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Astropy 👋 and congratulations on your first pull request! 🎉

A project member will respond to you as soon as possible; in the meantime, please have a look over the Checklist for Contributed Code and make sure you've addressed as many of the questions there as possible.

If you feel that this pull request has not been responded to in a timely manner, please send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail feedback@astropy.org.


# Fit the data using a Gaussian with units
g_init = models.Gaussian1D(amplitude=1.0 * u.mJy, mean=3 * u.cm, stddev=2 * u.mm)
g_init = models.Gaussian1D(amplitude=1.0 * u.mJy, mean=4 * u.cm, stddev=3 * u.mm)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original values were added by @astrofrog back in #4855 . So pinging him just in case there was a reason why it was set to 3 and 2.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any update on this? :)

@saimn saimn modified the milestones: v7.0.2, v7.1.1 May 12, 2025
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Aug 29, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@pllim pllim requested a review from dhomeier August 29, 2025 12:42
Caspar van Leeuwen added 2 commits August 29, 2025 08:43
…] failure on arm64 when using an OpenBLAS optimized for ARM64 using -march=native
@pllim pllim force-pushed the fix_test_fitting_with_initial_values_failure_on_arm branch from 2dd2ed9 to 0ebefd9 Compare August 29, 2025 12:43
@pllim pllim removed the Close? Tell stale bot that this issue/PR is stale label Aug 29, 2025
@pllim pllim enabled auto-merge (squash) August 29, 2025 13:07
@pllim

pllim commented Aug 29, 2025

Copy link
Copy Markdown
Member

Sorry for the delay! I took the liberty to rebase and remove change log. Hope you don't mind. This will merge when CI passes. Thanks, all.

@pllim pllim merged commit aebdc68 into astropy:main Aug 29, 2025
30 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/astropy that referenced this pull request Aug 29, 2025
pllim added a commit that referenced this pull request Aug 29, 2025
…958-on-v7.1.x

Backport PR #17958 on branch v7.1.x (Fixes test_fitting_with_initial_values[DogBoxLSQFitter] convergence failure on arm64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_fitting_with_initial_values[DogBoxLSQFitter] fails to converge with mamba/miniforge openblas on macOS/arm64

4 participants