-
Notifications
You must be signed in to change notification settings - Fork 164
feat: add gpu numa node attribute #1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
enoodle
wants to merge
2
commits into
kubernetes-sigs:main
Choose a base branch
from
enoodle:erez/add-gpu-numa-node-attribute
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+197
−3
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| Copyright The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| resourceapi "k8s.io/api/resource/v1" | ||
| "k8s.io/utils/ptr" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func newTestGpuInfo(numaNode *int) *GpuInfo { | ||
| return &GpuInfo{ | ||
| UUID: "GPU-test", | ||
| minor: 0, | ||
| productName: "NVIDIA Test GPU", | ||
| brand: "NVIDIA", | ||
| architecture: "Test", | ||
| cudaComputeCapability: "9.0", | ||
| driverVersion: "580.0.0", | ||
| cudaDriverVersion: "13.0", | ||
| numaNode: numaNode, | ||
| } | ||
| } | ||
|
|
||
| func requireNumaNodeAttribute(t *testing.T, attrs map[resourceapi.QualifiedName]resourceapi.DeviceAttribute, expected int64) { | ||
| t.Helper() | ||
|
|
||
| attr, ok := attrs[compatibilityNumaNodeAttribute] | ||
| require.True(t, ok) | ||
| require.NotNil(t, attr.IntValue) | ||
| require.Equal(t, expected, *attr.IntValue) | ||
| } | ||
|
|
||
| func TestGpuInfoAttributesIncludeCompatibilityNumaNode(t *testing.T) { | ||
| gpu := newTestGpuInfo(ptr.To(1)) | ||
|
|
||
| requireNumaNodeAttribute(t, gpu.Attributes(), 1) | ||
| } | ||
|
|
||
| func TestCommonMigAttributesIncludeCompatibilityNumaNode(t *testing.T) { | ||
| parent := newTestGpuInfo(ptr.To(2)) | ||
|
|
||
| requireNumaNodeAttribute(t, CommonAttributesMig(parent, "1g.10gb"), 2) | ||
| } | ||
|
|
||
| func TestVfioDeviceIncludesCompatibilityNumaNode(t *testing.T) { | ||
| vfio := &VfioDeviceInfo{ | ||
| UUID: "vfio-test", | ||
| deviceID: "0x1234", | ||
| vendorID: "0x10de", | ||
| index: 0, | ||
| productName: "NVIDIA Test GPU", | ||
| numaNode: 3, | ||
| addressableMemoryBytes: 1024, | ||
| } | ||
|
|
||
| requireNumaNodeAttribute(t, vfio.GetDevice().Attributes, 3) | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| Copyright The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/NVIDIA/go-nvlib/pkg/nvpci" | ||
| "github.com/NVIDIA/go-nvml/pkg/nvml" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestDiscoverNumaNodeUsesNVMLWhenAvailable(t *testing.T) { | ||
| lib := deviceLib{} | ||
|
|
||
| numaNode, err := lib.discoverNumaNode("0000:9f:00.0", func() (int, nvml.Return) { | ||
| return 1, nvml.SUCCESS | ||
| }) | ||
|
|
||
| require.NoError(t, err) | ||
| require.NotNil(t, numaNode) | ||
| require.Equal(t, 1, *numaNode) | ||
| } | ||
|
|
||
| func TestDiscoverNumaNodeFallsBackToPCIWhenNVMLUnsupported(t *testing.T) { | ||
| pci := &nvpci.InterfaceMock{ | ||
| GetGPUByPciBusIDFunc: func(pciBusID string) (*nvpci.NvidiaPCIDevice, error) { | ||
| require.Equal(t, "0000:9f:00.0", pciBusID) | ||
| return &nvpci.NvidiaPCIDevice{NumaNode: 2}, nil | ||
| }, | ||
| } | ||
| lib := deviceLib{nvpci: pci} | ||
|
|
||
| numaNode, err := lib.discoverNumaNode("0000:9f:00.0", func() (int, nvml.Return) { | ||
| return 0, nvml.ERROR_NOT_SUPPORTED | ||
| }) | ||
|
|
||
| require.NoError(t, err) | ||
| require.NotNil(t, numaNode) | ||
| require.Equal(t, 2, *numaNode) | ||
| require.Len(t, pci.GetGPUByPciBusIDCalls(), 1) | ||
| } | ||
|
|
||
| func TestDiscoverNumaNodeOmitsUnknownPCINumaNode(t *testing.T) { | ||
| pci := &nvpci.InterfaceMock{ | ||
| GetGPUByPciBusIDFunc: func(string) (*nvpci.NvidiaPCIDevice, error) { | ||
| return &nvpci.NvidiaPCIDevice{NumaNode: -1}, nil | ||
| }, | ||
| } | ||
| lib := deviceLib{nvpci: pci} | ||
|
|
||
| numaNode, err := lib.discoverNumaNode("0000:9f:00.0", func() (int, nvml.Return) { | ||
| return 0, nvml.ERROR_NOT_SUPPORTED | ||
| }) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Nil(t, numaNode) | ||
| } |
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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@enoodle instead of adding attributes with a custom prefix, better to use derived attributes feature that is proposed. Also, if we decide to publish an attribute for
numaNode, it will be a list attribute to support modern coherent memory systems.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently, dra-net, dra-cpu and dra-sriov-vf all seem to use same prefix to advertise this attribute. This could be an intermittent solution until the derived attributes and list-attributes features are GA to allow use cases where topology alignment using
numaNodemake sense. @varunrsekar WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not a fan of the short-term solution. GPU DRA driver does not own the “dra.net/numaNode” attribute. If anything, we should wait for this KEP kubernetes/enhancements#6073 to be merged and use the standardized attribute under the
resource.kubernetes.iodomain.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see that the standard attribute is now considered for 1.37. Thought there was a push back on this in favor of derived attributes feature which would have been only alpha in 1.37. @enoodle if kubernetes/enhancements#6073 is approved, then we can immediately use the same prefix in our driver. We have to propose same with the other drivers too.