Skip to content

Fix annotate_muscle_zscore crash with n_jobs='cuda'#13994

Open
kveni12 wants to merge 3 commits into
mne-tools:mainfrom
kveni12:fix/annotate-muscle-zscore-cuda-13993
Open

Fix annotate_muscle_zscore crash with n_jobs='cuda'#13994
kveni12 wants to merge 3 commits into
mne-tools:mainfrom
kveni12:fix/annotate-muscle-zscore-cuda-13993

Conversation

@kveni12

@kveni12 kveni12 commented Jun 27, 2026

Copy link
Copy Markdown

Fixes #13993

Summary

  • Add n_jobs_hilbert parameter to annotate_muscle_zscore so filtering and Hilbert transform can use separate parallelization settings
  • Filtering continues to accept n_jobs='cuda' while Hilbert defaults to n_jobs=1 when n_jobs_hilbert is not set
  • Add tests covering n_jobs='cuda', explicit integer n_jobs/n_jobs_hilbert, and unchanged default behavior

Test plan

  • Smoke-tested locally with synthetic data (n_jobs='cuda', n_jobs=4/n_jobs_hilbert=2, default)
  • CI: mne/preprocessing/tests/test_artifact_detection.py::test_muscle_annotation_n_jobs_cuda
  • CI: existing test_muscle_annotation tests

Add n_jobs_hilbert so filtering can use CUDA while the Hilbert
transform keeps integer-only parallelization.
@welcome

welcome Bot commented Jun 27, 2026

Copy link
Copy Markdown

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴

Comment on lines +124 to +126
raw_copy.apply_hilbert(
envelope=True, n_jobs=n_jobs_hilbert if n_jobs_hilbert is not None else 1
)

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.

Hmmm... this isn't backward compatible. Previously, if a user provided n_jobs=4 for example, this would use 4 jobs. So a better pattern I think is:

if n_jobs != "cuda" and n_jobs_hilbert is None:
    n_jobs_hilbert = n_jobs

And you say in the docstring that n_jobs_hilbert will default to the value of n_jobs when n_jobs != "cuda".

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

annotate_muscle_zscore does not work with n_jobs = 'cuda'

2 participants