feat(inspection,parser): print placed types as parser sugar - #166
Merged
Merged
Conversation
zhen8838
commented
Sep 13, 2026
zhen8838
added a commit
to zhen8838/TileFoundry
that referenced
this pull request
Sep 13, 2026
…added Summing LoopFootprintMetadata.footprints by storage level, the `details` opt-in that recovered the per-buffer rows, and the analysis spec text describing both had no reproduced problem behind them: the review's finding was about a printer duplicating metadata, not about how footprints project. The fixtures, goldens and focused tests that only existed to pin that projection go with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
PythonPrinter now inherits PythonTypePrinter instead of owning one, so an expression printer emits `expr.type` through the same `visit` that emits the type's children. Every `render_<Type>` entry folds into its `visit_<Type>`, and the `owner` back-delegation is gone. Mesh aliases are now filtered to the ones the prelude actually binds, so naming a mesh inside a printed type can no longer emit an undefined reference.
…added Summing LoopFootprintMetadata.footprints by storage level, the `details` opt-in that recovered the per-buffer rows, and the analysis spec text describing both had no reproduced problem behind them: the review's finding was about a printer duplicating metadata, not about how footprints project. The fixtures, goldens and focused tests that only existed to pin that projection go with it.
The printer could already emit `((dims), (strides))` and `{axis @ P(...)}`
that nothing could read back, and it fell back to the verbose
`ShardLayout(...)` whenever a function held more than one mesh. One parser
production now covers the whole sugar — dims with splits written inline, an
optional stride tuple, and an optional value-state set — so the printer can
emit sugar for every shard layout over a named mesh.
A layout whose mesh axes are all Broadcast now states them, instead of
relying on "the active mesh"; the bare form it used to emit reparsed as a
plain Layout and silently dropped the mesh.
Meshes with the same descriptor share one prelude name, and a printed type
names only a mesh the prelude binds, so a composed mesh rebuilt at each use
site no longer produces a prelude line per copy or an undefined reference.
The TIR fixtures are authored in that sugar and print back to their own
source again, restoring the round-trip contract inspection §2.7 states.
The analyze golden reads the same fixture the round-trip golden does, so a type that prints one way in emitted code and another inside an annotation is a diff here rather than two goldens drifting apart.
An unstated stride tuple is not shorthand for C-order: it is the sugar default a `Reshard` materializes from the storage tier it moves between, so printing a stated C-order tuple as absent turned one layout into another and left TIR views with no strides for CUDA codegen to emit. `render_mode()` and `mesh_count()` go with it — the shared type visitor left both without a caller.
…adata `main` now reports compute cost and traffic per topology level, so the golden's metadata comments carry `cta:`/`thread:` breakdowns. The type text the goldens exist to pin is unchanged.
zhen8838
added a commit
to zhen8838/TileFoundry
that referenced
this pull request
Sep 13, 2026
…added Summing LoopFootprintMetadata.footprints by storage level, the `details` opt-in that recovered the per-buffer rows, and the analysis spec text describing both had no reproduced problem behind them: the review's finding was about a printer duplicating metadata, not about how footprints project. The fixtures, goldens and focused tests that only existed to pin that projection go with it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
zhen8838
force-pushed
the
test/render-golden-final
branch
from
September 13, 2026 07:39
2c357d0 to
4d56e19
Compare
The page reproduces itself from its own blocks, so the reshard it displays is now the one-line placement sugar rather than a five-line `ShardLayout`, and the window it prints reaches the matmul that consumes the weight.
zhen8838
commented
Sep 13, 2026
`named_and_out_of_scope` adds a layout the author names rather than spells, and a reshard onto a mesh its scope never enters -- reshard is the one operation allowed to cross that boundary, so its target names a mesh that is not the scope it runs in. The golden records what the printer does with them today: the named layout is expanded back into sugar, the out-of-scope target is written as `thread.warp` from inside `with cta`, and `@func(mesh=...)` comes back as a `with` in the body. All three are wrong and none of them had a test.
`composed_mesh_pipeline` reshards to the same constant `named_and_out_of_scope` holds as a parameter. One function enters that constant's mesh with a `with`; the other never does. The golden records both printing identically today. Only the first has a scope binding a sugar identifier could refer to, so only the first should keep the sugar once the printer requires one.
A placement states two things — the extents as written, and where they go — and the layout it implies keeps only the second, divided beyond recovery. So the shape slot could not reuse the layout slot's pattern: it copied the whole syntax tree and recovered the extents itself, and `docs/spec/parser.md` carried that copy as a second production, word for word. One pattern now answers both halves and each slot takes the part it asked for. The rules follow: what sat on the placement were the layout slot's rules, so a placement's own rule reaches the constraints table for the first time and `PlacedShapeRule` goes with the pattern it guarded.
zhen8838
force-pushed
the
test/render-golden-final
branch
from
September 14, 2026 03:44
1db7e80 to
0a506dd
Compare
zhen8838
commented
Sep 14, 2026
zhen8838
commented
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
render_value()instead of visiting each expression's type;render_*methods shadowedvisit_*; the goldens showed canonicalShardLayout(...)dataclasses instead of parser sugar; the fixtures were too simple to show a composed mesh, a broadcast and a partial together; and the work had grown four tests where two were asked for.((dims), (strides))and{axis @ P("sum")}had no parser production at all, and a bare(8,)reparsed as a plainLayoutthat dropped the mesh.What
PythonPrinterinheritsPythonTypePrinter. Every type has exactly onevisit_<Type>, expression printers emitexpr.typethroughself.visit, and therender_*parallel entries andownerback-delegation are gone.{axis @ B(), axis @ P("sum")}set.ExplicitLayoutPatternfolds into it.detailsopt-in, and the spec text describing them, along with the fixtures and tests that existed only to pin that projection.Contract
docs/spec/inspection.md§2.3 states when the printer MUST use placement sugar and how it writes splits, strides and value states; §2.5 states one name per mesh descriptor and no named mesh the prelude does not bind.docs/spec/parser.md's generated grammar:placed-layoutnow carries the stride tuple and the value-state set;explicit-layoutis gone.Reshardmaterializes from the storage tier it moves between; the sugar states strides whenever the layout has them.TensorView.layoutis annotatedLayoutBase, so its slot parses as a layout.tests/inspection/test_tir_roundtrip.pyasserts fixture source equality again, as inspection §2.7 requires.Risk
tests/fixtures/tir/mma.pyuses placement sugar with namedwarp/laneaxes; the CUDA MMA tile scope uses the same mesh names so atom fragment layouts remain structurally equal.