hotkernels

Chapter 8 of 1317 min read

Results, and what they do not say

Every number, where it came from, and the cases where the result is narrower than the headline.

This chapter has two halves. The first is every number the project has, with where it came from. The second is the list of ways those numbers are narrower than they look. A speedup table without the second half is an advertisement.

What a user gets: timings from Python

These are the figures that matter to someone running NumPy code: one Python statement, timed from call to result, on plain NumPy and again after hotkernels.install(). They include everything: NumPy’s call path, the hook, the checks, any buffer the binding allocates.

Recorded timings of Python statements at three sizes, on plain NumPy and with hotkernels installed. Switch to "Calls left to NumPy" to see what a hook costs a call it does not serve. Read from the recorded result in the repository when this site was built.
Statement Elements 16 elements 1,048,576 elements
np.argmax(x) float32 15.3x 8.90x
x.argmax() float32 3.94x 8.88x
np.clip(x, -0.5, 0.5) float32 10.4x 7.98x
np.clip(x, -0.5, 0.5) float64 8.79x 3.18x
x[mask], half selected float32 2.28x 30.0x
x[mask], half selected float64 2.32x 15.8x
x[mask] = 0.0, half selected float64 5.76x 20.3x
np.nonzero(mask), few selected bool 1.24x 13.5x
np.nonzero(m), rows of 22, few True bool 1.36x 27.1x
np.cumsum(x) int64 1.89x 12.3x
x.astype(np.float32) uint8 1.71x 5.02x
np.sum(x) uint8 32.5x 14.9x
np.count_nonzero(x) float64 3.47x 3.56x
np.histogram(x, 50, (-3.0, 3.0)) float64 6.88x 9.35x
np.bincount(x) uint8 2.18x 6.74x
np.isin(x, eight_values) int64 63.4x 18.1x
np.searchsorted(a, v) float64 1.49x 8.14x
np.searchsorted(a, v, side='right') float64 1.41x 8.79x
np.digitize(x, bins), 1,000 bin edges float64 1.12x 26.9x
np.interp(x, xp, fp) float64 4.61x 22.8x
np.cumsum(mask), half True bool 2.73x 17.5x
np.maximum.accumulate(x) int64 2.39x 14.2x
np.fmax.accumulate(x) float64 2.38x 12.9x
np.fmax.reduceat(x, starts), runs of 16, 5% NaN float64 2.77x 3.06x
m.any(axis=1), rows of 22 bool 4.78x 24.1x
np.bincount(x), codes 0 to 63 int16 3.85x 9.39x
np.bincount(x), codes 0 to 63 int64 2.29x 4.23x
np.where(c, a, b), half true float64 3.89x 1.54x

The search and np.interp rows are timed with as many needles as elements, and np.digitize with 1,000 bin edges. The run started at a load average of 1.1, on a machine that also runs other work.

Read the two columns as two different stories. At a million elements the number is the kernel. At 16 elements it is mostly NumPy’s own call path being skipped: np.sum on 16 bytes is 33x faster because a 1.2 µs wrapper was replaced by a 37 ns call, not because of how the bytes are added, and np.clip is 11x faster because the kernel is called before NumPy’s wrapper and ufunc machinery run.

A whole program. examples/workload.py in the repository is an ordinary NumPy script, written with no knowledge of hotkernels: it cleans a signal, summarises an 8-bit image and looks up some ids, using eleven of these operations on two million elements. It runs in 45 ms on plain NumPy and 8.4 ms with the one line added, and every result is identical bit for bit.

Whole programs. The repository’s README times nineteen programs on an Apple M1 Pro and an Apple M4 Max, some written in the repository and the others libraries called as a user calls them or published benchmarks, on plain NumPy and with install(): they gain from 1.00x to 6.00x, by how much of their time is in calls a kernel takes. Where the rest of their time goes, program by program, is in docs/applications-findings.md and docs/applications-second-findings.md. With the lazy layer’s fusion on top, in the prototype, twenty-six programs at their large size on the M1 Pro run 0.98x to 5.14x of plain NumPy fused with install() in effect, where install() alone gives 0.97x to 5.28x: fusion’s own gain is on expressions on large arrays, the cavity flow 2.80x where install() alone gives 1.00x. Every program, both ways and on both architectures, is in what fusion gained.

The cost of being there. A call that reaches a hook and is not served costs 0.3 to 1.5 ns more than on plain NumPy: x[3] takes 66.7 ns on plain NumPy and 66.6 ns with hotkernels. Hooks that read keyword arguments cost a little more, and on calls that cost more: np.clip(x, -0.5, None), which no kernel serves, goes from 1.02 µs to 1.04 µs.

