Skip to content

Conversation

@mdboom
Copy link
Contributor

@mdboom mdboom commented Jan 16, 2026

This adds two convenience methods to convert between cuda.core.Device and cuda.core.system.Device.

I have a few design questions for this one:

  • Is the naming of Device.to_system_device and Device.to_cuda_device ok?
  • This could be a new type accepted by the constructor, e.g. cuda.core.Device(nvml_device), but that requires importing the other module from the constructor which could be a performance / cyclical import nightmare.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Jan 16, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mdboom mdboom force-pushed the cuda.core.system-convert-devices branch from 922270e to 23aefa3 Compare January 16, 2026 17:44
@mdboom mdboom requested a review from Copilot January 16, 2026 17:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds convenience methods to convert between cuda.core.Device (CUDA API) and cuda.core.system.Device (NVML API), enabling easier interoperability between the two device types.

Changes:

  • Added to_system_device() method to cuda.core.Device for converting to NVML device representation
  • Added to_cuda_device() method to cuda.core.system.Device for converting to CUDA device representation
  • Added comprehensive tests for both conversion methods

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
cuda_core/cuda/core/_device.pyx Implements to_system_device() method for converting CUDA Device to system Device using UUID mapping
cuda_core/cuda/core/system/_device.pyx Implements to_cuda_device() method for converting system Device to CUDA Device by searching all devices for matching UUID
cuda_core/tests/test_device.py Adds test for to_system_device() conversion, verifying UUID and PCI bus ID mapping
cuda_core/tests/system/test_system_device.py Adds test for to_cuda_device() conversion across all devices, verifying UUID and PCI bus ID mapping

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mdboom
Copy link
Contributor Author

mdboom commented Jan 16, 2026

/ok to test

@github-actions
Copy link

@mdboom
Copy link
Contributor Author

mdboom commented Jan 16, 2026

/ok to test

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