A naive nested loop for matrix multiplication can run at only 1.1% of the speed of a professional library like OpenBLAS because it fails to account for how a CPU fetches data into its cache. To bridge the gap between high-level code and high-performance kernels, Csongor Kiss is building Cachet, a language where hardware assumptions—such as which memory levels a buffer occupies—are explicit parts of the source code.
The Problem of Hidden Optimizations
Optimizing a program typically involves either hoping a compiler is smart enough to handle the data flow or rewriting the code by hand to match the hardware. In the latter case, abstractions break down, and developers must manage complex details like cache residency and vectorization manually.
In both scenarios, the critical decisions are often hidden. A compiler makes them based on an internal hardware model, while a human developer keeps them in their head or in comments. Cachet aims to move these decisions into the language itself, allowing the compiler to check that the programmer's assumptions about the hardware still hold as the code evolves.
“In Cachet, which cache a buffer stays in, how much data moves between memory levels, and which instructions the hardware provides are part of the language.”
— Write your own kernel optimiser | Csongor Kiss
Contractions and Schedules
Cachet uses a 'contraction' model to define computations. Instead of writing loops, a developer writes a mathematical equation for each output element. For example, a matrix multiplication is defined by a formula where the free indices determine the outputs and the summed indices determine the operations.

This image illustrates the manual computation process that Cachet aims to abstract into mathematical contractions.
Chart drawn by HN Digest from figures reported by blog.csongor.co.uk; values are shown as written in the source.
To turn this definition into a fast program, Cachet uses a 'schedule'—a sequence of transformations that rewrites the contraction into an optimized loop nest. The compiler checks each step of the schedule to ensure that the transformation preserves the original meaning of the computation, such as ensuring that different outputs do not overlap in a way that breaks the math.
Verifiable Rewrites and Hardware Mapping
The system uses a 'steps' library where each rewrite comes with a 'proof recipe.' This allows the compiler to verify that a transformation, like swapping loops to improve cache hits, is mathematically valid for the specific program being compiled.
This approach allows for complex optimizations like 'blocking,' which keeps a chunk of data in the cache while the processor performs multiple operations on it. By making these steps explicit, the developer can reason about the data movement between memory levels while the compiler ensures the logic remains sound.

This figure explains the concept of input reuse, which is a key component of the 'blocking' optimization mentioned in the text.

This image supports the discussion on tuning kernels and hardware mapping for maximum performance.
Trade-offs and Current Limits
The primary trade-off of Cachet is that it requires the programmer to have a deeper understanding of the underlying hardware architecture. While this provides safety by catching performance regressions at compile time, it demands more upfront architectural knowledge than a standard high-level library.
Currently, the tool can verify programs for NVIDIA H100 hardware, but it does not yet have the capability to build for that specific platform. The goal remains to provide a framework where performance is a deliberate, verifiable choice rather than a side effect of a 'clever' compiler.