[PR #1067] [CLOSED] hip/gfx906: __dp4a falls back to a 4-iteration loop although gfx906 has v_dot4_i32_i8 #3006

Closed
opened 2026-11-04 02:04:51 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1067
Author: @xxDoman
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: gfx906-140-dp4a


📝 Commits (10+)

  • f4e96d5 tests: gdn_rec_head also compares the PP (variant 4) and two-column (variant 5) recurrence kernels, bitwise
  • 16bc95a prefill: STRATA_HCD_EXACT=1 - the HC down projection by a WMMA kernel with hipBLASLt solution 1176/1177 k order (StaggerU included), bitwise
  • 502fcef #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too
  • 64d0136 cache: preserve checkpoints when split allocation fails
  • a0d0056 prefill: fused-expert exact wins (table16 via direct selector, float4 moe_combine, LDS alias + occupancy)
  • 5f5452b serve: park_current's try covers the checkpoint split too (#752): a host OOM skips parking
  • 8b19a38 Layer split: --vram-reserve-later-mib, a separate reserve for the later cards
  • ea83d0d Resident RAM mode with a layer split
  • d2d981f setup: the low-RAM mode's resident variant on several GPUs (#642)
  • cd62e5e serve: a split's stage-0 GPU profile line keeps its text (#848); later stages say which stage

📊 Changes

1 file changed (+3 additions, -2 deletions)

View changed files

📝 include/strata/hip_compat/intrinsics.hpp (+3 -2)

📄 Description

What

dp4a in include/strata/hip_compat/intrinsics.hpp has a native signed-dot4 path for RDNA3/RDNA4 (__builtin_amdgcn_sudot4) and for RDNA2 gfx103x (__builtin_amdgcn_sdot4), and a portable 4-iteration loop for every other target. The gfx906 build (STRATA_HIP_GFX906) is one of the "other targets", so every __dp4a in the decode path is 4 iterations instead of one instruction.

gfx906 (CDNA1 / GCN5, Instinct MI50/MI60, Radeon VII) has v_dot4_i32_i8, the same instruction the gfx103x branch already uses:

$ llvm-mc -arch=amdgcn -mcpu=gfx906 -show-encoding <<< 'v_dot4_i32_i8 v1, v2, v3, v4'
v_dot4_i32_i8 v1, v2, v3, v4        // dot1-insts

Fix

One line: add __gfx906__ to the gfx103x condition. Same signed x signed byte products, accumulated modulo 2^32, no clamp — exactly the CUDA __dp4a contract, and bit-identical to what the gfx103x path produces (no new instruction semantics are introduced).

Note on ordering

This is independent of the build fix in #1066: on the current tree fused_gr.cu does not even compile, but this change is orthogonal to it. Either order works.

Measurement (2x gfx906, not a repo benchmark)

Instinct MI50 32 GB master + Radeon VII 16 GB helper, IQ3_XXS, ctx 32000, 11552-token prompt, 128 decode, MI50 at 200 W, 4 runs:

tree prefill decode
0.1.39 + the same dot4 line 379-380 38.6-38.9
0.1.40 + this line 291-299 39.5-40.7

The decode difference is the point (~+3-4%); the value itself is one machine, so I would not quote it as a benchmark. An exactness check against the portable path (the tree's tests dp4a parity, or a small local one) is the right gate — happy to run and post it here if you want it before merging.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1067 **Author:** [@xxDoman](https://github.com/xxDoman) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `gfx906-140-dp4a` --- ### 📝 Commits (10+) - [`f4e96d5`](https://github.com/Niko1221/Strata/commit/f4e96d55b6f13622bae6b3ded2f81ca16cbd78f6) tests: gdn_rec_head also compares the PP (variant 4) and two-column (variant 5) recurrence kernels, bitwise - [`16bc95a`](https://github.com/Niko1221/Strata/commit/16bc95ab3e5293a6dd557ad0ec7e2a5eef23640a) prefill: STRATA_HCD_EXACT=1 - the HC down projection by a WMMA kernel with hipBLASLt solution 1176/1177 k order (StaggerU included), bitwise - [`502fcef`](https://github.com/Niko1221/Strata/commit/502fcef6ff29325427ecfb5409b242ac7bea18e1) #606: the fused SwiGLU q8_1 quantizers keep the block's scale and sum finite too - [`64d0136`](https://github.com/Niko1221/Strata/commit/64d01362bee3aa109fb340d9b4144a62d9192522) cache: preserve checkpoints when split allocation fails - [`a0d0056`](https://github.com/Niko1221/Strata/commit/a0d00560fdb3bd728001cac756e223b12e3a09e9) prefill: fused-expert exact wins (table16 via direct selector, float4 moe_combine, LDS alias + occupancy) - [`5f5452b`](https://github.com/Niko1221/Strata/commit/5f5452bec6fabe7c76b44af2397b29daac95feb4) serve: park_current's try covers the checkpoint split too (#752): a host OOM skips parking - [`8b19a38`](https://github.com/Niko1221/Strata/commit/8b19a38a57a80ee9c2bd03d677d8b55fc961d34b) Layer split: --vram-reserve-later-mib, a separate reserve for the later cards - [`ea83d0d`](https://github.com/Niko1221/Strata/commit/ea83d0dc5ef3fd481c53ee6bd99dd8016e10ce78) Resident RAM mode with a layer split - [`d2d981f`](https://github.com/Niko1221/Strata/commit/d2d981f5b2841cfcefcc88872730785b9d23bd78) setup: the low-RAM mode's resident variant on several GPUs (#642) - [`cd62e5e`](https://github.com/Niko1221/Strata/commit/cd62e5e07f5efa6be42a8ccfbbc82b78f6abfe93) serve: a split's stage-0 GPU profile line keeps its text (#848); later stages say which stage ### 📊 Changes **1 file changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/hip_compat/intrinsics.hpp` (+3 -2) </details> ### 📄 Description ## What `dp4a` in `include/strata/hip_compat/intrinsics.hpp` has a native signed-dot4 path for RDNA3/RDNA4 (`__builtin_amdgcn_sudot4`) and for RDNA2 gfx103x (`__builtin_amdgcn_sdot4`), and a portable 4-iteration loop for every other target. The gfx906 build (`STRATA_HIP_GFX906`) is one of the "other targets", so every `__dp4a` in the decode path is 4 iterations instead of one instruction. gfx906 (CDNA1 / GCN5, Instinct MI50/MI60, Radeon VII) has `v_dot4_i32_i8`, the same instruction the gfx103x branch already uses: ``` $ llvm-mc -arch=amdgcn -mcpu=gfx906 -show-encoding <<< 'v_dot4_i32_i8 v1, v2, v3, v4' v_dot4_i32_i8 v1, v2, v3, v4 // dot1-insts ``` ## Fix One line: add `__gfx906__` to the gfx103x condition. Same signed x signed byte products, accumulated modulo 2^32, no clamp — exactly the CUDA `__dp4a` contract, and bit-identical to what the gfx103x path produces (no new instruction semantics are introduced). ## Note on ordering This is independent of the build fix in #1066: on the current tree `fused_gr.cu` does not even compile, but this change is orthogonal to it. Either order works. ## Measurement (2x gfx906, not a repo benchmark) Instinct MI50 32 GB master + Radeon VII 16 GB helper, IQ3_XXS, ctx 32000, 11552-token prompt, 128 decode, MI50 at 200 W, 4 runs: | tree | prefill | decode | |---|---|---| | 0.1.39 + the same dot4 line | 379-380 | 38.6-38.9 | | **0.1.40 + this line** | 291-299 | **39.5-40.7** | The decode difference is the point (~+3-4%); the value itself is one machine, so I would not quote it as a benchmark. An exactness check against the portable path (the tree's `tests` dp4a parity, or a small local one) is the right gate — happy to run and post it here if you want it before merging. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:04:51 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3006
No description provided.