Skip to content

[hipBLASLt] Make generated code-object linking deterministic - #11129

Open
newling wants to merge 1 commit into
ROCm:developfrom
newling:users/newling/sort-explicit-code-object-inputs
Open

[hipBLASLt] Make generated code-object linking deterministic#11129
newling wants to merge 1 commit into
ROCm:developfrom
newling:users/newling/sort-explicit-code-object-inputs

Conversation

@newling

@newling newling commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

JIRA ID: ROCM-28430

What this changes

hipBLASLt includes a large collection of precompiled GPU kernels. During the
Tensile library-generation step, each kernel is first assembled into an object
file (.o). The generator then combines—or “links”—many of those object files
into a GPU code object (.co).

A .co is the binary container that hipBLASLt loads at runtime to execute its
GPU kernels. In the usual compressed build, it contains a GPU-specific ELF
binary together with the information needed to load it for a particular GPU
architecture.

The order in which object files are given to the linker matters. It determines
where the individual kernel functions are placed inside the resulting binary,
and therefore affects the final .co bytes and build ID.

For explicitly grouped code objects, Tensile currently collects the object-file
paths in a Python set and passes that set directly to the linker. Python sets
do not have a stable iteration order: their order can change with the Python
hash seed, the object paths, or other details of the build environment.

That means two builds can start from the same source and the same collection of
kernel object files, but link those files in different orders and produce
different .co binaries.

This PR sorts the object-file paths immediately before invoking the linker.
With a fixed set of object files, the linker now receives the same ordered list
on every build.

Why this is useful

Deterministic linking makes generated hipBLASLt libraries easier to:

  • reproduce across clean builds;
  • compare at the binary level;
  • cache effectively;
  • audit when investigating a generated kernel; and
  • bisect without accidentally changing code-object layout because of Python
    set iteration.

This does intentionally establish one canonical physical order for the kernel
functions inside each generated .co. It does not change which kernels are
included or their assembled instruction bytes.

The build-time cost is negligible: sorting 1,919 real object paths took
approximately 0.09 ms, compared with 0.52–0.55 seconds for linking and
4.32–4.36 seconds for compression.

Testing

The new characterization test constructs the same explicit code-object group
using two different kernel input orders. It verifies that both cases give the
linker the same lexicographically sorted list and that the linker receives a
concrete list, not a set iterator.

Validation performed:

  • The new test fails against unmodified origin/develop.
  • The complete ToolchainAssembly/test_assembly_char.py file passes:
    • 4 tests passed;
    • 3 existing snapshots passed.
  • The deterministic-order test passes with PYTHONHASHSEED=0, 1, and 42.
  • git diff --check passes.

Scope

This is a build-reproducibility fix. It makes the physical layout of generated
code objects deterministic, but it does not claim that one particular layout
changes or fixes numerical behavior.

@therock-pr-bot

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

therock-pr-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

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

@newling
newling requested review from KKyang and davidd-amd August 21, 2026 18:45
@newling
newling marked this pull request as ready for review August 21, 2026 18:46
@newling
newling requested a review from a team as a code owner August 21, 2026 18:46
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #11129      +/-   ##
===========================================
- Coverage    69.65%   69.65%   -0.00%     
===========================================
  Files         2789     2789              
  Lines       459421   459422       +1     
  Branches     67739    67740       +1     
===========================================
- Hits        319988   319987       -1     
- Misses      116264   116266       +2     
  Partials     23169    23169              
Flag Coverage Δ *Carryforward flag
TensileLite-CPP 38.13% <ø> (ø) Carriedforward from 496fdbb
TensileLite-Unit 76.58% <ø> (-<0.01%) ⬇️ Carriedforward from 496fdbb
hipBLAS 90.62% <ø> (ø) Carriedforward from 496fdbb
hipBLASLt 34.93% <ø> (-<0.01%) ⬇️
hipCUB 82.68% <ø> (ø) Carriedforward from 496fdbb
hipDNN 86.89% <ø> (ø) Carriedforward from 496fdbb
hipFFT 42.99% <ø> (ø) Carriedforward from 496fdbb
hipRAND 76.12% <ø> (ø) Carriedforward from 496fdbb
hipSOLVER 69.03% <ø> (ø) Carriedforward from 496fdbb
hipSPARSE 86.99% <ø> (ø) Carriedforward from 496fdbb
rocBLAS 48.26% <ø> (ø) Carriedforward from 496fdbb
rocFFT 51.24% <ø> (ø) Carriedforward from 496fdbb
rocRAND 57.05% <ø> (ø) Carriedforward from 496fdbb
rocSOLVER 77.25% <ø> (ø) Carriedforward from 496fdbb
rocSPARSE 74.59% <ø> (ø) Carriedforward from 496fdbb
rocThrust 91.60% <ø> (ø) Carriedforward from 496fdbb

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

Files with missing lines Coverage Δ
...ipblaslt/tensilelite/Tensile/Toolchain/Assembly.py 93.62% <ø> (-0.13%) ⬇️

... and 1 file 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.

1 participant