﻿# CuTe layout storage: size counts logical elements while cosize describes the index span

Distinguish CuTe logical domain size, positive-stride storage span, holes, and broadcast aliasing before sizing a backing allocation or validating a write mapping.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-cute-layout-size-cosize-storage-span/
Language: en

## Start from the layout function

The [CuTe layout tutorial](https://docs.nvidia.com/cutlass/4.5.0/media/docs/cpp/cute/01_layout.html) defines a layout as a coordinate-to-index mapping. Its `size` describes the logical domain, while `cosize` describes the codomain extent used by that mapping. These quantities answer different questions. This guide concerns ordinary nonnegative-stride examples where a backing array is addressed from its base, not a universal allocation formula for every composed or transformed iterator.

## Work through a padded mapping

Consider a layout with shape `(2,3)` and stride `(1,4)`. It has 6 logical positions, but its mapped offsets include 0, 1, 4, 5, 8, and 9. A base-addressed backing array must accommodate a span of 10 elements for these accesses. Allocating only the logical count misses the gaps between columns. This example illustrates why visible element count and occupied address interval cannot be substituted for each other when a kernel introduces padding into a tile representation.

## Keep the engine separate

The [tensor tutorial](https://docs.nvidia.com/cutlass/4.5.0/media/docs/cpp/cute/03_tensor.html) separates the layout from the engine or iterator holding data. Changing a layout does not automatically resize a nonowning allocation. The [versioned layout implementation](https://raw.githubusercontent.com/NVIDIA/cutlass/v4.5.0/include/cute/layout.hpp) supplies the actual mapping utilities. A correct view descriptor therefore cannot rescue a backing buffer that was allocated using the wrong quantity; verify the storage extent at the point where that allocation is created.

## Check aliasing as another property

A zero-stride broadcast mode can map several logical positions to the same storage element. In that case, domain size can exceed the referenced span. This may be intentional for reading a broadcast value, but it does not automatically make concurrent independent writes valid. Span sufficiency and mapping uniqueness are separate checks. An allocation large enough for all mapped offsets says nothing by itself about whether multiple threads target the same address or require an explicit reduction policy.

## Validate before changing tile padding

Record shape, stride, logical count, referenced offsets, backing extent, and read/write intent. Guides to [tensor strides](/journal/tensor-strides-transpose-contiguous/) and [GPU acceptance evidence](/journal/gpu-acceptance-evidence/) provide context. Enumerate a small mapping before testing a large kernel. This makes a padding or broadcast change reviewable without confusing domain size with storage or treating successful in-bounds reads as proof that a new parallel write layout is race-free.
