[ROCm] Add ROCm support and norm op. - #69
Open
WhatGhost wants to merge 4 commits into
Open
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
Author
|
@reed-lau Hi, could you please help to review this PR. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add AMD GPU (ROCm) support: build path + first norm operator
Background
HPC-Ops is currently a CUDA-only operator library targeting NVIDIA SM90. This PR starts bringing it to AMD GPUs (ROCm).
The goal is incremental: this first PR lands the compilation path for the ROCm backend plus one operator (
fused_rmsnorm_with_scale) as a working end-to-end example. More operators will be ported in follow-up PRs, and the performance of the ported operators will continue to be optimized over time.Target hardware for this PR: AMD MI350X (gfx950 / CDNA4).
1. HIP kernel with simple adaptation and optimization.
The original CUDA norm operator was converted to HIP and placed under a new
src/amd/tree. Made some changes to adapt it to HIP。It also includes a simple optimization2. ROCm build path for AMD GPUs.
CMakeLists.txtgains an opt-inUSE_ROCMbranch that compiles only the portedsrc/amd/**sources withhipcc, leaving the CUDA path byte-for-byte unchanged whenUSE_ROCMis off,andhpc/__init__.pytolerates operators not yet built on ROCm (only the norm op is compiled for now) so importinghpcworks.Testing
The norm operator was validated for correctness (60/60 parametrized pytest cases pass on gfx950) and benchmarked against four references:
aiterrms_norm(plain RMSNorm, bf16)Results (gfx950 / MI350X, latency μs, lower is better)
Measured with CUDA events, median-of-100 × 3 rounds (min), warmup 20, pinned to an idle GPU.
hidden = 5120
hidden = 4096
hidden = 320
Summary: HPC is fastest across small/medium batches and all
hidden=320sizes (while also doing the extra fp8 quant), and beats aiter/torch everywhere. On large batches with large hidden the picture is mixed: at batch 4096 it is competitive (faster than Triton at hidden=4096, within ~7% at hidden=5120), while at batch 8192 it trails Triton by ~11-13%; closing that batch-8192 gap is future optimization work.Benchmark script