Skip to content

fix(tensilelite): Fix output-store 32-bit address overflow#8801

Merged
jimbochi merged 10 commits into
developfrom
users/yuchi/ROCM-26455
Jul 9, 2026
Merged

fix(tensilelite): Fix output-store 32-bit address overflow#8801
jimbochi merged 10 commits into
developfrom
users/yuchi/ROCM-26455

Conversation

@jimbochi

@jimbochi jimbochi commented Jun 25, 2026

Copy link
Copy Markdown
Member

Motivation

Conversion kernels compute the output byte-offset as idxD * sizeof(destType) in
32-bit arithmetic. When the output tensor's leading dimension is large enough that
an element's byte-offset exceeds 2^31, the 32-bit multiplication wraps and the
buffer_store intrinsic writes to a wrong address, producing silent data corruption.
This PR widens the output-store offset path to 64-bit, fixing the address overflow
for large-output matmul cases.
JIRA ID : ROCM-26455

Technical Details

  1. memory_gfx.h — Added a splitBufferOffset() helper that splits a 64-bit
    voffset into a low-32-bit portion (passed as the hardware voffset) and folds
    the high-32 bits into the buffer base pointer. Each buffer_store specialisation
    (1B / 2B / 4B / 8B / 16B) gains a new constructor overload accepting uint64_t voffset that calls this helper before issuing the intrinsic.
  2. KernelWriterConversion.py — The codegen now pre-computes
    uint64_t byteOffsetD = idxD * sizeof(destType) and passes it to buffer_store
    instead of the inline idxD * sizeof(...) expression, ensuring the multiplication
    is performed in 64-bit.
  3. known_bugs.yaml — Removed the obsolete gfx950 MXFP4 subtile scaleAlphaVec
    entries (ROCM-27082, resolved). Added a size_t / 32-bit overflow tracking section
    (AIHPBLAS-3806) with a template and the ROCM-26455 bf16 output-overflow reproducer
    entry (currently commented out, ready to activate when the matching gtest lands).

Test Plan

test_KernelWriterConversion_64bit_offset.py

Test Result

