Add Device.arch property for convenient compute capability string access#877
Add Device.arch property for convenient compute capability string access#877
Conversation
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Device.arch that returns the CC value as a string
leofang
left a comment
There was a problem hiding this comment.
@copilot looking good! One nit: in all samples, could you just merge the dev.arch access to the f-strings where arch is needed, instead of having a separate call?
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Done! I've updated all the example files to inline the |
|
@copilot looking good, please add a release note |
Co-authored-by: leofang <5534781+leofang@users.noreply.github.com>
Added release note for the new Device.arch property in the "New features" section. The note documents the property and its convenience benefit. (7fc9d1b) |
|
/ok to test 7fc9d1b |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: kkraus14 <3665167+kkraus14@users.noreply.github.com>
|
/ok to test |
@kkraus14, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/ |
|
/ok to test 491fb89 |
|
…ess (#877) * Initial plan * Add Device.arch property and update examples to use it Co-authored-by: leofang <5534781+leofang@users.noreply.github.com> * Inline dev.arch calls in f-strings per PR feedback Co-authored-by: leofang <5534781+leofang@users.noreply.github.com> * Add release note for Device.arch property Co-authored-by: leofang <5534781+leofang@users.noreply.github.com> * Use f-string instead of "".join for Device.arch property Co-authored-by: kkraus14 <3665167+kkraus14@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: leofang <5534781+leofang@users.noreply.github.com> Co-authored-by: kkraus14 <3665167+kkraus14@users.noreply.github.com>
This PR adds a convenient
Device.archproperty that returns the compute capability as a concatenated string, eliminating the need for repetitive string concatenation code throughout the codebase.Problem
Previously, getting the compute capability as a string required this verbose pattern everywhere:
This pattern appeared in 8 locations across 7 example files and was identified as annoying repetitive code.
Solution
Added a new
archproperty to theDeviceclass:Now the usage is much cleaner:
Changes
Device.archproperty incuda_core/cuda/core/experimental/_device.pycuda_core/examples/vector_add.pycuda_core/examples/simple_multi_gpu_example.py(2 occurrences)cuda_core/examples/pytorch_example.pycuda_core/examples/strided_memory_view_gpu.pycuda_core/examples/saxpy.pycuda_core/examples/cuda_graphs.pycuda_core/examples/memory_ops.pytest_device.pyBenefits
Fixes #729.
💡 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.