Faster fallback matrix multiplication - #590
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
3892d1b to
1499c12
Compare
416b28f to
5d9ab82
Compare
26ea632 to
33e8809
Compare
|
OpenCL POCL before and after:
OpenCL RUSTICL before and after:
|
|
I updated this to include the overflow and other various improvements recently applied to the fallback matmul, and reimplemented on top of KernelAbstractions instead of KernelInterface so we can merge sooner rather than later. |
I had Claude look into the Without Confirmed on Metal with TILE=2, 3×3: masked kernel + So for a cooperative tiled kernel that does its own bounds checks, Note that KA's |
The early return zeroed C whenever A or B was empty, but for K == 0 the result is β*C. The tiled kernel already handles that (no tiles to process), so only skip the launch when C itself is empty. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The 0.9 example hasn't been fixed, but the 0.10 example got fixed (and then I switched it over to KernelInterface so it was no longer an issue) I've updated the PR description to reflect the current state |
Both computed the same thing, element [i, j] of op(X); only the call sites differ in which index is the contraction one. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A fallback kernel does not need a tunable here; hardcode the one-row padding that avoids shared-memory bank conflicts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
It is the tile dimension, not an upper bound. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
It already unwraps the operands via wrapper_char/_unwrap, instead of indexing through the wrapper with 'N' flags. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The gemm tests only used 4×4 inputs, which never exercise partial tiles or an inner dimension spanning several tiles, i.e. exactly the failure mode of a tiled kernel. Use 33×17×5 (and n=33 for Symmetric/Hermitian, which was a tile-aligned 128) so every dimension has a partial tile; the test load does not increase. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Pushed a handful of clean-ups/minimizations by Fable. |
|
Julia 1.11 Metal failure seems unrelated? |
|
This PR on from my fork lets just wait for #772 to be merged and rebase. |
|
CI failure is JuliaGPU/Metal.jl#937 |
OK, I'll let you apply the stack if you don't mind. |
|
Adapted from the Metal scalar gemm kernel and modified for the macro-based KernelAbstractions interface based on the KA "performant_matmul.jl" example but with some fixes.