python3 -m pytest Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py -v
=====================test session starts=====================
platform linux -- Python 3.12.3, pytest-8.4.2, pluggy-1.6.0 -- /opt/venv/bin/python3
cachedir: .pytest_cache
rootdir: /src/Issues/projects/hipblaslt/tensilelite
configfile: pytest.ini
plugins: hydra-core-1.3.2
collected 8 items
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestKernelWriterConversion64BitOffset::test_byteOffsetD_declared_as_uint64 PASSED [ 12%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestKernelWriterConversion64BitOffset::test_buffer_store_uses_byteOffsetD PASSED [ 25%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestKernelWriterConversion64BitOffset::test_no_inline_idxD_multiply_in_buffer_store PASSED [ 37%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestMemoryGfxSplitBufferOffset::test_splitBufferOffset_exists PASSED [ 50%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestMemoryGfxSplitBufferOffset::test_splitBufferOffset_signature PASSED [ 62%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestMemoryGfxSplitBufferOffset::test_splitBufferOffset_masks_high_bits PASSED [ 75%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestMemoryGfxSplitBufferOffset::test_buffer_store_uint64_overloads_exist PASSED [ 87%]
Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py::TestMemoryGfxSplitBufferOffset::test_overloads_call_splitBufferOffset PASSED [100%]
===================== 8 passed in 0.06s=====================

Submission Checklist

@codecov-commenter

codecov-commenter commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

❌ Your project status has failed because the head coverage (77.89%) 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    #8801      +/-   ##
===========================================
- Coverage    64.58%   64.58%   -0.00%     
===========================================
  Files         2675     2658      -17     
  Lines       420244   415455    -4789     
  Branches     62446    61689     -757     
===========================================
- Hits        271410   268304    -3106     
+ Misses      128348   126984    -1364     
+ Partials     20486    20167     -319     
Flag Coverage Δ *Carryforward flag
TensileLite 34.84% <100.00%> (+<0.01%) ⬆️
hipBLAS 90.81% <ø> (ø) Carriedforward from 70e98fd
hipBLASLt 34.71% <ø> (ø)
hipCUB 82.68% <ø> (ø) Carriedforward from 70e98fd
hipDNN 86.69% <ø> (+0.69%) ⬆️ Carriedforward from 70e98fd
hipFFT 50.17% <ø> (+0.07%) ⬆️ Carriedforward from 70e98fd
hipRAND 76.12% <ø> (ø) Carriedforward from 70e98fd
hipSOLVER 69.18% <ø> (ø) Carriedforward from 70e98fd
hipSPARSE 86.55% <ø> (+0.45%) ⬆️ Carriedforward from 70e98fd
rocBLAS 48.08% <ø> (+0.03%) ⬆️ Carriedforward from 70e98fd
rocFFT 47.16% <ø> (+0.82%) ⬆️ Carriedforward from 70e98fd
rocRAND 57.07% <ø> (+0.03%) ⬆️ Carriedforward from 70e98fd
rocSOLVER 77.89% <ø> (+0.97%) ⬆️ Carriedforward from 70e98fd
rocSPARSE 72.37% <ø> (+<0.01%) ⬆️ Carriedforward from 70e98fd
rocThrust 91.34% <ø> (-0.01%) ⬇️ Carriedforward from 70e98fd

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

Files with missing lines Coverage Δ
...aslt/tensilelite/Tensile/KernelWriterConversion.py 56.61% <100.00%> (+0.05%) ⬆️

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

@therock-pr-bot

therock-pr-bot Bot commented Jun 29, 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 29, 2026

Copy link
Copy Markdown

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

@jimbochi jimbochi changed the title [tensilelite] Fix output-store 32-bit address overflow in conversion … fix(tensilelite): Fix output-store 32-bit address overflow in conversion … Jul 6, 2026
@jimbochi jimbochi changed the title fix(tensilelite): Fix output-store 32-bit address overflow in conversion … fix(tensilelite): Fix output-store 32-bit address overflow Jul 6, 2026
@talumbau talumbau self-requested a review July 6, 2026 15:01
Comment thread projects/hipblaslt/clients/tests/data/known_bugs.yaml Outdated

Copilot AI 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.

Pull request overview

This PR fixes a TensileLite conversion-kernel bug where large output tensors could trigger 32-bit address/offset truncation in buffer_store, causing silent writes to the wrong address. It does this by widening the output byte-offset computation and plumbing a 64-bit offset path through the buffer_store helpers.

Changes:

  • Added splitBufferOffset() plus uint64_t voffset overloads for buffer_store specializations (1/2/4/8/16B) to support >4GB byte offsets via base-pointer adjustment.
  • Updated KernelWriterConversion.py to compute byteOffsetD as a 64-bit value and pass it into buffer_store.
  • Added unit tests validating the codegen/header patterns, and updated known_bugs.yaml commentary/entries for overflow tracking.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
projects/hipblaslt/tensilelite/Tensile/Source/memory_gfx.h Adds splitBufferOffset() and buffer_store uint64 overloads to safely handle large byte offsets.
projects/hipblaslt/tensilelite/Tensile/KernelWriterConversion.py Switches conversion-kernel store offset computation to byteOffsetD and passes it to buffer_store.
projects/hipblaslt/tensilelite/Tensile/Tests/unit/test_KernelWriterConversion_64bit_offset.py Adds unit tests to guard the new 64-bit offset path and helper/overload presence.
projects/hipblaslt/clients/tests/data/known_bugs.yaml Removes obsolete entries and adds an overflow-coverage tracking section/template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ROCm ROCm deleted a comment from therock-pr-bot Bot Jul 8, 2026
@jimbochi jimbochi merged commit 4c61502 into develop Jul 9, 2026
60 checks passed
@jimbochi jimbochi deleted the users/yuchi/ROCM-26455 branch July 9, 2026 07:11
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.

4 participants