Skip to content

Rotom: Layout Representation updates for tiled layouts - #3169

Merged
copybara-service[bot] merged 1 commit into
google:mainfrom
edwjchen:rotom-pr-01
Jul 9, 2026
Merged

Rotom: Layout Representation updates for tiled layouts#3169
copybara-service[bot] merged 1 commit into
google:mainfrom
edwjchen:rotom-pr-01

Conversation

@edwjchen

@edwjchen edwjchen commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Three attribute-layer changes preparing the layout search for split and tiled packings:

Part 1 of #2980.

  • preprocessLayoutData produces a LayoutPiece list and a deduped axes table that maps one ISL domain variable per logical tensor dim. A traversal piece is a mixed-radix digit (i / divBy) mod modBy of its axis's index, so an axis split into several pieces (tiled or ct/slot-straddling layouts) shares one ISL domain variable.
  • The axes table canonicalizes to ascending dim id. Previously row- and column-major materialized identical relations, making conversions between them silently free when lowered to the ISL domain.
  • The dim assembly separates ciphertext dims from slot dims with | (e.g., [ct pieces | slot pieces]). Unused slots is written as an explicit gap piece.
  • Replication and gap dims print as R and G ([R:4:1], [G:4:1]); the numeric ids -1/-2 are still accepted on input and round-trip to the letter forms.

@edwjchen edwjchen changed the title Rotom: Layout Representation updates for tiled layouts. Rotom: Layout Representation updates for tiled layouts Jul 7, 2026
@edwjchen
edwjchen force-pushed the rotom-pr-01 branch 2 times, most recently from ccaff25 to 8483b5f Compare July 7, 2026 21:03
@edwjchen
edwjchen requested review from asraa and j2kun and removed request for asraa July 7, 2026 21:06
Comment thread lib/Dialect/Rotom/IR/RotomAttributes.cpp Outdated
Comment thread lib/Dialect/Rotom/IR/RotomAttributes.cpp Outdated
Comment thread lib/Dialect/Rotom/IR/RotomAttributes.cpp Outdated
@j2kun

j2kun commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

I guess one thing I don't quite understand about the design here is explained with this example:

#rotom.layout<n = 4, dims = [[0:8:1]]> 

Here you'd split the single dim into two pieces because it has size 8 and there are only 4 slots, right?

What is the benefit of doing that instead of, say, explicitly representing what piece is slots and what piece is ciphertext?

#rotom.layout<n = 4, ct_dims = [[0:2:4]], slot_dims = [[0:4:1]]> 

I guess what I'm saying is: if you explicitly represented this, would you be able to avoid most of the work in this PR?

…elling

Attribute-layer rework preparing the layout search for split and tiled
packings:

- preprocessLayoutData produces a LayoutPiece list (one per written dim,
  tagged Traversal/Replication/Gap) plus a deduped axes table -- one ISL
  domain variable per logical tensor dim. A traversal piece is a
  mixed-radix digit (i / divBy) mod modBy of its axis's index, so an axis
  split into several pieces (tiled or ct/slot-straddling layouts) shares
  one variable. Multi-piece axes are validated as complete mixed-radix
  decompositions. The ISL emitter reads the per-piece digit descriptors
  when building address terms.
- The axes table canonicalizes to ascending dim id. Consumers read it
  positionally as tensor dims (most importantly the ISL domain), so a
  layout whose pieces lead with a later dim (column-major) must not leak
  piece order into the domain: previously row- and column-major
  materialized identical relations, making conversions between them
  silently free.
- The dim assembly separates ciphertext dims from slot dims with `|`
  ([ct... | slot...], omitted when there are no ct dims). The split is
  derived (the longest dims suffix whose extents fill n) and the written
  `|` is validated against it, so a layout never reads differently than
  it packs. The slot side must fill n exactly; unused capacity is written
  as an explicit gap piece rather than synthesized.
- Replication and gap dims print as R and G ([R:4:1], [G:4:1]); the
  numeric ids -1/-2 are still accepted on input and round-trip to the
  letter forms.

Affected materialize/syntax/seed tests re-blessed.
@edwjchen

edwjchen commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

The layout representation is now updated to have a clear separation between ct and slot dimensions:

#rotom.layout<n = 4, dims = [[0:2:4]  | [0:4:1]]>

where LayoutPieces before the | correspond to ct dims and after the | correspond to slot dims.

The remaining changes in this PR are for adding robustness checks to constructing a Rotom layout (in preprocessLayoutData) and facilitating lowering a Rotom layout into an ISL relation (by canonicalizing the relationship between LayoutPieces and the original tensor axes.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Jul 9, 2026
@copybara-service
copybara-service Bot merged commit accefb9 into google:main Jul 9, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants