Skip to content

Canonical variant lists assign ABI IDs by position, which conflicts with the append-only ledger #604

Closed

Description

@honeyspoon

Summary

A family's canonical variant list assigns ABI IDs sequentially by list position, but intrinsics/abi-v1.toml is globally append-only. Once a later family consumes the ID that follows a family's block, that family can no longer be extended — the two invariants conflict and there is no way to satisfy both.

Reproduction

Adding one verified-lowering variant to scalar_math (f16 ex2.approx):

  1. ScalarMathFormat gains F16 (it is {F32, F64} today), plus the six match arms the compiler identifies.
  2. canonical_scalar_math_variants() gains (F16, Ex2, Approx, Preserve).
  3. intrinsics/overlay/scalar_math.toml gains the matching [[scalar_math.variant]].

Then:

error: ex2_approx_f16 must reserve ABI ID i0822

i0822 follows i0821, the last scalar_math variant. But it is already taken:

abi_id = "i0822"
catalog_id = "cvt_rn_satfinite_e4m3x2_f16x2"
operation_key = "packed.convert.f16x2.e4m3x2.nearest_even.satfinite"

packed_conversion claimed i0822–i0829 afterwards, closing scalar_math's block. Using the next globally free ID instead (i0830) fails the other check, since the expansion derives the expected ID from list position.

So the addition is blocked in both directions, and not by anything about the intrinsic itself: llvm.nvvm.ex2.approx.f16 lowers cleanly to ex2.approx.f16 under the pinned llc (LLVM 22.1.2-rust), verified by probe.

Why it will keep happening

This is structural, not specific to scalar_math. Every family with a canonical N variants assertion has the same coupling, so any family whose ID block has been closed off by a later family is now frozen. The more families are added, the more get frozen.

It currently blocks at least these verified-lowering additions (each probed with llc on nightly-2026-04-03, instruction confirmed in the emitted PTX):

intrinsic emits
llvm.nvvm.ex2.approx.f16 ex2.approx.f16
llvm.nvvm.bmsk.clamp / .wrap bmsk.clamp.b32 / bmsk.wrap.b32
llvm.nvvm.fns fns.b32
llvm.nvvm.f2f16.rn / .rn.relu cvt.rn.f16.f32 / cvt.rn.relu.f16.f32
llvm.nvvm.f2bf16.rn / .rn.relu cvt.rn.bf16.f32 / cvt.rn.relu.bf16.f32

(The .satfinite siblings of those conversions, and ex2.approx.f16x2, cannot be selected by the same llc, so they are correctly absent — the canonical lists' curation is doing real work, which is why I would rather extend the mechanism than bypass it.)

Possible directions

  1. Reserve ID blocks per family with headroom, so later additions have space.
  2. Decouple ID assignment from list position — let a family's variants carry non-contiguous IDs, which is what an append-only ledger naturally produces. The expansion would read the ID from the overlay entry rather than deriving it.

(2) looks less invasive and matches the ledger's existing semantics, but it touches the admission checks for every compact family, so I did not want to pick without input.

Happy to implement whichever you prefer.

Activity

  1. added
    bug
    intrinsics
    build-related
    on Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbuild-relatedintrinsics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions