Skip to content

Add TLU support for DirectToVgpr via global_load_tr - #1332

Merged
cliffxzx merged 4 commits into
developfrom
users/cliffxzx/dtvwithtlu
Sep 11, 2025
Merged

cliffxzx merged 4 commits into
developfrom
users/cliffxzx/dtvwithtlu

Conversation

@cliffxzx

@cliffxzx cliffxzx commented Aug 25, 2025 •

Copy link
Copy Markdown
Contributor

Motivation

After some experimentation, we found that the pack code in the F8 NT and NN cases was the performance bottleneck because the WMMA and pack code share the same pipeline. Starting from GFX12, a new instruction called global_load_tr allows us to eliminate the cost of the pack code by remapping the data. This makes it possible to support DirectToVgpr in the TLU case.

Technical Details

To use it as 16x16x16x1 WMMA input, the offset for global_load_tr should follow this order:

global_load_tr_b128

image

global_load_tr_b64

image

Test Plan

Test different MacroTile and parameters combinations on F8F8S and HHS across NN, NT, and TT cases.

      ForkParameters:
        - MatrixInstruction:
          - [16, 16,16, 1, 1, 1, 1, 1, 1]

          - [16, 16,16, 1, 1, 1, 1, 4, 1]
          - [16, 16,16, 1, 1, 2, 1, 4, 1]
          - [16, 16,16, 1, 1, 2, 1, 2, 2]
          - [16, 16,16, 1, 1, 3, 1, 2, 2]
          - [16, 16,16, 1, 1, 7, 1, 1, 4]
          - [16, 16,16, 1, 1, 8, 1, 1, 4]
          - [16, 16,16, 1, 1, 9, 1, 1, 4]
          - [16, 16,16, 1, 1, 10, 1, 1, 4]

          - [16, 16,16, 1, 1, 1, 1, 1, 4]
          - [16, 16,16, 1, 1, 1, 2, 1, 4]
          - [16, 16,16, 1, 1, 1, 2, 2, 2]
          - [16, 16,16, 1, 1, 1, 3, 2, 2]
          - [16, 16,16, 1, 1, 1, 7, 4, 1]
          - [16, 16,16, 1, 1, 1, 8, 4, 1]
          - [16, 16,16, 1, 1, 1, 9, 4, 1]
          - [16, 16,16, 1, 1, 1, 10, 4, 1]

          - [16, 16, 16, 1, 1, 2, 2, 2, 4]
          - [16, 16, 16, 1, 1, 2, 2, 4, 1]
        - ScheduleIterAlg: [3]
        - PrefetchLocalRead: [1]
        - PrefetchGlobalRead: [2]
        - DepthU: [16,64]
        - WavefrontSize: [32]
        - LocalReadVectorWidth: [8]
        - GlobalReadVectorWidthA: [8]
        - GlobalReadVectorWidthB: [8]
        - InnerUnroll: [1]
        - VectorWidthA: [1]
        - VectorWidthB: [1]
        - StoreVectorWidth: [-1]
        - StoreRemapVectorWidth: [0]
        - TransposeLDS: [-1,2]
        - 1LDSBuffer: [0,1]
        - ScheduleLocalWrite: [1]
        - GlobalSplitU: [1]
        - GlobalSplitUAlgorithm: ["MultipleBuffer"]
        - SourceSwap: [0,1]
        - ExpandPointerSwap: [0,1]
        - PreloadKernArgs: [1]
        - DirectToVgprA: [0,1]
        - DirectToVgprB: [0,1]
      BenchmarkFinalParameters:
        - ProblemSizes:
          - Range: [[1], [1], [1], [1]]
          - Range: [[64], [64], [1], [64]]
          - Range: [[128], [128], [1], [128]]
          - Range: [[256], [256], [1], [256]]
          - Range: [[512], [512], [1], [512]]
          - Range: [[1024], [1024], [1], [1024]]

          - Range: [[32], [32], [1], [32]]
          - Range: [[64], [64], [1], [32]]
          - Range: [[128], [128], [1], [64]]
          - Range: [[128], [128], [1], [32]]
          - Range: [[64], [64], [1], [512]]
          - Range: [[64], [64], [1], [1024]]
          - Range: [[64], [64], [1], [2048]]
          - Range: [[512], [512], [1], [32]]
          - Range: [[512], [128], [1], [64]]
          - Range: [[128], [128], [1], [512]]
          - Range: [[256], [128], [1], [32]]
          - Range: [[256], [128], [1], [64]]
          - Range: [[128], [512], [1], [64]]
          - Range: [[128], [512], [1], [512]]
          - Range: [[512], [512], [1], [512]]
          - Range: [[512], [512], [1], [128]]
          - Range: [[64], [64], [1], [256]]
          - Range: [[64], [64], [1], [512]]
          - Range: [[256], [512], [1], [256]]
          - Range: [[512], [384], [1], [384]]
          - Range: [[640], [512], [1], [512]]
          - Range: [[512], [256], [1], [640]]
          - Range: [[512], [512], [1], [896]]
          - Range: [[512], [512], [1], [1152]]
          - Range: [[512], [256], [1], [1024]]

          - Range: [[128], [128], [1], [63]]
          - Range: [[512], [512], [1], [65]]
          - Range: [[512], [512], [1], [66]]
          - Range: [[512], [512], [1], [127]]
          - Range: [[512], [512], [1], [129]]
          - Range: [[513], [513], [1], [129]]

          - Range: [[127], [127], [1], [127]]
          - Range: [[129], [129], [1], [129]]
          - Range: [[128], [128], [1], [96]]
          - Range: [[85], [128], [1], [64]]
          - Range: [[640], [513], [1], [64]]
          - Range: [[640], [512], [1], [64]]
          - Range: [[528], [512], [1], [64]]
          - Range: [[520], [512], [1], [64]]
          - Range: [[128], [128], [1], [64]]
          - Range: [[512], [513], [1], [64]]
          - Range: [[524], [512], [1], [64]]
          - Range: [[513], [513], [1], [64]]
          - Range: [[513], [512], [1], [64]]
          - Range: [[513], [513], [1], [64]]

          - Range: [ [8, 35, 256], [8, 35, 256], [1], [8, 36, 256] ]
          - Range: [ [8, 43, 512], [8, 65, 512], [1], [8, 88, 512] ]
          - Range: [ [32, 32, 256], [32, 32, 256], [1], [32, 32, 256] ]
        - BiasTypeArgs: s
        - ActivationArgs:
          - [Enum: relu]

Test Result

All Passed

image

Benchmark Result

7k eff DTVA DTVB DTVA+DTVB Ori New
NT F16 83.34% 80.98% 88.43% 80% 88.43%
NT F8 75% 74.06% 87.80% 60% 87.80%
NN F16 91.03% 85% 75.04% 85% 91.03%
NN F8 82.21% 65.01% 74.21% 65% 82.21%
image image image image

Benchmark results on LLaMA model sizes show about a 7.3% average performance improvement.

Submission Checklist

@cliffxzx
cliffxzx requested a review from cmingch August 25, 2025 08:20
@cliffxzx cliffxzx self-assigned this Aug 25, 2025
@cliffxzx cliffxzx changed the title Enable DirectToVgpr with TLU Enable DirectToVgpr with TLU via global_load_tr Aug 25, 2025
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch 5 times, most recently from 1869617 to 6820911 Compare September 1, 2025 07:50
@cliffxzx cliffxzx changed the title Enable DirectToVgpr with TLU via global_load_tr Add TLU support for DirectToVgpr via global_load_tr Sep 1, 2025
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch 2 times, most recently from f870f7f to 336e426 Compare September 1, 2025 09:30
@cliffxzx
cliffxzx marked this pull request as ready for review September 3, 2025 05:28
Copilot AI review requested due to automatic review settings September 3, 2025 05:28
@cliffxzx
cliffxzx requested a review from a team as a code owner September 3, 2025 05:28

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 adds TLU (transpose/layout) support for DirectToVgpr via global_load_tr instruction, targeting improved performance on GFX12 architecture. The implementation introduces new global_load_tr instructions (TR8_B64 and TR16_B128) that allow data remapping during load operations, eliminating the performance bottleneck from pack code that previously shared the same pipeline as WMMA instructions.

Key changes include:

  • Added new global_load_tr instructions for 8-byte (TR8_B64) and 16-byte (TR16_B128) transpose operations
  • Renamed class hierarchy from "GlobalRead/Write" to "TextureRead/Write" with corresponding function updates
  • Updated kernel generation logic to support GL (Global Load) transpose operations
  • Added hardware capability detection for the new transpose instructions

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rocisa/test/test_instruction.py Updated test function name from countGlobalRead to countTextureRead
rocisa/src/instruction/mem.cpp Renamed GlobalInstruction classes to TextureInstruction and added GLOBALReadInstruction with new TR instruction bindings
rocisa/src/enum.cpp Added new instruction types INST_TR8_B64 and INST_TR16_B128
rocisa/src/count.cpp Renamed countGlobalRead function to countTextureRead
rocisa/src/container.cpp Added GLOBALModifiers container class for global load instruction modifiers
rocisa/include/instruction/mem.hpp Refactored class hierarchy and added GlobalLoadTR8B64 and GlobalLoadTR16B128 instruction classes
rocisa/include/hardware_caps.hpp Added hardware capability detection for GL transpose instructions
rocisa/include/enum.hpp Added TR instruction enum values
rocisa/include/container.hpp Added GLOBALModifiers struct definition
Tensile/Tests/common/gemm/gfx12/*.yaml Added test configurations for FP8 and FP16 with DirectToVgpr transpose support
Tensile/SolutionStructs/Solution.py Added enableGLTr logic and DirectToVgpr compatibility checks for transpose operations
Tensile/KernelWriterAssembly.py Updated kernel generation to support GL transpose instructions and memory access patterns
Tensile/KernelWriter.py Updated function references from countGlobalRead to countTextureRead
Tensile/Components/*.py Updated function references and added transpose-aware code generation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch from 336e426 to c6feafe Compare September 3, 2025 12:24
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch from c6feafe to 3153bca Compare September 4, 2025 08:45

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

good job

@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch from 3153bca to e3f2acf Compare September 5, 2025 08:07
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch 2 times, most recently from bc3da25 to cf03ed0 Compare September 8, 2025 02:18
@cliffxzx
cliffxzx requested a review from a team September 8, 2025 02:19
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch 2 times, most recently from 69f1bc2 to 73ea821 Compare September 8, 2025 07:18
@cliffxzx
cliffxzx force-pushed the users/cliffxzx/dtvwithtlu branch from 73ea821 to 5a2130c Compare September 10, 2025 06:36
@cliffxzx
cliffxzx merged commit c7720c1 into develop Sep 11, 2025
@cliffxzx
cliffxzx deleted the users/cliffxzx/dtvwithtlu branch September 11, 2025 14:35
assistant-librarian Bot pushed a commit to ROCm/hipBLASLt that referenced this pull request Sep 11, 2025
Add TLU support for DirectToVgpr via global_load_tr

## Motivation

After some experimentation, we found that the pack code in the F8 NT and
NN cases was the performance bottleneck because the WMMA and pack code
share the same pipeline. Starting from GFX12, a new instruction called
global_load_tr allows us to eliminate the cost of the pack code by
remapping the data. This makes it possible to support DirectToVgpr in
the TLU case.

## Technical Details

To use it as 16x16x16x1 WMMA input, the offset for global_load_tr should
follow this order:

#### global_load_tr_b128
<img width="830" height="549" alt="image"
src="https://github.com/user-attachments/assets/9b7d239b-fd31-4e57-9134-da605e53ec66"
/>

#### global_load_tr_b64
<img width="876" height="568" alt="image"
src="https://github.com/user-attachments/assets/5a4635b7-f6e1-4a4e-98c6-29a79821d682"
/>

## Test Plan

Test different MacroTile and parameters combinations on F8F8S and HHS
across NN, NT, and TT cases.

```yaml=
      ForkParameters:
        - MatrixInstruction:
          - [16, 16,16, 1, 1, 1, 1, 1, 1]

          - [16, 16,16, 1, 1, 1, 1, 4, 1]
          - [16, 16,16, 1, 1, 2, 1, 4, 1]
          - [16, 16,16, 1, 1, 2, 1, 2, 2]
          - [16, 16,16, 1, 1, 3, 1, 2, 2]
          - [16, 16,16, 1, 1, 7, 1, 1, 4]
          - [16, 16,16, 1, 1, 8, 1, 1, 4]
          - [16, 16,16, 1, 1, 9, 1, 1, 4]
          - [16, 16,16, 1, 1, 10, 1, 1, 4]

          - [16, 16,16, 1, 1, 1, 1, 1, 4]
          - [16, 16,16, 1, 1, 1, 2, 1, 4]
          - [16, 16,16, 1, 1, 1, 2, 2, 2]
          - [16, 16,16, 1, 1, 1, 3, 2, 2]
          - [16, 16,16, 1, 1, 1, 7, 4, 1]
          - [16, 16,16, 1, 1, 1, 8, 4, 1]
          - [16, 16,16, 1, 1, 1, 9, 4, 1]
          - [16, 16,16, 1, 1, 1, 10, 4, 1]

          - [16, 16, 16, 1, 1, 2, 2, 2, 4]
          - [16, 16, 16, 1, 1, 2, 2, 4, 1]
        - ScheduleIterAlg: [3]
        - PrefetchLocalRead: [1]
        - PrefetchGlobalRead: [2]
        - DepthU: [16,64]
        - WavefrontSize: [32]
        - LocalReadVectorWidth: [8]
        - GlobalReadVectorWidthA: [8]
        - GlobalReadVectorWidthB: [8]
        - InnerUnroll: [1]
        - VectorWidthA: [1]
        - VectorWidthB: [1]
        - StoreVectorWidth: [-1]
        - StoreRemapVectorWidth: [0]
        - TransposeLDS: [-1,2]
        - 1LDSBuffer: [0,1]
        - ScheduleLocalWrite: [1]
        - GlobalSplitU: [1]
        - GlobalSplitUAlgorithm: ["MultipleBuffer"]
        - SourceSwap: [0,1]
        - ExpandPointerSwap: [0,1]
        - PreloadKernArgs: [1]
        - DirectToVgprA: [0,1]
        - DirectToVgprB: [0,1]
      BenchmarkFinalParameters:
        - ProblemSizes:
          - Range: [[1], [1], [1], [1]]
          - Range: [[64], [64], [1], [64]]
          - Range: [[128], [128], [1], [128]]
          - Range: [[256], [256], [1], [256]]
          - Range: [[512], [512], [1], [512]]
          - Range: [[1024], [1024], [1], [1024]]

          - Range: [[32], [32], [1], [32]]
          - Range: [[64], [64], [1], [32]]
          - Range: [[128], [128], [1], [64]]
          - Range: [[128], [128], [1], [32]]
          - Range: [[64], [64], [1], [512]]
          - Range: [[64], [64], [1], [1024]]
          - Range: [[64], [64], [1], [2048]]
          - Range: [[512], [512], [1], [32]]
          - Range: [[512], [128], [1], [64]]
          - Range: [[128], [128], [1], [512]]
          - Range: [[256], [128], [1], [32]]
          - Range: [[256], [128], [1], [64]]
          - Range: [[128], [512], [1], [64]]
          - Range: [[128], [512], [1], [512]]
          - Range: [[512], [512], [1], [512]]
          - Range: [[512], [512], [1], [128]]
          - Range: [[64], [64], [1], [256]]
          - Range: [[64], [64], [1], [512]]
          - Range: [[256], [512], [1], [256]]
          - Range: [[512], [384], [1], [384]]
          - Range: [[640], [512], [1], [512]]
          - Range: [[512], [256], [1], [640]]
          - Range: [[512], [512], [1], [896]]
          - Range: [[512], [512], [1], [1152]]
          - Range: [[512], [256], [1], [1024]]

          - Range: [[128], [128], [1], [63]]
          - Range: [[512], [512], [1], [65]]
          - Range: [[512], [512], [1], [66]]
          - Range: [[512], [512], [1], [127]]
          - Range: [[512], [512], [1], [129]]
          - Range: [[513], [513], [1], [129]]

          - Range: [[127], [127], [1], [127]]
          - Range: [[129], [129], [1], [129]]
          - Range: [[128], [128], [1], [96]]
          - Range: [[85], [128], [1], [64]]
          - Range: [[640], [513], [1], [64]]
          - Range: [[640], [512], [1], [64]]
          - Range: [[528], [512], [1], [64]]
          - Range: [[520], [512], [1], [64]]
          - Range: [[128], [128], [1], [64]]
          - Range: [[512], [513], [1], [64]]
          - Range: [[524], [512], [1], [64]]
          - Range: [[513], [513], [1], [64]]
          - Range: [[513], [512], [1], [64]]
          - Range: [[513], [513], [1], [64]]

          - Range: [ [8, 35, 256], [8, 35, 256], [1], [8, 36, 256] ]
          - Range: [ [8, 43, 512], [8, 65, 512], [1], [8, 88, 512] ]
          - Range: [ [32, 32, 256], [32, 32, 256], [1], [32, 32, 256] ]
        - BiasTypeArgs: s
        - ActivationArgs:
          - [Enum: relu]
```

## Test Result

All Passed

<img width="869" height="65" alt="image"
src="https://github.com/user-attachments/assets/9cfea544-fdbd-425b-97bb-429e7c5c1903"
/>

## Benchmark Result

| 7k eff |    DTVA    |  DTVB  | DTVA+DTVB  | Ori |    New     |
| :----: | :--------: | :----: | :--------: | :-: | :--------: |
| NT F16 |   83.34%   | 80.98% | **88.43%** | 80% | **88.43%** |
| NT F8  |    75%     | 74.06% | **87.80%** | 60% | **87.80%** |
| NN F16 | **91.03%** |  85%   |   75.04%   | 85% | **91.03%** |
| NN F8  | **82.21%** | 65.01% |   74.21%   | 65% | **82.21%** |

<img width="1072" height="471" alt="image"
src="https://github.com/user-attachments/assets/eec837fd-7580-4348-a495-0ce1ea682bb9"
/>

<img width="1072" height="471" alt="image"
src="https://github.com/user-attachments/assets/f1673882-0c7a-4988-a24a-6c632cb046a1"
/>

<img width="1079" height="475" alt="image"
src="https://github.com/user-attachments/assets/c0e86b3d-0ed8-4085-9ae0-62231d325e92"
/>

<img width="1077" height="476" alt="image"
src="https://github.com/user-attachments/assets/8487227f-d56b-4ada-8d5c-2009e2f09563"
/>

Benchmark results on LLaMA model sizes show about a 7.3% average
performance improvement.
<!-- 9.9%, 2.57%, 7.05%, and 9.9%. -->

## Submission Checklist

- [x] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
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