Skip to content

refactor(rocke): read gfx1250-only checks from target facts in both engines - #14040

Merged
cgmillette merged 3 commits into
developfrom
users/cgmillette/rocke/gfx1250-checks-from-facts
Oct 21, 2026
Merged

cgmillette merged 3 commits into
developfrom
users/cgmillette/rocke/gfx1250-checks-from-facts

Conversation

@cgmillette

Copy link
Copy Markdown
Contributor

Motivation

Both engines decided whether a target may use the tensor data mover, workgroup clusters, multicast loads, data prefetch, the split and named barriers and the scaled WMMA atoms by comparing the target's name with "gfx1250". The target's row in arch_specs.json already records these facts (memory.has_tdm, memory.has_cluster_launch, ...; the MMA catalog lists the scaled atoms), so a second target with the same features would be refused by code that never looks at them. Some of the checks were also spelled differently in the two engines: scaled WMMA was refused by name in C++ and by backend class in Python, with different messages.

Each check now reads one recorded fact, with the same rule and the same message in both engines.

ISSUE ID : AICK-2661

Technical Details

Three commits, grouped by area.

  1. Memory and control lowering
    • The LLVM-23-only operations are admitted by the fact that names their feature: memory.has_tdm (tensor load/store, s_wait_tensorcnt), memory.has_cluster_launch (cluster_dims, cluster id reads, cluster_barrier), memory.has_multicast_load (cluster_load, cluster_load_async_to_lds), memory.has_scalar_data_prefetch, memory.has_global_prefetch. Operations no flag records (split and named barriers, s_setreg, global_load_tr16_b128, global_store_async_from_lds) use target_family gfx12_cdna.
    • Python _OpTargetFact and C++ rocke_ll_target_fact_t name the facts; one shared C++ helper replaces three copies of the name check. The refusal reads "<op> requires a target with <fact>, got <target>" in both engines. The llvm23 requirement is unchanged.
  2. MMA catalog and scaled WMMA (LLVM)
    • The catalog loader admits the scaled-family declaration by its content on any row; scaled fragment shapes are registered from every catalog that lists the family.
    • A scaled op resolves to its operand contract through a target-free lookup over all catalogs (_mma_op_by_id / rocke_arch_mma_op_by_id), first hit in known-arch order like the existing op_id lookups.
    • LLVM lowering admits a scaled op on a target whose MMA catalog lists its atom. The Python emitter moves to the ISA backend base class so every backend applies the rule; both engines refuse with "<op> is not available on <target>: its MMA catalog does not list it".
  3. HIP lowering: the C++ HIP lowerer applies the catalog rule the Python HIP lowerer already used, with its message.

Only gfx1250 records these facts and lists these atoms, so every target accepts and refuses exactly what it did before and no emitted IR or HIP source changes.

Not changed: the inline-asm scalar controls (s_delay_alu, s_wait_alu, s_clause, s_wait_xcnt) record required_arch: "gfx1250" in the IR itself; expressing that as a fact would change the IR. The backend registries still map each target name to its backend, as for every target.

Test Plan

  • New test_target_fact_gates.py: every gated operation on every known target with both engines: identical IR where the target records the fact, the same refusal from both engines elsewhere. Also checks that each fact admits on some target and refuses on another, and lowers the scaled atoms to LLVM IR and to HIP on every known target with both engines.
  • Updated refusal messages in the gfx1250 cluster, multicast, prefetch, TDM and LLVM-bridge tests and in the C++ future_intrinsic_lowering cases.
  • test_arch_mma_ssot.py and C++ test_mma_catalog_lookup.cpp: the scaled-family declaration is accepted on another arch's row; the target-free lookup finds every catalog atom.
  • Byte identity at llvm20, llvm22, llvm23; ctest; full platform suite; pre-commit.

Test Result

  • All of the above pass.
  • Byte identity green at llvm20, llvm22 and llvm23; ctest passes; full platform suite passes with no failures; pre-commit passes.

Submission Checklist

🤖 Generated with Claude Code

cgmillette and others added 3 commits October 20, 2026 13:29
…facts

Both engines refused the tensor data mover, workgroup-cluster, multicast,
data-prefetch, split and named barrier, s_setreg, transposed global load and
asynchronous LDS-to-global store operations unless the target's name was
gfx1250. They now read the fact the target's row records instead:

- memory.has_tdm: tensor_load_to_lds, tensor_store_from_lds, s_wait_tensorcnt
- memory.has_cluster_launch: cluster_dims, the cluster id reads, cluster_barrier
- memory.has_multicast_load: cluster_load, cluster_load_async_to_lds
- memory.has_scalar_data_prefetch: s_prefetch_data, s_buffer_prefetch_data
- memory.has_global_prefetch: global_prefetch, flat_prefetch
- target_family gfx12_cdna: the split and named barriers, s_setreg,
  global_load_tr16_b128, global_store_async_from_lds (no flag records these)

The Python engine names the facts in _OpTargetFact and the C++ engine in
rocke_ll_target_fact_t; one shared C++ helper replaces the three copies of the
name check. The refusal now reads "<op> requires a target with <fact>, got
<target>", identically in both engines. The llvm23 flavor requirement is
unchanged. Every target that lowered these operations still does, so no
emitted IR changes.

A new test lowers each operation on every known target with both engines:
targets that record the fact must produce identical IR, all others must be
refused by both with the same message.

Co-Authored-By: Claude <noreply@anthropic.com>
… a target name

The scaled WMMA (SCALE/SCALE16) support read gfx1250's row by name in four
places. Each now reads the catalog data instead:

- The MMA row loader admits the scaled-family declaration by its content on
  any arch's row; it only accepted it on gfx1250's.
- Scaled fragment shapes are registered for the family's atoms in every
  arch's catalog, not only gfx1250's.
- An op_id resolves to its scaled operand contract through a target-free
  lookup over all catalogs (_mma_op_by_id in Python, rocke_arch_mma_op_by_id
  in C++), first hit in known-arch order, as the existing op_id lookups do.
- LLVM lowering admits a scaled WMMA op on a target whose MMA catalog lists
  its atom. The C++ engine checked the target name; the Python engine only
  reached the emitter through the gfx1250 backend class. The emitter moves to
  the ISA backend base class and both engines refuse with the same message,
  "<op> is not available on <target>: its MMA catalog does not list it".

Only gfx1250 lists these atoms today, so no emitted IR changes. Tests cover
the declaration on another arch's row, the target-free lookup in both engines,
and scaled WMMA lowering on every known target with both engines.

Co-Authored-By: Claude <noreply@anthropic.com>
The C++ HIP lowerer refused a scaled WMMA op unless the target's name was
gfx1250, while the Python HIP lowerer already asked whether the target's MMA
catalog lists the atom. The C++ lowerer now applies the catalog rule too and
refuses with the Python message, so both engines admit and refuse the same
targets with the same text. Only gfx1250 lists these atoms, so the emitted
HIP source does not change.

A test lowers the scaled atoms to HIP on every known target with both
engines.

Co-Authored-By: Claude <noreply@anthropic.com>
@cgmillette
cgmillette requested a review from a team as a code owner October 20, 2026 17:58
@therock-pr-bot

therock-pr-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ✅ Pass —
🔎 pre-commit ✅ Pass —
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —
🤖 therock-pr-bot ✅ Pass —

🎉 All checks passed! This PR is ready for review.

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

Copy link
Copy Markdown

🎉 All checks passed! This PR is ready for review.

@CongMa13 CongMa13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new issues found.

@CongMa13 CongMa13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new P0 or P1 issues were identified during this review. The changes are approved.

@cgmillette
cgmillette merged commit c09edd8 into develop Oct 21, 2026
201 of 211 checks passed
@cgmillette
cgmillette deleted the users/cgmillette/rocke/gfx1250-checks-from-facts branch October 21, 2026 02:35
@assistant-librarian

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants