Skip to main content

Module section_shape

Module section_shape 

Source
Expand description

The canonical SHAPE of a section — its choreography with every name forgotten.

★ WHY A SHAPE IS NOT A SECTION. Sixty-four decoder layers are the same handful of dataflows run over and over against different weights. The compiler proves that today by unrolling: four real-width layers compose into 153 sections, and sixty-four would be hundreds of gigabytes of IR describing a program no SN50 could hold anyway — 432 MB of SRAM against 27 GB of weights means the chip runs ONE layer’s dataflow and streams the layers through it.

Turning that unrolled form into a loop needs the regularity to be a CHECKED FACT, not an assumption about how the model was authored. A shape is that fact: a section reduced to its op sequence with every buffer, semaphore, group, site and engine renumbered by first appearance, and every TENSOR forgotten. Two sections share a shape exactly when their event graphs are isomorphic — which is the precise sense in which layer 7 and layer 8 “are the same”.

What a shape deliberately keeps: loop counts, buffer depths and page sizes, semaphore roles, access patterns, and the compute bodies. Two sections that differ in any of those run different dataflows, however alike they look in the source.

Functions§

section_repeat_groups
Sections grouped by shape: (shape, the sections that have it), ordered by each group’s first section so the answer is stable. The groups partition the sections.
section_shapes
The canonical shape of every section, in section order.