Skip to content

fix(hipdnn): winner-cache follow-up fixes (ALMIOPEN-2505) - #11493

Draft
SamuelReeder wants to merge 3 commits into
developfrom
users/sareeder/almiopen-2505-winner-cache-followups
Draft

fix(hipdnn): winner-cache follow-up fixes (ALMIOPEN-2505)#11493
SamuelReeder wants to merge 3 commits into
developfrom
users/sareeder/almiopen-2505-winner-cache-followups

Conversation

@SamuelReeder

Copy link
Copy Markdown
Contributor

Summary

Implement the ALMIOPEN-2505 follow-up fixes from the ALMIOPEN-2451 review and PR #11101. The changes harden LineStore behavior, make winner-cache writes deterministic under races, improve malformed-record handling, and complete the related test and install-tree coverage.

JIRA ID : ALMIOPEN-2505

Related PR: #11101

Risk Assessment

Risk level: 3. The change affects the shared LineStore header, winner-cache persistence, and CMake test installation. The ingestor remains disabled by default, and the changed behavior is covered by focused data SDK and plugin SDK tests. Windows-specific behavior still requires Windows CI confirmation.

ASIC Coverage

The changes are architecture-independent host-side persistence, locking, test, and build infrastructure changes. They do not alter kernel selection, provider applicability, dispatch, or device behavior. Standard PR CI is sufficient; Windows CI is required for the Windows handle and process-test changes. A full multi-arch sweep is not required.

Testing Summary

  • Built hipDNN with the kernel ingestor enabled and disabled.
  • Ran the complete data SDK test suite and repeated all LineStore tests 20 times.
  • Ran the winner-cache and GenericPlanBuilder tests.
  • Ran DiskCacheCrossProcess tests in the build tree and installed tree.
  • Verified the HOME-unset CacheRoot regression and no literal ~ directory creation.
  • Verified the cross-process tests pass with an ambient truthy HIPDNN_DISABLE_CACHE.

Testing Checklist

  • Ingestor-enabled build - cmake --build build - Status: Passed
  • Ingestor-disabled data SDK build - cmake --build build-off --target hipdnn_data_sdk_tests - Status: Passed
  • Data SDK tests - /usr/bin/ctest --test-dir build/projects/hipdnn -R hipdnn_data_sdk_tests --output-on-failure - Status: Passed
  • LineStore stability - hipdnn_data_sdk_tests --gtest_filter='TestLineStore.*' --gtest_repeat=20 - Status: Passed
  • Winner-cache and GenericPlanBuilder tests - hipdnn_plugin_sdk_tests --gtest_filter='TestIngestorWinnerCache*:TestIngestorGenericPlanBuilder*' - Status: Passed
  • Build-tree DiskCacheCrossProcess tests - ctest --test-dir build/projects/hipdnn -R DiskCacheCrossProcess --output-on-failure - Status: Passed
  • Installed-tree DiskCacheCrossProcess tests - ctest --test-dir stage/bin/hipdnn -R DiskCacheCrossProcess --output-on-failure - Status: Passed
  • HOME-unset CacheRoot regression - hipdnn_data_sdk_tests --gtest_filter='TestCacheRoot.*' - Status: Passed
  • Windows CI - handle deletion and cross-process lock tests - Status: Pending
  • pre-commit - required repository check - Status: Pending
  • PR CI - GitHub checks - Status: Pending

Technical Changes

  • Retain LineStore descriptors on failure paths where closing can release an unrelated fcntl lock, retry interrupted lock acquisition, add Windows delete sharing, and contain Windows macro definitions.
  • Decline unresolved home-directory expansions instead of creating a literal ~ cache path.
  • Add a per-line winner-cache format version and reject non-integer or out-of-range device fields.
  • Replace ranking comparison with an explicit fresh-miss versus coverage-rebenchmark write cause.
  • Release the shard lock before logging append failures.
  • Add malformed-record, lock-decline, fault-injection, barrier, Windows, and install-tree test coverage.
  • Remove the duplicated ContentCarryingTestGraph test fixture and use the flatbuffers SDK fixture.
  • Document the accepted shard-path and engine-name sanitization deviations.

Five correctness fixes, three Windows fixes, the write-path adopt-gate
change plus one lock-hold fix, six test/CI fixes, and one doc wording
fix, per the ALMIOPEN-2451/PR#11101 review follow-ups.

- LineStore.hpp: retain descriptors on the two unsafe close paths in
  openOrFindLineStoreEntry()/findExistingLineStoreEntry(); retry
  fcntl(F_SETLKW) on EINTR; add FILE_SHARE_DELETE to both registry
  CreateFileW calls; stop leaking NOMINMAX/WIN32_LEAN_AND_MEAN past
  <windows.h>.
- CacheRoot.hpp: decline an unresolved '~'/'%USERPROFILE%' instead of
  creating a literal '~' cache directory.
- PathSanitizer.hpp: correct the collision-bound doc comment.
- WinnerCacheFile.hpp: per-line format-version stamp; bounded integer
  reads for warp_size/multi_processor_count.
- WinnerCache.hpp/KernelIngestorStateManager.hpp/GenericPlanBuilder.hpp:
  replace the ranking-comparison adopt gate with an explicit
  WinnerWriteCause (fresh-miss presence check vs. coverage-rebenchmark
  append); release the shard lock before logging an append failure.
- Test/CI: clear HIPDNN_DISABLE_CACHE in the cross-process ctest env;
  ship the three DiskCacheCrossProcess_* entries in the install tree;
  new LineStore nested-exclusive-decline and fault-injection tests;
  remove wall-clock dependence from the LineStore process tests; port
  the cross-process lock tests to Windows; dedupe
  ContentCarryingTestGraph.hpp in favor of flatbuffers_sdk's copy.
- docs/Environment.md: record the two accepted design deviations
  (shard path shape, sanitizeForPath() on the engine component) and
  the Windows delete-safety caveat pending CI observation.

Verified in-container: ingestor-ON and -OFF builds clean (clang-tidy
gated); hipdnn_data_sdk_tests and hipdnn_plugin_sdk_tests suites pass,
including TestLineStore.* repeated 20x with zero flakes;
DiskCacheCrossProcess_* pass in both the build tree and an installed
tree, including under an ambient truthy HIPDNN_DISABLE_CACHE; HOME-unset
CacheRoot regression test passes and creates no literal '~' directory.
@therock-pr-bot

therock-pr-bot Bot commented Aug 31, 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

Pre-commit check failed

pre-commit failed

Please run locally:

  • python -m pip install pre-commit
  • pre-commit install
  • pre-commit run --all-files --show-diff-on-failure

This repo uses .pre-commit-config.yaml.

…Helper

- Reformat the 6 files pre-commit flagged (clang-format-18, project style).
- LineStoreLockHelper: set stdout to binary mode on Windows so the CRT
  does not rewrite the helper's \n to \r\n, which made the parent test
  read back "arm\r" instead of "arm" on Windows CI.
@therock-pr-bot

Copy link
Copy Markdown

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

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...dk/include/hipdnn_data_sdk/utilities/CacheRoot.hpp 0.00% 0 Missing and 1 partial ⚠️
...dk/include/hipdnn_data_sdk/utilities/LineStore.hpp 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #11493      +/-   ##
===========================================
+ Coverage    69.35%   69.37%   +0.01%     
===========================================
  Files         2810     2811       +1     
  Lines       464609   464651      +42     
  Branches     68557    68558       +1     
===========================================
+ Hits        322227   322323      +96     
+ Misses      118866   118820      -46     
+ Partials     23516    23508       -8     
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 38.33% <ø> (ø) Carriedforward from 630a341
TensileLite-Unit 76.15% <ø> (ø) Carriedforward from 630a341
hipBLAS 90.62% <ø> (ø) Carriedforward from 630a341
hipBLASLt 35.22% <ø> (ø) Carriedforward from 630a341
hipCUB 82.68% <ø> (ø) Carriedforward from 630a341
hipDNN 86.95% <66.67%> (+0.10%) ⬆️
hipFFT 44.78% <ø> (ø) Carriedforward from 630a341
hipRAND 76.12% <ø> (ø) Carriedforward from 630a341
hipSOLVER 69.03% <ø> (ø) Carriedforward from 630a341
hipSPARSE 86.99% <ø> (ø) Carriedforward from 630a341
rocBLAS 48.22% <ø> (ø) Carriedforward from 630a341
rocFFT 46.60% <ø> (ø) Carriedforward from 630a341
rocRAND 56.91% <ø> (ø) Carriedforward from 630a341
rocSOLVER 77.32% <ø> (ø) Carriedforward from 630a341
rocSPARSE 74.60% <ø> (ø) Carriedforward from 630a341
rocThrust 91.60% <ø> (ø) Carriedforward from 630a341

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...nclude/hipdnn_data_sdk/utilities/PathSanitizer.hpp 91.14% <ø> (ø)
...dk/include/hipdnn_data_sdk/utilities/CacheRoot.hpp 93.55% <0.00%> (+9.68%) ⬆️
...dk/include/hipdnn_data_sdk/utilities/LineStore.hpp 76.73% <80.00%> (+7.09%) ⬆️

... and 10 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.

- Fix stale writeBackToShard()/recordWinner() doc comments that still
  described the deleted rankedIdsEqual() gate instead of the cause-based
  adopt/append rule (B1).
- Resolve the Windows cache-root-deletion doc placeholder now that
  TestLineStore.AShardsParentDirectoryCanBeRemovedWhileTheRegistryHoldsItOpen
  has passed on Windows CI: deletion is safe on both platforms (B2).
- Make ChildProcess in TestLineStore.cpp move-only and self-reaping (RAII
  kill+reap+close), so an ASSERT_* between spawning a helper and the normal
  awaitChild()/awaitProbe() reap no longer orphans a child spinning on the
  barrier file for the rest of the CI job (I1/I2). Bound
  LineStoreLockHelper's barrier wait with a 60s timeout as a second,
  independent backstop.
- Apply the NOMINMAX/WIN32_LEAN_AND_MEAN define/undef-after-<windows.h>
  containment to PlatformUtils.windows.hpp, matching LineStore.hpp; this
  header was the one still leaking both macros to every downstream Windows
  translation unit (I3).
- Strengthen ARecordUnderAnUnusableGraphKeyIsNotStored to record a valid
  key first, so the test distinguishes rejecting the unusable key from
  recordWinner() doing nothing at all (I4).
- Strengthen the probe-mode arm checks in TestLineStore.cpp to assert the
  marker text, not just presence.
- Make WinnerWriteCause a required recordWinner() parameter (no more
  FRESH_MISS default), with every call site now passing it explicitly.
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.

1 participant