Skip to content

perf: hoist unsupported-dtype blacklist out of the scipy.fft interface hot path - #405

Open
intel-python-devops wants to merge 2 commits into
masterfrom
chore/agentic-sweep-28
Open

intel-python-devops wants to merge 2 commits into
masterfrom
chore/agentic-sweep-28

Conversation

@intel-python-devops

@intel-python-devops intel-python-devops commented Nov 2, 2026 •

Copy link
Copy Markdown

Note

This pull request is entirely AI-generated. Please review thoroughly.

  • mkl_fft/interfaces/_float_utils.py: _supported_array_or_not_implemented (called once by every mkl_fft.interfaces.scipy_fft entry point via _validate_input) used to rebuild a black_list list and re-run two hasattr(np, ...) probes on every call, and _x.dtype in black_list then coerced each scalar type to a dtype per comparison. The unsupported dtypes are now computed once at import time as _UNSUPPORTED_DTYPES, a module-level frozenset of np.dtype objects, so the check is a single hash lookup.

Behavior is unchanged: master and this branch accept and reject the same dtypes, including byte-swapped, metadata-carrying, structured, object and StringDType inputs.

Per-call time in µs (median of 12 interleaved rounds, Python 3.12, NumPy 2.5.3, i7-1185G7):

call n master this PR
mkl_fft.interfaces.scipy_fft.fft 8 3.29 2.72 (−17.5%)
64 3.45 2.90 (−16.1%)
1024 4.91 4.34 (−11.6%)
scipy.fft.fft with set_backend 8 3.78 3.35 (−11.4%)
64 4.15 3.56 (−14.3%)
1024 5.40 4.92 (−8.8%)

Large transforms (n=65536) are unchanged within noise.

Comparing a dtype against np.half/np.float128/np.complex256 with `in`
on a list coerces each scalar type to a dtype on every call. Storing
np.dtype objects in a frozenset turns it into one hash lookup, roughly
doubling the per-call saving of the previous commit on small transforms.
@jharlow-intel jharlow-intel changed the title perf: hoist unsupported-dtype blacklist out of the scipy.fft interface h perf: hoist unsupported-dtype blacklist out of the scipy.fft interface hot path Nov 3, 2026
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.

2 participants