Skip to content

Sweep reduction shapes for one real and one complex element type - #810

Merged
maleadt merged 1 commit into
mainfrom
tb/reduction-test-shapes
Oct 8, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/reduction-test-shapes

Conversation

@maleadt

@maleadt maleadt commented Oct 8, 2026

Copy link
Copy Markdown
Member

The reduction testsets reduce every element type in every shape with every operator. Each new combination compiles its own kernels and host code, and that compilation is most of these testsets' time on back-ends where it's slow: Metal's and pocl's CI currently exceed their timeout, mostly because of a regression fixed in JuliaGPU/AcceleratedKernels.jl#153, but even with that fixed these testsets remain among the slowest.

The shapes select code paths independently of the element type (a whole-array reduction, one along some dimensions keeping others, one without reduced dimensions, an empty one), so this runs the full shape lists for Float32 and ComplexF32 only. The other element types are reduced in a whole-array, a dims and an empty shape, still with every operator, so per-type arithmetic keeps its coverage. The large mapreducedim!_large cases, which reach the vectorized by-block path, are unchanged.

On Metal (M1, Julia 1.12, with AcceleratedKernels.jl#153), wall time in seconds:

testset before after
reductions/mapreducedim! 130 100
reductions/mapreduce 93 51
reductions/sum prod 82 46
reductions/minimum maximum extrema 67 36

The reduction testsets reduce every element type in every shape, with
every operator. Each new combination of element type, operator and
shape compiles its own kernel and host code, which dominates the time
of these testsets on back-ends where compilation is slow. The shapes
choose code paths independently of the element type, so run the full
list of shapes for Float32 and ComplexF32 only, and a whole-array, a
dims and an empty reduction for the other element types, still with
every operator.

On Metal (with AcceleratedKernels#153), the mapreducedim!, mapreduce,
sum prod and minimum maximum extrema testsets take 233 s instead of
372 s.
@maleadt

maleadt commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

A bit ad hoc, I think @kshyatt is working on a larger redesign, but let's do the quick fix for now.

@maleadt
maleadt merged commit 6ef94ae into main Oct 8, 2026
17 of 18 checks passed
@maleadt
maleadt deleted the tb/reduction-test-shapes branch October 8, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant