Skip to content

Simplify driver APIs and improve nvl72 fabric network detection#540

Merged
artulab merged 2 commits into
mainfrom
artulab/improve_driver_api
Jun 25, 2026
Merged

Simplify driver APIs and improve nvl72 fabric network detection#540
artulab merged 2 commits into
mainfrom
artulab/improve_driver_api

Conversation

@artulab

@artulab artulab commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Tested on NVL72 and AMD clusters with fabric and local network topologies.

Test Result

PASS

Submission Checklist

@artulab
artulab requested a review from mawad-amd as a code owner June 24, 2026 01:33
Copilot AI review requested due to automatic review settings June 24, 2026 01:33
@artulab
artulab requested review from BKP and neoblizz as code owners June 24, 2026 01:33
@github-actions github-actions Bot added in-progress We are working on it iris Iris project issue labels Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR simplifies the driver API for export/import/cleanup by introducing structured placement and export descriptors, and updates NVIDIA fabric discovery to query NVML directly via ctypes (including v3/v2 struct support) for improved NVL72 detection.

Changes:

  • Replaced per-driver va/access_va/access_size parameters with MappingPlacement, and unified cleanup_import/cleanup_local into cleanup(target).
  • Introduced ExportableMemory to standardize exporting either driver-created allocations or arbitrary local memory ranges (where supported).
  • Updated NVIDIA NVML fabric detection to use direct ctypes calls and added unit tests for the new NVML path.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/unittests/test_topology.py Adds tests to validate the direct-NVML (ctypes) fabric info path and byref usage.
tests/unittests/test_drivers.py Updates tests to match the unified cleanup() API and ExportableMemory export API.
iris/host/memory/symmetric_heap.py Switches peer mapping calls to MappingPlacement and unified cleanup().
iris/host/memory/allocators/vmem_chunked_allocator.py Refactors shared-region tracking to ExportableMemory, uses MappingPlacement, and updates cleanup/export calls.
iris/host/distributed/topology.py Implements direct NVML fabric info query (v3/v2) and removes CUDA fabric-handle probing fallback.
iris/drivers/local/nvidia.py Updates export/import/cleanup APIs to use ExportableMemory, MappingPlacement, and unified cleanup().
iris/drivers/local/amd.py Updates export/import/cleanup APIs similarly; removes export_pointer_handle.
iris/drivers/fabric/nvidia.py Updates APIs to use ExportableMemory, MappingPlacement, and unified cleanup().
iris/drivers/fabric/amd.py Updates abstract API surface to match new base driver interfaces.
iris/drivers/base.py Introduces ExportableMemory, MappingPlacement, and unified cleanup() in the base interface.
iris/drivers/init.py Re-exports new driver API types.

Comment on lines +277 to +309
def _fabric_info_from_nvml_struct(fabric_info) -> FabricInfo:
# Check registration state — must be COMPLETED (value 3)
state = getattr(fabric_info, "state", None)
if state is not None and int(state) != 3:
return FabricInfo()

# Check status — must be SUCCESS (value 0)
status = getattr(fabric_info, "status", None)
if status is not None and int(status) != 0:
return FabricInfo()

cluster_uuid_raw = getattr(fabric_info, "clusterUuid", None)
if cluster_uuid_raw is None:
return FabricInfo()

if isinstance(cluster_uuid_raw, bytes):
cluster_uuid_hex = cluster_uuid_raw.hex()
elif isinstance(cluster_uuid_raw, (list, tuple)):
cluster_uuid_hex = bytes(cluster_uuid_raw).hex()
else:
try:
cluster_uuid_hex = bytes(cluster_uuid_raw).hex()
except TypeError:
cluster_uuid_hex = str(cluster_uuid_raw)

if all(c == "0" for c in cluster_uuid_hex):
return FabricInfo()

clique_id = getattr(fabric_info, "cliqueId", 0)
return FabricInfo(
cluster_uuid=cluster_uuid_hex,
clique_id=int(clique_id),
)
Comment on lines +246 to +254
class _NvmlGpuFabricInfoV2(ctypes.Structure):
_fields_ = [
("version", ctypes.c_uint),
("clusterUuid", ctypes.c_ubyte * 16),
("status", ctypes.c_int),
("cliqueId", ctypes.c_uint),
("state", ctypes.c_ubyte),
("healthMask", ctypes.c_uint),
]
Comment on lines +261 to +270
class _NvmlGpuFabricInfoV3(ctypes.Structure):
_fields_ = [
("version", ctypes.c_uint),
("clusterUuid", ctypes.c_ubyte * 16),
("status", ctypes.c_int),
("cliqueId", ctypes.c_uint),
("state", ctypes.c_ubyte),
("healthMask", ctypes.c_uint),
("healthSummary", ctypes.c_ubyte),
]
Comment on lines +336 to +339
nvml_path = ctypes.util.find_library("nvidia-ml") or "libnvidia-ml.so.1"
nvml = ctypes.CDLL(nvml_path)
get_fabric_info = nvml.nvmlDeviceGetGpuFabricInfoV
get_fabric_info.restype = ctypes.c_int
Comment on lines 1267 to 1269
all_node_infos = [json.loads(s) for s in all_node_jsons]

# Group ranks by hostname
Comment on lines +341 to +349
for info_type in (_NvmlGpuFabricInfoV3, _NvmlGpuFabricInfoV2):
info = info_type()
get_fabric_info.argtypes = [ctypes.c_void_p, ctypes.POINTER(info_type)]
ret = get_fabric_info(handle, ctypes.byref(info))
if ret != 0:
continue
fabric_info = _fabric_info_from_nvml_struct(info)
if fabric_info.is_valid:
return fabric_info
@artulab artulab self-assigned this Jun 24, 2026
@artulab
artulab merged commit ee92548 into main Jun 25, 2026
46 of 47 checks passed
@artulab
artulab deleted the artulab/improve_driver_api branch June 25, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in-progress We are working on it iris Iris project issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants