-
Notifications
You must be signed in to change notification settings - Fork 24
Add requirements.txt, missing patch to ASV benchmarks #331
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,6 @@ | |
| "build_cache_size": 2, | ||
| "default_benchmark_timeout": 500, | ||
| "regressions_thresholds": { | ||
| ".*": 0.3 | ||
| ".*": 0.2 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||
| """MKL patch setup — executed once per ASV worker process at import time. | ||||||
|
|
||||||
| Patches NumPy FFT with the Intel MKL FFT implementation. | ||||||
| Hard-fails with a descriptive RuntimeError if mkl_fft is missing or the | ||||||
| patch does not take effect, so benchmarks never silently run on stock NumPy. | ||||||
| """ | ||||||
|
|
||||||
| _PATCH_MAP = [ | ||||||
| ("mkl_fft", "patch_numpy_fft"), | ||||||
| ] | ||||||
|
Comment on lines
+8
to
+10
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. making this a dictionary would make more sense to me, especially with the name "PATCH_MAP" |
||||||
|
|
||||||
|
|
||||||
| def _apply_patches(): | ||||||
| import importlib | ||||||
|
|
||||||
| import numpy as np | ||||||
|
|
||||||
| patched = {} | ||||||
|
|
||||||
| for mod_name, patch_fn_name in _PATCH_MAP: | ||||||
| try: | ||||||
| mod = importlib.import_module(mod_name) | ||||||
| except ImportError as exc: | ||||||
| raise RuntimeError( | ||||||
| f"[mkl-patch] Cannot import {mod_name}: {exc}\n" | ||||||
| f" Ensure the conda env contains {mod_name} " | ||||||
| f"from the Intel channel.\n" | ||||||
| " Required channels: " | ||||||
| "https://software.repos.intel.com/python/conda" | ||||||
| ) from exc | ||||||
|
|
||||||
| patch_fn = getattr(mod, patch_fn_name, None) | ||||||
| if patch_fn is None: | ||||||
| raise RuntimeError( | ||||||
| f"[mkl-patch] {mod_name} has no {patch_fn_name}(). " | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all |
||||||
| f"Upgrade {mod_name} to a version that exposes " | ||||||
| "the stock-numpy patch API." | ||||||
| ) | ||||||
|
|
||||||
| try: | ||||||
| patch_fn() | ||||||
| except Exception as exc: | ||||||
| raise RuntimeError( | ||||||
| f"[mkl-patch] {mod_name}.{patch_fn_name}() raised: {exc!r}" | ||||||
| ) from exc | ||||||
|
|
||||||
| is_patched_fn = getattr(mod, "is_patched", None) | ||||||
| if callable(is_patched_fn) and not is_patched_fn(): | ||||||
| raise RuntimeError( | ||||||
| f"[mkl-patch] {mod_name}.is_patched() returned False " | ||||||
| "after patching. NumPy may have been imported before " | ||||||
| "patching in a conflicting state." | ||||||
| ) | ||||||
|
|
||||||
| patched[mod_name] = mod | ||||||
|
|
||||||
| _attr_checks = { | ||||||
| "mkl_fft": lambda: np.fft.fft.__module__, | ||||||
| } | ||||||
| for mod_name in patched: | ||||||
| try: | ||||||
| attr = _attr_checks[mod_name]() | ||||||
| except Exception: | ||||||
| attr = "unknown" | ||||||
| print(f"[mkl-patch] {mod_name}: numpy.fft dispatch -> {attr}") | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, a call with verbose patching could substitute |
||||||
|
|
||||||
| print("[mkl-patch] ALL OK -- mkl_fft active") | ||||||
|
vchamarthi marked this conversation as resolved.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can drop this line -- the patching already has a verbose mode. If anything, we could just call into the verbose mode, I feel. |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| psutil | ||
| scipy | ||
|
vchamarthi marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.