Skip to content

Neighborhood filter reductions are making uxarray imports slow #1706

Closed

Description

@cmdupuis3

The new neighborhood filters require support for vectorized reduction kernels:

_MEAN_KERNEL = _make_kernel(lambda window, _: np.mean(window))
_SUM_KERNEL = _make_kernel(lambda window, _: np.sum(window))
_MIN_KERNEL = _make_kernel(lambda window, _: np.min(window))
_MAX_KERNEL = _make_kernel(lambda window, _: np.max(window))
_PTP_KERNEL = _make_kernel(lambda window, _: np.max(window) - np.min(window))
_MEDIAN_KERNEL = _make_kernel(_median)
_VAR_KERNEL = _make_kernel(_variance)
_STD_KERNEL = _make_kernel(lambda window, ddof: np.sqrt(_variance(window, ddof)))
# ``percentile`` is ``quantile`` on a 0-100 scale, so both methods rescale onto
# this one kernel rather than compiling a near-duplicate.
_QUANTILE_KERNEL = _make_kernel(lambda window, q: np.quantile(window, q))

However, this block is resulting in severe performance degradations of uxarray imports, notably affecting the benchmark suites.

In exploratory work with PR #1700, I found that this block can affect thread pooling as well. The strategy seems to be to lazily generate these kernels, which would defer the overeager thread pooling and limit the burden on uxarray imports.

Activity

  1. self-assigned this
    on Aug 25, 2026
  2. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Aug 25, 2026
  3. moved this from 📝 To-Do to 👀 In review in UXarray Developmenton Aug 31, 2026
  4. moved this from 👀 In review to ✅ Done in UXarray Developmenton Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions