mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #322] [CLOSED] hip: fast packed-byte intrinsics for RDNA3/RDNA4 (v_perm_b32 + SWAR) #2574
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2574
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/322
Author: @bsorensen110
Created: 10/1/2026
Status: ❌ Closed
Base:
main← Head:fast-intrinsics-rdna4📝 Commits (2)
7e7e6e1hip: fast packed-byte intrinsics for RDNA3/RDNA4 (v_perm_b32 + SWAR)2a57d8dModify selector assignment in fast_intrinsics_parity.cpp📊 Changes
4 files changed (+112 additions, -29 deletions)
View changed files
📝
CMakeLists.txt(+6 -0)📝
cmake/hip_backend.cmake(+1 -1)📝
include/strata/hip_compat/intrinsics.hpp(+30 -28)➕
tests/hip/fast_intrinsics_parity.cpp(+75 -0)📄 Description
What
Speeds up the four emulated CUDA packed-byte intrinsics in
include/strata/hip_compat/intrinsics.hppon the validated wave32 architectures (gfx1100, gfx1201), and adds an exhaustive parity test.__byte_perm,__vsub4,__vsubss4and__vcmpne4are used in the i-quant dequant/sign paths (iq_kernels.cu: 28 uses,native_mmvq.cu: 14 uses). Today:__byte_permlowers to a byte-array access in private memory — scratch traffic in the table lookups.This patch:
__byte_perm→v_perm_b32in one instruction (selector nibbles spread to bytes, masked to 0–7).__vsub4/__vsubss4/__vcmpne4→ branchless SWAR (Hacker's Delight 2-18 style). I probed the gfx1201 ISA directly: the RDNA1/2-era packed ops (v_sub_u8,v_add_u8,v_cmp_ne_u8,v_sub_u16, …) are not in the ISA, so lane isolation is done with the top-bit trick, not ISA lanes.v_perm_b32is present and is the only 1:1 mapping.tests/hip/fast_intrinsics_parity.cpp(registered aship_fast_intrinsics_parity, HIP-only likehip_intrinsics): 262,144 cases against an independent host reference — all 65,536 byte pairs × 4,096 selectors exhaustively, plus randomized mixed-lane words, plus output guards.Evidence
Radeon AI PRO R9700 (gfx1201), engine 0.1.30, Swift 1.5 IQ3_XXS, 131072 ctx, INT8 KV, MTP, same machine/config, three fresh 512-token trials per arm:
hip_fast_intrinsics_parity: PASS (262144 cases / 1048576 operation results, all 65536 byte pairs, 4096 selectors, 16 guards).-E '^(ple_parity|platform_memory_test|expert_parity|pool_test)$', the same exclusions as the release docs;hip_prefill_hipblaslt_gemmskips, no gfx1201 table shipped).Notes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.