Skip to content

Conversation

@Hrzwahusa
Copy link

🚀 Add ROCm/HIP Support for AMD GPUs

📋 Summary

This PR adds full AMD GPU support to QPyTorch through ROCm/HIP, enabling low-precision arithmetic simulation on AMD hardware alongside the existing NVIDIA CUDA support.

🔧 Changes

  • HIP Kernel Implementation: Ported all CUDA quantization kernels to HIP for AMD GPU compatibility
  • Automatic Platform Detection: Build system now automatically detects and builds for either CUDA or ROCm/HIP
  • Seamless Integration: No changes required to existing user code - works with the same API
  • Comprehensive Testing: All existing tests pass on both CPU and AMD GPU (ROCm 7.1)

💻 Technical Details

  • Added qtorch/quant/quant_hip/ directory with HIP kernel implementations
  • Modified qtorch/quant/quant_function.py to detect ROCm and load appropriate extensions
  • Updated .gitignore to exclude HIP build artifacts
  • Tested on ROCm 7.1.25424

✅ Testing

Included test script (run_all_tests.sh) with logging. All tests pass:

  • ✅ test_backward
  • ✅ test_clamp
  • ✅ test_device
  • ✅ test_random
  • ✅ test_relation
  • ✅ test_stochastic

🎯 Benefits

  • Enables QPyTorch on AMD GPUs (Tested on 7900XTX, should work with other models too)
  • Maintains full backward compatibility with CUDA
  • No performance degradation on existing CUDA setups

📦 Requirements

  • ROCm >= 5.0 (tested with 7.1)
  • PyTorch compiled with ROCm support

- Implemented HIP kernels for quantization operations
- Added automatic CUDA/ROCm detection in build system
- Updated README with ROCm installation instructions
- Added test script with logging capabilities
- Tested with ROCm 7.1 on AMD 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.

1 participant