Skip to content

feat(hiptensor): Build lib with a stub implementation when GPU_TARGETS is empty#8874

Open
evedovelli wants to merge 6 commits into
developfrom
users/evedovel/hiptensor/build-empty-targets
Open

feat(hiptensor): Build lib with a stub implementation when GPU_TARGETS is empty#8874
evedovelli wants to merge 6 commits into
developfrom
users/evedovel/hiptensor/build-empty-targets

Conversation

@evedovelli

@evedovelli evedovelli commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Motivation

hipTensor depends on Composable Kernel, which only supports a subset of gfx targets. On architectures where the effective GPU_TARGETS resolves to empty (e.g. a single-arch build for an unsupported gfx), the device library and its CK
dependency cannot be built, which previously broke configuration and left downstream consumers with no hiptensor package at all.

This PR makes hipTensor degrade gracefully in that case by building a host-only stub library

Technical Details

  • HIPTENSOR_ENABLE_DEVICE option: when GPU_TARGETS is explicitly empty, it is turned off automatically (with a warning) instead of failing the build.
  • Stub library (library/stub/): a host-only libhiptensor that implements the full public API, returning HIPTENSOR_STATUS_NOT_SUPPORTED for every entry point. The package, headers, and hiptensor-config.cmake are still produced, so
    downstream find_package(hiptensor) and linking keep working, and callers get a well-defined runtime error instead of an unresolved symbol.
  • Device build unchanged: when GPU_TARGETS is valid, the real library/src library is built as before; CK and tests/samples only configure in that path.
  • Build-time API coverage check: a configure-time codegen parses the public header for every HIPTENSOR_EXPORT function and links a reference to each against the stub. If the stub is missing any public API, the build fails with an
    unresolved symbol. This runs for any GPU_TARGETS (device or stub), so the stub can never drift out of sync with the public API.

Test Plan and Results

  • Device build (GPU_TARGETS=gfx1201, HIPTENSOR_ENABLE_DEVICE=ON): full build + coverage check link, PASS.
  • Stub build (empty GPU_TARGETS): stub libhiptensor, headers, and CMake config produced and installed; coverage check links, PASS.
  • Negative: removing a stub function fails the build with undefined symbol: hiptensorReduce, confirming the coverage check catches an incomplete stub.

Submission Checklist

ISSUE ID : ROCm/TheRock#6268

@therock-pr-bot

therock-pr-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

✅ All Checks Passed — Ready for Review

Check Status Details
🌿 Branch Name ✅ Pass
📝 PR Title/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.

@therock-pr-bot

therock-pr-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

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

@evedovelli evedovelli changed the title [hiptensor] Build lib with a stub implementation when GPU_TARGETS is empty feat: [hiptensor] Build lib with a stub implementation when GPU_TARGETS is empty Jun 30, 2026
@evedovelli evedovelli marked this pull request as ready for review June 30, 2026 20:15
@evedovelli evedovelli requested a review from a team as a code owner June 30, 2026 20:15
@evedovelli evedovelli force-pushed the users/evedovel/hiptensor/build-empty-targets branch from 7176411 to 5a139ea Compare July 3, 2026 17:53
@evedovelli evedovelli requested a review from a team as a code owner July 3, 2026 17:53
@evedovelli evedovelli changed the title feat: [hiptensor] Build lib with a stub implementation when GPU_TARGETS is empty feat(hiptensor): Build lib with a stub implementation when GPU_TARGETS is empty Jul 3, 2026
@evedovelli evedovelli removed the request for review from a team July 3, 2026 19:22

@TorreZuk TorreZuk 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.

The stub pattern seems fine but does add maintenance for for matching up change in API.
Not clear if some macro stubs could also be used in the original API to comment out the code blocks and just return not_supported but that one might think is quirky as well.

@evedovelli

Copy link
Copy Markdown
Contributor Author

The stub pattern seems fine but does add maintenance for for matching up change in API. Not clear if some macro stubs could also be used in the original API to comment out the code blocks and just return not_supported but that one might think is quirky as well.

Thank you for the review @TorreZuk. I'll dig and see if I could put something like this in place. For now there is an extra maintenance in the cpp stubs, but I did put in place a compile time verification that will trigger a failure if the stub implementation isn't aligned with the API.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (76.92%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8874      +/-   ##
===========================================
+ Coverage    65.13%   65.17%   +0.05%     
===========================================
  Files         2628     2628              
  Lines       413118   413284     +166     
  Branches     61884    61891       +7     
===========================================
+ Hits        269044   269348     +304     
+ Misses      123563   123391     -172     
- Partials     20511    20545      +34     
Flag Coverage Δ *Carryforward flag
TensileLite 33.42% <ø> (ø) Carriedforward from 4da814d
hipBLAS 90.81% <ø> (ø) Carriedforward from 4da814d
hipBLASLt 41.36% <ø> (ø) Carriedforward from 4da814d
hipCUB 82.68% <ø> (ø) Carriedforward from 4da814d
hipDNN 85.91% <ø> (ø) Carriedforward from 4da814d
hipFFT 50.17% <ø> (ø) Carriedforward from 4da814d
hipRAND 76.12% <ø> (ø) Carriedforward from 4da814d
hipSOLVER 69.18% <ø> (ø) Carriedforward from 4da814d
hipSPARSE 86.55% <ø> (ø) Carriedforward from 4da814d
rocBLAS 48.49% <ø> (+0.43%) ⬆️
rocFFT 46.30% <ø> (ø) Carriedforward from 4da814d
rocRAND 57.04% <ø> (ø) Carriedforward from 4da814d
rocSOLVER 76.92% <ø> (ø) Carriedforward from 4da814d
rocSPARSE 72.37% <ø> (ø) Carriedforward from 4da814d
rocThrust 91.36% <ø> (ø) Carriedforward from 4da814d

*This pull request uses carry forward flags. Click here to find out more.
see 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants