HIP: vectorize rowwise INT8 quantization with 16-byte loads - #127
HIP: vectorize rowwise INT8 quantization with 16-byte loads#127tangzzycc wants to merge 1 commit into
Conversation
|
🎉 Thank you for your contribution, we really appreciate it! 🎉 Like many open source projects, we require contributors to sign our Contributor License Agreement (CLA). A CLA makes the ownership of contributions explicit, so contributors and the project share a clear understanding of how the code can be used. By signing, you:
CLAs are standard practice across major open source projects including those under the Apache Software Foundation and the Linux Foundation. Ours is based on the Apache Software Foundation's CLA. Most importantly, it would enable us to relicense the project under a more permissive license in the future, giving the project and its community greater flexibility. ✍ To sign, please post a new comment on this PR with exactly the following text: ✍ I have read and agree to the Contributor License Agreement You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughChangesHIP INT8 quantization
Sequence Diagram(s)sequenceDiagram
participant RowwiseLauncher
participant VectorizedKernel
participant InputBuffer
participant QuantizedOutput
RowwiseLauncher->>InputBuffer: Check alignment and row width
RowwiseLauncher->>VectorizedKernel: Launch vectorized kernel when supported
VectorizedKernel->>InputBuffer: Load uint4 chunks
VectorizedKernel->>VectorizedKernel: Compute absmax and quantize values
VectorizedKernel->>QuantizedOutput: Write quantized values and scales
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This PR adds a guarded vectorized INT8 quantization path while retaining the scalar fallback, with reported coverage for FP32, FP16, BF16, aligned, and offset-contiguous inputs. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Cross-checked this on RDNA4 (gfx1200), since the numbers here are all gfx1151. Correct and bit-identical, no regression, but no speedup either on this part. CorrectnessBuilt this branch and Tests: Performance on gfx1200: flatMedian of 5 interleaved rounds alternating the two builds process by process, wall-clock timed around the direct extension call with preallocated outputs. Only listing shapes whose run-to-run spread stayed under 10 percent; anything under about 150 us was dominated by launch overhead here and could not be separated from noise in either direction.
As a noise gauge, The generated code is what the patch intends, so this is not a missed-vectorization artifact: the gfx1200 ISA shows For what it is worth, two other things I tried on top of this branch are flat here as well, both verified bit-identical to None of that argues against the change: it is portable, guarded, bit-exact, worth 2x where you measured it, and costs nothing here. |
Summary
Implements Change 2 proposed in #102:
uint4for FP32, FP16, and BF16 inputs.keep the existing scalar fallback.
The vectorized path uses the portable HIP
uint4type and has no architecture-specific guard, so it also applies to other supported HIP architectures. Performance was measured on gfx1151.Performance
Measured on AMD Radeon 8060S (gfx1151), ROCm 7.2, with aligned BF16 inputs:
Geometric-mean speedup: 1.96x.
For large BF16 shapes, one-read DRAM-equivalent bandwidth is about 214–229 GB/s, consistent with the 256 GB/s bandwidth of this gfx1151 system.
Testing
including aligned and offset-contiguous inputs.