What the kernels do: timings as native functions

These are the judge’s figures: each kernel called from C, against the naive C reference compiled with clang -O3, and against the NumPy statement called from Python. “All sizes” is the geometric mean over eleven sizes from 16 to 16,777,216 elements with its 95% interval; the four columns after it are single sizes. A row whose input is marked † is the mean of ten runs, and its brackets hold the lowest and highest of the ten instead.

Kernel Input vs naive C, all sizes at 16 at 4,096 at 1M at 16M vs NumPy at 1M
argmax_f32 random 23.4x [23.39 – 23.41] 6.05x 45.9x 26.6x 18.7x 8.82x
argmin_f32 random 23.4x [23.39 – 23.41] 6.04x 45.8x 26.7x 18.8x 8.86x
argmax_f64 random 12.5x [12.53 – 12.54] 4.11x 22.9x 12.7x 9.37x 6.86x
argmin_f64 random 12.6x [12.60 – 12.65] 4.11x 22.7x 13.2x 9.38x 7.10x
compress_f32 half selected 2.76x [2.73 – 2.76] 1.97x 3.54x 2.70x 2.62x 41.7x
compress_f32 few selected 5.14x [5.13 – 5.14] 1.97x 7.61x 5.70x 3.70x 17.3x
compress_f32 all 3.77x [3.74 – 3.77]
compress_f64 half selected 1.85x [1.85 – 1.86] 1.69x 2.61x 1.67x 1.47x 22.5x
compress_f64 few selected 4.15x [4.14 – 4.15] 1.69x 7.63x 4.10x 2.06x 11.0x
compress_f64 all 2.77x [2.77 – 2.78]
nonzero_bool half selected 2.68x [2.68 – 2.68] 2.20x 2.98x 2.47x 2.49x 5.15x
nonzero_bool few selected 6.89x [6.89 – 6.90] 2.20x 8.09x 8.08x 7.60x 19.2x
nonzero_bool all 4.30x [4.30 – 4.30]
maskfill_f64 half selected 7.19x [7.04 – 7.26] 2.88x 3.54x 19.0x 18.7x 21.4x
maskfill_f64 few selected 2.87x [2.87 – 2.88] 1.60x 2.75x 4.64x 3.14x 7.48x
maskfill_f64 all 4.54x [4.50 – 4.57]
isin_i64 mostly misses 4.54x [4.53 – 4.54] 2.12x 5.64x 5.34x 4.39x 75.6x
isin_i64 wide values 0.98x [0.98 – 0.98] 0.87x 1.00x 1.00x n.s. 1.00x n.s. 1.83x
isin_i64 all 2.11x [2.11 – 2.11]
searchsorted_f64 1,000 needles † 9.08x [8.98 – 9.14] 5.42x 9.47x 8.83x 15.5x 6.40x
interp_f64 1,000 queries † 5.00x [4.93 – 5.03] 1.80x 4.87x 6.40x 10.2x 16.8x
histogram_f64 random 3.48x [3.47 – 3.49] 2.27x 3.82x 3.59x 3.57x 9.70x
bincount_u8 random 1.24x [1.24 – 1.25] 1.07x 1.29x 1.31x 1.30x 6.74x
cumsum_i64 random 1.90x [1.89 – 1.93] 1.36x 2.43x 1.95x 1.69x 12.5x
cumsum_f64 random 4.46x [4.43 – 4.47] 1.74x 5.76x 5.48x 4.78x 20.1x
cumsum_f32 random 6.10x [6.02 – 6.11] 1.74x 7.76x 7.83x 7.22x 29.0x
sum_u8 random 5.85x [5.84 – 5.85] 3.33x 8.87x 5.07x 4.40x 15.7x
count_nonzero_i64 random 1.28x [1.28 – 1.28] 1.73x 1.50x 1.03x 1.07x 3.25x
count_nonzero_f64 random 1.41x [1.41 – 1.41] 1.39x 1.71x 1.28x 1.08x 3.79x
clip_f32 bounds (-0.5, 0.5), random † 1.38x [1.33 – 1.41] 1.17x 1.55x 1.44x 1.10x 11.0x
clip_f32 bounds (0, 1), random † 1.23x [1.21 – 1.24] 1.17x 1.32x 1.31x 1.08x 10.0x
clip_f32 bounds (0, 1), sparse -0.0 † 1.01x [1.00 – 1.02] 1.17x 0.99x 1.00x 1.00x 7.62x
clip_f32 bounds (0, 1), rounded † 1.01x [1.01 – 1.01] 1.17x 0.99x 1.00x 1.00x 7.67x
clip_f32 all six tables † 1.22x [1.21 – 1.23]
clip_f64 bounds (-0.5, 0.5), random † 1.36x [1.31 – 1.38] 1.09x 1.60x 1.35x 1.08x 5.06x
clip_f64 bounds (0, 1), random † 1.22x [1.20 – 1.23] 1.09x 1.34x 1.30x 1.07x 4.88x
clip_f64 bounds (0, 1), sparse -0.0 † 1.02x [1.02 – 1.02] 1.10x 1.01x 1.01x 1.00x 3.78x
clip_f64 bounds (0, 1), rounded † 1.00x [0.99 – 1.00] 1.10x 1.01x 1.01x 1.00x 3.77x
clip_f64 all six tables † 1.20x [1.19 – 1.21]
nanmin_cols_f64 37 columns, C order ¶ 4.29x [4.28 – 4.30] 1.59x 4.98x 3.15x 6.48x 3.86x
nanmin_cols_f64 64 columns, C order ¶ 3.11x [3.10 – 3.11] 1.59x 4.52x 2.45x 2.59x 3.04x
nanmin_cols_f64 rolling windows of 64 ¶ 4.16x [4.15 – 4.17] 1.59x 4.57x 4.48x 4.54x 5.24x
nanmin_cols_f64 all three tables ¶ 3.81x [3.81 – 3.82]
nanmax_cols_f64 37 columns, C order ¶ 4.27x [4.25 – 4.29] 1.61x 5.01x 3.15x 6.25x 3.73x
nanmax_cols_f64 64 columns, C order ¶ 3.05x [3.04 – 3.07] 1.60x 4.54x 2.19x 2.48x 2.73x
nanmax_cols_f64 rolling windows of 64 ¶ 4.16x [4.15 – 4.17] 1.59x 4.58x 4.53x 4.55x 5.27x
nanmax_cols_f64 all three tables ¶ 3.79x [3.78 – 3.79]
cast_u8_f32 random ships as its C 2.68x
argsort_f64 uniform ‡ ships as its C 17.3x
argsort_f64 classifier scores ‡ ships as its C 17.6x
argsort_f64 normal ‡ ships as its C 13.4x
argsort_i64 the whole range ‡ ships as its C 17.3x
argsort_i64 values below 1,000 ‡ ships as its C 64.9x
argsort_u64 the whole range ‡ ships as its C 14.7x
argsort_u64 values below 1,000 ‡ ships as its C 78.0x
cummax_i64 random 3.17x [3.16 – 3.18] 1.46x 5.77x 2.83x 3.24x 11.1x
cummax_i64 rising 3.37x [3.33 – 3.38] 1.47x 5.30x 2.90x 3.18x 11.3x
cummax_i64 all 3.27x [3.24 – 3.28]
cumsum_bool random 2.90x [2.89 – 2.94] 3.06x 3.96x 2.06x 2.06x 12.9x
any_rows_bool sparse, rows of 22 7.62x [7.61 – 7.62] 1.00x n.s. 12.9x 8.68x 8.03x 38.7x
any_rows_bool sparse, rows of 4 35.5x [35.50 – 35.55] 4.67x 68.2x 36.6x 31.4x 141x
any_rows_bool sparse, rows of 64 1.70x [1.70 – 1.70] 1.00x n.s. 2.52x 1.48x 1.31x 22.0x
any_rows_bool all six tables 7.71x [7.71 – 7.71]
bincount_i16 uniform, 64 counters 2.07x [2.07 – 2.07] 1.03x 1.78x 2.94x 2.94x 11.0x
bincount_i16 uniform, 1,000 counters 1.47x [1.47 – 1.47] 1.08x 1.49x 1.71x 1.70x 6.39x
bincount_i16 four values, 64 counters 4.21x [4.21 – 4.21] 1.28x 4.24x 7.13x 7.05x 13.2x
bincount_i16 four values, 1,000 counters 2.82x [2.82 – 2.82] 1.10x 3.14x 4.84x 4.82x 8.94x
bincount_i16 all four tables 2.45x [2.45 – 2.45]
bincount_i64 uniform, 64 counters 1.27x [1.27 – 1.27] 0.88x 1.19x 1.56x 1.49x 6.19x
bincount_i64 uniform, 1,000 counters 1.13x [1.13 – 1.13] 1.03x 1.08x 1.25x 1.25x 4.97x
bincount_i64 four values, 64 counters 2.38x [2.38 – 2.38] 1.05x 2.23x 3.52x 3.53x 8.96x
bincount_i64 four values, 1,000 counters 1.92x [1.92 – 1.93] 1.01x 2.04x 3.05x 3.07x 7.77x
bincount_i64 all four tables 1.60x [1.60 – 1.60]
where_f64 half true 1.81x [1.81 – 1.82] 1.92x 2.61x 1.34x 1.14x 1.56x
where_f64 95% true 1.83x [1.83 – 1.83] 1.92x 2.60x 1.32x 1.18x 1.56x
where_f64 both tables 1.82x [1.82 – 1.82]
fmax_reduce_f64 random 8.23x [8.23 – 8.24] 9.64x 11.9x 6.56x 4.72x 1.02x
fmax_reduce_f64 5% NaN 8.25x [8.24 – 8.25] 9.64x 11.7x 6.55x 4.71x 1.02x
fmax_reduce_f64 both tables 8.24x [8.24 – 8.24]
cumfmax_f64 random 13.6x [13.25 – 13.63] 5.28x 26.2x 11.2x 12.9x 15.4x
cumfmax_f64 rising 13.9x [13.27 – 13.92] 5.28x 21.4x 12.9x 12.7x 17.8x
cumfmax_f64 5% NaN 13.9x [13.53 – 14.12] 5.28x 24.9x 13.1x 12.9x 18.2x
cumfmax_f64 all three tables 13.8x [13.49 – 13.83]
nonzero_2d_bool 5% true, rows of 22 § 10.9x [10.85 – 10.87] 2.29x 13.9x 14.0x 13.5x 35.7x
nonzero_2d_bool 5% true, rows of 3 § 10.5x [10.45 – 10.46] 1.68x 13.8x 14.0x 13.5x 46.8x
nonzero_2d_bool 5% true, rows of 32 § 10.9x [10.88 – 10.89] 2.29x 13.9x 14.0x 13.6x 34.8x
nonzero_2d_bool 5% true, rows of 1,000 § 14.0x [14.01 – 14.03] 2.29x 19.2x 20.5x 18.1x 47.4x
nonzero_2d_bool half true, rows of 22 § 3.49x [3.47 – 3.55] 2.29x 4.39x 3.67x 3.19x 22.5x
nonzero_2d_bool half true, rows of 3 § 3.41x [3.39 – 3.46] 1.68x 4.27x 3.81x 3.32x 24.8x
nonzero_2d_bool half true, rows of 32 § 3.91x [3.89 – 3.98] 2.29x 5.05x 4.22x 3.41x 25.5x
nonzero_2d_bool half true, rows of 1,000 § 3.96x [3.93 – 4.01] 2.29x 5.13x 4.27x 3.71x 25.0x
nonzero_2d_bool all eight tables § 6.50x [6.49 – 6.53]
searchsorted_i64 64 needles 4.36x [4.36 – 4.36] 3.21x 3.93x 5.46x 8.32x 2.44x
searchsorted_i64 1,000 needles 4.55x [4.55 – 4.55] 3.50x 3.97x 4.59x 9.50x 1.72x
searchsorted_i64 both tables 4.45x [4.45 – 4.45]
searchsorted_right_i64 64 needles 4.27x [4.26 – 4.27] 3.13x 3.93x 4.96x 6.69x 2.44x
searchsorted_right_i64 1,000 needles 4.57x [4.57 – 4.58] 3.51x 3.96x 5.06x 9.42x 1.76x
searchsorted_right_i64 both tables 4.42x [4.42 – 4.42]
any_cols_bool sparse, rows of 31 16.9x [16.88 – 16.90] 7.80x 27.6x 18.0x 13.5x 40.5x
any_cols_bool dense, rows of 31 16.8x [16.79 – 16.85] 7.80x 27.7x 18.0x 12.9x 40.5x
any_cols_bool sparse, rows of 8 26.8x [26.82 – 26.85] 2.32x 62.6x 37.3x 29.5x 99.3x
any_cols_bool dense, rows of 8 26.8x [26.79 – 26.87] 2.32x 62.6x 37.3x 29.4x 99.6x
any_cols_bool sparse, rows of 64 4.81x [4.81 – 4.81] 2.17x 7.93x 4.66x 3.92x 19.1x
any_cols_bool dense, rows of 64 4.81x [4.81 – 4.82] 2.17x 7.93x 4.66x 3.87x 19.1x
any_cols_bool sparse, rows of 256 2.71x [2.71 – 2.72] 2.36x 3.91x 2.19x 1.77x 5.13x
any_cols_bool dense, rows of 256 2.72x [2.71 – 2.72] 2.35x 3.91x 2.16x 1.84x 5.13x
any_cols_bool all eight tables 8.77x [8.76 – 8.77]

“n.s.” marks a difference the judge did not find statistically significant. Kernels timed on two kinds of input have a row for each and one for both together.

Three patterns are worth reading out of that table:

  • Speedups over the compiler peak in the middle. At 16 elements fixed work dominates; at 16 million, memory does. The largest ratios are at 4,096 elements, where the data fits the first-level cache and the loop is all that is being measured.
  • The NumPy column and the C column measure different things. argmax_f32 is 26.6x over naive C and 8.82x over NumPy: NumPy’s argmax was already better than naive C. isin_i64 on wide values ties the C and is still 1.83x over NumPy. clip gains little over the compiler and a lot over NumPy. The C column is what assembly added. The NumPy column is what the user gains.
  • The two search kernels gain at the largest sizes, where everything else fades, because overlapping cache misses is what they do.

How these were measured

  • Machine. Apple M1 Pro, macOS, NumPy 2.5.5, Apple clang 21. Native, one core.
  • Method. 30 interleaved samples per contender per size; ratio of medians; paired bootstrap interval, as in chapter 3.
  • Passes. Most rows come from one pass on an idle machine. The rows of the eight second-shortlist kernels, the last in the table, are one recorded run each, taken on a quiet machine at a load average of 1.4 to 2.9: locked for six, and --unlocked for fmax_reduce_f64 and cumfmax_f64, whose narrowed specs were not yet on the main branch when they were taken. The clip and search rows, marked †, were taken later on a machine that could not be made quiet (load average about 3 for most runs), so each is the mean of ten locked runs. Up to about 65,536 elements those runs agree within 1%; from a million elements up single runs differ by 10 to 15%.
  • Unlocked. The judge normally refuses to time a kernel whose spec differs from the main branch. The single-pass runs were made in the same change that introduced the specs, with that refusal overridden, and the judge marks such results as untrusted. Nothing was recorded as an official result from those runs for that reason.

