Fix the field-id enum name in the nvml test helper supports_nvlink - #2560
Open
LeSingh1 wants to merge 1 commit into
Open
Fix the field-id enum name in the nvml test helper supports_nvlink#2560LeSingh1 wants to merge 1 commit into
LeSingh1 wants to merge 1 commit into
Conversation
def supports_nvlink(device):
fields = nvml.FieldValue(1)
fields[0].field_id = nvml.FI.DEV_NVLINK_GET_STATE
There is no `FI` attribute on cuda.bindings.nvml. The enum is `FieldId`
(nvml.pyx:1229), with DEV_NVLINK_GET_STATE at nvml.pyx:1454, and the sibling
test uses the correct spelling: test_nvlink.py:19 does
`fields[0].field_id = nvml.FieldId.DEV_NVLINK_LINK_COUNT`.
So the helper raises AttributeError on its first line of real work. Nobody
has noticed because it has no callers -- a repo-wide grep for
`supports_nvlink` finds only its own definition. Contrast util.supports_ecc,
which is called from test_page_retirement.py.
Adds tests/nvml/test_util.py, which stubs nvml.device_get_field_values so the
helper can be exercised without an NVLink-capable device, and asserts both
that it returns True and that it queried FieldId.DEV_NVLINK_GET_STATE. It
fails with AttributeError before this change.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is no
FIattribute oncuda.bindings.nvml. The enum isFieldId(
nvml.pyx:1229), withDEV_NVLINK_GET_STATEatnvml.pyx:1454. The sibling test usesthe correct spelling:
So the helper raises
AttributeErroron its first line of real work.Nobody has noticed because it has no callers — a repo-wide grep for
supports_nvlinkfinds only its own definition. Contrast
util.supports_eccin the same file, which iscalled from
test_page_retirement.py:35,61. This is a guard that cannot fire because itis never invoked, and would crash if it were.
Why fix rather than delete
Deleting the dead helper is the other reasonable option, and I am happy to switch if you
prefer it. I went with the fix because
supports_nvlinksits next tosupports_eccandis_vgpuas part of an obviously intended capability-probe set, and because a test nowkeeps it honest instead of letting it rot again.
Test
New
cuda_bindings/tests/nvml/test_util.py. It stubsnvml.device_get_field_values, sothe helper runs without an NVLink-capable device, and asserts both that it returns
Trueand that it queried
FieldId.DEV_NVLINK_GET_STATE. It fails onmainwithAttributeError: module 'cuda.bindings.nvml' has no attribute 'FI'.The test uses the package-relative
from . import utilthattest_gpu.pyandtest_page_retirement.pyalready use, and inherits thehardware_supports_nvml()gate intests/nvml/__init__.py.ruff checkandruff format --checkare clean.