Skip to content

docs(book): the dialect inventories in mlir-dialects have drifted from the tree - #964

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:docs/book-op-inventories
Aug 17, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
vyncint:docs/book-op-inventories

Conversation

@vyncint

@vyncint vyncint commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

All four hand-maintained inventories on cuda-oxide-book/compiler/mlir-dialects.md are stale, and nothing checks any of them. Every count below was recomputed from the tree at a766fc26.

1. dialect-mir types: "seven" → nine

mir.union and mir.fp16 both have #[pliron_type(...)] declarations in dialect-mir/src/types.rs and no row. mir.union is not a corner case — #857 and #927 are both about union constants.

2. dialect-mir operations: 54 across 11 categories → 62 across 12

Category Book Tree Missing
control flow 5 6 mir.unroll_hint
memory 9 11 mir.memcpy, mir.memmove
comparison 6 7 mir.cmp
aggregate 8 10 mir.construct_slice, mir.construct_disjoint_slice
enum 3 4 mir.set_discriminant
debug — 1 mir.dbg_value — no row at all

3. LLVM dialect: 62 → 69

Counted at the pinned pliron revision 8447aa42, where pliron-llvm/src/ops.rs declares 51 ops with #[pliron_op( plus 18 through its binop macros. The table gains indirectbr, insert_element, shuffle_vector, poison, and a row for the four with no existing category (freeze, va_arg, blockaddress, blocktag).

Two names are wrong rather than merely missing:

  • inline_asm_multi does not exist. Not in any version of pliron-llvm, and nowhere in this repository — this page is the only place the string appears anywhere. Same shape as the fictional shuffle_xor_{f32,i32} rows docs(api-ref): the shuffle i32 variants documented here do not exist #815 removed from the API quick reference.
  • extractelement is spelled llvm.extract_element.