Where a result is narrower than its number

np.isin: it depends on the test values, and on their order

The 75.6x over NumPy applies when all eight test values lie between 0 and 65,534, or within 32,767 of the first one. For arbitrary 64-bit values the kernel is the compiled C: 1.83x over NumPy. Because the second window is centred on the first test value, the same set of values can be fast in one order and slow in another. At 16 elements the kernel is slower than naive C on wide values (0.87x), because it has tried and rejected the fast set-ups first.

np.clip: it depends on the bounds, and with a zero bound on the data

  • With neither lo = +0.0 nor hi = -0.0, the two-operation path runs: about 1.6x over the compiled C in cache.
  • With lo = +0.0, as in np.clip(x, 0, 1), a three-operation path runs: about 1.3x in cache, if the data holds no negative zeros. One negative zero among the first 7,264 float32 elements (3,632 for float64) sends the rest of the array to the compare-and-select loop, however long the array is. Rounded data is such data.
  • With hi = -0.0 the kernel is the compare-and-select loop: the speed of the C.
  • For reversed or NaN bounds the kernel is not used at all.

Against NumPy it is 3.5x to 11x faster in all of the cases it handles. The conditions affect how much of that is owed to assembly.

Float np.cumsum: faster because it is a different sum

Not bit-identical, by necessity (chapter 6), and not monotonic on non-negative input. Installed only with install(inexact=True). Running sums above about 10^{153} in float64 take the slow path. Arrays shorter than 32 float64 or 20 float32 elements are summed in NumPy’s order and are exact.

