Skip to content

feat: use hipBLASLt for HIP INT8 GEMM - #15

Open
ray73864 wants to merge 2 commits into
leejet:sd.cppfrom
ray73864:feat/hipblaslt-int8-gemm
Open

ray73864 wants to merge 2 commits into
leejet:sd.cppfrom
ray73864:feat/hipblaslt-int8-gemm

Conversation

@ray73864

Copy link
Copy Markdown

Summary

Add an optional hipBLASLt dispatch path for HIP INT8 GEMM operations.

When the HIP backend is built with hipBLASLt, INT8 GEMM now tries the hipBLASLt heuristic path before falling back to the existing hipBLAS/cuBLAS-compatible implementation. Builds without hipBLASLt and non-HIP backends retain their existing behavior.

The path also declines dispatch while a HIP stream is being captured, because ROCm 10.1 hipBLASLt may submit work to the legacy stream during capture. The existing GEMM path remains responsible for captured graphs.

Validation

Tested on an AMD Radeon RX 9070 XT (gfx1201) with ROCm 10.1:

  • Native HIP build completed with Ninja.
  • 2048x2048 INT8 diffusion sampling: 69.46 s to 30.77 s.
  • Total generation: 78.57 s to 40.03 s.
  • Fixed-seed 768x768 output was byte-for-byte identical between paths.
  • HIP stream-capture requests use the existing fallback path.

The implementation is limited to the HIP backend and is guarded by optional hipBLASLt detection in CMake.

@leejet
leejet changed the base branch from master to sd.cpp October 29, 2026 17:19

@leejet leejet left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the optimization. I think two lifecycle issues should be addressed before merging:

Reuse the hipBLASLt handle. Creating and destroying it for every GEMM adds allocation overhead, and hipblasLtDestroy() implicitly synchronizes the device. This introduces a synchronization point after every INT8 GEMM, including unsuccessful dispatch attempts. Please cache the handle in the backend context and release it during context teardown.

Initialize the fallback before graph capture. If warmup uses hipBLASLt exclusively, ctx.cublas_handle() remains uninitialized until the capture-time fallback. Depending on the ROCm configuration, creating that handle can itself initialize hipBLASLt and perform operations incompatible with capture. Please initialize and warm up the fallback outside capture, and test repeated execution of a pure INT8 graph on a fresh backend context.

The second issue is based on the initialization call chain; I haven’t reproduced it on HIP hardware.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants