sass2mlir / Manual

Pass-writing manual

A practical route from a verified cubin to a narrow, tested SASS optimization and honest GPU evidence.

Manual

Write a pass whose contract you can explain

A useful pass needs more than a matching instruction sequence. It must explain which inputs it admits, which values and effects it preserves, how it publishes valid code, and what its tests establish. Start with one transformation and explicit refusals; broaden it only when the new cases have their own evidence.

What good looks like

Four questions for every transformation

  1. Why is this site eligible? Name the architecture, operand forms, numerical policy, control-flow assumptions, and unsupported effects.
  2. What changes together? Keep structured instruction fields, actual SSA sources/results, predicates, old destination values, and scheduling evidence consistent. Remove stale raw encoding authority when content changes.
  3. Can the result be published? Use shared encoding and layout machinery; reject unencodable words, unresolved remaps, and invalid metadata ownership.
  4. What has been proved? Host tests establish structure and encoding. GPU comparisons establish the tested numerical behavior and progress. Timing follows correctness and names the exact workload and artifact.

The FMA walkthrough answers each question against the shipped implementation and shows how to check the affected contract. It is the starting point for writing passes in this tree.

Beyond the first pass

Capture and research case studies