The mask kernels: weakest between the densities that are timed

Timed at 5% and 50% selected. Near 10% the switch between the sparse and dense plans mispredicts, and nonzero_bool measured about 2.8 times its 5% cost per element there. From Python, x[mask] and np.nonzero keep roughly two thirds of the kernel’s speed, because of the buffer, the copy and the mask scan.

x[mask] = v: writes elements it does not change

Identical results, but unselected elements in dense regions are stored back with their own bits. The array must be writable throughout. The binding holds the interpreter lock during the kernel so that no other Python thread can write in between.

Scalar arguments: verified for the values listed, and no others

clip is checked with twelve pairs of bounds; histogram with sixteen bin counts and ranges; masked assignment with six values. The judge has value classes for arrays and none for scalars. A combination nobody listed is untested.

What the judge does not see

The judge is the reason any of this can be trusted, so its blind spots are the most important caveats in the report. Each of these was found the hard way.

Blind spot What it hid, or could hide
Scalar combinations nobody listed The clip reference disagreeing with NumPy for reversed bounds; clip’s dependence on its bounds; the histogram overflow bug at the top of the float64 range, which no listed range was near
Data that follows the scalars Nothing places elements on a histogram’s bin edges, the only place a histogram goes wrong. That evidence comes from separate differential tests
One input per size from 4,096 elements up A branch predictor memorises a repeated input, so branchy code looks faster than it is up to about 16,384 elements. This understates the masked-assignment kernel at those sizes, and hides the mask kernels’ own mispredictions
Densities and distributions between the ones timed The mask kernels near 10% density; bincount on all-equal bytes, which runs at 2.1 ns per byte below 8,192 elements
Paths behind a size cap interp’s large-array path: NumPy’s interp is too slow to act as an oracle beyond 65,537 elements, so that path was compared with the reference outside the judge, without guard pages
A tolerance that widens with size For float32 cumsum beyond some tens of thousands of elements, the bound is wide enough that a single skipped element would pass
Inputs outside what a spec can express Mask bytes other than 0 or 1; an output that is the input; a concurrent writer. All found when the kernels met real calls, and all screened by the binding
Prefetch addresses Two kernels issue prefetch hints up to 256 KB past the end of very large arrays. A prefetch never faults and reads nothing, so this is safe, and invisible

