Repository navigation
hotkernels 0.1.0
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.argmaxandnp.argmin,np.clip,x[mask]andx[mask] = v,np.nonzero,np.cumsumonint64,x.astype(np.float32)fromuint8,np.sumonuint8,np.count_nonzero,np.histogram,np.bincountandnp.isin.install(inexact=True)addsnp.cumsumonfloat32andfloat64, which are within a declared tolerance of NumPy rather than bit-identical. - From Python, at a million elements:
x[mask]onfloat32is 31.0x faster,x[mask] = 0.020.6x,np.sumonuint815.6x,np.cumsumonint6413.7x,np.histogram9.41x andnp.argmax8.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, andprint(hotkernels.report())names it on its first line. (#28)