Skip to content
Merged
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
95634a2
feat(ingestor): gfx942 dense attention engine manifest and selection
AnaghaRaoAMD Oct 22, 2026
b385c60
feat(hip-kernel-provider): add hipkernel:Gfx942AttentionDense ingesto…
AnaghaRaoAMD Oct 22, 2026
10b4ca5
test(hip-kernel-provider): gfx942 dense attention device test and ful…
AnaghaRaoAMD Oct 22, 2026
297043f
test(integration-tests): claim SdpaFwd support for hipkernel:Gfx942At…
AnaghaRaoAMD Oct 22, 2026
e18262d
fix(ingestor-gen): read current winner-cache shards in variant_reduce
AnaghaRaoAMD Oct 23, 2026
5d509e9
feat(hip-kernel-provider): reduce hipkernel:Gfx942AttentionDense to 1…
AnaghaRaoAMD Oct 23, 2026
fedcc30
style: apply pinned clang-format and black to the gfx942 dense engine…
AnaghaRaoAMD Nov 2, 2026
b892825
Merge origin/develop into users/anarao/gfx942-dense-aot
AnaghaRaoAMD Nov 2, 2026
296636e
fix(hip-kernel-provider): adapt gfx942 dense engine to develop's left…
AnaghaRaoAMD Nov 2, 2026
a0ae5b5
fix(rocke,hip-kernel-provider): pin gfx942 dense AOT kernels to the q…
AnaghaRaoAMD Nov 2, 2026
6694b28
fix(hip-kernel-provider): clear clang-tidy errors in the gfx942 dense…
AnaghaRaoAMD Nov 3, 2026
ca281cc
Merge origin/develop into users/anarao/gfx942-dense-aot
AnaghaRaoAMD Nov 3, 2026
e72d184
fix(hip-kernel-provider): decline ragged and empty-row SDPA graphs in…
AnaghaRaoAMD Nov 3, 2026
1d1b6c0
fix(rocke): scope the grid knobs out of gfx942_dense_qbminor
AnaghaRaoAMD Nov 3, 2026
b224b2d
test(ingestor-gen): gate the gfx942 manifest, selection and descripto…
AnaghaRaoAMD Nov 3, 2026
94df1bc
Merge origin/develop into users/anarao/gfx942-dense-aot
AnaghaRaoAMD Nov 3, 2026
00c3447
fix(rocke): refuse gfx942 dense windows that leave query rows no key
AnaghaRaoAMD Nov 3, 2026
c4dba6c
test(ingestor-gen): derive the shipped bundles from the engine manifests
AnaghaRaoAMD Nov 3, 2026
22a8467
chore: tidy the round-2 review follow-ups
AnaghaRaoAMD Nov 3, 2026
f67b8cb
fix(hip-kernel-provider): expose lds_row_pad and pv_priority as gfx94…
AnaghaRaoAMD Nov 3, 2026
98069a0
refactor(hip-kernel-provider): share one dense attention pack between…
AnaghaRaoAMD Nov 3, 2026
d25e374
feat(hip-kernel-provider): serve SdpaFwd stats (LSE) on hipkernel:Gfx…
AnaghaRaoAMD Nov 3, 2026
090ef13
test(integration-tests): BSHD SdpaFwd stats bundles for hipkernel:Gfx…
AnaghaRaoAMD Nov 3, 2026
1c85825
feat(hip-kernel-provider): persistent D128 and grid block orders for …
AnaghaRaoAMD Nov 4, 2026
cde4c65
feat(hip-kernel-provider): expose the gfx942 dense body levers and ra…
AnaghaRaoAMD Nov 4, 2026
fb7582b
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 4, 2026
42ed6fe
fix(integration-tests): list the dense stats bundles in the BSHD refe…
AnaghaRaoAMD Nov 4, 2026
21270e5
refactor(hip-kernel-provider): read dense attention graphs through Sd…
AnaghaRaoAMD Nov 4, 2026
90a6352
fix(hip-kernel-provider): decline non-float SDPA compute types in the…
AnaghaRaoAMD Nov 4, 2026
36e418b
test(hip-kernel-provider): share the dense attention unit suites acro…
AnaghaRaoAMD Nov 4, 2026
9711c3e
test(hip-kernel-provider): run a top-left window whose last query row…
AnaghaRaoAMD Nov 4, 2026
0db339c
test(rocke): pin every gfx942 dense candidate as opt-in
AnaghaRaoAMD Nov 4, 2026
9dee6cb
fix(ingestor-gen): carry a per-arm policy resolution in the compact s…
AnaghaRaoAMD Nov 4, 2026
645da43
feat(hip-kernel-provider): ship the swept 224-kernel gfx942 dense att…
AnaghaRaoAMD Nov 4, 2026
6fcccc2
test(hip-kernel-provider): run every shipped gfx942 dense kernel in t…
AnaghaRaoAMD Nov 4, 2026
07611be
test(hip-kernel-provider): freeze the gfx942 dense saved-plan contrac…
AnaghaRaoAMD Nov 4, 2026
513cd87
docs(hip-kernel-provider): align the dense decline reasons and record…
AnaghaRaoAMD Nov 5, 2026
d76162b
test(ingestor-gen): keep #14242's unified census files out of the reg…
AnaghaRaoAMD Nov 5, 2026
274669b
style(ingestor-gen): black-format the registry regeneration gates
AnaghaRaoAMD Nov 5, 2026
5f764cc
fix(hip-kernel-provider): keep packModuleCacheEntries const-clean wit…
AnaghaRaoAMD Nov 5, 2026
e230caa
refactor(hip-kernel-provider): one SDPA shape, reader and compute-typ…
AnaghaRaoAMD Nov 5, 2026
b8c5964
test(hip-kernel-provider): pin the persistent fast-division dividend …
AnaghaRaoAMD Nov 5, 2026
a4c41e3
test(hip-kernel-provider): share the dense attention test graph build…
AnaghaRaoAMD Nov 5, 2026
809b374
test(hip-kernel-provider): share the dense knob suites' fixture and d…
AnaghaRaoAMD Nov 5, 2026
053764d
docs(rocke): list all five gfx942 dense attention candidates
AnaghaRaoAMD Nov 5, 2026
40c5c7b
test(hip-kernel-provider): bind the manifest's rocKE before rendering…
AnaghaRaoAMD Nov 5, 2026
5576283
test(hip-kernel-provider): name the knob suites' graph description In…
AnaghaRaoAMD Nov 5, 2026
4683cb4
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 5, 2026
0b2202f
test(ingestor-gen): skip the unified 2D manifest's stale launch surface
AnaghaRaoAMD Nov 5, 2026
1b7440a
fix(rocke): keep the gfx942 ingestor candidates on the grid they pin
AnaghaRaoAMD Nov 5, 2026
30ca2ac
fix(hip-kernel-provider): bound the gfx942 dense attention scale to […
AnaghaRaoAMD Nov 5, 2026
3dfa417
test(hip-kernel-provider): run the gfx942 stats bundles in the extern…
AnaghaRaoAMD Nov 5, 2026
1a9aa6c
fix(ingestor-gen): record the pin that supplied each enumerated spec
AnaghaRaoAMD Nov 5, 2026
cafc5de
test(ingestor-gen): load the dense golden generators through bind_pro…
AnaghaRaoAMD Nov 5, 2026
57ba99c
test(ingestor-gen): report the manifests the bundle gates cannot pass…
AnaghaRaoAMD Nov 5, 2026
bfdd6ea
refactor(hip-kernel-provider): one scale range for both dense attenti…
AnaghaRaoAMD Nov 6, 2026
6c69c25
fix(rocke): check the dense attention scale range in the gfx942 runne…
AnaghaRaoAMD Nov 6, 2026
6b1d376
refactor(rocke): split KV in the gfx942 tuned default, not in the spe…
AnaghaRaoAMD Nov 6, 2026
90b1b02
test(hip-kernel-provider): define the SdpaFwd bundle filters once
AnaghaRaoAMD Nov 6, 2026
adeba44
refactor(ingestor-gen): give the score-golden generator a public enum…
AnaghaRaoAMD Nov 6, 2026
639e197
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 6, 2026
53df1bb
test(ingestor-gen): list #14259's hand-formatted census test as a kno…
AnaghaRaoAMD Nov 6, 2026
050ccfd
fix(hip-kernel-provider): apply the dense saved-plan refusals on both…
AnaghaRaoAMD Nov 6, 2026
0f773b7
refactor(rocke): public names for the gfx942 dense cfvst and exp2 pol…
AnaghaRaoAMD Nov 6, 2026
e5db957
fix(ingestor-gen): refuse base_spec for sections that reshape their c…
AnaghaRaoAMD Nov 6, 2026
4d9064f
test(rocke): pin the gfx942 tuned default's no-split rule for sinks a…
AnaghaRaoAMD Nov 6, 2026
7c32457
test(hip-kernel-provider): guard the SdpaFwd bundle filters
AnaghaRaoAMD Nov 6, 2026
f6343a9
refactor(rocke): one home for the dense KV-split rule
AnaghaRaoAMD Nov 6, 2026
1eaf329
docs(hip-kernel-provider): state the dense saved-launch rules once
AnaghaRaoAMD Nov 6, 2026
01de338
docs(integration-tests): describe the hip-kernel-provider lane filter…
AnaghaRaoAMD Nov 6, 2026
02f1ed6
test(rocke): run the dense scale and key-less-window tests in CI
AnaghaRaoAMD Nov 6, 2026
fec2a79
docs: describe the shared dense scale check and the arch hooks as the…
AnaghaRaoAMD Nov 6, 2026
a70e6d0
fix(ingestor-gen): emit the census test's long lines as clang-format …
AnaghaRaoAMD Nov 6, 2026
16d6004
test(hip-kernel-provider): run the gfx942 Unified3d knob suite on the…
AnaghaRaoAMD Nov 6, 2026
ccdda14
refactor(hip-kernel-provider): register the engine-pinned attention e…
AnaghaRaoAMD Nov 6, 2026
9076359
refactor(hip-kernel-provider): drive census, knob suites and filter t…
AnaghaRaoAMD Nov 6, 2026
23ee321
test(hip-kernel-provider): one home for the unit-test SDPA layouts an…
AnaghaRaoAMD Nov 6, 2026
b178943
test(hip-kernel-provider): share the SDPA test strides with the integ…
AnaghaRaoAMD Nov 6, 2026
2a1516b
test(hip-kernel-provider): fail on a mistyped attention engine table …
AnaghaRaoAMD Nov 6, 2026
f21b18f
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 6, 2026
a411a13
refactor(hip-kernel-provider): register the dgrad census like the att…
AnaghaRaoAMD Nov 6, 2026
00846da
test(hip-kernel-provider): run the gfx942 dense knob rows in the comp…
AnaghaRaoAMD Nov 6, 2026
5ff1ff3
test(hip-kernel-provider): check the knob suites' engines against the…
AnaghaRaoAMD Nov 6, 2026
e8a73bc
test(rocke): cover the ragged and varlen KV-split clauses
AnaghaRaoAMD Nov 6, 2026
3b5cd4d
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 6, 2026
13dd161
Merge remote-tracking branch 'origin/develop' into users/anarao/gfx94…
AnaghaRaoAMD Nov 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dnn-providers/hip-kernel-provider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ if(HIPKERNELPROVIDER_ENABLE_TESTS)
set(HIPKERNELPROVIDER_ASM_SDPA_INTEGRATION_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/ASM_SDPA_ENGINE_test_categories_integration.yaml")
set(HIPKERNELPROVIDER_GFX950_ATTENTION_INTEGRATION_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/hipkernel_Gfx950Attention_test_categories_integration.yaml")
set(HIPKERNELPROVIDER_GFX942_ATTENTION_UNIFIED_3D_INTEGRATION_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/hipkernel_Gfx942AttentionUnified3d_test_categories_integration.yaml")
set(HIPKERNELPROVIDER_GFX942_ATTENTION_DENSE_INTEGRATION_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/hipkernel_Gfx942AttentionDense_test_categories_integration.yaml")
set(ROCKE_ENGINE_CTEST_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/ROCKE_ENGINE_test_categories_external.yaml")
set(HKP_PACK_CTEST_CATEGORIES_YAML "${CMAKE_CURRENT_SOURCE_DIR}/HKP_PACK_test_categories_external.yaml")
set(HIPKERNELPROVIDER_CTEST_INSTALL_FILE "")
Expand All @@ -493,6 +494,7 @@ if(HIPKERNELPROVIDER_ENABLE_TESTS)
AND EXISTS "${HIPKERNELPROVIDER_ASM_SDPA_INTEGRATION_CATEGORIES_YAML}"
AND EXISTS "${HIPKERNELPROVIDER_GFX950_ATTENTION_INTEGRATION_CATEGORIES_YAML}"
AND EXISTS "${HIPKERNELPROVIDER_GFX942_ATTENTION_UNIFIED_3D_INTEGRATION_CATEGORIES_YAML}"
AND EXISTS "${HIPKERNELPROVIDER_GFX942_ATTENTION_DENSE_INTEGRATION_CATEGORIES_YAML}"
AND EXISTS "${ROCKE_ENGINE_CTEST_CATEGORIES_YAML}"
AND EXISTS "${ROCM_LIBRARIES_ROOT}/shared/ctest/TestCategories.cmake")
include("${ROCM_LIBRARIES_ROOT}/shared/ctest/TestCategories.cmake")
Expand All @@ -503,6 +505,7 @@ if(HIPKERNELPROVIDER_ENABLE_TESTS)
"${HIPKERNELPROVIDER_ASM_SDPA_INTEGRATION_CATEGORIES_YAML}"
"${HIPKERNELPROVIDER_GFX950_ATTENTION_INTEGRATION_CATEGORIES_YAML}"
"${HIPKERNELPROVIDER_GFX942_ATTENTION_UNIFIED_3D_INTEGRATION_CATEGORIES_YAML}"
"${HIPKERNELPROVIDER_GFX942_ATTENTION_DENSE_INTEGRATION_CATEGORIES_YAML}"
"${ROCKE_ENGINE_CTEST_CATEGORIES_YAML}"
"${HIPKERNELPROVIDER_CTEST_CATEGORIES_YAML}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@
# See https://github.com/ROCm/rocm-libraries/issues/8852 for background on the
# category execution model.
# Tier behaviour (cumulative — each tier is a superset of the ones below it):
# - quick: run non-Full tests only.
# - quick: run tests with neither a Comprehensive* nor a Full* prefix.
# - standard: quick coverage (quick tests). No distinct Standard* prefix
# exists, so standard runs the same non-Full tests as quick.
# - comprehensive: standard + quick coverage. No distinct Comprehensive*
# prefix exists, so comprehensive runs the same non-Full tests as standard.
# exists, so standard runs the same tests as quick.
# - comprehensive: standard + quick coverage, plus Comprehensive*
# parameterised expansions.
# - full: all tests (non-Full + Full* parameterised expansions), excluding
# only disabled tests.
#
# Neither the unit tests in tests/ nor the ASM SDPA / rocKE-client integration
# tests in integration_tests/ currently use a Full*/Standard*/Comprehensive*
# GTest prefix, so all four tiers below run the same coverage until a suite
# adopts one of those prefixes (matching miopen-provider's convention).
# Comprehensive* and Full* are GTest instantiation prefixes (matching
# miopen-provider's convention): the gfx942 dense attention knob suite's
# per-kernel rows are Comprehensive/, and FlyDSL's every-object cases Full/.
#
# These categories apply to hip_kernel_provider_tests and
# hip_kernel_provider_integration_tests. The external hipdnn_integration_tests
Expand All @@ -33,31 +32,33 @@
# GTest naming conventions.
test_categories:
quick:
description: "Fast sanity checks (target: < 5 min) - excludes Full* parameterised expansions"
description: "Fast sanity checks (target: < 5 min) - excludes Comprehensive* and Full* parameterised expansions"
test_patterns:
- "*"
exclude:
- "*DISABLED*"
- "Comprehensive*"
- "Full*"
labels:
- "quick"
- "pre-commit"
- "smoke"

standard:
description: "Pre-checkin validation (cumulative: runs quick coverage) - excludes Full* parameterised expansions"
description: "Pre-checkin validation (cumulative: runs quick coverage) - excludes Comprehensive* and Full* parameterised expansions"
test_patterns:
- "*"
exclude:
- "*DISABLED*"
- "Comprehensive*"
- "Full*"
labels:
- "standard"
- "pr"
- "precheckin"

comprehensive:
description: "Nightly comprehensive validation (cumulative: runs standard + quick coverage) - excludes Full* parameterised expansions"
description: "Nightly comprehensive validation (cumulative: runs standard + quick coverage, plus Comprehensive*) - excludes Full* parameterised expansions"
test_patterns:
- "*"
exclude:
Expand All @@ -84,6 +85,7 @@ test_categories:
- "*"
exclude:
- "*DISABLED*"
- "Comprehensive*"
- "Full*"
labels:
- "ffm-quick"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Integration test configuration for hipkernel:Gfx942AttentionDense
# Filters use GTest-style globs: * matches any sequence of characters

[meta]
version = 1

# All bundles for this engine are forward-only dense SDPA on gfx942.
# No tolerance overrides needed: the forward pass uses the common SdpaAttributes
# tolerance (tol::sdpa::getToleranceFwd<T>()). That includes the FP32 stats (LSE) output
# of the dense BSHD stats bundles, graded at getToleranceFwd<float>() = 1e-5; the knob
# suite measures the LSE against the CPU reference at under 4e-6 absolute.
#
# No [[test_skips]] entry: the engine's packs arch-prune before the matcher, so a
# non-gfx942 device declines through the ordinary path. An entry cannot express
# "skip everywhere except gfx942" -- the schema has no negation, and an empty
# `archs` list means EVERY arch (TestSettings.hpp: `entry.archs.empty() || ...`),
# so a skip written that way would silence gfx942 too.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,12 @@ too. Two answers decide which engine-pinned tests are registered:

- **Per-arch registrations** (the census, and the external and gpu_ref integration
checks) install into a gfx-specific shard and are gated on
`hkp_gfx950_attention_dense_available()`, which reads what the shard for that arch
ships.
- **Host-side sources that pin an engine**, such as the gfx950 knobs suite, are gated on
`hkp_product_offers_engine()`, which reads what the product root carries for any arch
under this build's filters. It never reads `GPU_TARGETS`: the host libraries and
`hkp_product_ships_engine_for_arch()`, which reads what the shard for that arch
ships. The single-arch rocKE attention engines pinned against the SdpaFwd bundles
are registered from one table, `HKP_PINNED_ATTENTION_ENGINES` in `src/CMakeLists.txt`.
- **Host-side sources that pin an engine**, such as the attention knob suites, are gated
on `hkp_product_offers_engine()`, which reads what the product root carries for any
arch under this build's filters. It never reads `GPU_TARGETS`: the host libraries and
tests must work with another build's arch content.

A probe that cannot answer leaves the root wired, so the packer reports what is wrong
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1407,24 +1407,6 @@ function(hkp_product_ships_engine_for_arch out_var engine arch)
endif()
endfunction()

# ---------------------------------------------------------------------------
# hkp_gfx950_attention_dense_available(<out>)
# hkp_product_ships_engine_for_arch() for hipkernel:Gfx950AttentionDense on gfx950.
# ---------------------------------------------------------------------------
function(hkp_gfx950_attention_dense_available out_var)
hkp_product_ships_engine_for_arch(_available "hipkernel:Gfx950AttentionDense" gfx950)
set(${out_var} "${_available}" PARENT_SCOPE)
endfunction()

# ---------------------------------------------------------------------------
# hkp_gfx942_attention_unified_3d_available(<out>)
# hkp_product_ships_engine_for_arch() for hipkernel:Gfx942AttentionUnified3d on gfx942.
# ---------------------------------------------------------------------------
function(hkp_gfx942_attention_unified_3d_available out_var)
hkp_product_ships_engine_for_arch(_available "hipkernel:Gfx942AttentionUnified3d" gfx942)
set(${out_var} "${_available}" PARENT_SCOPE)
endfunction()

# ---------------------------------------------------------------------------
# hkp_product_offers_engine(<out_var> <engine>)
# TRUE when the `product` root, under this build's excluded folders and disabled
Expand All @@ -1433,7 +1415,7 @@ endfunction()
# Arch-agnostic: it reads what the root offers, never GPU_TARGETS, because it gates
# host and test content outside the arch content, which must work with another build's
# arch content. Registrations that ship in a per-arch shard use
# hkp_gfx950_attention_dense_available() instead.
# hkp_product_ships_engine_for_arch() instead.
#
# FALSE when `product` is neither wired nor recorded dormant, and when it was never
# probed (an empty root). A probe that could not answer reads as
Expand Down Expand Up @@ -1465,16 +1447,6 @@ function(hkp_product_offers_engine out_var engine)
endif()
endfunction()

# ---------------------------------------------------------------------------
# hkp_gfx950_conv_dgrad_aot_available(<out>)
# The same predicate for the shape-generic AOT-instance backward-data engine,
# hipkernel:Gfx950ConvDgradAot, which ships its own bundle (the `product` root).
# ---------------------------------------------------------------------------
function(hkp_gfx950_conv_dgrad_aot_available out_var)
hkp_product_ships_engine_for_arch(_ships "hipkernel:Gfx950ConvDgradAot" gfx950)
set(${out_var} "${_ships}" PARENT_SCOPE)
endfunction()

# ---------------------------------------------------------------------------
# _hkp_resolve_rocke_args(out_args out_comgr_lib)
# Resolve the rocKE toolchain once and return the keyword list every pack target is
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
"""The attention engines' bundle selection agrees between CMake and the category YAMLs.

Each HKP_PINNED_ATTENTION_ENGINES row in src/CMakeLists.txt names the GTEST_FILTER
variable its engine's external integration check (and GPU-reference target in
src/integration_tests/) passes, and the ../CMakeLists.txt variable holding its
hipkernel_*_test_categories_integration.yaml, from which the check's CTest suites take
theirs under YAML categorization, one per category. Both must name the same bundles, so
editing one without the other fails here. Rows sharing a YAML must share a filter, and
every attention categories YAML must be some row's. Each attention knob suite in
src/integration_tests/CMakeLists.txt pins engines the table names.

A pattern is "<tier>_<bundle>", <tier> one of the four bundle tier directories or "*"
for all of them. Each category selects every bundle the CMake filter does at each tier
it runs, and the categories together run every tier the CMake filter does.
Excludes are not compared: the CMake filters have none, and the YAMLs' (DISABLED,
SdpaBackward) reach no SdpaFwd bundle.
"""

import re
from pathlib import Path

import pytest
import yaml

pytestmark = pytest.mark.quick

PROVIDER = Path(__file__).resolve().parents[2]
PROVIDER_CMAKE = PROVIDER / "CMakeLists.txt"
SRC_CMAKE = PROVIDER / "src/CMakeLists.txt"
INTEGRATION_CMAKE = PROVIDER / "src/integration_tests/CMakeLists.txt"
KNOB_SUITES_DIR = PROVIDER / "src/integration_tests/kernel_ingestor_engine"
PACKS = PROVIDER / "src/tests/engines/kernel_ingestor_engine/packs"
TABLE = "HKP_PINNED_ATTENTION_ENGINES"
ROW_FIELDS = 6


def pinned_engines():
"""The table's rows: arch, slug, engine, filter, TOML, categories YAML variable."""
text = SRC_CMAKE.read_text(encoding="utf-8")
calls = re.findall(rf"\bset\(\s*{TABLE}\s([^)]*)\)", text)
assert len(calls) == 1, f"{SRC_CMAKE}: {TABLE} set {len(calls)} times"
fields = re.sub(r"#[^\n]*", "", calls[0]).split()
assert (
fields and len(fields) % ROW_FIELDS == 0
), f"{SRC_CMAKE}: {TABLE} has {len(fields)} fields, not rows of {ROW_FIELDS}"
return [fields[i : i + ROW_FIELDS] for i in range(0, len(fields), ROW_FIELDS)]


def categories_yaml(var):
"""The file name ../CMakeLists.txt sets `var` to."""
text = PROVIDER_CMAKE.read_text(encoding="utf-8")
names = re.findall(
rf'\bset\(\s*{var}\s+"\$\{{CMAKE_CURRENT_SOURCE_DIR\}}/([^"/]+)"\s*\)', text
)
assert len(names) == 1, f"{PROVIDER_CMAKE}: {var} set {len(names)} times"
return names[0]


def yaml_filters():
"""{categories YAML: {filter variables of the rows naming it}}."""
pairs = {}
for *_, filter_var, _toml, yaml_var in pinned_engines():
pairs.setdefault(categories_yaml(yaml_var), set()).add(filter_var)
return pairs


PINNED = yaml_filters()

TIERS = ("quick", "standard", "comprehensive", "full")
TIERED = re.compile(r"(?P<tier>quick|standard|comprehensive|full|\*)_(?P<bundle>.+)")


def cmake_filter(name):
"""`name`'s value as src/CMakeLists.txt defines it, ${...} references expanded."""
text = SRC_CMAKE.read_text(encoding="utf-8")
# set(<var> "<arg>"...) or string(JOIN "<glue>" <var> "<arg>"...).
calls = re.findall(
rf'\b(?:set|string)\(\s*(?:JOIN\s+"([^"]*)"\s+)?{name}\s([^)]*)\)', text
)
assert len(calls) == 1, f"{SRC_CMAKE}: {name} defined {len(calls)} times"
glue, args = calls[0]
# A set() list reaches --gtest_filter ':'-joined, as string(JOIN ":") does.
value = (glue or ":").join(re.findall(r'"([^"]*)"', args))
return re.sub(r"\$\{(\w+)\}", lambda ref: cmake_filter(ref[1]), value)


def selection(patterns, where):
"""{(tier, bundle)} the positive gtest `patterns` select; a "*" tier is all four."""
pairs = set()
for pattern in patterns:
match = TIERED.fullmatch(pattern)
assert match, f"{where}: {pattern!r} has no tier prefix ({', '.join(TIERS)}, *)"
tiers = TIERS if match["tier"] == "*" else (match["tier"],)
pairs.update((tier, match["bundle"]) for tier in tiers)
return pairs


@pytest.mark.parametrize("row", pinned_engines(), ids=lambda row: f"{row[0]}_{row[1]}")
def test_each_row_names_an_arch_its_toml_and_its_packs_suite(row):
"""A misspelt arch or engine local name ships nothing for the row, so its census,
external integration check and GPU-reference target drop out silently; fail here."""
arch, _slug, local, _filter_var, toml, _yaml_var = row
assert re.fullmatch(r"gfx[0-9a-f]+", arch), f"{SRC_CMAKE}: {TABLE} arch {arch!r}"
config = PROVIDER / "config" / toml
assert config.is_file(), f"{SRC_CMAKE}: {TABLE} {local}: no {config}"
suite = PACKS / f"Test{local}Packs.cpp"
assert suite.is_file(), f"{SRC_CMAKE}: {TABLE} {local}: no {suite}"
# The census keys its expected inventory by arch, so a wrong arch pins none.
assert f'{{"{arch}",' in suite.read_text(
encoding="utf-8"
), f"{SRC_CMAKE}: {TABLE} {local}: {suite.name} pins no {arch} inventory"


def knob_suites():
"""The _knob_suites rows of src/integration_tests/CMakeLists.txt: (source, engines)."""
text = INTEGRATION_CMAKE.read_text(encoding="utf-8")
calls = re.findall(r"\bset\(\s*_knob_suites\s([^)]*)\)", text)
assert len(calls) == 1, f"{INTEGRATION_CMAKE}: _knob_suites set {len(calls)} times"
fields = re.sub(r"#[^\n]*", "", calls[0]).split()
assert (
fields and len(fields) % 2 == 0
), f"{INTEGRATION_CMAKE}: _knob_suites {fields}"
return [(fields[i], fields[i + 1].split(",")) for i in range(0, len(fields), 2)]


@pytest.mark.parametrize(
"source, engines",
[pytest.param(source, engines, id=source) for source, engines in knob_suites()],
)
def test_each_knob_suite_pins_engines_the_table_names(source, engines):
"""A misspelt engine is offered by no product, so its suite compiles silently out."""
assert (KNOB_SUITES_DIR / source).is_file(), f"{INTEGRATION_CMAKE}: no {source}"
pinned = {local for _arch, _slug, local, *_ in pinned_engines()}
unknown = sorted(set(engines) - pinned)
assert not unknown, f"{INTEGRATION_CMAKE}: {source} pins {unknown}, not in {TABLE}"


def test_rows_sharing_a_categories_yaml_share_a_filter():
"""One YAML selects one set of bundles, so it can agree with one filter only."""
shared = {
name: sorted(filters) for name, filters in PINNED.items() if len(filters) > 1
}
assert not shared, f"{SRC_CMAKE}: {TABLE} rows pair a YAML with filters {shared}"


def test_every_attention_category_yaml_is_compared():
"""A new attention engine's YAML is checked against its filter, not skipped."""
found = {
path.name
for path in PROVIDER.glob("hipkernel_*Attention*_test_categories_*.yaml")
}
assert found == set(PINNED)


@pytest.mark.parametrize(
"yaml_name, name",
sorted((yaml_name, name) for yaml_name, names in PINNED.items() for name in names),
)
def test_categories_select_the_cmake_filter_bundles(yaml_name, name):
positive = cmake_filter(name).partition("-")[0]
expected = selection(positive.split(":"), f"{SRC_CMAKE} {name}")

path = PROVIDER / yaml_name
categories = yaml.safe_load(path.read_text(encoding="utf-8"))["test_categories"]
assert categories, f"{path}: no test_categories"
union = set()
for category, info in categories.items():
selected = selection(info["test_patterns"], f"{path} {category}")
tiers = {tier for tier, _ in selected}
want = {(tier, bundle) for tier in tiers for _, bundle in expected}
assert selected == want, (
f"{path} {category}: at tiers {sorted(tiers)}, missing "
f"{sorted(want - selected)} and extra {sorted(selected - want)} against "
f"{name} in {SRC_CMAKE}"
)
union |= selected
assert union == expected, (
f"{path}: categories select {sorted(union)}; "
f"{name} in {SRC_CMAKE} selects {sorted(expected)}"
)
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def answer(shipped, probe_ok):
set_property(GLOBAL PROPERTY HKP_PACK_PROBE_OK_product {probe_ok})
set_property(GLOBAL PROPERTY HKP_PACK_SHIPPED_ENGINES_product
"{_cmake_string(json.dumps(shipped))}")
hkp_gfx950_attention_dense_available(_available)
hkp_product_ships_engine_for_arch(_available "hipkernel:Gfx950AttentionDense" gfx950)
if(_available)
set(_available TRUE)
else()
Expand Down Expand Up @@ -496,7 +496,7 @@ def gates(force_probe_failure):
+ _wire_root("product", arches="gfx90a", enable_rocke=enable_rocke)
+ f"""{forced}
hkp_product_offers_engine(_offered "test_fixture:attention")
hkp_gfx950_attention_dense_available(_available)
hkp_product_ships_engine_for_arch(_available "hipkernel:Gfx950AttentionDense" gfx950)
get_property(_dormant GLOBAL PROPERTY HKP_PACK_DORMANT_LABELS)
{_report("dormant", "${_dormant}")}
foreach(_name IN ITEMS offered available)
Expand Down
Loading
Loading