Repository navigation
Conversation
tilelens.ir.ttir_reader.parse_ttir reads one kernel specialization's TTIR into an AccessGraph: the function arguments, every global load, store and atomic as an element offset from a pointer argument with its mask and branch path, the loop and its loop-carried pointers, and the integer width obligations under which the unbounded-integer reading is exact. What it cannot represent it refuses with an UnsupportedTTIR of a typed kind (indirect-address, control-flow, call, inline-asm, ...). ParseCache's default reader is this one from now on. The structure comes from tilelens.ir._mlir_walk. Triton 3.8's MLIR bindings parse the text and give the op tree, the values, their locs, and the integer and enum attributes the reader reads (the cmpi predicate, the program-id axes, make_range's bounds, expand_dims' axis, integer constants). A line scan of the same text gives only what the bindings cannot: each op's line and a region op's closing line, the locs of ops without results (through the #loc alias table), scf.for's `unsigned` keyword and a generic-form tt.load's operand segments. Every printed loc of an op with results must equal the loc the bindings report for it, so a misread line is a reader-misalignment refusal, never a silent misread. Two inputs would abort the process inside Triton, so they never reach the bindings: a block-pointer type is refused before parsing, and an integer constant wider than 64 bits reads as non-integer data (a test runs that case in a child process). On any other Triton release the walk refuses. The tests compile their TTIR at test time instead of reading committed goldens. tests/unit/ir/ttir_corpus.py compiles the kernels of ttir_kernels.py and reader_kernels.py up to the TTIR stage only (no GPU, no Triton cache, about 0.3 s for the whole corpus) and holds the nine hand-written texts inline; text(name) keeps the former golden names (ttir/<name>.ttir, reader_ttir/<name>.ttir). The corpus also holds the four kernels the compiled sanitizer's tests read: golden_pid_branch, golden_grid_stride, golden_cas and golden_gather (sm80). Left out for now; they stay on ir-mode-tests-archive: - reader fields only a race detector reads: AtomicInfo (and the atomics' rmw_op, sem and scope), AccessEvent.atomic/atomic_val/atomic_cmp/ elem_float/is_read/is_write, FuncArg.elem_float, AccessGraph.pid_axes, LoopInfo.induction_var, DataDep.keep, observed_indices, and ttg.barrier's address space. Observed stays; - hardening and meta tests: mutation, fuzz and independent-extractor tests, process, thread, fork and memory tests, determinism and frozen graph tests, and the end-to-end smoke tests, which cover no line the other tests leave uncovered.
mark14wu
added this pull request to stack #496
October 4, 2026 23:48
This was referenced Oct 4, 2026
This was referenced Oct 4, 2026
Performance Benchmark
Iterations: 1 warmup + 20 measured |
This branch has not been deployed
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.
Summary
Adds the TTIR reader that IR clients build on:
tilelens.ir.ttir_reader.parse_ttirreads one kernel specialization's TTIR into anAccessGraph— the function arguments, every global load, store and atomic as an element offset from a pointer argument with its mask and branch path, the loop and its loop-carried pointers, and the integer width obligations under which the unbounded-integer reading is exact. What it cannot represent it refuses with anUnsupportedTTIRof a typed kind (indirect-address, control-flow, call, inline-asm, ...).Part of the stack #494 → #479 → #495 → #480 → #482.
How the TTIR is read
tilelens/ir/_mlir_walk.pyparses the text with Triton 3.8's MLIR bindings and takes from them the op tree, values, locs and the integer and enum attributes the reader needs (arith.cmpipredicate, program-id axes,make_rangebounds,expand_dimsaxis, integer constants). A line scan of the same text supplies only what the bindings cannot: op line numbers, the locs of ops without results (e.g.tt.store),scf.for'sunsignedkeyword and a generic-formtt.load's operand segments. Every printed loc of an op with results must equal the loc the bindings report, so a misread line is a refusal, never a silent misread. Inputs that would abort the process inside Triton (block-pointer types, integer constants wider than 64 bits) never reach the bindings.Tests
The tests compile their TTIR at test time instead of reading committed goldens:
tests/unit/ir/ttir_corpus.pycompiles the kernels inttir_kernels.py/reader_kernels.pyup to the TTIR stage only (no GPU, no Triton cache, about 0.3 s for the whole corpus) and holds the nine hand-written texts inline. Triton 3.8, CPU only: 564 passed at this branch's tip.Validation of the bindings-first walk against the previous text-based one on 7,152 distinct TTIR texts (566k ops): identical op trees, values and every attribute the reader reads; the reader's result is identical on all but one hand-written generic-form text, which is now read instead of refused.
Left out for now (kept on
ir-mode-tests-archive): reader fields only a race detector reads (atomic details, pid axes, the loop's induction variable,DataDep.keep, ...), and hardening/meta tests (mutation, fuzz, independent extractor, process/thread/fork, determinism, smoke tests with no unique coverage).