Also records that llvm-export contributes one op of its own (llvm.dbg_value), which the surrounding prose did not mention, and that this table tracks an upstream crate — so it moves when the pin moves (as it did in #919), not when this repository changes.

4. dialect-nvvm: 123 → 543

Not so much drift as a different tree. Six of the twelve modules listed no longer exist: thread and warp are gone (the warp ops now live in warp_shuffle, redux, vote, warp_match, warp_barrier, active_mask, elect), and mbarrier split into mbarrier_basic / mbarrier_extended. The ones that do exist are 4×–9× low — tcgen05 is listed at 24 and has 210, tma at 15 and has 111. Eighteen modules are missing outright, including sreg at 44 ops.

Rewritten around the split adding-new-intrinsics.md already documents — 7 hand-written modules (18 ops) against 34 generated ones (525 ops, resolved from 986 catalog entries, since several intrinsics share one structural op). That is what decides where a contributor would add an op, and a table saying warp when the file is ops/generated/warp_shuffle.rs sends them to the wrong place.

The per-module "Minimum SM / GPU Family" columns go with it. Those requirements are per intrinsic, not per module, and the catalog already records them: intrinsics/generated-reference.md renders the PTX version and minimum SM for each of the 986 entries and is regenerated with the ops. The page now points there instead of keeping a second copy by hand.

Note on the neighbouring PR

crates/dialect-mir/README.md carries its own copy of the operation inventory, stale in the same way and by a different amount — it says 55, and already had set_discriminant the book was missing. Two hand-kept copies drifting apart at different rates is the argument for reading src/ops/ rather than either. Fixed separately, no file overlap with this PR.

I checked #946 before writing these numbers: it touches all 35 generated dialect-nvvm files but adds zero #[pliron_op( declarations (only the regenerated catalog-SHA headers change), so the counts here are stable against it.

Testing

Local, no GPU.

  • Every count recomputed from the tree by script; all 12 dialect-mir modules, all 7 hand-written and all 34 generated dialect-nvvm modules, and all 10 grouped areas match exactly
  • The types table's nine rows match #[pliron_type( in dialect-mir/src/types.rs exactly
  • just book (sphinx-build -W --keep-going) succeeds
  • check-book-api-names.sh, check-toolchain-parity.sh, check-cli-doc-coverage.sh pass
  • cargo oxide run <example> — not applicable, documentation only

vyncint and others added 2 commits August 17, 2026 07:01
…m the tree

All four hand-maintained inventories on this page are stale and nothing
checks any of them. Counts below are from the tree at a766fc2.

**dialect-mir types: seven -> nine.** `mir.union` (Rust unions, every field
a view of the same bytes) and `mir.fp16` (`f16`) both have
`#[pliron_type(...)]` declarations in `dialect-mir/src/types.rs` and no row.
`mir.union` is load-bearing right now -- NVIDIA#857 and NVIDIA#927 are both about union
constants.

**dialect-mir operations: 54 across 11 categories -> 62 across 12.** Six
categories are short and one whole module is missing:

  control_flow   5 -> 6    `mir.unroll_hint`
  memory         9 -> 11   `mir.memcpy`, `mir.memmove`
  comparison     6 -> 7    `mir.cmp`
  aggregate      8 -> 10   `mir.construct_slice`, `mir.construct_disjoint_slice`
  enum_ops       3 -> 4    `mir.set_discriminant`
  debug          - -> 1    `mir.dbg_value`, absent from the table entirely

**LLVM dialect: 62 -> 69**, counted at the pinned `pliron` revision
(8447aa42), where `pliron-llvm/src/ops.rs` declares 51 ops with
`#[pliron_op(` plus 18 through its binop macros. The table gains
`indirectbr`, `insert_element`, `shuffle_vector`, `poison`, and a row for
the four with no existing category (`freeze`, `va_arg`, `blockaddress`,
`blocktag`).

Two of the names in it are wrong rather than merely missing:

  * `inline_asm_multi` does not exist. It is in no version of `pliron-llvm`
    and nowhere in this repository -- this page is the only place the string
    appears. Same shape as the fictional `shuffle_xor_{f32,i32}` rows NVIDIA#815
    removed from the API quick reference.
  * `extractelement` is spelled `llvm.extract_element`.

Also notes that `llvm-export` contributes one op of its own, `llvm.dbg_value`,
which the surrounding prose did not mention, and that this table tracks an
upstream crate -- so it moves when the pin moves (as it did in NVIDIA#919), not
when this repository changes.

**dialect-nvvm: 123 -> 543.** This one is not a drift so much as a different
tree. Six of the twelve modules listed no longer exist: `thread` and `warp`
are gone (the warp ops are now split across `warp_shuffle`, `redux`, `vote`,
`warp_match`, `warp_barrier`, `active_mask` and `elect`), and `mbarrier`
split into `mbarrier_basic` and `mbarrier_extended`. The counts for those
that do exist are 4x-9x low: `tcgen05` is listed at 24 and has 210, `tma` at
15 and has 111. Eighteen modules are missing outright, including `sreg` at 44
ops.

Rewritten around the split `adding-new-intrinsics.md` already documents --
7 hand-written modules (18 ops) against 34 generated ones (525 ops, resolved
from 986 catalog entries) -- because that is what decides where a
contributor would add an op, and a table that says `warp` when the file is
`ops/generated/warp_shuffle.rs` sends them to the wrong place.

The per-module "Minimum SM / GPU Family" columns go with it. Those
requirements are per intrinsic, not per module, and the catalog already
records them: `intrinsics/generated-reference.md` renders the PTX version and
minimum SM for each of the 986 entries and is regenerated with the ops. The
page now points there instead of keeping a second copy by hand.

`crates/dialect-mir/README.md` carries its own copy of the operation
inventory, stale in the same way and by a different amount (it says 55, and
already had `set_discriminant` the book was missing). That is a separate
file with no overlap here and is fixed separately.

Verified: every count above recomputed from the tree; `just book`
(`sphinx-build -W --keep-going`) succeeds; check-book-api-names,
check-toolchain-parity and check-cli-doc-coverage all pass.

Signed-off-by: Vyncint Ng <[email protected]>
The page's own thesis is that unchecked hand counts drift. The LLVM
table got an "at the pinned pliron revision" stamp; give the
dialect-nvvm totals the equivalent anchor: the catalog SHA-256 that
every ops/generated/ file header prints. A reader can now tell at a
glance whether 543/41/986 describe the catalog they are looking at.
@nihalpasham nihalpasham added documentation Improvements or additions to documentation codegen Device code-generation pipeline (Rust MIR to IR to PTX) intrinsics Device intrinsics and libdevice math mappings labels Aug 17, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Recomputed every figure on the page at a766fc2 - all exact, including the 543/525/986 split.

One correction, and a commit layered for it:

Merging.

@nihalpasham
nihalpasham merged commit 0803381 into NVIDIA:main Aug 17, 2026
44 checks passed
nihalpasham added a commit that referenced this pull request Aug 18, 2026
…ted in #406 (#977)

* docs(mir-lower): the intrinsic converter table names two modules deleted in #406

`README.md`'s "GPU Intrinsic Converters (`convert/intrinsics/`)" table has 13
rows for a directory holding 24 modules. Two of the 13 do not exist:

  convert/intrinsics/stmatrix.rs   deleted in 6a9a637 (#406)
  convert/intrinsics/tcgen05.rs    deleted in 6a9a637 (#406)

Both were removed when "Generate CUDA intrinsics from pinned LLVM metadata"
moved those families onto the catalog path. The table still describes them as
hand-written converters with an "Inline PTX" strategy; `stmatrix` and
`tcgen05` are mentioned 460 times in `convert/generated_intrinsics.rs` today.
So a reader looking for where either is lowered is sent to a file that has not
existed for many releases. Same shape as #797, one crate over.

A third row, `generated_intrinsics`, is real but not in that directory -- it is
`convert/generated_intrinsics.rs`, one level up. That is the row most worth
getting right, since it is where nearly every intrinsic now goes.

Fourteen modules that do exist had no row at all: `asm`, `cp_async`,
`dotprod`, `execution_control`, `extended_minmax`, `integer_minmax`,
`ldmatrix`, `memory`, `packed`, `prmt`, `scalar_arithmetic`,
`scalar_conversion`, `scalar_math`, `wmma`. `integer_minmax` arrived last
batch with #967.

Rewritten as one row per file, with each description taken verbatim from that
module's own `//!` doc comment, so the table cannot drift from the code
without the doc comment drifting first. The "Strategy" and "GPU" columns are
dropped: they were per-module guesses at what are per-intrinsic properties,
and the catalog already records the PTX version and minimum SM for each,
rendered into `intrinsics/generated-reference.md` alongside the sources. The
page now points there instead of keeping a second copy by hand -- the same
treatment #964 gave the book's dialect-nvvm table.

The Core Modules table on the same page was short by four: the top-level
`type_conversion_interface`, `scalarize_block_args` and
`wgmma_deferred_accumulator`, plus `convert/enum_payload_storage`.

Verified by script: the converter table's rows are now exactly the set of
`.rs` files in `convert/intrinsics/` (24 and 24, no ghost and no missing), and
every top-level `src/*.rs` module and every `convert/*.rs` module has a row.

Signed-off-by: Vyncint Ng <[email protected]>

* docs(mir-lower): add the convert/type_interface_impls row

The Core Modules table listed convert/interface_impls but not its
type-conversion counterpart; description taken from the module's
own doc comment.

---------

Signed-off-by: Vyncint Ng <[email protected]>
Co-authored-by: nihalpasham <[email protected]>
nihalpasham pushed a commit that referenced this pull request Aug 18, 2026
… not exist (#978)

`README.md`'s "`terminator/intrinsics/` — GPU Intrinsics" table has 12 rows.
Only 7 name a module that exists; the other 5 were deleted:

  intrinsics/sync.rs      deleted in 6a9a637 (#406)
  intrinsics/cluster.rs   deleted in 6a9a637 (#406)
  intrinsics/tcgen05.rs   deleted in 6a9a637 (#406)
  intrinsics/clc.rs       deleted in 6a9a637 (#406)
  intrinsics/warp.rs      deleted in 4c1d583 (#833)

#406 moved those families onto the catalog path and #833 dropped the last of
them, so all five are handled by `generated.rs` today. Meanwhile eight modules
that do exist had no row: `asm`, `bigint`, `bitops`, `exact_div`,
`float_math`, `iket`, `layout`, `saturating`. Between the two, the table
describes a directory that has not existed for a long time -- and it is the
one place a contributor looks to find where an intrinsic is translated.

The book's `compiler/mir-importer.md` already describes the current model
correctly ("`intrinsics/catalog.json` has its arm generated into
... `generated.rs`", and "the `intrinsics/` modules beside the generated file
hold the cases the ..."), so this README was the last copy still on the old
one. Rewritten to match, one row per file, each description taken verbatim
from that module's own `//!` doc comment. The per-module "GPU" column is
dropped for the reason #964 dropped its equivalent: minimum-SM is a
per-intrinsic property the catalog already records and
`intrinsics/generated-reference.md` already renders.

Two smaller gaps on the same page:

* The `translator/` table was missing `layout`, `location` and
  `payload_store`.
* The Error Types table lists 7 of `PipelineError`'s 12 variants, missing
  `Optimization`, `TargetSelection`, `UnsupportedLinking`,
  `LibdeviceUnavailable` and `InvalidMirPassPipeline`. It also never says
  that `PipelineError` is defined in `cuda-oxide-codegen` and re-exported
  here, nor that the crate's own `TranslationErr` -- `Unsupported`,
  `TypeError`, `InvalidOp` -- is a different, narrower error. Both are now
  stated. (I first read this table against `error.rs` and thought every row
  was fictional; it is not. The variants are real, just defined a crate away.)

Verified by script against the tree, with no ghost and no missing row in any
of the three tables: the intrinsics table is now exactly the 15 files in
`terminator/intrinsics/`; the translator table exactly the 9 files in
`translator/` plus the `terminator` subdirectory it also lists; and the error
table exactly the 12 `PipelineError` variants.

Signed-off-by: Vyncint Ng <[email protected]>
nihalpasham pushed a commit that referenced this pull request Aug 18, 2026
…alidates (#969)

The obligation #964's merge comment attached to #946 landing. #946 has landed
(d485edb), and it was not the only batch member to move these numbers.

The page carries a self-invalidating stamp: "If the header stamp no longer
starts with `df42ef97`, the counts on this page predate the catalog you are
reading." Every `ops/generated/` header now prints `20440c06...`, so it does.

Recomputed from the tree at d485edb, with each delta attributed by
`git ls-tree` + `git show` per module rather than from a PR diff:

  generated/integer_minmax.rs   0 -> 8    new module (#967, DPX min/max)
  generated/packed_alu.rs      22 -> 30   f32x2 arithmetic (#946)
  ops/wgmma.rs                  6 -> 7    counted-K pipeline op (#935)

which moves five figures and adds a row:

  stamp                    df42ef97 -> 20440c06
  total                    543 across 41 modules -> 560 across 42
  hand-written             18 ops -> 19 (`wgmma` 6 -> 7)
  generated                34 modules / 525 ops / 986 catalog entries
                        -> 35 modules / 541 ops / 1002 catalog entries
  Packed (SIMD-in-reg)     43 -> 51
  Integer min/max (DPX)    new row, 8 -- `integer_minmax`

`integer_minmax` gets its own row rather than joining Scalar math beside
`extended_minmax`: six of its eight ops are `16x2` packed forms
(`max_s16x2`, `min_relu_s16x2`, ...) and two are scalar `s32`, so it is a
feature area rather than a scalar-math addition.

Checked and unchanged in the same pass: dialect-mir is still 62 ops across 12
modules with 9 types, and the `pliron` pin is still 8447aa42, so the LLVM
dialect's 69 stands.

**A correction to my own #964 while I am here.** That PR asserted #946 added
no ops, on the strength of `gh pr diff 946 | grep -c pliron_op` returning 0.
As the merge comment noted, `gh pr diff` returns empty on a diff that large,
so the grep was counting nothing rather than finding nothing -- an
unfalsifiable check that reads as a clean result. Every count in this commit
is derived from git objects in the tree instead.

Separately, the chapter's opening said cuda-oxide "works across three pliron
dialects ... two defined locally". Two more local pliron dialects exist and
the book never mentions either: `dialect-iket` (7 ops, 2 types) and
`dialect-ptx` (#917). The claim is now scoped to the lowering path, which is
what this chapter actually covers, with a pointer to the two crates' READMEs.
The same count appears in `pliron.md` and `architecture-overview.md`; those
are a separate change, and this one does not touch either file.

Verified: every figure on the page recomputed by script against the tree;
`just book` (`sphinx-build -W --keep-going`) succeeds; check-book-api-names
passes.

Signed-off-by: Vyncint Ng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Device code-generation pipeline (Rust MIR to IR to PTX) documentation Improvements or additions to documentation intrinsics Device intrinsics and libdevice math mappings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants