Manuscript Offprint
arXiv:2610.13679A Simplified Layout Algebra for GPU Kernels
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
The layout algebra behind NVIDIA’s CuTe library describes how tensor tiles map onto threads and memory. A layout is a shape with a stride for each entry, so a coordinate’s address is the sum of its indices times their strides. As formalized by Shah and by Cecka, its central operations (e.g., composition, complement, division, product) are guarded by at least six interacting admissibility conditions. We show that this complexity is an artifact of a representational choice, not of the domain.
We present a layout algebra in which every layout names the space its inputs and outputs live in: logical, physical, or thread-value indices. A layout into logical or thread-value space must be a bijection from its N coordinates onto . A layout into physical space must be alias-free: distinct coordinates land on distinct addresses, except under broadcast, where many threads read one value on purpose and the layout must mark where. Nothing maps out of a physical index.
Composing with requires only that 's range be exactly 's flattened coordinate set. The index arithmetic can always be emitted naively: compute , split the result by division and remainder into 's coordinates, and apply . Often the composite simplifies to a layout; we show that when it does, there is a coarsest such form, whose digits every other one refines, and we emit that.
A warp’s or thread’s slice is a restriction. A restricted layout is no longer composable, which forces the user to settle the whole view of a tile before taking slices.
We validate the algebra by reproducing within it CuTe's operations, such as composition, complement, and division. We implement it in OCaml and use the implementation to rederive CuTe's atoms and usage patterns. The decision procedure is proved correct in Rocq.
1 Introduction
For GPU kernels, it is important to have a scheme for describing how to move tiles of tensors between global memory, shared memory and registers. The de facto vocabulary for such schemes is the CuTe layout algebra underlying NVIDIA’s CUTLASS library [1, 2]. The most fundamental concept is the layout, which we shall reuse heavily.
Definition 1 (Layout). A shape is a positive integer , or a tuple of shapes; its size is and size . A coordinate of is an integer , respectively a tuple of coordinates of the ; write for the set of them. A layout is a shape together with a stride of the same structure: an integer where is a positive integer, and a tuple where is . Its index function
Coord(S) → Z is defined by recursion on the shape,
Flattening is a bijection , taken row-major, so that the last component varies fastest, with inverse unflatten_S. For an integer shape both are the identity, and for , writing ,
A coordinate may therefore be given as a single integer, and we say that integer is the coordinate. The cosize of the layout is the least with its image inside , which is one plus the largest value it takes. The layout is dense when its image is an initial segment of the integers, and a dense bijection when it is moreover injective, in which case and every value below is taken exactly once. A mode is one entry of the shape together with the matching entry of the stride. Two layouts concatenate: for and the layout is , and it sends to .
Layouts are fundamentally the correct concept here, because physical memory is linearly addressed while the logical space is multidimensional and dense as we imagine it. They are a natural way to abstract and describe those mappings.
The algebra has four operations. Three of them, composition, complement and logical division, are formalized by Shah [3]; the fourth, logical product, we take from the CUTLASS implementation. We follow Shah's notation, which lists modes as CuTe does, indexed from 0 with the first varying fastest. Section 6 relates that order to the row-major one of Definition 1. The complement of a layout , sorted by stride, with respect to an integer , is
chosen so that the concatenation has size and its layout function is a bijection of onto itself. Logical division is , which reindexes so that one mode runs inside the tile selects and the other runs across copies of it. Logical product is , where , the smallest for which the composition is defined. Its first mode is one copy of , and its second walks through the addresses does not occupy, so the result is size copies of placed in the pattern names.
These operations are critical for constructing the layouts one usually wants, but they are partial: each is defined only under arithmetic side conditions on its operands. Layouts are in general non-injective and non-surjective onto , and CuTe always wants to write the composite as a layout again. This causes at least six conditions. Two are in the complement, whose shape entries are quotients and so must divide: for every , and . The other four belong to composition. Write the flattened shape of as . It is left divisible by when for some , where is smaller than and divides it, and weakly left divisible when the same holds except that need not divide . For each mode of this is three checks, since the prefix must divide , the leftover must divide , and what remains after must be weakly left divisible by . One more is required across modes, that the intervals on which they act be pairwise disjoint [3].
However, none of these conditions is part of the interface, and CuTe checks few of them: composition's divisibility is checked only at compile time, when both operands are static, and the complement checks only that each of its quotients is at least 1. Where a condition fails, the result can be wrong without a diagnostic. For example, has no complement for : takes the values 0, 1, 3, 4, and no shifted copy of it covers 2 without overlapping . CuTe applies the formula anyway, truncating to 1, and returns a complement that together with covers only 16 of the 24 values; compiled against CUTLASS 4.8, this raises no error. Running the complement on every static rank-2 layout with , and , at , we found 40 such cases: a divisibility condition fails, and CuTe returns a complement that violates the postconditions of its own unit test, without an error.
We try to resolve those complexities by restricting what a layout can be.
Explicit index spaces. The input and the output of a layout each represent one of three things: a logical index into a tile, a thread-value index, or a physical offset in memory. Therefore a layout should declare which of the three its input and its output are, and we allow only the maps worth having between them. Logical and thread-value indices map into one another in either direction. Logical indices map into physical offsets. Nothing maps out of a physical offset. By design, a thread reaches memory by composing its map into logical space with the storage map.
Requirements that follow from the space. We allow those maps and not others because the three spaces do not carry the same obligations. Logical and thread-value indices have to account for their contents losslessly, so a map into either must be a dense bijection. Composition can only happen when one layout's image and the other's domain agree completely, which is natural because a physical offset is forbidden as a domain. A physical offset carries far fewer requirements, since gaps in memory are common and sharing one address between threads, to read the same element, is often what is wanted, so a map into physical need only be alias-free, meaning that distinct coordinates reach distinct addresses except where the layout marks a broadcast.
Composition and simplification. The composite of two layouts is not a layout in general. But we can decide if it can be written as a layout, and when it is a layout we emit one weighted sum of the coordinates. When it is not, we emit the composition literally, at the cost of a longer expression and more work at run time.
Definition 2 (Spaces). Each side of a layout carries a space from {logical, physical, thread-value}, written . A layout may be annotated for , or logical physical, and no other pair is constructible. Composition takes logical and logical to , so thread-value physical exists only as a composite.
Definition 3 (Replication). Extend Definition 1 by allowing the stride against a positive integer n to be the mark in place of an integer, with
A zero stride is rejected rather than read as replication. This is because replication is legal for reads and not for writes, since simultaneous loads of one address are a broadcast while simultaneous stores are a race. It is better not to use 0, so that the two can never be mixed.
Definition 4 (Swizzled layout). A swizzle is a bijection physical → physical of the form
its two fields and disjoint. A layout physical followed by a swizzle is a swizzled layout, again physical.
A swizzle runs from physical to physical, so it can only ever be the last step, and being a bijection it sends distinct addresses to distinct addresses. It therefore leaves the conditions below untouched, and matters only in the arithmetic that is finally emitted.
Definition 5 (Composition). Let logical and let have domain shape . The composite is defined when is a dense bijection onto , and is the map
whose domain shape is that of f.
A chain is therefore one thread-value → logical map, then any number of logical → logical maps, then one logical → physical map.
Definition 6 (Declared replicas). For a layout L with domain shape S, define a relation on Coord(S):
-
if is a layout, when and agree at every mode whose stride is an integer, that is, they differ only at modes with stride ;
-
if with of domain shape , then when unflatten unflatten.
Definition 7 (Validity). Let be a layout with domain shape . Then is valid when
It is write-valid when B = physical and in addition
Only a write-valid layout may be the target of a store.
Validity admits overlap only as the replication of whole modes: two coordinates may share an address only if they differ at modes of stride alone. A map whose images overlap in part, such as the sliding windows of a convolution, where neighbouring windows share some elements and not others, is therefore not valid. Such read-only overlaps are outside the scope of this paper.
When a layout’s output is a logical or thread-value index, being valid means being a dense bijection. This need not be checked by enumerating coordinates: whether a layout is a dense bijection depends only on its sizes and strides.
Lemma 1 (Dense bijections). Let be a flat layout with no stride , its modes carrying sizes and strides with every , and put . Then is a dense bijection onto if and only if, after sorting the modes by stride, and for every : the sorted strides are the running products of the sorted sizes.
The two restrictions cost nothing. A mode of size 1 only ever takes the index 0, so it contributes nothing and is dropped beforehand; a nested layout is read through the flat layout of its leaves.
Proof. ( ) With running-product strides the map is the flattening of Definition 1 for the shape , a bijection onto .
(⇒) No stride is negative: index 1 at a mode of negative stride, and 0 elsewhere, would put a negative value in the image. Sort the modes by stride and write (so ). Claim: for every . Every image value below comes from a coordinate supported on modes , since a nonzero index at any later mode contributes at least and no contribution is negative; those modes produce at most distinct values, so surjectivity onto forces , and as this is . Consequently
the last equality by telescoping. But the left side is the maximum of the image, and surjectivity onto requires the maximum to be exactly . The two sums therefore agree, and since each term on the left is at most the corresponding term on the right, they agree termwise; as this gives for every , which is the running-product condition.
3 Operations
We define the following operations. Each takes a layout L, except canonical, which takes a shape, and where a second argument is needed it is written out; S ranges over shapes and A over layouts.
canonical(S) for a flat shape , the layout
For an entry that is itself a shape, we take the canonical layout of that shape, with every stride multiplied by the product of the sizes to its right.
canonical((3, 4)) = (3, 4): (4, 1)
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | 1 | 2 | 3 | |
| 1 | 4 | 5 | 6 | 7 |
| 2 | 8 | 9 | 10 | 11 |
split(n:d, ) for size , the shape carrying the strides of canonical() each multiplied by , which for a flat is
and for a nested follows its nesting. The argument gives with every stride .
\begin{array}{c@c格格g}{{{6:2}}} \\{{{0}}}&{{{1}}}&{{{2}}}&{{{3}}}&{{{4}}}&{{{5}}} \\{{{0}}}&{{{2}}}&{{{4}}}&{{{6}}}&{{{8}}}&{{{10}}}\end{array} \begin{array}{c@c@c}{{{0}}}&{{{1}}}&{{{2}}} \\{{{0}}}&{{{0}}}&{{{2}}}&{{{4}}} \\{{{1}}}&{{{6}}}&{{{8}}}&{{{10}}} \\\end{array}divide partitions into tiles of shape . Let and let with . Each mode splits as
and collecting the second component of every split into one group and the first into another gives
The first group indexes a mode inside a tile and the second indexes which tile. It is easy to see that precomposing with the flattening that sends each pair back to recovers .
, coloured by tile
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 | |
| 1 | 6 | 7 | 8 | 9 | 10 | 11 |
| 2 | 12 | 13 | 14 | 15 | 16 | 17 |
| 3 | 18 | 19 | 20 | 21 | 22 | 23 |
divide: tile coordinate as row, tile as column
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
repeat copies of arranged in the layout of , which is required to be a valid logical logical layout and so a dense bijection:
where , , and multiplies every stride of by . If is a dense bijection then , and the addresses take every value in exactly once: the result is a dense bijection.
When carries a swizzle , repeat is defined only if is a power of two, , and both fields of lie below bit . Then and every copy is swizzled alike. Otherwise the copy index reaches the bits reads, and the operation rejects.
interleave the same copies interleaved element by element rather than laid out one after another, with again a valid logical logical layout:
The coordinate lands at , so each element of becomes a run of size consecutive addresses holding that element of every copy, where repeat instead gives each copy a run of its own. If is a dense bijection the result is again a dense bijection onto . On a swizzled it has no defined meaning and rejects.
| 0 | 0 | 1 |
|---|---|---|
| 1 | 2 | 3 |
repeat
(3, (2, 2)): (4, (2, 1))
| 0 | 0 | 1 | 0 | 1 |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 |
| 0 | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| 1 | 4 | 5 | 6 | 7 |
| 2 | 8 | 9 | 10 | 11 |
interleave
(3, (2, 2)): (1, (6, 3))
| 0 | 0 | 1 | 0 | 1 |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 |
| 0 | 0 | 3 | 6 | 9 |
|---|---|---|---|---|
| 1 | 1 | 4 | 7 | 10 |
| 2 | 2 | 5 | 8 | 11 |
broadcast size copies of at the same addresses:
writing for the stride with at every entry of . The coordinate lands at whatever is. The second argument is a shape and not a layout because the copies share their addresses and so have no strides to carry. The result is valid when is, and not write-valid once .
broadcast(4:1, (3)) = (3, 4): (⊥, 1): copy as row
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | 0 | 1 | 2 | 3 |
| 1 | 0 | 1 | 2 | 3 |
| 2 | 0 | 1 | 2 | 3 |
inverse(L) for a flat dense bijection with modes , every ; as in Lemma 1, modes of size 1 are dropped first. Give mode the canonical weight and list the modes in decreasing order of stride. Then
again a dense bijection. Read both as maps on , each unflattening the integer it is given into its own shape, and they are mutually inverse.
, coloured by element
inverse(L) = (3, 2):(1, 3), at address
the element
| 0 | 1 | 2 | |
|---|---|---|---|
| 0 | 0 | 2 | 4 |
| 1 | 1 | 3 | 5 |
| 0 | 1 | |
|---|---|---|
| 0 | 0 | 3 |
| 1 | 1 | 4 |
| 2 | 2 | 5 |
4 Deciding whether a composite is a layout
While a composite can be natively emitted as is, sometimes we can simplify the codegen if that composite is actually itself a layout.
Fix a map on a shape . We take flat, since a nested shape has the coordinates of the flat shape of its leaves, regrouped. Write for a coordinate and for the origin. Every layout sends to 0, and composition and swizzle preserve this, so for every composite. Maps take values in throughout this section: strides are integers, and Section 5 subtracts a constant.
Definition 8 (Refinement). A refinement of a flat shape is a shape with each flat and size . A coordinate of is identified with its flattening in (Definition 1), so and are the same set. A map is the layout when
for every coordinate; for this says . The question of this section is whether is a layout for some refinement of and some stride .
Lemma 2 (Separability). Let be a flat shape and . For let be the coordinate with entry equal to 1 and every other entry 0, and define by . Then is a layout for some refinement of if and only if
and each is a layout of some flat shape of size .
Proof. ( ) Let with . By Definition 1,
At every term but the th is a layout evaluated at coordinate 0, hence 0, so (unflatten): the th term is , which is (1), and . () If for each , the same identity read backwards gives .
Checking (1) is one pass over Coord(S). What remains is one coordinate at a time: a map with , and the question whether there is a flat shape of size and a stride with . To decide it we need this composite as a formula in .
Number the entries of from the right, , so that indices increase with the weights below. By Definition 1, unflatten is the coordinate of with
the being the strides of canonical; so , , and . Solving for the components,
which we write . Therefore
and is the layout exactly when equals this sum for every .
Two remarks turn the search for into a search for the . An entry with has and contributes nothing, so we assume has none; then , each dividing the next and dividing , which we write and call the chain of . Conversely, every such chain is the chain of exactly one such , given by with . Theorem 1 finds by finding its chain.
Each component is the remainder of on division by . The lemma rewrites with floors alone.
Lemma 3 (Components as differences of floors). For positive integers and every integer ,
Let be a flat shape of size with entries, with chain , entry sizes , and components as above, and let integers and be related by
a relation that determines either family from the other. Then for a map ,
and when these hold, .
Proof. Write and . The remainder of on division by is , and for positive integers , which is the identity. With , , and it reads
where for , on . Hence
which is the equivalence. The relation gives , so either family determines the other. Finally, is 0 for because , is 1 for because , and is 0 for because is a multiple of ; so .
With floors alone, first differences read the chain off , because is 1 if and 0 otherwise.
Theorem 1 (Linear recognition). Let (for , is the layout (1):0), let with , and let for . Run the following scan. Keep a copy of , an integer initially 1, and a set initially empty. For in order, if : if or , reject; otherwise put in , set and , and replace by for every multiple of in . If no rejects, accept.
Then is a layout of some flat shape of size if and only if the scan accepts. If it accepts, is the chain of a flat shape of size ; is the layout with ; and every flat shape of size without entries of size 1 of which is a layout has a chain containing . We call this the coarsest. The scan takes arithmetic operations.
Proof. By Lemma 3, is a layout of the shape with chain if and only if there are integers , , with for every . Since and , this is equivalent to
Suppose (2) holds for some chain and coefficients . We show by induction on that when the scan reaches , with the recorded equal to those of (2), and if and otherwise. At , is empty and because is the only divisor of 1. Given the claim at : . If then and ; because every element of divides ; and , which is the largest element of or else 1, lies in below and so divides because is a chain. The scan records with , and the claim holds at ; if nothing is recorded and the claim holds at as well. So the scan accepts, and ; with , .
Conversely suppose the scan accepts. At each either was 0 or was subtracted from it, and later steps change only at or beyond their own ; so at the end , that is, for . Every element of divides , lies below , and is a multiple of the element recorded before it or of 1, so is a chain; let be its shape, and put if . Then (2) holds for , so is a layout of by Lemma 3, with strides .
Each element of is at least twice the one before, so the subtractions touch fewer than entries of ; the rest of the scan is one pass over .
The methodology is similar to Appendix A.2.1 of Axe [7].
Codegen therefore emits one of two expressions. If the map is a layout for a refinement , it emits , with the components of unflatten , for the coarsest ; no such expression has fewer terms. Otherwise it emits the composite as Definition 5 writes it: the value of the right operand, unflattened into the left operand's domain shape, evaluated by the left operand. Section 5 extends this to restricted maps, which do not vanish at the origin.
5 Restriction
A warp or a thread uses one slice of an address map: the map with its own warp and thread coordinates fixed.
Definition 9 (Restriction). Let with flat, let , and let for each . The restriction of to is the map on the coordinates of the shape given by
is in general not a layout: is the contribution of the fixed entries, which need not be 0, while every layout vanishes at .
is in general not dense, since its image omits the other slices, so it is not a valid map into logical or thread-value (Definition 7) and cannot be the right operand of a composition (Definition 5). Restriction is therefore allowed only for maps into physical, and is applied after composition, where the warp and thread coordinates are entries of the composite's domain. Restricting a restriction is restricting by the union of the fixed entries.
The address expression of a slice is Section 4 applied to , which vanishes at the origin, plus the constant ; when that map is not a layout, the composite's expression is emitted with the fixed coordinates replaced by their values. The difference can take negative values, which is why Section 4 is stated over : for under the swizzle with , , (Definition 4), that is , , fixing gives and . The emitted arithmetic then carries a negative coefficient. For , and , the slice is .
6 CuTe in this algebra
CuTe lists the modes of a layout with the first varying fastest; we reverse the list, recursively, and the two then agree as functions on the same integers. Layouts quoted from CuTe's documentation are written in CuTe's order and marked as such; all others are in ours. CuTe's composition(A, B) applies B first and is in our algebra, with B the right operand of Definition 5. We take the four operations in the order of Section 1, state what each is in our algebra, and name the documented examples [1] on which the two are checked to agree.
Composition. In CuTe, composition(A, B) is the layout L with for every . In our algebra, is the map , defined whenever B is a dense bijection onto , and Theorem 1 decides whether it is a layout. For such a B, when CuTe's composition exists the two are the same function, so Theorem 1 accepts and returns the coarsest shape that realizes it. Checked on the three documented examples, in CuTe's order,
as functions at every coordinate; in all three B is a dense bijection onto .
Complement. In CuTe, is the layout of Section 1, defined under two divisibility conditions. In our algebra there is no complement operator. For the two conditions make every factor of an integer. Let be the shape of these factors in our order, , and let be with every entry other than the replaced by 1. Then
after dropping entries of size 1: the tile is and the rest is its complement. Whether a given pair is a bijection onto is decided by Lemma 1. Checked on the six documented complements: divide(canonical(24), (4)) has tile 4:1 and rest 6:4, which are and ; divide(canonical((12, 2)), (4, 1)) has tile 4:2 and rest (3, 2):(8, 1), which is in CuTe's order; and all six pairs are bijections onto .
Division. In CuTe, . In our algebra, for a tile given as a shape S with , this is divide(A, S) of Section 3, and
whose right operand is a regrouping of the identity on and so a dense bijection onto it. For a tile given as a layout it is the composite itself: is a bijection onto , so Definition 5 applies with no further condition. Checked, as functions, on the documented strided tiler, in CuTe's order,
CuTe's zipped_divide groups the result as ((tile), (rest)), which is the grouping divide produces; logical_divide groups it per mode, a regrouping of the same layout.
Product. In CuTe, with . In our algebra,
When A is a dense bijection, , so
When the two differ. Take and . Printed as CuTe prints layouts, one cell per coordinate holding its address and coloured by the copy it belongs to, is

