From 4d1a34eee87b18f8532dea3d8ba47daeb6d70587 Mon Sep 17 00:00:00 2001 From: Hiroshi Shinaoka Date: Sat, 31 Oct 2026 09:08:04 +0900 Subject: [PATCH] rules: prohibit handwritten contraction loops with explicit exceptions --- rules/rust/performance.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rules/rust/performance.md b/rules/rust/performance.md index b78ddc9..742094b 100644 --- a/rules/rust/performance.md +++ b/rules/rust/performance.md @@ -62,6 +62,15 @@ - No hidden row-major compatibility shims or silent row-major round-trips. - Use the owning backend/linalg abstraction for GEMM, einsum, decompositions, and solves. Do not reimplement kernels in downstream layers. + +Contractions, GEMM, decompositions and solves must use the owning abstraction +(`einsum_tensors`, `tcontract`, `tlinalg`, or the backend provider); never replace +them with a repository-local inner scalar-accumulate loop. Handwritten kernels +bypass the tuned path, threading/SIMD policy and the abstractions' numeric +contract. If a loop genuinely cannot be expressed through the abstraction, put +`// contraction-kernel-ok: ` immediately above that loop and explain the +exception in the PR description. + - When integrating faer, BLAS, LAPACK, or CUDA libraries, keep packing and ABI copies at explicit boundaries and reuse scratch where possible. - A work copy's leading dimension must not be a multiple of 1 KiB. A column