Skip to content

hotkernels 0.1.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 14:59
· 1055 commits to main since this release
318d7e6

hotkernels 0.1.0

Highlights

The first release of hotkernels. One line, hotkernels.install(), points NumPy at hand-written kernels for the calls where NumPy is slowest, and existing NumPy code runs faster with no other change. A call no kernel handles goes to NumPy exactly as before, and costs under a nanosecond more.

  • 18 kernels for 13 NumPy operations are installed by default: np.argmax and np.argmin, np.clip, x[mask] and x[mask] = v, np.nonzero, np.cumsum on int64, x.astype(np.float32) from uint8, np.sum on uint8, np.count_nonzero, np.histogram, np.bincount and np.isin. install(inexact=True) adds np.cumsum on float32 and float64, which are within a declared tolerance of NumPy rather than bit-identical.
  • From Python, at a million elements: x[mask] on float32 is 31.0x faster, x[mask] = 0.0 20.6x, np.sum on uint8 15.6x, np.cumsum on int64 13.7x, np.histogram 9.41x and np.argmax 8.90x. An unmodified example program, examples/workload.py, goes from 45.2 ms to 8.4 ms with the same results bit for bit.
  • Checked against NumPy itself. 70,031 NumPy calls give the same result, exceptions and warnings with hotkernels as without, and NumPy's own test suite gives the same outcome for each of its 47,234 tests.
  • print(hotkernels.report()) shows what is installed and how often each kernel ran, so you can see whether your code reaches them.

Where it runs. macOS on Apple Silicon, Python 3.11 to 3.14, NumPy 2. Wheels are published for that platform only; there is no source distribution yet, so pip install hotkernels finds nothing elsewhere. On free-threaded Python install() does nothing and report() says why.

Measured on an Apple M1 Pro with NumPy 2.5.5 and Python 3.12.7, on a machine in use (load average about 3). Every statement at three sizes is in delivery/results/apple-m1-pro.md.

Other changes

  • hotkernels.__version__ gives the installed release, and print(hotkernels.report()) names it on its first line. (#28)