The pattern is consistent: the judge verifies what its generated inputs exercise. Every defect that got past it was in a region the generator did not reach, and each one that was found led to a new value class, a new scalar set or a new check in the binding.

What is not delivered

  • np.digitize with decreasing bins. It searches the bins reversed, as a view no kernel takes.
  • np.interp with left, right or period, and with more than 64 sample points per query, where reading the sample points for NaN would cost more than the kernel saves.
  • One or two element types per operation. np.argmax on int32, x[mask] on float16, np.sum on int64: all go to NumPy. (NumPy is already fast on several of those.)
  • One call at a time. Every kernel the package installs serves one NumPy call, so a * b + c is still two passes over memory. Kernels that compute a whole expression in one pass exist only in a prototype outside the package, on a lazy layer that writes the program down as a graph first; fusion describes them and its results what they gained on twenty-six programs and ten from other codebases, on both architectures.
  • Plain arrays only. Subclasses reaching the function, method and indexing hooks go to NumPy.
  • np.compress with axis or out. The compress kernels write past the elements they keep, so they never run on a buffer the caller owns.
  • Wheels for CPython 3.11 to 3.14. With another Python, installing compiles the package.
  • Two platforms. macOS on Apple Silicon, and Linux on x86-64 processors of the x86-64-v3 level. Anywhere else install() does nothing.
  • Free-threaded Python is not supported.
  • NumPy before 2.3 is not supported. Earlier NumPy 2 releases answer np.clip and np.count_nonzero slightly differently, and the kernels give the later answer.

Decisions that are still open

Three choices were made provisionally, each with a recommendation the implementation follows:

Question Why it is a question Current answer
May masked assignment rewrite unselected elements? It is the whole of the gain on dense masks, and it is observable by a concurrent writer Yes, with the interpreter lock held
May clip read and write the floating-point status register? Without it the kernel is the compare-and-select loop, which ties the compiler in cache. It is more than “a pure function over its buffers” suggests Yes, as a stated exception; flags are only ever added
Should float cumsum test for overflow once per block instead of four times? About 12% faster from 256 to 16,384 elements. The proof that infinities land where NumPy has them would no longer hold near the largest finite value No

Three machines

The ARM64 figures in this report are from an Apple M1 Pro, the x86-64 figures of chapter 9 and of fusion on x86-64 from an Intel Core i5-14600KF, and the workloads over time from an Apple M4 Max. The techniques are general: they rest on latency, ports, prediction and caches, which every modern processor has. The constants are not. The number of accumulators, the block sizes, the thresholds between paths were all tuned to one core of each architecture by measurement, and another core would want them measured again. The repository contains everything needed to do that: the judge, the specs and the logs. On an Apple Silicon Mac, uv run judge run <kernel> reproduces any row of the table above in about half a minute, and on Linux x86-64 any row of chapter 9’s.