and the two products are, with the element of as the row and the copy as the column,
In CuTe:
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| (0,0) | 0 | 2 | 8 | 10 | 16 | 18 |
| (0,1) | 1 | 3 | 9 | 11 | 17 | 19 |
| (1,0) | 4 | 6 | 12 | 14 | 20 | 22 |
| (1,1) | 5 | 7 | 13 | 15 | 21 | 23 |
In our algebra: repeat(A, B)
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| (0,0) | 0 | 6 | 12 | 18 | 24 | 30 |
| (0,1) | 1 | 7 | 13 | 19 | 25 | 31 |
| (1,0) | 4 | 10 | 16 | 22 | 28 | 34 |
| (1,1) | 5 | 11 | 17 | 23 | 29 | 35 |
In CuTe the copy offsets are in CuTe's order, that is in ours, taking , and
is a bijection onto . In our algebra the copy offsets are the multiples of cosize , and repeat is injective and not dense. CuTe's placement is available in our algebra: divide(canonical is the pair of the complement paragraph, and composing it on the right with repeat , which sends to , gives for every dense bijection ; for that composition is the identity, and for this
All of this is checked. With the operands exchanged and a dense bijection, , which is interleave up to the order of the two coordinate groups. CuTe's blocked_product and raked_product are both with the two coordinate groups zipped per mode, block index first or copy index first: the same map on coordinates, regrouped. For and , , raked_product is , the same map with its two coordinates exchanged, and .
Conditions. CuTe's six conditions exist because its composition and complement must return a layout, so the operands are checked in advance for the result to be expressible as one. In our algebra neither operation has to: a composite is a map, and whether it is a layout is decided afterwards, for code generation only; and a complement is never formed on its own, it is the rest of a divide. So none of the six is checked. What is checked instead is that the right operand of a composition is a dense bijection onto the left operand's coordinates, by the stride criterion of Lemma 1; that a map into logical or thread-value space is a dense bijection and a map into physical space is alias-free; and the precondition of each operation, such as for divide.
Example. Two hardware instructions and a kernel's use of them. The thread-value maps are transcribed from the PTX ISA fragment tables [8]. For mma.m16n8k16, lane holds four accumulator values , at row and column of the tile; with the tile row-major,
For ldmatrix, lane holds elements and of an matrix,
Printed as CuTe prints thread-value layouts, one cell per element of the tile, labelled with the lane and value that hold it and coloured by lane:
: the accumulator
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|---|
| 0 | T0V0 | T0V1 | T1V0 | T1V1 | T2V0 | T2V1 | T3V0 | T3V1 |
| 1 | T4V0 | T4V1 | T5V0 | T5V1 | T6V0 | T6V1 | T7V0 | T7V1 |
| 2 | T8V0 | T8V1 | T9V0 | T9V1 | T10V0 | T10V1 | T11V0 | T11V1 |
| 3 | T12V0 | T12V1 | T13V0 | T13V1 | T14V0 | T14V1 | T15V0 | T15V1 |
| 4 | T16V0 | T16V1 | T17V0 | T17V1 | T18V0 | T18V1 | T19V0 | T19V1 |
| 5 | T20V0 | T20V1 | T21V0 | T21V1 | T22V0 | T22V1 | T23V0 | T23V1 |
| 6 | T24V0 | T24V1 | T25V0 | T25V1 | T26V0 | T26V1 | T27V0 | T27V1 |
| 7 | T28V0 | T28V1 | T29V0 | T29V1 | T30V0 | T30V1 | T31V0 | T31V1 |
| 8 | T0V2 | T0V3 | T1V2 | T1V3 | T2V2 | T2V3 | T3V2 | T3V3 |
| 9 | T4V2 | T4V3 | T5V2 | T5V3 | T6V2 | T6V3 | T7V2 | T7V3 |
| 10 | T8V2 | T8V3 | T9V2 | T9V3 | T10V2 | T10V3 | T11V2 | T11V3 |
| 11 | T12V2 | T12V3 | T13V2 | T13V3 | T14V2 | T14V3 | T15V2 | T15V3 |
| 12 | T16V2 | T16V3 | T17V2 | T17V3 | T18V2 | T18V3 | T19V2 | T19V3 |
| 13 | T20V2 | T20V3 | T21V2 | T21V3 | T22V2 | T22V3 | T23V2 | T23V3 |
| 14 | T24V2 | T24V3 | T25V2 | T25V3 | T26V2 | T26V3 | T27V2 | T27V3 |
| 15 | T28V2 | T28V3 | T29V2 | T29V3 | T30V2 | T30V3 | T31V2 | T31V3 |
: one matrix
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|---|
| 0 | T0V0 | T0V1 | T1V0 | T1V1 | T2V0 | T2V1 | T3V0 | T3V1 |
| 1 | T4V0 | T4V1 | T5V0 | T5V1 | T6V0 | T6V1 | T7V0 | T7V1 |
| 2 | T8V0 | T8V1 | T9V0 | T9V1 | T10V0 | T10V1 | T11V0 | T11V1 |
| 3 | T12V0 | T12V1 | T13V0 | T13V1 | T14V0 | T14V1 | T15V0 | T15V1 |
| 4 | T16V0 | T16V1 | T17V0 | T17V1 | T18V0 | T18V1 | T19V0 | T19V1 |
| 5 | T20V0 | T20V1 | T21V0 | T21V1 | T22V0 | T22V1 | T23V0 | T23V1 |
| 6 | T24V0 | T24V1 | T25V0 | T25V1 | T26V0 | T26V1 | T27V0 | T27V1 |
| 7 | T28V0 | T28V1 | T29V0 | T29V1 | T30V0 | T30V1 | T31V0 | T31V1 |
A kernel uses them through the operations. Two warps, , computing a tile side by side have the thread-value map
with domain (warp, (lane, value)), and one warp loading the four matrices of an tile with ldmatrix.x4 has
with domain (matrix, (lane, value)). Coloured by warp and by matrix respectively; in the first, cells are labelled by the thread :
two warps on
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 | T32 | T32 | T33 | T33 | T34 | T34 | T35 | T35 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 1 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 | T36 | T36 | T37 | T37 | T38 | T38 | T39 | T39 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 2 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 | T40 | T40 | T41 | T41 | T42 | T42 | T43 | T43 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 3 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 | T44 | T44 | T45 | T45 | T46 | T46 | T47 | T47 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 4 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 | T48 | T48 | T49 | T49 | T50 | T50 | T51 | T51 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 5 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 | T52 | T52 | T53 | T53 | T54 | T54 | T55 | T55 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 6 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 | T56 | T56 | T57 | T57 | T58 | T58 | T59 | T59 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 7 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 | T60 | T60 | T61 | T61 | T62 | T62 | T63 | T63 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 8 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 | T32 | T32 | T33 | T33 | T34 | T34 | T35 | T35 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 9 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 | T36 | T36 | T37 | T37 | T38 | T38 | T39 | T39 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 10 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 | T40 | T40 | T41 | T41 | T42 | T42 | T43 | T43 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 11 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 | T44 | T44 | T45 | T45 | T46 | T46 | T47 | T47 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 12 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 | T48 | T48 | T49 | T49 | T50 | T50 | T51 | T51 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 13 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 | T52 | T52 | T53 | T53 | T54 | T54 | T55 | T55 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 14 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 | T56 | T56 | T57 | T57 | T58 | T58 | T59 | T59 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | |
| 15 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 | T60 | T60 | T61 | T61 | T62 | T62 | T63 | T63 |
| V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 | V2 | V3 |
ldmatrix.x4 on
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 | T0 | T0 | T1 | T1 | T2 | T2 | T3 | T3 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 1 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 | T4 | T4 | T5 | T5 | T6 | T6 | T7 | T7 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 2 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 | T8 | T8 | T9 | T9 | T10 | T10 | T11 | T11 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 3 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 | T12 | T12 | T13 | T13 | T14 | T14 | T15 | T15 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 4 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 | T16 | T16 | T17 | T17 | T18 | T18 | T19 | T19 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 5 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 | T20 | T20 | T21 | T21 | T22 | T22 | T23 | T23 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 6 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 | T24 | T24 | T25 | T25 | T26 | T26 | T27 | T27 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | |
| 7 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 | T28 | T28 | T29 | T29 | T30 | T30 | T31 | T31 |
| V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 | V0 | V1 |
Both are dense bijections, as Definition 7 requires of a map into logical. Composed onto storage they become address maps, and Section 4 emits their code. With the tile stored row-major with leading dimension 24, that is with (16, 16):(24, 1) : logical physical in place of canonical((16, 16)), the two-warp map is decided to be a layout and the emitted address is
where c0 is the warp and c1_0_0, c1_0_1, c1_1_0, c1_1_1 are g, , , : the address . The slice for warp 1 (Section 5) is
With the tile stored with leading dimension 40, the ldmatrix map emits
with c0 the matrix and c1_0_0, c1_0_1, c1_1 the lane's g and q and the value v. The tests build the same construction for a tile and four warps, and the ldmatrix reader of a GEMM mainloop (Section 7).
Usage. The table lists the idioms CUTLASS kernels are written with and what each is in our algebra. fixes the entries named to (Definition 9). : thread-value logical is a valid map, such as above; is a dense bijection arranging the warps, as above; and : logical thread-value is a dense bijection from the positions of a tile to the threads.
| CuTe | Our algebra |
| make_layout(S, D) | , modes reversed |
| composition(A, B) | |
| complement(B, M) | rest of divide(canonical(), ), above |
| logical_divide(A, S), zipped_divide | divide() |
| local_tile(A, S, b) | |
| local_partition(A, T, t) | |
| partition_A/B/C, tensor(-, k) | |
| logical_product(A, B), blocked_product, tile_to_shape | repeat(), a dense bijection |
| raked_product(A, B) | repeat() with the two coordinate groups exchanged in each mode |
| logical_product(B, A), copies first | interleave(), a dense bijection, up to the order of the groups |
| stride-0 modes | broadcast(); read-only |
| Swizzle<B,M,S> | with , , (Definition 4) |
| -stage pipeline buffer | repeat() |
| TiledCopy: partition_S/D, vector width | divide() interleave(, 32:1) over the lanes |
| TiledMMA: over a CTA tile with warp grid | divide() interleave() |
| rightInverse(L); retile_S/D coalesce | inverse(); inverse() |
| group_modes, select, flatten recast, upcast by | not needed: the kernel declares the shape it iterates regrouping the shape; same function |
| divide(); the change of element size is outside the algebra | |
| TMA box ; multicast | divide(); broadcast across CTAs |
Every row is one of composition, divide, restrict, repeat, interleave, broadcast, a swizzle, inverse, or a regrouping of a shape.
7 Evaluation
The implementation is 956 lines of OCaml, over 403 lines of interface; the tests are 2,432.
The decision procedure is correct. The criterion of Lemma 1 agrees with enumeration on 400 random layouts. The scan of Theorem 1 is compared with an oracle that tries every chain of divisors of and checks the strides it forces at every point. Over every function with , for and if , 3 otherwise, that is 186,293 functions, the two accept the same 58, with the same chain.
https://github.com/annp0/simplified-layout
The theory is mechanized. Every lemma and theorem of Sections 2–4, and every claim of each operation in Section 3, is proved in Rocq 9.0, in 4,546 lines, with details in the repository. The proved scan is further extracted to OCaml and run beside the implementation’s on every map of this enumeration: on all 186,293 they agree on the verdict and, on the 58 they accept, digit for digit. The correspondence with CuTe of Section 6 and the restriction arithmetic of Section 5 are not proved but checked by the tests.
It matters in practice. The tests build 207 layouts, from CuTe's documented examples, CUTLASS's atoms, the usage table of Section 6 and the laws of Section 3, and check each against its emitted expression at every coordinate. Of those, 172 are affine in their coordinates, 11 are layouts of a refinement with one coordinate split, and 24 are not layouts and are emitted as composites. On 600 random composites of a dense bijection with a padded storage map, 524 are layouts of some refinement, and their emitted forms contain 686 divisions and moduli where the composites contain 1,026. With a random swizzle on the storage map, none of 300 is a layout.
The algebra is enough for a kernel. The SM90 GMMA accumulator, built from the SM80 mma.m16n8k16 C fragment as
equals NVIDIA’s printed layout at all 8,192 coordinates. A GEMM mainloop built from the operations alone, an tile of 16-bit elements copied in 16-byte vectors by one warp into two shared-memory stages of the SW64 atom and read back by ldmatrix, with the writer and reader of Section 6 and the stages by repeat, is consistent: for every element, the address the copy writes is the address the mma operand is read from.
8 Related work
CuTe [1, 2] is the system under study; its operations and their conditions are stated in Section 1. Shah [3] formalizes the algebra and gives the conditions under which the composite of two layouts is again a layout. In our algebra that is decided after the fact by Theorem 1, and a composite that is not a layout is still a legal map. Carlisle et al. [4] model a class of CuTe layouts as morphisms of two categories, define composition, logical product and logical division on the morphisms, and characterize the layouts so obtained. Linear layouts [5], in Triton, represent a layout as a matrix over acting on the bits of the hardware index, which gives generic layout-to-layout conversion; a swizzle of Definition 4 is such a matrix. Bhaskaracharya et al. [6] represent both CuTe layouts and linear layouts as integer set relations in ISL and implement composition, inversion and complement with its operations; the question of Section 4 can be posed there, and Theorem 1 answers it without a solver. Axe [7] maps logical coordinates to a multi-axis physical space through named axes and unifies tiling, sharding, replication and offsets from device meshes to threads; its replication is explicit, as broadcast is in our algebra, and its Appendix A.2.1 uses the floor expansion and first differences of Section 4 to prove a normalized representation unique. Halide [9], TVM [10] and MLIR [11] carry general integer expression simplifiers; Section 4 decides the layout question directly instead.
9 Conclusion
CuTe's layout algebra guards its operations with admissibility conditions that its API does not show, and it may silently fail when one is violated. We propose a new layout algebra in which each layout declares the space it maps into, and that declaration alone reduces those conditions to one. The algebra still reproduces CuTe's documented examples and CUTLASS's atoms, and its decision procedure and operations are proved in Rocq.
The next step is to compile with these layouts: a GPU DSL in which each warp is a SIMD program and warps communicate through pipes, so that kernels built from the algebra alone can be measured against their CuTe counterparts.
References
[1] NVIDIA. CuTe: Layouts and Layout Algebra. CUTLASS documentation, docs.nvidia.com/cutlass, accessed 2026.
[2] C. Cecka. CuTe Layout Representation and Algebra. NVIDIA Research; arXiv:2603.02298, 2026.
[3] J. Shah. A Note on the Algebra of CuTe Layouts. Colfax Research technical note, 2024.
[4] J. Carlisle, J. Shah, R. Stern, P. VanKoughnett. Categorical Foundations for CuTe Layouts. arXiv:2601.05972, 2026.
[5] K. Zhou, M. Lezcano, A. Goucher, A. Rakhmati, J. Niu, J. Lebar, P. Szczerbuk, P. Bell, P. Tillet, T. Raoux, Z. Moudallal. Linear Layouts: Robust Code Generation of Efficient Tensor Computation Using . ASPLOS 2026; arXiv:2505.23819.
[6] S. G. Bhaskaracharya, A. Acharya, B. Hagedorn, V. Grover. Modeling Layout Abstractions Using Integer Set Relations. arXiv:2511.10374, 2025.
[7] B. Hou, H. Jin, G. Wang, J. Chen, Y. Cai, L. Yang, Z. Ye, Y. Ding, R. Lai, T. Chen. Axe: A Simple Unified Layout Abstraction for Machine Learning Compilers. arXiv:2601.19092, 2026.
[8] NVIDIA. Parallel Thread Execution ISA. Matrix fragment layout tables, accessed 2026.
[9] J. Ragan-Kelley, C. Barnes, A. Adams, S. Paris, F. Durand, S. Amarasinghe. Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines. PLDI 2013.
[10] T. Chen et al. TVM: An Automated End-to-End Optimizing Compiler for Deep Learning. OSDI 2018.
[11] C. Lattner et al. MLIR: Scaling Compiler Infrastructure for Domain Specific Computation. CGO 2021.