Skip to content

[BugFix][ROCm] Broadcast 8-bit integers with 8 and 16 lanes - #3955

Open
ghostrider0470 wants to merge 1 commit into
tile-ai:mainfrom
Horizon-Tech-doo:rocm-int8-broadcast
Open

ghostrider0470 wants to merge 1 commit into
tile-ai:mainfrom
Horizon-Tech-doo:rocm-int8-broadcast

Conversation

@ghostrider0470

Copy link
Copy Markdown
Contributor

Problem

LegalizeSafeMemoryAccess gives a dynamically indexed copy a zero else branch and binds the zero to a variable. For 8-bit integer vectors, HIP's Broadcast then fails in one of two ways:

  • 4 lanes: ICHECK(p) on as_const_int, because the value is a variable.
  • 8 and 16 lanes: make_uint2/make_uint4 is emitted with one argument per byte, and hipcc rejects it ("no matching function for call to 'make_uint4'" with 16 arguments).

On main (72d986e) the new test reproduces both: the 64-column/256-thread copy hits Check failed: (p) at codegen_hip.cc:2246, and the two copies with 8- and 16-lane vectors fail in hipcc.

The 4-lane case is also addressed by #3886; this PR's distinct part is the 8- and 16-lane form.

Approach

8-bit integer vectors are stored as 32-bit words (see PrintType), so emit one packed word per 4 lanes, for constant and non-constant values: the constant path packs the byte as before, the non-constant path emits (uint)(uchar)(v) * 0x01010101u. The output for a constant 4-lane broadcast is unchanged.

test_tilelang_hip_uint8_broadcast.py copies a uint8 row tile through shared memory at 3 column/thread combinations that give 4-, 8- and 16-lane vectors, checks the copied values, and checks that an out-of-bounds index reads zeros. 3 passed on 72d986e with this change on MI250X (gfx90a), ROCm 6.2.4.

Not covered: the non-constant value is printed once per packed word, so for 8 and 16 lanes it appears 2 or 4 times in the source. It is always a variable here, but an effectful value is not rejected (#3886 adds that check for 4 lanes).

Rebased onto current main (348e807) without conflicts. The test results above were measured on 72d986e and have not been rerun on the new base.

8-bit integer vectors are stored as 32-bit words, but Broadcast built
make_uint2/make_uint4 with one argument per byte and required a constant
value. Emit one packed word per 4 lanes, for constant and non-constant values.
The output for a constant 4-lane broadcast is unchanged.
@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HIP code generation now supports signed and unsigned 8-bit broadcasts with 4, 8, or 16 lanes, including runtime values. A ROCm-gated test checks dynamically indexed uint8 row-tile copies, including an out-of-bounds index.

Changes: HIP 8-bit Broadcast

Layer / File(s) Summary
Broadcast emission and validation
src/rocm/codegen/codegen_hip.cc, testing/python/amd/test_tilelang_hip_uint8_broadcast.py
The broadcast path packs constant or runtime values into 32-bit words for 4-, 8-, and 16-lane vectors. The ROCm test checks copied rows for index 3 and zero output for out-of-bounds index 16 across three configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • tile-ai/tilelang#3886: Both changes modify nonconstant 8-bit broadcast emission in the same code-generation path, including the four-lane case.

Suggested labels: bug

Suggested reviewers: zhangnju

Merge Risk: Minimal · up to 3be99

This change adds HIP broadcast support for 8-bit integer vectors with 8 and 16 lanes and fixes the 4-lane constant-value failure. No concrete merge-blocking risk was identified. Effectful scalar values are printed once per packed word, as the author documents.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: fixing HIP broadcast of 8-bit integers with 8 and 16 lanes. It also marks the ROCm bugfix scope. It matches the changeset summary, which adds 8- and 16-lane uint8/int8…
Description check Passed The description explains the problem, the packed 32-bit word approach, the new test, and the test environment. It also lists known gaps, such as repeated printing of non-constant values and the untest…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: fixing HIP broadcast of 8-bit integers with 8 and 16 lanes. It also marks the ROCm bugfix scope. It matches the changeset summary, which adds 8- and 16-lane uint8/int8 broadcast handling in codegen_hip.cc.

Full details: Description check

Explanation

The description explains the problem, the packed 32-bit word approach, the new test, and the test environment. It also lists known gaps, such as repeated printing of non-constant values and the untested rebase. It relates directly to the changes in codegen_hip.cc and the new ROCm test file.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 348e807 and 3be994a.

Files selected for processing: 2

  • src/rocm/codegen/codegen_hip.cc
  • testing/python/amd/test_tilelang_hip_uint8_broadcast.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@coderabbitai
coderabbitai Bot requested a review from zhangnju November 11, 2026 23:58
@coderabbitai coderabbitai Bot added the bug Something isn't working label Nov 11, 2026

@zhangnju zhangnju left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Verified the included test on gfx950, gfx1100 (W7900) and gfx1201 (R9700) - all 3 passed on each.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants