Skip to content

Conversation

@Andy-Jost
Copy link
Contributor

@Andy-Jost Andy-Jost commented Nov 14, 2025

Description

Standardizes the way device arguments are accepted in public APIs. Previously, some functions could accept either a Device or int representing a device ordinal, whereas other would accept only an ordinal. This change updates everything to accept either.

Also, rather than use getattr to convert argument, this change uses Device(arg) to convert any supported argument to a device (or raise an exception), matching the way Stream arguments are converted.

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Nov 14, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Andy-Jost Andy-Jost self-assigned this Nov 14, 2025
@Andy-Jost Andy-Jost added the cuda.core Everything related to the cuda.core module label Nov 14, 2025

"""
__slots__ = ("_id", "_mr", "_has_inited", "_properties", "_uuid")
__slots__ = ("_id", "_memory_resource", "_has_inited", "_properties", "_uuid")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this to match a request in a recent change to _memory/_buffer.*

Comment on lines -989 to -1003
# If the device is in TCC mode, or does not support memory pools for some other reason,
# use the SynchronousMemoryResource which does not use memory pools.
with nogil:
HANDLE_RETURN(
cydriver.cuDeviceGetAttribute(
&attr, cydriver.CUdevice_attribute.CU_DEVICE_ATTRIBUTE_MEMORY_POOLS_SUPPORTED, dev_id
)
)
if attr == 1:
from cuda.core.experimental._memory import DeviceMemoryResource
device._mr = DeviceMemoryResource(dev_id)
else:
from cuda.core.experimental._memory import _SynchronousMemoryResource
device._mr = _SynchronousMemoryResource(dev_id)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to @property memory_resource (lazy init). This was resulting in a circularity with DeviceMemoryResource using Device.

…public APIs taking a device to accept either.
@Andy-Jost
Copy link
Contributor Author

/ok to test 267b268

@github-actions

This comment has been minimized.

Copy link
Collaborator

@rparolin rparolin left a comment

Choose a reason for hiding this comment

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

lgtm

@leofang leofang added this to the cuda.core beta 10 milestone Nov 15, 2025
@leofang leofang added enhancement Any code-related improvements P1 Medium priority - Should do labels Nov 15, 2025
@Andy-Jost Andy-Jost merged commit db8058d into NVIDIA:main Nov 17, 2025
59 checks passed
@Andy-Jost Andy-Jost deleted the device-arg-cleanup branch November 17, 2025 21:10
@github-actions
Copy link

Doc Preview CI
Preview removed because the pull request was closed or merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants