Repository navigation
Conversation
|
Thanks @FeathBow for tracking down these 55 operands. This PR exposes a deeper problem. The failure comes from how lowering represents a staged So I will take this PR over and rework it. No further change is needed from you here. I will link the result in this thread, so that you can continue your work on top of it. |
|
The replacement binds integer-address ring TensorViews, their tuple and each selected stage, carries analyzed shared-memory peaks into host launches, and shares one target-resolved default pipeline. Final local verification: source 1514 passed / 12 skipped; installed 167 passed, including all 13 tutorial checks and four page reproductions. All differences across the 60 finalized HIR fixtures were attributed to host entries, ring bindings or the host entry point. Follow-ups are tracked in #278 and #255. |
## Why - Supersedes #276. Unbound ring views and stage selections reach CUDA operands without SSA names, and compilation entry points assemble different pass lists. ## What - Keep ring stages as a tuple of bound TensorViews and bind each selected stage once per consuming scope. - Share `default_pipeline` across finalize, compile and scaffold. Resolve the core host-entry pass through `Target.resolve`, with CUDA supplying an `@bind` implementation. - Make `Module.entry` the host starting point and carry analyzed shared-memory peaks into host launches. - Link all CPU hosts on the call paths, with the root host first. ## Contract - Both `InsertHostEntryPass.create(target, options)` and `ConvertHIRToTIR.create(target, options)` support target-owned implementations. - `link_program` removes `entries`; the loader binds the first linked host, and `build` requires a CPU host root. - Full lowering requires memory-analysis metadata. `ConvertHIRToTIR` is a no-op for skeletons or modules without HIR; a CPU host root being lowered must launch exactly one HIR callee. ## Risk - #278 tracks Broadcast layout normalization; the remaining layout-adaptation views are retained. - #255 tracks SymbolRef/function references; indexed child entries remain excluded from synthesized hosts, and Launch type repair remains necessary.
Why
Lowering passed a selected ring stage straight to an instruction, as in
T.copy_async_tensor(value, lhs_ring_stages[k % 3]). The CUDA emitters read tensor operands by variable name, so each of these failed inname_forat compile time. Finalizing the schedule fixtures gave 55 such operands, fromcopy,copy_asyncandcopy_async_tensor.Lowering already binds a view at a constant
smemaddress, or overgmemscratch, in each scope that uses it. A staged buffer's selected stage was the one view it returned unbound, and nothing in TIR verification looked at the form of an operand.This relates to the #230 item in #255. Lowering now binds each selected stage, so the CUDA emitters need no change for it.
What
TirBuilder.declarereturns a staged buffer's selected stage as aViewwith the stage's own shape and layout. Copies, other instructions and the MMA issue loop then bindT.tensor_view(T.ptr_of(stages[i]), ...)in the scope that uses it and pass that variable.TensorView,SliceorTupleGetItemcall as an operand of an effect Op. Finalize verifies what lowering writes, so this form now fails there.Contract
An effect Op no longer accepts a
TensorView,SliceorTupleGetItemcall as an operand; aLetStmtbinds it and the Op takes the variable. Other expressions, such as scalar arithmetic, stay inline. This covers a scalarTupleGetItemas well. The handwritten TIR in the repository already binds all three.Risk
smem_padded_stages. Four others get past this point and stop at other errors: a register output parameter, a copy not split over threads, and a sliced mesh naming several levels.persistent_tile_union_countfails earlier than before: its stage index reads a CTA coordinate that codegen cannot render yet, which it now meets before the TMA copy that has no emitter (feat(codegen): emit T.copy_async_tensor with host-encoded tensor maps #248).smem_padded_stagesnow compiles its finalize output. All four fail with main's lowering and verifier. Apart from them, the CPU suite fails the same tests with either version.