-
Notifications
You must be signed in to change notification settings - Fork 12
feat: Add AMD accelerator detection and tracking in libfabric topology #22
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
Changes from all commits
dc9323d
8fbe1ad
77e1225
1937abd
fb4af61
48c5c65
626c3af
b5c03bb
5eecce9
d5fcb0a
06e339f
3145110
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,4 +20,7 @@ cufile.log | |
| .cache/ | ||
|
|
||
| # Asio | ||
| subprojects/asio-* | ||
| subprojects/asio-* | ||
|
|
||
| build | ||
| subprojects/.wraplock | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,7 @@ class nixlLibfabricTopology { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // System information | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int num_aws_accel; // AWS Trainium accelerators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int num_nvidia_accel; // NVIDIA GPU accelerators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int num_amd_accel; // AMD GPU accelerators | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int num_numa_nodes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int num_devices; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -145,6 +146,8 @@ class nixlLibfabricTopology { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isNeuronAccel(hwloc_obj_t obj) const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isAmdAccel(hwloc_obj_t obj) const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isEfaDevice(hwloc_obj_t obj) const; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // retrieves line speed of NIC from map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -210,6 +213,11 @@ class nixlLibfabricTopology { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return num_nvidia_accel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getNumAmdAccel() const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return num_amd_accel; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const std::vector<std::string> & | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getAllDevices() const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return all_devices; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -231,7 +239,13 @@ class nixlLibfabricTopology { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enum fi_hmem_iface | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getMrAttrIface(int device_id) const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return (device_id < num_nvidia_accel) ? FI_HMEM_CUDA : FI_HMEM_NEURON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (device_id < num_nvidia_accel) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return FI_HMEM_CUDA; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (device_id < num_nvidia_accel + num_amd_accel) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return FI_HMEM_ROCR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return FI_HMEM_ROCR; | |
| // NOTE: FI_HMEM_ROCR is not yet fully supported in the memory | |
| // registration path (mr_attr.device.rocr initialization). Until | |
| // that wiring is complete, fall back to system memory. | |
| return FI_HMEM_SYSTEM; |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMrAttrIface() selects the HMEM interface by comparing the provided device_id against (num_nvidia_accel, num_amd_accel). In the current call chain, device_id is passed through from the backend as the runtime’s device ordinal (e.g., CUDA device index), not a global index across vendors; on systems with mixed accelerator vendors this can misclassify an AMD/Neuron device_id=0 as CUDA and register memory with the wrong iface. Consider deriving the iface from the device’s PCI vendor (e.g., via device_pci_bus_id + hwloc lookup) or from a single selected runtime, rather than from device_id ranges.
| if (device_id < num_nvidia_accel) { | |
| return FI_HMEM_CUDA; | |
| } else if (device_id < num_nvidia_accel + num_amd_accel) { | |
| return FI_HMEM_ROCR; | |
| } else { | |
| return FI_HMEM_NEURON; | |
| } | |
| // The device_id passed here is a runtime-specific ordinal (e.g., CUDA | |
| // device index) and is not guaranteed to be a global cross-vendor index. | |
| // To avoid misclassifying devices on mixed-vendor systems, only infer | |
| // the iface from vendor counts when exactly one accelerator vendor is | |
| // present. Otherwise, fall back to a generic system HMEM iface. | |
| (void)device_id; // currently unused; kept for API compatibility | |
| int vendor_count = 0; | |
| if (num_nvidia_accel > 0) { | |
| vendor_count++; | |
| } | |
| if (num_amd_accel > 0) { | |
| vendor_count++; | |
| } | |
| if (num_aws_accel > 0) { | |
| vendor_count++; | |
| } | |
| // Single-vendor configurations: preserve legacy behavior by selecting | |
| // the corresponding HMEM iface for all device_ids. | |
| if (vendor_count == 1) { | |
| if (num_nvidia_accel > 0) { | |
| return FI_HMEM_CUDA; | |
| } | |
| if (num_amd_accel > 0) { | |
| return FI_HMEM_ROCR; | |
| } | |
| // num_aws_accel > 0 and no other vendors | |
| return FI_HMEM_NEURON; | |
| } | |
| // Mixed-vendor or no-accelerator configuration: we cannot safely infer | |
| // a vendor-specific iface from device_id. Use a generic system iface | |
| // to avoid registering memory with the wrong accelerator runtime. | |
| return FI_HMEM_SYSTEM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ok with this here, but its probably something that we will have to address at one point. The order in which devices are presented on the HIP layer and on the HSA layer doesn't necessarily have to match. So the clean solution is to have somewhere some code that performs the matching using the BDF retrieved for a hip device, and identifying the HSA agent with the same BDF