Repository navigation
fix(codegen): emit effect-form Cast, Fill through kernel-param views, and MeshCoord/Dim-arith slice coordinates - #240
Merged
Conversation
… and MeshCoord/Dim-arith slice coordinates Four CUDA TIR emission gaps hit by every scheduled program that finalizes against the composed cta x thread mesh: - arith: register an EMIT handler for tir Cast (effect form). The store into the destination converts, so the elementwise functor is the identity, as for UnaryKind.CAST. Previously any effect-form Cast raised 'no codegen handler'. - fill: write through the <name>_tensor view when the destination is a kernel parameter, matching the naming tensor_view establishes. Previously Fill on a kernel param named the raw pointer and the emitted kernel did not compile. - tensor_view: price slice pointer offsets with _coord_ref instead of render_scalar_expr so Dim arithmetic resolves against mesh coordinates; teach _COORD_OPERATORS DimFloorDiv/DimMod; render MeshCoord call targets as cute::get<axis>(cute::flatten(mesh_coords(...))); refuse unknown Call targets with a named error instead of falling through. Validated against upstream's test suite at aaa8054 (tests/codegen: 27 passed).
zhen8838
approved these changes
Oct 16, 2026
zhen8838
left a comment
Collaborator
There was a problem hiding this comment.
I’m sorry that I haven‘t had time to do much work on CodeGen and Runtime recently. I really want to further improve the runtime of tilefoundry to the extent that it can be used as a distributed runtime lib. So thank you very much for your contribution to the tilefoundry project. Help us take a step closer to that direction.
Register effect-form Cast on the Unary emitter as UnaryKind.CAST instead of a copied body, which also clears the D205/D209 docstring lint that failed CI. Fill names its destination through tensor_view's _tensor_ref, and the MeshCoord rendering is one helper shared by the coordinate and scalar renderers. A CUDA test narrows a mesh-coordinate window with T.cast and fills a kernel parameter; it fails on main for each of the three fixes.
sablin39
added a commit
to sablin39/tilelang-cuda-skills
that referenced
this pull request
Oct 20, 2026
…iagnostics fixed Upstream main moved aaa8054 -> 25fbbaa (6 commits). Notables: - Our four emitter fixes (slice coords, MeshCoord, Cast, Fill on kernel params) merged upstream as a5501c9 (PR tile-ai/TileFoundry#240). - I-3 fixed via #241 (closes #237): schedule finalize errors are now actionable -- they name the site, list instruction candidates, and point at tf.schedule. Skill guidance updated to the new error shape. - #244 adds AMX (Intel CPU) support; harmless for this GPU suite. Still open and reproducing byte-identically at the new pin: #239 (I-1/I-2 predicted-ns billing artifacts -- trust-table numbers unchanged), TMA/WGMMA/Where emitter gaps, warps_per_group reduce-dispatch bug, I-5 example bit-rot. Verification at the new pin: probe harness 12/12 PASS (two finalize fingerprints updated to the actionable error text); pin ritual green (tutorial extraction + analyze ideal-ns=13, scan twin check PASS both outputs, tests/ops/tir/test_copy 1 passed); rms_norm_quant TileLang twin check PASS (equal on fp8, allclose on f32 scale); trust-table spot checks byte-identical (scan fused ideal-ns=125063, GEMM scheduled ideal-ns=143256 bound-by=compute).
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.
What
Four CUDA TIR emission gaps that fire on scheduled programs finalized
against the composed cta×thread mesh (the shape every multi-CTA
schedule finalizeproduces). One commit,src/tilefoundry/codegen/cuda/tironly, +45/−10.
arith.py— effect-formCastemitter.Castin effect form hadno registered EMIT handler, so any scheduled program whose TIR carries
one raised "no codegen handler". The store into the destination
converts, so the elementwise functor is the identity — the same shape
as the existing
UnaryKind.CASTpath, dynamic-extent clip included.fill.py— Fill on a kernel parameter.Fillnamed the rawpointer for a kernel-param destination while
tensor_viewestablishesthe
<name>_tensorview for params; the emitted kernel referenced anundeclared name and did not compile. Now routes through
ctx.is_kernel_param, matchingtensor_view's naming.tensor_view.py— slice pointer offsets through_coord_ref.PtrOf(Slice(...))offsets were rendered withrender_scalar_expr,which cannot resolve mesh-relative Dim arithmetic; slice coordinates on
Dim expressions failed or mis-rendered.
_coord_refresolves themagainst the mesh binding. Also teaches
_COORD_OPERATORSDimFloorDiv/DimModand rendersMeshCoordcall targets ascute::get<axis>(cute::flatten(mesh_coords(...))).tensor_view.py— named refusal for unknown coordinate calls.An unsupported
Calltarget in a coordinate previously fell through toa generic leaf path; it now raises a
NotImplementedErrornaming thetarget type.
May close part of #230 (sliced pointers / nested layouts) — the slice
coordinate half overlaps; happy to rebase if that lands first.
Validation
aaa8054with this commit: 1802 passed,11 skipped (
pytest tests -n 4). The single failure in that run,tests/cli/test_cli.py::test_target_list_expressions_execute_and_show_accepts_their_identities,is an artifact of the development environment (a locally registered
custom target in the CLI registry); it passes with a pristine registry
and is unrelated to this change.
driving a scheduled RMSNorm through
scaffold/compile()on sm_90.Not in scope
CopyAsyncTensor(TMA), WGMMA (TiledMmanon-SM80 atoms), andWhereemitters remain absent as documented in
docs/spec/codegen.md
and
docs/spec/tir.md
— the schedule tutorial's optimal GEMM still cannot compile. Deliberate
raises today; unchanged here.
warps_per_groupfor a composed cta×thread mesh (singleis_threadper mesh in
reduce_common_impl.h,
so thread axes inside a cta-scoped composed mesh count their full
extent as warps → OOB smem reads on an RMSNorm repro). Not touched by
this PR; will file separately with the repro.