-
Notifications
You must be signed in to change notification settings - Fork 21
Add CUDA backend support for NVIDIA GPUs with automatic detection #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mawad-amd
merged 23 commits into
main
from
copilot/fix-4d83afe6-045c-4573-a6ec-6f6dd80f6f0e
Oct 8, 2025
Merged
Add CUDA backend support for NVIDIA GPUs with automatic detection #200
mawad-amd
merged 23 commits into
main
from
copilot/fix-4d83afe6-045c-4573-a6ec-6f6dd80f6f0e
Oct 8, 2025
Conversation
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
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot finished work on behalf of
mawad-amd
October 6, 2025 00:59
mawad-amd
reviewed
Oct 6, 2025
- Add custom build backend (build_backend.py) to support --config-settings - Update pyproject.toml to use custom build backend - Modify iris/hip.py to prioritize build-time config over env vars - Update README with pip install --config-settings backend=nvidia examples - Add 3 new unit tests for build-time configuration (11 tests total pass) - Update example script to document both build-time and runtime methods - Add iris/.config/ to .gitignore Backend detection priority is now: 1. Build-time configuration (--config-settings backend=nvidia/hip) 2. IRIS_BACKEND environment variable (runtime) 3. Auto-detection based on available libraries 4. Default to HIP for backward compatibility Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot finished work on behalf of
mawad-amd
October 6, 2025 01:09
mawad-amd
reviewed
Oct 6, 2025
mawad-amd
reviewed
Oct 6, 2025
Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
mawad-amd
reviewed
Oct 6, 2025
- Add build() hook in setup.py to handle --config-settings - Sets IRIS_BACKEND environment variable during build - Normalizes backend names (nvidia→cuda, amd/rocm→hip) - Updated build_backend.py to also set env var for consistency - All 11 unit tests pass Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
mawad-amd
reviewed
Oct 6, 2025
mawad-amd
reviewed
Oct 6, 2025
- Restore README.md to state before PR changes - Keep only code changes without documentation updates - All linting checks pass Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot finished work on behalf of
mawad-amd
October 6, 2025 04:24
mawad-amd
reviewed
Oct 6, 2025
- Remove build() function from setup.py (back to original) - Simplify iris/hip.py to use only auto-detection (no build-time config) - Remove _backend_selected.py from .gitignore (not used) - Backend selection now purely based on library availability - Minimal changes - keeps only essential backend auto-detection Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot finished work on behalf of
mawad-amd
October 6, 2025 05:22
mawad-amd
reviewed
Oct 6, 2025
- Remove separate _hip.py and _cuda.py files - Add backend auto-detection at module load time (_is_amd_backend flag) - All functions now branch internally based on _is_amd_backend - Minimal changes - keeps original hip.py structure - Dynamic IPC handle size (64 for HIP, 128 for CUDA) - Zero configuration required - works out of the box Co-authored-by: mawad-amd <112003944+mawad-amd@users.noreply.github.com>
Copilot finished work on behalf of
mawad-amd
October 6, 2025 05:40
mawad-amd
approved these changes
Oct 8, 2025
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 CUDA Backend Support ✅
This PR implements CUDA backend support for Iris, enabling the framework to run seamlessly on both AMD GPUs (via HIP) and NVIDIA GPUs (via CUDA) with transparent backend auto-detection.
Summary
Iris now supports both AMD GPUs (HIP backend) and NVIDIA GPUs (CUDA backend) with automatic backend detection based on available GPU libraries. All backend logic is consolidated into a single
iris/hip.py
file with conditional branching.Changes Made
Unified Backend Module (
iris/hip.py
):_is_amd_backend
flag for internal useget_ipc_handle_size()
for use by iris.pyDynamic Sizing (
iris/iris.py
):get_ipc_handle_size()
importKey Features:
Code Quality:
Usage
Implementation Details
Backend Detection (in
iris/hip.py
):libamdhip64.so
→ sets_is_amd_backend = True
libcudart.so
→ sets_is_amd_backend = False
Conditional Functions:
hip_try()
- branches to hipGetErrorString or cudaGetErrorStringhipIpcMemHandle_t
- 64 bytes for HIP, 128 bytes for CUDAopen_ipc_handle()
- calls hipIpcOpenMemHandle or cudaIpcOpenMemHandle_is_amd_backend
Backend-Specific Behavior:
get_rocm_version()
- returns (-1, -1) for CUDAget_arch_string()
- returns GCN arch for HIP, compute capability for CUDA (e.g., "sm_90")get_num_xcc()
- returns actual count for AMD, 1 for NVIDIACode Statistics
iris/hip.py
,iris/iris.py
Backend Detection Logic
libamdhip64.so
→ use HIP backendlibcudart.so
→ use CUDA backendSupported Hardware
AMD GPUs (HIP Backend):
NVIDIA GPUs (CUDA Backend):
Notes
References
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.