Rework the einsum f32 JIT with static backend dispatch per spec pattern - #115
Open
MesTTo wants to merge 3 commits into
Open
Rework the einsum f32 JIT with static backend dispatch per spec pattern#115MesTTo wants to merge 3 commits into
MesTTo wants to merge 3 commits into
Conversation
This was referenced Jun 24, 2026
The owned Dense|Csr enum had no consumers (the benches use any::Tensor, which already covers these variants plus DenseMut) and it shadowed that name. The benches/graph.rs hunk was pure reformatting of code this branch does not otherwise touch; restore main's formatting so the diff is only the plan layer.
Collaborator
|
Awesome! We'll want to stabilize and generalize the JIT before integrating this change (see #132 ) |
Contributor
Author
|
that makes sense to me, and i am in no rush on this one. i think it sits behind #132 either way, the VM monomorphization i measured on #132 (-6.84% instructions, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a plan layer over the existing Cranelift einsum JIT:
EinsumF32Plan/einsum_auto, typed fallible execution (try_run,JitRunError) replacing panic-onlyrun, a native sparse-dense matmul routine, and recognizers that route GEMM-shaped and attention-shaped specs to the BLAS kernels when theblasfeature is on.The dispatch is static and structural, decided once at plan-compile time — a fixed precedence (sparse-dense matmul pattern, then BLAS-recognized dense patterns under
#[cfg(feature = "blas")], else the general JIT loop nest), keyed purely on the spec's subscript structure and input kinds. There is no cost model, no runtime data, no thresholds — the same shape-recognition dispatch numpy/torch do for GEMM-shaped einsums.Depends on #111 (the OpenBLAS backend module): building
--features jit,blaswithout it fails to resolvecrate::blas_backend, so #111 should merge first. Validation:--features jit69/0 green standalone; with #111,--features jit,blas63/0 green including the fourplan_selects_*dispatch tests. #121's graph_tensor consumeseinsum_autofor its GCN SpMM.