feat(hip-kernel-provider): rocKE AOT producer + kpack packaging (AICK-1473)#9207
Draft
BrianHarrisonAMD wants to merge 9 commits into
Draft
feat(hip-kernel-provider): rocKE AOT producer + kpack packaging (AICK-1473)#9207BrianHarrisonAMD wants to merge 9 commits into
BrianHarrisonAMD wants to merge 9 commits into
Conversation
3bb81b5 to
8ecbe46
Compare
Base automatically changed from
users/bharriso/aick-1471-rocke-dispatcher-wiring
to
develop
July 9, 2026 02:45
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
80f2b23 to
5d91b29
Compare
Pre-commit check failed⛔ pre-commit failed Please run locally:
This repo uses |
|
🎉 All checks passed! This PR is ready for review. |
5d91b29 to
67749be
Compare
BrianHarrisonAMD
added a commit
that referenced
this pull request
Jul 9, 2026
…AOT producer+kpack # Conflicts: # dnn-providers/hip-kernel-provider/rocke/CMakeLists.txt
5 tasks
…-1473) Re-land the #8866 AOT build + sidecar generator onto #9159's rocke/library/ layout and extend it through kpack packaging + install. Producer + packaging only; no C++ engine/dispatcher change (AotCatalog stays empty). Leg 1 (producer): port aot tooling to library/aot/; family handler to kernels/common/fmha_mfma_aot.py (imports rewired to the kernels package); instances to kernels/<arch>/fmha_fwd_mfma/aot_list.json; schemas to library/aot/schemas/ (+ fmha_fwd_mfma/ overlay). Build tool takes --handler/--schema-dir; parse_instance_list gains handler_path. rocke_aot.cmake driven by ROCKE_PYENV_PYTHON, depends on the pyenv stamp; AOT pip deps via library/aot/requirements.txt installed into rocke-pyenv. Leg 2 (kpack): rocke_kpack_pack.py packs each HSACO under toc_key rocke/<op>/<family>/<name> into rocke_client_<arch>.kpack (verifying packed sha256 == sidecar artifact.hsaco_sha256) and emits a hipdnn.rocke.bundle/v1 manifest (bundle.schema.json) carrying selection/launch/args_signature through from the sidecars. rocke_client_aot_kpack target; rocke_client_aot_artifacts depends on it. Install .kpack + manifest + aot_list.json under HIPDNN_RELATIVE_INSTALL_PLUGIN_ENGINE_DIR/hip_kernel_provider/rocke/<arch>/. rocm_kpack from ROCKE_KPACK_PYTHON_DIR with a configure-time import gate. Tests: ported instance/schema/sidecar/sdpa suites + kpack round-trip and manifest-validation tests; coverage gate --fail-under=90 held.
defaultArtifactRoot() was a placeholder (share/hipdnn_plugins/rocke-client/aot) that predated the kpack install layout. Point it at the real plugin-relative root, <plugin_dir>/hip_kernel_provider/rocke/<arch>/, where the kpack packaging installs each arch's rocke_client_<arch>.kpack + .json sidecar (and future kernel-selection heuristics). Still a path constant only -- loadDefault() remains empty (Phase 1); the dispatcher-wiring work consumes it. Comments updated to the confirmed install form.
893eaae to
9cb5beb
Compare
…k-1471-rocke-aot-producer-kpack # Conflicts: # dnn-providers/hip-kernel-provider/rocke/CMakeLists.txt
The AOT build dlopen's libamd_comgr, whose dependency closure (libclang-cpp, libLLVM, vendored rocm_sysdeps libs like librocm_sysdeps_z) lives in the compiler toolchain, not next to comgr: at build time comgr is a BUILD_DEP staged alone, so its $ORIGIN rpath siblings are absent. Chasing individual deps was fragile and broke whenever comgr gained a dependency. Forward the whole toolchain lib set instead, derived once from the compiler resource dir, probing both layouts (POSIX lib/, Windows bin/) and keeping whichever exist: LLVM/clang libs, rocm_sysdeps, comgr-adjacent libs, toolchain bin. On POSIX these go on LD_LIBRARY_PATH; on Windows they are forwarded in ROCKE_COMGR_DEP_DIRS and the comgr loader registers each via os.add_dll_directory (PATH is not a reliable dependent-DLL search path under Python's secure DLL loading). New comgr deps land in these same dirs, so this stops breaking as comgr evolves.
Replace the hand-listed toolchain lib dirs with CMake's runtime-dependency resolver (file(GET_RUNTIME_DEPENDENCIES), the machinery behind install(RUNTIME_DEPENDENCY_SET)). It reads libamd_comgr's actual dependency closure and we forward exactly the directories it resolves, so the set tracks comgr's real deps instead of guessing, and anything unresolved is reported at configure rather than surfacing as a runtime OSError. The amd-llvm toolchain (comgr's declared RUNTIME_DEP), located via the compiler resource dir, is only the resolver's search hint: comgr and its deps are staged separately at build time, so there is no in-tree rpath to read. The resolver is guarded on CMAKE_OBJDUMP and falls back to forwarding the search roots if unavailable, so it can never harden into a configure failure. Forwarding seam is unchanged: LD_LIBRARY_PATH on POSIX, ROCKE_COMGR_DEP_DIRS -> os.add_dll_directory on Windows.
…RUNTIME_DEPENDENCIES file(GET_RUNTIME_DEPENDENCIES) is documented as an install-time command, not for project mode, so using it at configure required manually wiring CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM/TOOL/COMMAND from CMAKE_OBJDUMP. Worse, it still had to be handed the amd-llvm toolchain dirs as DIRECTORIES search hints (comgr's RUNPATH cannot reach its split-staged deps), so it never removed the derivation it was meant to replace, and it carried a silent fallback that would forward the raw search dirs whenever the resolver was unavailable. Since the env helper forwards whole directories (not individual libraries), the resolver's per-file precision was unused at runtime. Derive the two directories comgr's deps actually live in straight from the compiler: the amd-llvm lib/bin dir (from clang --print-resource-dir) and its rocm_sysdeps sibling, existence filtered. No objdump, no platform vars, no fallback. If comgr ever needs a library outside these dirs the AOT build fails loudly at that point instead of degrading silently. Forwarding seam unchanged (LD_LIBRARY_PATH on POSIX, ROCKE_COMGR_DEP_DIRS -> os.add_dll_directory on Windows).
… forwarding comgr's own RUNPATH ($ORIGIN, $ORIGIN/llvm/lib, $ORIGIN/rocm_sysdeps/lib) already resolves its full dependency closure (libLLVM, libclang-cpp, the vendored rocm_sysdeps libs) when comgr is loaded from an assembled tree, as it is under /opt/rocm. The forwarding machinery only existed because we resolved comgr from its isolated superbuild stage, where those $ORIGIN-relative siblings are absent. With TheRock now declaring amd-comgr as a build dep of hipkernelprovider, comgr's assembled dist (comgr + amd-llvm + rocm_sysdeps) is on CMAKE_PREFIX_PATH, so we resolve it via find_package(amd_comgr) and let its RUNPATH do the rest. This deletes the toolchain dep-dir derivation, the env helper's LD_LIBRARY_PATH / ROCKE_COMGR_DEP_DIRS wiring, and comgr.py's _register_dep_dirs(). comgr's own directory is still added on Windows (co-located deps), and ROCKE_COMGR_LIB still overrides discovery.
The rocKE per-arch AOT bundles installed to <plugin_dir>/hip_kernel_provider/rocke/<arch>/ which created an engines/hip_kernel_provider/ *directory* next to the hip_kernel_provider plugin file. hipDNN's plugin loader (and the integration harness, which passes engines/hip_kernel_provider in ABSOLUTE mode) resolves that base path: with the directory present, is_directory() is true so it scans the dir for *.so/*.dll, finds none, and loads no plugin -> every graph returns GRAPH_NOT_SUPPORTED. Only reproduces with rocKE enabled. Install under a generic per-arch container instead: <plugin_dir>/arch_content/<engine>/<arch>/ so rocKE is arch_content/rocke/<arch>/ and future engines (aiter, asm, ...) get sibling subdirs with no split-handler changes. arch_content is not a plugin base name, so it never shadows a plugin file. AotCatalog::defaultArtifactRoot() points at arch_content/rocke. JIRA ID : AICK-1471
472753a to
2d02fa6
Compare
| @@ -0,0 +1,84 @@ | |||
| { | |||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | |||
| "$id": "hipdnn.rocke.bundle/v1", | |||
Contributor
There was a problem hiding this comment.
Should this be rocke.aot.bundle to follow the format of the other schema ID's
Contributor
There was a problem hiding this comment.
Is this intended to be committed?
| from rocke_client_aot.instance_schema import AOT_LIST_FILENAME | ||
| from rocke_client_aot.json_schema import load_json_schema, validate_json_schema | ||
|
|
||
| BUNDLE_SCHEMA = "hipdnn.rocke.bundle/v1" |
Contributor
There was a problem hiding this comment.
This will also need to change if we align it with the other schema ID's
…k-1471-rocke-aot-producer-kpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-lands PR #8866's rocKE AOT build + sidecar generator onto the
rocke/library/layout from #9159, and extends it through kpack packaging and install. Producer
and packaging only: the engine's
AotCatalogstays empty, so it still declinesevery graph at runtime. The only C++ touched is a path constant
(
defaultArtifactRoot()) pointed at the final install layout.JIRA ID : AICK-1473
Install layout
Per arch, the producer packs HSACO into
rocke_client_<arch>.kpackwith arocke_client_<arch>.json(hipdnn.rocke.bundle/v1) bundle manifest, installednext to the engine plugin at
lib/hipdnn_plugins/engines/hip_kernel_provider/rocke/<arch>/(the future homefor rocke's per-arch kernel-selection heuristics too). Arch-scoped paths union
cleanly, so TheRock's multi-arch merge needs no kpack fusing.
AotCatalog'sdefaultArtifactRoot()now names this plugin-relative root; it is resolved nextto the loaded plugin and the device arch appended. It remains a path constant
(nothing reads it in Phase 1); the dispatcher-wiring work consumes it.
Cross-repo sequence
hipkernelproviderkpack split handler.Requires TheRock #6427's build deps (
ROCKE_KPACK_PYTHON_DIR, comgr) to buildunder the superbuild.
Risk Assessment
Low behaviorally. Adds a build-time producer plus packaging subsystem (Python and
CMake) and its pip deps to the rocke-pyenv; no engine behavior change and the
catalog stays empty, so there is no regression surface for #9159's dispatcher
tests. Risk is confined to the build/packaging path.
Testing Summary
handler, build-tool CLI, kpack round-trip, manifest validation), 90% gate.
library/aotsubtree: target graph, per-archkpack and install rules, fail-loud
rocm_kpackgate, comgr resolution.rocm_kpack): packedsha256 == sidecar
hsaco_sha256, manifest schema-valid, selection/launch/args_signature carried through unchanged.
and provider tests.
Testing Checklist
--cov-fail-under=90) - 96 passed, 98.80%sdpa_aot_numeric), gfx942/gfx950 - not run locallyTechnical Changes
rocke/library/aot/:rocke_client_aot,tools/rocke_aot_build.py, and shared plus family JSON schemas; family handlerto
kernels/common/fmha_mfma_aot.py; instance lists tokernels/<arch>/fmha_fwd_mfma/aot_list.json.rocke_aot.cmake: runs under${ROCKE_PYENV_PYTHON}; locates comgr viafind_library, then forwards the amd-llvm toolchain directories comgr'stransitive deps (
libclang-cpp,libLLVM, vendoredlibrocm_sysdeps_*) livein, derived straight from the compiler (
clang --print-resource-dir-> thelib//bin/androcm_sysdepssiblings), existence filtered. The superbuildstages comgr apart from amd-llvm so comgr's own RUNPATH cannot reach them; the
AOT tool's
dlopen(libamd_comgr)needs them on its load path. Forwarding is viaLD_LIBRARY_PATHon POSIX andROCKE_COMGR_DEP_DIRS->os.add_dll_directoryon Windows. Whole directories are forwarded (no per-dependency resolution), so a
missing dep fails the AOT build loudly rather than degrading silently.
tools/rocke_kpack_pack.py: packs each arch's HSACO intorocke_client_<arch>.kpackundertoc_key = rocke/<op>/<family>/<name>,verifying packed sha256 against the sidecar; emits the per-arch bundle manifest
as the single source of truth (
aot_list.jsonis a build input, not installed)..kpack+ manifest under${HIPDNN_RELATIVE_INSTALL_PLUGIN_ENGINE_DIR}/hip_kernel_provider/rocke/<arch>/.AotCatalog.cpp/.hpp: pointdefaultArtifactRoot()at the installedplugin-relative bundle root (path constant only; catalog stays empty).
Dependencies
ROCKE_KPACK_PYTHON_DIRand the comgr build dep.artifact-hipkernelprovider.toml) is handled in bump the rock version in rocm-libraries #6427.