Skip to content

feat: allocate GPUs through DRA for profile-based services - #64

Open
salexo wants to merge 15 commits into
feature/dra-node-matchingfrom
feature/dra-allocation
Open

salexo wants to merge 15 commits into
feature/dra-node-matchingfrom
feature/dra-allocation

Conversation

@salexo

@salexo salexo commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Merge order: merge after #62. This PR targets #62's branch feature/dra-node-matching, so GitHub retargets it to main when #62 merges and its branch is deleted. Merge #95 first too: without it, the NoNodesForAllocation status write below is refused by the status enum.

Part 3b of DRA support. DRA allocation is marked experimental. Services that use the device plugin behave as on main.

What changes

  • acceleratorAllocation.mode (Auto, DRA, DevicePlugin) is added to the shared runtime config, so it can be set in an AIMRuntimeConfig, an AIMClusterRuntimeConfig or on the AIMService.
    • Auto is the default. It uses the device plugin when a device-plugin node has the profile's GPUs, and DRA when only DRA nodes have them (DRA-only hardware, or nodes with mixed GPU models).
    • With a spec.resources override, the nodes that fit the service's resources decide. With profileOverrides, the overlay profile's nodes decide.
    • A running InferenceService keeps its mode while it serves the same profile and that mode has nodes, or while neither mode has any. Adding DRA nodes never moves a running service.
    • The mode is decided in ComposeState. Fetch reads the profile's ServingRuntime as before, plus its DRA variant for GPU profiles.
  • Where DRA doesn't apply, the device plugin is used. A DRA mode inherited from a runtime config leaves NVIDIA profiles and LLMInferenceService services on the device plugin. Only a DRA mode the service sets itself is refused, with AcceleratorAllocationUnsupported.
  • Profile selection follows an explicit mode. With DRA or DevicePlugin, a selector skips Ready profiles that have no nodes for that mode. If no candidate has any, it keeps them all, so the service still binds and reports NoNodesForAllocation.
  • DRA services get a ResourceClaimTemplate owned by the service.
    • It requests acceleratorCount devices from the gpu.amd.com DeviceClass. There is no spec.dra.deviceClassName: node matching reads only gpu.amd.com slices.
    • Devices are selected by PCI device ID, from Match profiles against AMD GPU DRA nodes and report them separately #62's amdGPUModelsByDeviceID, and by partitioning mode. A matchAttribute on gpu.amd.com/deviceID keeps a multi-GPU claim to one model.
    • The template name hashes the service name and the device request (model, partitioning, count), not the CEL text. A template's spec is immutable, so an existing one isn't applied again.
    • A stale template is deleted only after the InferenceService stops referencing it and its rollout has finished, and once no predictor pod references it.
    • The operator owns the templates (Owns), so it watches them when the cluster serves resource.k8s.io/v1.
    • The InferenceService references <runtime>-dra, a variant of the profile's ServingRuntime without amd.com/gpu and node affinity. KServe's MergeContainerWithPatch can override amd.com/gpu but not remove it, and ServingRuntimePodSpec has no resourceClaims before v0.21. The variant is projected only when a DRA service needs it.
  • Projected ServingRuntimes stay device-plugin only. A ServingRuntime can't carry a claim, so status.projectedRuntimeName and the model-slug runtime are projected only when a device-plugin node matches.
  • Profiles count DRA nodes in status.matchingNodes and HardwareAvailable.
  • Tainted DRA devices don't count, because the claims tolerate no DRA device taints. The mismatch reason names them.
  • status.acceleratorAllocation is added to the AIMService, with two new reasons:
    • NoNodesForAllocation when the chosen mode has no node.
    • AcceleratorAllocationUnsupported when a DRA service sets amd.com/gpu in spec.resources, or when the service itself sets DRA for a non-AMD profile or for LLMInferenceService serving.
  • RBAC for resource.k8s.io ResourceClaimTemplates.

Upgrade note

DRA allocations are not requests.amd.com/gpu. With Auto as the default, new services whose GPUs exist only on DRA nodes bypass namespace quotas and dashboards keyed on that resource. Quota on the DeviceClass (gpu.amd.com.deviceclass.resource.k8s.io/devices) is the only way to limit them: a namespace runtime config or the service can set DRA whatever the cluster runtime config says. The changelog, runtime-config.md and security.md say so.

DRA pods get no toleration from ExtendedResourceToleration, so AIM Engine adds the same amd.com/gpu:NoSchedule toleration to them. Other taints need spec.tolerations (#63).

The claim and ServingRuntime of DRA services may change in later releases, which restarts their pods once on that upgrade. The rollback section of upgrading.md lists what v0.2.7 leaves behind: the -dra ServingRuntimes and their ConfigMaps, and the ResourceClaimTemplates.

Tests

  • TestDevicePluginServicesAreUnchanged runs the service pipeline for five device-plugin services and compares their InferenceService, ServingRuntime and ConfigMap with a golden file generated on Match profiles against AMD GPU DRA nodes and report them separately #62's branch. Each also runs in a cluster with a DRA node. The cases are profile defaults, spec.resources, tolerations, four GPUs and an NVIDIA profile.
  • Unit tests cover:
    • The mode decision: explicit modes, runtime-config DRA on NVIDIA and LLMInferenceService services, and Auto with a running service whose mode lost its nodes or whose profile changed.
    • Overlay profiles: the counts that decide Auto come from the overlay.
    • The resolver with an explicit mode: an MI300X profile with only DRA nodes and an MI355X profile with only device-plugin nodes.
    • The claim template shape and name: a changed selector text keeps the name, and two services with the same truncated prefix get different names.
    • The DRA InferenceService: no amd.com/gpu, the claim wired in, and the DRA runtime name.
    • Invalid DRA services and their reason.
    • Stale template cleanup during and after a rollout.
    • Tainted devices.
  • TestDRAClaimSelectorAgreesWithNodeMatcher evaluates the generated CEL with cel-go for every model and partitioning mode, over the ResourceSlices the driver publishes (hack/fakegpu/testdata), and requires the Go matcher's verdict for every device.
  • The generated CEL selectors were run against a real scheduler with the fake fleet. MI355X ×8, CPX-NPS4 ×4, and R9700 ×2 on a node mixed with MI350P all allocate, and a partition selector on a Radeon node doesn't.
  • New KWOK test tests/e2e/kwok/dra-inference-service: an Auto-mode service on DRA-only hardware gets status.acceleratorAllocation: DRA, a claim template, the GPU-less runtime, and a predictor pod on a DRA MI355X node with eight allocated devices.
  • tests/e2e/kwok/profile-node-matching now expects DRA nodes in matchingNodes.

@pre

pre commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

A node can run amd.com/gpu pods on DRA devices when a DeviceClass has extendedResourceName: amd.com/gpu, but the node match counts such a node only as a DRA node. After the upgrade to this PR, a service that main deployed on such a node gets NoNodesForAllocation, and so does a new service with explicit DevicePlugin mode. Below are two failing unit tests and a 22-line fix.

I read this PR together with #62 and ran the unit tests at 0ab708d. My evidence is two unit tests (below) and a code reading. I did not run aim-engine end to end on such a cluster. On real AMD GPUs I only saw plain pods that request amd.com/gpu get DRA devices through the mapping. That cluster had Kubernetes 1.36, driver v1.0.1 and a hand-made DeviceClass with the mapping.

Important: a DRA node with the amd.com/gpu extended resource mapping counts only as a DRA node

A DeviceClass can set extendedResourceName: amd.com/gpu (KEP-5004). The scheduler then serves a plain amd.com/gpu request from DRA devices, on nodes that report no allocatable amd.com/gpu (scheduler). The feature gate DRAExtendedResource is beta and on by default in 1.36, and GA in 1.37. The AMD DRA driver chart sets this mapping by default on its development branch (values.yaml). Release v1.0.1 does not set it yet.

matchNodes evaluates the device-plugin match on a DRA node only when the node has allocatable amd.com/gpu (node_match.go#L475, #L673-L676). A mapped node therefore gives DevicePlugin: 0, DRA: 1. The effects, most important first:

  • A service that already runs, default Auto. Auto keeps the device-plugin mode of an existing InferenceService (dra.go#L110-L115). The profile is then ready for the service only when DevicePlugin > 0 (reconcile.go#L1064, dra.go#L137-L145). So after an upgrade from main, the service gets NoNodesForAllocation (reconcile.go#L550-L555) and resource planning stops (reconcile.go#L1251-L1254). Its pod still runs on the node. I found no code that deletes the InferenceService in this state, so I expect that the model stays up and only the reconciliation stops.
  • Explicit DevicePlugin. The same check stops a new service with NoNodesForAllocation, and the message suggests DRA mode. A plain amd.com/gpu pod would schedule on this node.
  • A new service, Auto. It gets a ResourceClaimTemplate instead of amd.com/gpu (dra.go#L116-L121). The model runs, and this PR gives DRA pods the amd.com/gpu toleration, so this can be what you intend. It matters only where admission refuses resource claims or rewrites the amd.com/gpu request. slurm-bridge is such a case, because its webhook refuses pods with resource claims (admission.go#L140-L141).

So on a mapped cluster the controller stops reconciling a running service, and no mode gives a new service a pod that requests amd.com/gpu, as main does today.

Two tests reproduce this (first block below):

  • TestMatchProfileNodesDRANodeWithExtendedResourceMapping is a two-row table test. It runs ListNodeInventory on a fake client and then MatchProfileNodes. The fixture is a node with the detector labels and no allocatable amd.com/gpu, 8 MI300X DRA devices, and a DeviceClass with and without the mapping. At 0ab708d the mapped row fails with device plugin 0, DRA 1; want 1 and 1. The unmapped row passes, so the Match profiles against AMD GPU DRA nodes and report them separately #62 fix for unmapped DRA nodes stays.
  • TestAutoKeepsRunningDevicePluginServiceOnMappedDRANode makes the node counts from the same kind of inventory. It then calls decideAllocation with an existing InferenceService, and allocationAvailable. At 0ab708d it fails with mode "DevicePlugin", nodes available false (device plugin 0, DRA 1).

For the explicit DevicePlugin case, your TestAllocationAvailable already shows that the counts (0, 2) give no node.

The suggested fix is 22 lines without the tests. ListNodeInventory lists the DeviceClasses and sets a flag when one has extendedResourceName: amd.com/gpu. matchNodes evaluates the device-plugin match also when the flag is set. The RBAC markers get deviceclasses. Both tests pass with it, and make test passes locally. I did not run lint, e2e or the KWOK lane.

The sketch has these limits:

  • It does not watch DeviceClasses, so a mapping change shows at the next Node or ResourceSlice event.
  • The flag is for the whole cluster and does not read the DeviceClass selectors. With AutoPartition, the driver puts the mapping on a class for whole GPUs only, gpu.amd.com-spx (values.yaml#L24-L27). A node with only partitioned GPUs then also counts as a device-plugin node.
  • Auto then uses amd.com/gpu for a new service on a mapped node, as it does on a device-plugin node. A service that needs the exact model and partition selection of a claim must set mode DRA.
Failing tests (both fail at 0ab708d and pass with the fix below)
diff --git a/internal/v1alpha2/aimprofile/node_inventory_test.go b/internal/v1alpha2/aimprofile/node_inventory_test.go
index cac1bdc2..b2580496 100644
--- a/internal/v1alpha2/aimprofile/node_inventory_test.go
+++ b/internal/v1alpha2/aimprofile/node_inventory_test.go
@@ -34,6 +34,8 @@ import (
 	"k8s.io/utils/ptr"
 	"sigs.k8s.io/controller-runtime/pkg/client/fake"
 
+	aimv1alpha1 "github.com/amd-enterprise-ai/aim-engine/api/v1alpha1"
+	aimv1alpha2 "github.com/amd-enterprise-ai/aim-engine/api/v1alpha2"
 	"github.com/amd-enterprise-ai/aim-engine/internal/constants"
 )
 
@@ -124,3 +126,59 @@ func TestListNodeInventoryWithoutResourceAPI(t *testing.T) {
 		t.Errorf("inventory = %+v, want one node and no DRA devices", inventory)
 	}
 }
+
+// When a DeviceClass sets extendedResourceName: amd.com/gpu, the scheduler
+// serves an amd.com/gpu request from DRA devices. The node then has no
+// allocatable amd.com/gpu, but a device-plugin style pod still runs there.
+func TestMatchProfileNodesDRANodeWithExtendedResourceMapping(t *testing.T) {
+	node := makeNode("dra", map[string]string{
+		AcceleratorVendorLabelPrefix + "GPU.AMD":                  "8",
+		AcceleratorLabelPrefix + "MI300X":                         "8",
+		PartitioningSchemeLabelPrefix + PartitioningSchemeDefault: "8",
+	}, hostCapacity("192"))
+	slice := amdSlice("dra", "dra", "dra", 1, repeatDevices(8, "0x74a1", DRADeviceTypeGPU, "spx_nps1")...)
+	spec := aimv1alpha2.AIMProfileSpecCommon{
+		AcceleratorType:  aimv1alpha1.AcceleratorTypeGPU,
+		AcceleratorModel: "MI300X",
+		AcceleratorCount: 1,
+	}
+
+	for _, tt := range []struct {
+		name                 string
+		extendedResourceName *string
+		wantDevicePlugin     int32
+	}{
+		{name: "no mapping", wantDevicePlugin: 0},
+		{name: "class maps amd.com/gpu", extendedResourceName: ptr.To(constants.AMDGPUResourceName), wantDevicePlugin: 1},
+	} {
+		t.Run(tt.name, func(t *testing.T) {
+			class := &resourcev1.DeviceClass{
+				ObjectMeta: metav1.ObjectMeta{Name: constants.AMDGPUDRADriverName},
+				Spec: resourcev1.DeviceClassSpec{
+					Selectors: []resourcev1.DeviceSelector{{CEL: &resourcev1.CELDeviceSelector{
+						Expression: "device.driver == '" + constants.AMDGPUDRADriverName + "'",
+					}}},
+					ExtendedResourceName: tt.extendedResourceName,
+				},
+			}
+			scheme := runtime.NewScheme()
+			if err := corev1.AddToScheme(scheme); err != nil {
+				t.Fatal(err)
+			}
+			if err := resourcev1.AddToScheme(scheme); err != nil {
+				t.Fatal(err)
+			}
+			c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(&node, &slice, class).Build()
+
+			inventory, err := ListNodeInventory(context.Background(), c)
+			if err != nil {
+				t.Fatal(err)
+			}
+			result := MatchProfileNodes(inventory, spec, ResolveProfileResources(spec))
+			if result.MatchingNodes != tt.wantDevicePlugin || result.DRAMatchingNodes != 1 {
+				t.Errorf("device plugin %d, DRA %d; want %d and 1\nmismatches: %+v",
+					result.MatchingNodes, result.DRAMatchingNodes, tt.wantDevicePlugin, result.NodeMismatches)
+			}
+		})
+	}
+}
diff --git a/internal/v1alpha2/aimservice/dra_test.go b/internal/v1alpha2/aimservice/dra_test.go
index d1b012c8..dd944f52 100644
--- a/internal/v1alpha2/aimservice/dra_test.go
+++ b/internal/v1alpha2/aimservice/dra_test.go
@@ -288,6 +288,61 @@ func TestAllocationAvailable(t *testing.T) {
 	}
 }
 
+// A service made before the allocation modes requests amd.com/gpu. When a
+// DeviceClass maps amd.com/gpu, its pod still runs on a DRA node, so the
+// device-plugin mode that Auto keeps for it must find that node.
+func TestAutoKeepsRunningDevicePluginServiceOnMappedDRANode(t *testing.T) {
+	node := &corev1.Node{
+		ObjectMeta: metav1.ObjectMeta{Name: "dra", Labels: map[string]string{
+			aimprofile.AcceleratorLabelPrefix + "MI300X":                                    "8",
+			aimprofile.PartitioningSchemeLabelPrefix + aimprofile.PartitioningSchemeDefault: "8",
+		}},
+		Status: corev1.NodeStatus{Allocatable: corev1.ResourceList{
+			corev1.ResourceCPU:    resource.MustParse("192"),
+			corev1.ResourceMemory: resource.MustParse("1Ti"),
+		}},
+	}
+	slice := &resourcev1.ResourceSlice{
+		ObjectMeta: metav1.ObjectMeta{Name: "dra"},
+		Spec: resourcev1.ResourceSliceSpec{
+			Driver:   constants.AMDGPUDRADriverName,
+			NodeName: ptr.To("dra"),
+			Pool:     resourcev1.ResourcePool{Name: "dra", Generation: 1, ResourceSliceCount: 1},
+			Devices: []resourcev1.Device{{
+				Name: "gpu-0",
+				Attributes: map[resourcev1.QualifiedName]resourcev1.DeviceAttribute{
+					"deviceID":         {StringValue: ptr.To("0x74a1")},
+					"type":             {StringValue: ptr.To(aimprofile.DRADeviceTypeGPU)},
+					"partitionProfile": {StringValue: ptr.To(aimprofile.DRAUnpartitionedProfile)},
+				},
+			}},
+		},
+	}
+	class := &resourcev1.DeviceClass{
+		ObjectMeta: metav1.ObjectMeta{Name: constants.AMDGPUDRADriverName},
+		Spec:       resourcev1.DeviceClassSpec{ExtendedResourceName: ptr.To(constants.AMDGPUResourceName)},
+	}
+	spec := sampleProfileSpec()
+	service := &aimv1alpha1.AIMService{ObjectMeta: metav1.ObjectMeta{Name: testServiceName, Namespace: "ns"}}
+	profile := &aimv1alpha2.AIMClusterProfile{ObjectMeta: metav1.ObjectMeta{Name: testClusterProfileName}}
+	c, _ := newProfileRuntimePipelineFixture(t, service, profile, node, slice, class)
+
+	inventory, err := aimprofile.ListNodeInventory(context.Background(), c)
+	if err != nil {
+		t.Fatal(err)
+	}
+	match := aimprofile.MatchProfileNodes(inventory, *spec, aimprofile.ResolveProfileResources(*spec))
+	status := profileStatusWith(match.MatchingNodes, match.DRAMatchingNodes)
+	running := &servingv1beta1.InferenceService{}
+
+	decision := decideAllocation(service, testClusterProfileName, spec, status.MatchingNodesByAllocation, running, nil)
+
+	if decision.mode != aimv1alpha1.AcceleratorAllocationDevicePlugin || !allocationAvailable(decision, status) {
+		t.Errorf("mode %q, nodes available %t (device plugin %d, DRA %d); want DevicePlugin with a node",
+			decision.mode, allocationAvailable(decision, status), match.MatchingNodes, match.DRAMatchingNodes)
+	}
+}
+
 func TestStaleClaimTemplateCleanup(t *testing.T) {
 	obs := ServiceObservation{}
 	named := func(name string) resourcev1.ResourceClaimTemplate {

Output at 0ab708d:

=== RUN   TestMatchProfileNodesDRANodeWithExtendedResourceMapping
=== RUN   TestMatchProfileNodesDRANodeWithExtendedResourceMapping/no_mapping
=== RUN   TestMatchProfileNodesDRANodeWithExtendedResourceMapping/class_maps_amd.com/gpu
    node_inventory_test.go:179: device plugin 0, DRA 1; want 1 and 1
        mismatches: []
--- FAIL: TestMatchProfileNodesDRANodeWithExtendedResourceMapping (0.05s)
    --- PASS: TestMatchProfileNodesDRANodeWithExtendedResourceMapping/no_mapping (0.05s)
    --- FAIL: TestMatchProfileNodesDRANodeWithExtendedResourceMapping/class_maps_amd.com/gpu (0.00s)
=== RUN   TestAutoKeepsRunningDevicePluginServiceOnMappedDRANode
    dra_test.go:341: mode "DevicePlugin", nodes available false (device plugin 0, DRA 1); want DevicePlugin with a node
--- FAIL: TestAutoKeepsRunningDevicePluginServiceOnMappedDRANode (0.04s)
Suggested fix (diff against the test commit, without the generated config/rbac/role.yaml)
diff --git a/internal/controller/aimservice_controller.go b/internal/controller/aimservice_controller.go
index 11730f37..05c4b136 100644
--- a/internal/controller/aimservice_controller.go
+++ b/internal/controller/aimservice_controller.go
@@ -160,7 +160,7 @@ type AIMServiceReconciler struct {
 // +kubebuilder:rbac:groups=keda.sh,resources=scaledobjects,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
-// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices,verbs=get;list;watch
+// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices;deviceclasses,verbs=get;list;watch
 // +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceclaimtemplates,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
 // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
diff --git a/internal/v1alpha2/aimprofile/node_inventory.go b/internal/v1alpha2/aimprofile/node_inventory.go
index a9ae2ac7..c366e0cb 100644
--- a/internal/v1alpha2/aimprofile/node_inventory.go
+++ b/internal/v1alpha2/aimprofile/node_inventory.go
@@ -31,6 +31,7 @@ import (
 	resourcev1 "k8s.io/api/resource/v1"
 	"k8s.io/apimachinery/pkg/api/meta"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/utils/ptr"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	"github.com/amd-enterprise-ai/aim-engine/internal/constants"
@@ -63,6 +64,10 @@ type NodeInventory struct {
 	// ResourceSlices to the devices they publish. Such a node presents its
 	// GPUs through DRA, not as device-plugin resources.
 	DRADevices map[string][]DRADevice
+	// AMDGPUExtendedResource is true when a DeviceClass has
+	// extendedResourceName amd.com/gpu. The scheduler then serves amd.com/gpu
+	// requests from DRA devices on nodes that do not advertise amd.com/gpu.
+	AMDGPUExtendedResource bool
 }
 
 // NodesOnly is an inventory of nodes without DRA devices.
@@ -85,7 +90,17 @@ func ListNodeInventory(ctx context.Context, c client.Reader) (NodeInventory, err
 		}
 		return NodeInventory{}, fmt.Errorf("list ResourceSlices: %w", err)
 	}
-	return BuildNodeInventory(nodes.Items, slices.Items), nil
+	inventory := BuildNodeInventory(nodes.Items, slices.Items)
+	var classes resourcev1.DeviceClassList
+	if err := c.List(ctx, &classes); err != nil {
+		return NodeInventory{}, fmt.Errorf("list DeviceClasses: %w", err)
+	}
+	for _, class := range classes.Items {
+		if ptr.Deref(class.Spec.ExtendedResourceName, "") == constants.AMDGPUResourceName {
+			inventory.AMDGPUExtendedResource = true
+		}
+	}
+	return inventory, nil
 }
 
 // BuildNodeInventory combines nodes with the devices of the AMD GPU DRA
diff --git a/internal/v1alpha2/aimprofile/node_match.go b/internal/v1alpha2/aimprofile/node_match.go
index 99d93551..167199d8 100644
--- a/internal/v1alpha2/aimprofile/node_match.go
+++ b/internal/v1alpha2/aimprofile/node_match.go
@@ -472,7 +472,9 @@ func matchNodes(
 		}
 		// A node can publish DRA devices while amd.com/gpu is still allocatable,
 		// for example while it moves from the device plugin to the DRA driver.
-		if !draNode || draReq == nil || advertisesAMDGPUs(node) {
+		// With the extended resource mapping, an amd.com/gpu request also gets
+		// DRA devices.
+		if !draNode || draReq == nil || advertisesAMDGPUs(node) || inventory.AMDGPUExtendedResource {
 			devicePluginReasons := nodeMismatchReasons(
 				node,
 				vendorReq,
diff --git a/internal/v1alpha2/controller/aimclusterprofile_controller.go b/internal/v1alpha2/controller/aimclusterprofile_controller.go
index 247f0f18..8aafa5b4 100644
--- a/internal/v1alpha2/controller/aimclusterprofile_controller.go
+++ b/internal/v1alpha2/controller/aimclusterprofile_controller.go
@@ -78,7 +78,7 @@ type AIMClusterProfileReconciler struct {
 // +kubebuilder:rbac:groups=aim.eai.amd.com,resources=aimclusterprofiles/finalizers,verbs=update
 // +kubebuilder:rbac:groups=serving.kserve.io,resources=clusterservingruntimes,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
-// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices,verbs=get;list;watch
+// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices;deviceclasses,verbs=get;list;watch
 // +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
 
 func (r *AIMClusterProfileReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
diff --git a/internal/v1alpha2/controller/aimprofile_controller.go b/internal/v1alpha2/controller/aimprofile_controller.go
index 22fa3b17..e283bd9c 100644
--- a/internal/v1alpha2/controller/aimprofile_controller.go
+++ b/internal/v1alpha2/controller/aimprofile_controller.go
@@ -81,7 +81,7 @@ type AIMProfileReconciler struct {
 // +kubebuilder:rbac:groups=aim.eai.amd.com,resources=aimprofilecaches,verbs=get;list;watch
 // +kubebuilder:rbac:groups=serving.kserve.io,resources=servingruntimes,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch
-// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices,verbs=get;list;watch
+// +kubebuilder:rbac:groups=resource.k8s.io,resources=resourceslices;deviceclasses,verbs=get;list;watch
 // +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
 // +kubebuilder:rbac:groups="",resources=events,verbs=create;patch
 

@pre pre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes: on a cluster where a DeviceClass maps amd.com/gpu to DRA devices, a pod can still request amd.com/gpu, but this PR counts those nodes as DRA-only. Hence, a service that main deployed there gets NoNodesForAllocation after the upgrade and DevicePlugin mode finds no node. The failing tests and a 22-line fix are in #64 (comment)

@pre

pre commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

I ran the cases from my comment above on real GPUs. The regression shows there, and the fix removes it.

Setup. One node with 8 AMD Instinct MI300X (SPX, NPS1), Kubernetes v1.36.6, and the AMD GPU DRA driver v1.0.1 with no device plugin. The DeviceClass gpu.amd.com has extendedResourceName: amd.com/gpu. The feature gate DRAExtendedResource is beta and on by default in 1.36. KServe is 0.16.0. I rebased PR 60 to PR 64 on main 7f1aa36, where the PR 64 code is the same as at 0ab708d. I built the operator image and the chart from that, and installed them cluster-wide. The model is Llama 3.1 8B Instruct FP8 with a 1-GPU MI300X profile.

Without the fix, every profile reports matchingNodesByAllocation: {devicePlugin: 0, dra: 1}. A Pod that requests amd.com/gpu: 1 still schedules on this node through the mapping.

Service Result
acceleratorAllocation.mode: DevicePlugin, no spec.resources No InferenceService. NoNodesForAllocation: "No node can serve profile ... with DevicePlugin allocation (device-plugin nodes: 0, DRA nodes: 1); set acceleratorAllocation.mode to DRA to use the DRA nodes"
DevicePlugin with spec.resources No InferenceService. ProfileNotReady: "No cluster nodes match profile ... with the service resource override and DevicePlugin allocation"
Auto with amd.com/gpu in spec.resources (this manifest runs on v0.2.7) Failed: "spec.resources requests amd.com/gpu, but the service allocates GPUs through DRA; remove it or set acceleratorAllocation.mode to DevicePlugin". The suggested DevicePlugin mode fails too (row 2).
Auto without amd.com/gpu Runs with a DRA claim. Ready in about 3 minutes, and it answers a chat request.
A service that v0.2.7 deployed before the upgrade ProfileNotReady as in row 2. The existing InferenceService and Pod continue to run.

With the fix from my comment above, applied on 0ab708d, every profile reports {devicePlugin: 1, dra: 1}.

  • Auto with and without amd.com/gpu in spec.resources, and DevicePlugin with spec.resources, all select DevicePlugin. The Pod requests amd.com/gpu: 1, and the scheduler allocates the GPU through the mapping. Each model was Ready in about 3 minutes. I checked the chat answer only for Auto without amd.com/gpu.
  • The service that v0.2.7 deployed keeps DevicePlugin and Running, and the operator does not roll it out again.
  • A service that already had a DRA claim keeps it.
  • acceleratorAllocation.mode: DRA works with a 2-GPU profile (Llama 3.3 70B Instruct FP8, tp2). The ResourceClaimTemplate has count: 2 and the constraint matchAttribute: gpu.amd.com/deviceID. The scheduler allocated two whole GPUs with the same device ID, and the container saw both. The model was Ready about 7 minutes after the apply, and the 67.7 GiB download took about 3 minutes of that. It answered a chat request.

DRA mode also works without the fix. With and without the mapping, Auto without amd.com/gpu made a ResourceClaimTemplate with a CEL selector on deviceID 0x74a1, the -dra ServingRuntime and one claim. The model answered a chat request.

Two more findings:

  1. The AIMService status cannot hold NotAvailable. AIMServiceStatus.SetStatus copies a NotAvailable component state to status.status. The CRD enum has only Pending, Starting, Running, Degraded and Failed (aimservice_types.go#L610). So the API server refuses the whole status update with status.status: Unsupported value: "NotAvailable": supported values: "Pending", "Starting", "Running", "Degraded", "Failed". A new service shows Pending with no conditions, and a running service keeps Running and Ready=True. This PR does not cause the bug. Since #177, v0.2.7 sets NotAvailable when no node matches the service resource override (reconcile.go#L541). I saw the failure only with this PR stack. In it, the new reason NoNodesForAllocation also ends in NotAvailable, so the user never sees that reason.
  2. This PR adds the -dra ServingRuntime and its ConfigMap, and the AIMProfile owns them. They stay after you delete the service. They also stayed after I downgraded to v0.2.7.

@salexo

salexo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Applied. The node counting lives in #62, so the fix and TestMatchProfileNodesDRANodeWithExtendedResourceMapping are there (d793442); TestAutoKeepsRunningDevicePluginServiceOnMappedDRANode is here (a5df2d8), on top of the updated #62. Both credit you as co-author. The mapped-class test fails without the fix with your error and passes with it.

profiles.md now says that every DRA node counts as a device-plugin node while a DeviceClass maps amd.com/gpu, and spells out the limits you listed: the check is cluster-wide, ignores the class selector, and a changed DeviceClass shows at the next Node or ResourceSlice change.

The NotAvailable status value the CRD rejects and the -dra ServingRuntime left behind after deleting a service are separate from this PR; both need their own fixes.

@salexo
salexo requested a review from pre November 18, 2026 09:36

@pre pre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested the changes, they work, thank you!

@salexo
salexo force-pushed the feature/dra-node-matching branch from d793442 to 55e2a4e Compare November 19, 2026 10:15
@salexo
salexo force-pushed the feature/dra-allocation branch from a5df2d8 to ba60b37 Compare November 19, 2026 10:15
@AVSuni AVSuni added this to the v0.2.9 milestone Dec 1, 2026
salexo and others added 9 commits December 1, 2026 10:49
Add acceleratorAllocation.mode (Auto, DRA, DevicePlugin) to the shared
runtime config, with Auto as the default: DRA when a node with the AMD
GPU DRA driver has the profile's GPUs, the device plugin otherwise. A
running service keeps the mode its InferenceService uses.

A DRA service gets a ResourceClaimTemplate selecting devices of one GPU
model by PCI device ID and partitioning mode, and references a variant
of the profile's ServingRuntime without amd.com/gpu or node affinity.
Profiles count DRA nodes in matchingNodes and HardwareAvailable; their
projected runtimes stay device-plugin only.
Auto now uses DRA only when no device-plugin node has the profile's
GPUs, and decides from the nodes that fit the service's resources when
spec.resources overrides them. DRA pods get the amd.com/gpu NoSchedule
toleration that ExtendedResourceToleration gives device-plugin pods.
Document the new RBAC and the upgrade behaviour.
…node

A service deployed before the allocation modes requests amd.com/gpu.
When a DeviceClass maps amd.com/gpu, its pod still runs on a DRA node,
so the device-plugin mode Auto keeps for it must find that node.

Co-authored-by: Petrus Repo <petrus.repo@amd.com>
…artitioned claims

AMD GPU nodes with more than one GPU model can serve AIMServices through
DRA, which selects devices by model. Say so in the mixed-model mismatch
reason for AMD nodes and in the accelerator detection and upgrade docs.

An unpartitioned DRA claim now also requires the device to have no
partition profile or the spx_nps1 profile, so it does not take a
partition of a partitioned GPU.
Evaluate the CEL selector of every model and partitioning mode with cel-go
against the ResourceSlices the ROCm GPU DRA driver publishes, and require
the same verdict as the Go node matcher for each device. A drift would let
a profile report DRA nodes that its claims cannot be allocated on.
The scheduler allocates a device with a DRA device taint only to a claim
that tolerates it, and the claims AIM Engine creates tolerate none. Leave
tainted devices out of the DRA match and name them in the mismatch reason.
The CEL selector stays taint-free: the scheduler checks taints apart from
a claim's selectors.
@salexo
salexo force-pushed the feature/dra-node-matching branch from 55e2a4e to 506e365 Compare December 1, 2026 08:54
@salexo
salexo force-pushed the feature/dra-allocation branch from ba60b37 to f806e26 Compare December 1, 2026 08:54
@salexo

salexo commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto the updated #62 and onto main, which now removes template serving (#68) and adds LLMInferenceService serving (#67). What changed here:

  • LLMInferenceService services use the device plugin. The LLMInferenceServiceConfig projection requests amd.com/gpu, so Auto resolves to DevicePlugin for spec.servingAPI: LLMInferenceService. An explicit DRA mode, set on the service or through its runtime config, is refused with ConfigValid=False and AcceleratorAllocationUnsupported. DRA for LLMInferenceService can follow separately.
  • Template-based services are gone, so the v1alpha1 AcceleratorAllocationConfig check is removed. AcceleratorAllocationUnsupported now covers DRA on an LLMInferenceService service and on a non-AMD profile, both reported through the profile config check.
  • One device-ID table. The CEL generator and the node matcher both read amdGPUModelsByDeviceID from Match profiles against AMD GPU DRA nodes and report them separately #62.
  • Follow-ups from the Match profiles against AMD GPU DRA nodes and report them separately #62 review:
    • TestDRAClaimSelectorAgreesWithNodeMatcher checks the CEL selector against the Go matcher with cel-go over the hack/fakegpu/testdata slices (970c9de).
    • Tainted DRA devices no longer count (f806e26).
  • The no-DRA parity golden file records the new mixed-model reason, which now points AMD nodes to DRA. Node counts are unchanged.

@bjorn-amd bjorn-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review summary

Verdict: Request changes.

DRA isn't behind an operator flag, so the requirement for merging is that every path where DRA doesn't apply behaves as it does on main. DRA allocation itself can ship as experimental. Items 7 and later only affect services that use DRA, and can be follow-ups.

The rebase, the LLMInferenceService handling in Auto, the shared device-ID table and the CEL/matcher test look good.

References are to f806e26f.

Before merge

  1. NotAvailable is rejected by the status enum (internal/v1alpha2/aimservice/reconcile.go:679, :689). The framework keeps NotAvailable as the worst component state, and SetStatus passes it through to status.status, whose enum is Pending;Starting;Running;Degraded;Failed (api/v1alpha1/aimservice_types.go:676). The API server rejects the whole status update (on kind: status.status: Unsupported value: "NotAvailable"), so the service keeps its previous status and conditions, e.g. Running/Ready=True. main has the same bug (reconcile.go:660; SetStatus passes the value through unchanged), but this PR makes it the only path that reports NoNodesForAllocation. Suggest a separate PR to main that maps NotAvailable in SetStatus, with a test that the status write succeeds.

  2. Paths where DRA doesn't apply:

    • A cluster-wide mode: DRA. requestedAllocationMode falls back to the runtime config's mode. decideAllocation then sets an error for every NVIDIA profile (dra.go:109-111) and every LLMInferenceService service (dra.go:105-108), so they all report Failed (ConfigValid=False) and nothing more is applied for them, running ones included. A unit test with only the runtime config set to DRA gives ProfileConfig Failed/AcceleratorAllocationUnsupported for both. Is that intended? Erroring only when the AIMService itself sets DRA, and falling back to DevicePlugin when the mode comes from a runtime config, would avoid it.
    • An explicit DevicePlugin mode. resolver.go doesn't consider the mode, and a profile that only DRA nodes can serve is Ready. In a unit test with an MI300X profile matching only DRA nodes and an MI355X profile matching only device-plugin nodes, a service with a selector matching both and mode DevicePlugin resolves to the MI300X profile, which has no nodes for its mode.
    • ResourceClaimTemplates are listed for every GPU service but never watched (dra.go:306). With the cached client this starts an informer inside the reconcile, as the DeviceClass list in #62 did, so I'd expect the same blocking without RBAC (not reproduced). Owns(&resourcev1.ResourceClaimTemplate{}), gated on the API being served (e.g. in WatchAMDGPUDRAInventory), also makes a deleted template trigger a reconcile.
    • Device-plugin services. #62 now has a parity test for profiles. Is there an equivalent for services, checking that an existing device-plugin service's InferenceService and ServingRuntime are unchanged by this PR?
  3. The quota docs don't hold. CHANGELOG.md:52 recommends mode: DevicePlugin in the cluster runtime config to keep amd.com/gpu quotas effective, and runtime-config.md:466 offers DevicePlugin as the alternative to DeviceClass quota. But a namespace AIMRuntimeConfig takes precedence over the cluster one when they are merged, and requestedAllocationMode prefers the AIMService's own mode, so either can set DRA. Quota on the DeviceClass is the only effective control, and security.md should say so.

  4. spec.dra.deviceClassName (api/v1alpha1/aimruntimeconfig_shared.go:291-295):

    • Node matching only reads gpu.amd.com slices (the cache is now restricted to that driver), so a different class can leave a profile Ready while pods stay Pending.
    • A misspelled class isn't detected.
    • The documented quota key assumes the default class.

    Remove the field for now. Adding it later is not a breaking change; removing it after release is.

  5. Leftovers from the rebase:

    • The #63 changelog entry (CHANGELOG.md:24) has lost "and an empty list removes the inherited one". main and the v0.2.8 notes in #94 still have it.
    • Nothing in the code says why the -dra ServingRuntime variant is needed. The reason still holds with KServe v0.20: MergeContainerWithPatch (pkg/utils/container_merge.go) applies a strategic merge patch built from the marshalled InferenceService container, which can override amd.com/gpu but not remove it. A comment on DRARuntimeName (serving/runtime.go:114) would help.
  6. Mark DRA allocation as experimental in the docs and changelog, including that services using DRA may restart on operator upgrades.

After the retarget to main this needs two new approvals. @pre, could you re-run the MI300X check then?

Follow-ups (affect only services that use DRA)

  1. Auto keeps the existing InferenceService's mode unconditionally (dra.go:119-124). The InferenceService name comes from the service name and namespace only, so the mode is kept after the mode has no nodes left, and after a spec.profile.name change, a selector rebind or a forced rebind.
  2. profileOverrides and node counts (reconcile.go:867-870). Without spec.resources, the counts come from seedObs.resolvedProfileStatus. For a service whose profileOverrides change the GPU model, is that the overridden profile's status or the base profile's?
  3. Stale ResourceClaimTemplates are deleted in the same plan that applies the new InferenceService (dra.go:300, called from reconcile.go:1656). If the old ReplicaSet recreates a pod while the rollout is still in progress, that pod's template is already gone. Since pod claims are created from the template, I'd expect such a pod to stay Pending (not reproduced).
  4. The claim template name (dra.go:196-198). The hash covers the device class, count and selector, but not the service name. Two services in the same namespace whose names share the truncated prefix, and that request the same devices, get the same template. Because the rendered CEL is part of the hash, any change to the selector text renames every template and restarts every DRA service. Changing the hash later also restarts DRA services, so it's cheaper to fix before release.
  5. The rollback section in upgrading.md (:357) doesn't mention that -dra ServingRuntimes and ResourceClaimTemplates are left behind.
  6. Question: could decideAllocation move from Fetch to Compose, by fetching both ServingRuntime names and deciding there?

Run the service pipeline for services that use the device plugin and
compare their InferenceService, ServingRuntime and ConfigMap with a golden
file generated before AIM Engine allocated GPUs through DRA. Each service
is also run in a cluster that has a DRA node, where Auto must still pick
the device plugin.
Reconcile lists a service's templates through the cached client, which
otherwise starts the informer inside the reconcile. Own them when the
cluster serves resource.k8s.io/v1, so the informer starts with the manager
and a deleted template reconciles its service.
KServe merges the InferenceService container into the runtime container
with a strategic merge patch, which can override amd.com/gpu but not
remove it.
…ates

Decide the mode after the profileOverrides overlay is resolved, so the
node counts are those of the profile the service runs. Fetch reads the
profile's ServingRuntime as before, plus its DRA variant for GPU profiles,
and ComposeState swaps in the variant for DRA services.

A DRA mode inherited from a runtime config applies only to services that
can use DRA: NVIDIA profiles and LLMInferenceService services keep the
device plugin, and only a DRA mode the service sets itself is refused.

Auto keeps the mode of a running InferenceService only while it serves the
same profile and that mode has nodes, or neither mode has any.

Name claim templates from the service name and the device request rather
than the CEL text, so rewriting the selector keeps running pods. A
template's spec is immutable, so an existing one is not applied again.
Delete a stale template only once the InferenceService no longer
references it, its rollout has finished and no predictor pod references
it.

Remove spec.dra.deviceClassName: node matching reads only gpu.amd.com
slices, so another class could leave a profile Ready with pods Pending.
A profile that only DRA nodes can serve is Ready, so a selector with mode
DevicePlugin could resolve to it and report NoNodesForAllocation while
another candidate had device-plugin nodes. With an explicit mode, from the
service or its runtime config, the resolver now skips Ready profiles
without nodes for the mode the service would use on them. When no
candidate has any, it keeps them all, so the service still binds and
names the mode that has nodes. The runtime config is fetched before the
profile is resolved for this.
Quota on the gpu.amd.com DeviceClass is the only way to limit DRA devices:
a namespace runtime config and the service itself take precedence over
the cluster runtime config's mode. Say so in the changelog, the runtime
config page and the security page.

DRA services may restart once on a later operator upgrade. The rollback
section names the -dra ServingRuntimes and ResourceClaimTemplates that
v0.2.7 leaves behind. Restore the #63 changelog wording that an empty
toleration list removes the inherited one.
@salexo

salexo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Everything is addressed in f806e26f..e47911bd, as new commits on top.

  1. NotAvailable. Report Pending for an AIMService that no node can run #95 maps it to Pending in SetStatus, with a test that the status passes the CRD schema. It should merge before this PR.
  2. Paths where DRA doesn't apply:
    • Runtime-config DRA. A runtime config's DRA now falls back to DevicePlugin for NVIDIA profiles and LLMInferenceService services. Only a DRA the service sets itself is refused (369e906). Both cases are in TestDecideAllocation.
    • Explicit DevicePlugin. With an explicit mode, the resolver skips Ready profiles that have no nodes for the mode the service would use on them (77c5749). Your MI300X/MI355X setup is the test. If no candidate has nodes, all of them are kept, so the service still binds and reports NoNodesForAllocation rather than ProfileNotFound.
    • ResourceClaimTemplates. Owns(&resourcev1.ResourceClaimTemplate{}), gated on resource.k8s.io/v1 (5486094). It's in the service's RegisterWatches rather than WatchAMDGPUDRAInventory, because the profile controllers also use that helper and don't own templates.
    • Device-plugin services. TestDevicePluginServicesAreUnchanged (5f86181) runs the service pipeline for five device-plugin services and compares the InferenceService, ServingRuntime and ConfigMap with a golden file generated on Match profiles against AMD GPU DRA nodes and report them separately #62's branch. The services are: profile defaults, spec.resources, tolerations, four GPUs, and NVIDIA. Each one also runs in a cluster with a DRA node. The output is identical, and making Auto pick DRA whenever DRA nodes exist fails it.
  3. Quota. The changelog, runtime-config.md and a new "GPU Quotas" section in security.md now say that quota on the DeviceClass is the only control, and why the mode isn't one (e47911b).
  4. spec.dra.deviceClassName. Removed. Claims always use gpu.amd.com.
  5. Rebase leftovers. The Add tolerations for inference pods to runtime configs and AIMService #63 wording is restored, and DRARuntimeName has the MergeContainerWithPatch comment (cc43b67).
  6. Experimental. DRA allocation is marked experimental in the changelog, runtime-config.md, upgrading.md and the DRA enum comment, including the restart on a later upgrade.
  7. Auto stickiness. Auto keeps the running mode only while the InferenceService references this profile's runtime (so a profile change, selector rebind or forced rebind decides again), and while that mode has nodes or neither mode does. One consequence to flag: a running device-plugin service whose device-plugin nodes all disappear moves to DRA if DRA nodes have its GPUs. That also helps the mixed-model upgrade case, and upgrading.md now says so.
  8. profileOverrides. It was the base profile's status. The decision now runs in ComposeState after the overlay switch, so it uses the overlay's status (TestAutoAllocationUsesOverlayProfileNodes).
  9. Stale templates. A stale template is deleted only after the InferenceService stops referencing it and predictorRolloutFinished holds, and once no predictor pod references it. If the InferenceService is gone, it is deleted right away.
  10. Template name. The hash now covers the service name, the class, and the request (count, model, partitioning), but not the CEL text. A template's spec is immutable, so an existing one isn't applied again. Rewriting the selector therefore leaves running pods on their template.
  11. Rollback. "Rollback limits" now names the -dra ServingRuntimes, their ConfigMaps and the ResourceClaimTemplates, and says that v0.2.7 moves DRA services back to the device plugin.
  12. Fetch vs Compose. Yes, and done. Fetch reads the profile's ServingRuntime as on main, plus its DRA variant for GPU profiles, and ComposeState decides the mode and swaps in the variant for DRA services. This is also what fixed item 8.

Lint, the full unit suite and per-commit build/vet/tests pass. I haven't run the KWOK chainsaw tests locally for this push.

@salexo
salexo requested a review from bjorn-amd December 2, 2026 10:43
@pre

pre commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

I ran e47911b on real GPUs, with #95 merged on top so that NoNodesForAllocation reaches the status. Two problems show up when services run while a node moves from the device plugin to DRA. I'm posting these two now so that you can start on them. Some tests are still running, and I'll post their results in a second comment later: DRA-only services, stuck rollouts, quota, taints and rollback.

Setup. One node with 8 AMD Instinct MI300X in SPX and NPS1 mode, Kubernetes v1.36.6, KServe 0.16.0, the ROCm device plugin, and the AMD GPU DRA driver v1.0.1. The DeviceClass gpu.amd.com has no extendedResourceName, so the device plugin and the DRA driver each hand out the same 8 GPUs. The models are Llama 3.1 8B Instruct FP8 on 1 GPU and Llama 3.3 70B Instruct FP8 on 2 GPUs. I installed #62 at 506e365, deployed five device-plugin services, and upgraded to this PR.

The upgrade is clean. The five services kept their pods, and their InferenceService, ServingRuntime and ConfigMap did not change. The only diff is the new status.acceleratorAllocation: DevicePlugin. When the DRA driver started on the node, none of them moved.

Important: Auto moves a running service onto a GPU that its old pod still holds

When the device plugin stops on a node, Auto moves a running service to DRA, as runtime-config.md#L441 says. The code is dra.go#L149-L160. The Deployment starts the DRA pod while the old pod still runs. The old pod keeps the GPU that the device plugin gave it, and neither the DRA driver nor the scheduler knows about that GPU. So the claim of the new pod can get the same GPU.

On the test node this happened to all three services that moved:

Service GPUs of the old device-plugin pod GPUs of the new pod's claim
8B, Auto gpu-17 gpu-17, its own old GPU
8B, Auto, CPU and memory in spec.resources gpu-1 gpu-9, the GPU of another service's pod
70B tp2, Auto gpu-33, gpu-41 gpu-25 and gpu-33, one of its own old GPUs

vLLM in each new pod sees 179 GB of the GPU in use and exits with Free memory on device cuda:0 (17.49/191.98 GiB) on startup is less than desired GPU memory utilization (0.9, 172.79 GiB). After 15 minutes each new pod had restarted 6 or 7 times. The Deployments had ProgressDeadlineExceeded, and the services showed Ready False with RolloutStalled. The old pods kept serving and answered chat requests, so no model went down. But the crash-looping pods keep their claims, and the rollouts do not finish on their own.

Only one of the eight GPUs was free at that moment, so a collision was likely, and the allocator did not pick the free one. An earlier service moved to DRA when more GPUs were free, and its claim got a free GPU.

Two more cases fail the same way:

  • Device plugin and DRA driver on the same node. The comment at node_match.go#L473 describes this transition state. A service whose namespace runtime config sets mode: DRA got the GPU of a running device-plugin pod and crash-looped. Its status showed only Starting.
  • replicas: 2 on a DRA service after the device plugin stopped. The second replica got a GPU that an old device-plugin pod held. The service stayed Ready True with one crash-looping replica.

Could Auto keep the running mode while a predictor pod of that mode still runs, and move only when none is left? A replacement pod from the old ReplicaSet requests amd.com/gpu, so it stays Pending when the device plugin is gone. The service would then move at its next pod restart or node drain, and the two allocators would never give out the same GPU. If the move stays as it is, runtime-config.md and upgrading.md should tell administrators to move the device-plugin GPU pods off a node before its GPUs go to DRA. I'm still testing whether deleting the old pod lets a stalled rollout finish.

Important: a service with spec.model.image stays at NoNodesForAllocation when nodes for its mode appear

The service had spec.model.image and spec.profile.selector, and its namespace runtime config set mode: DRA. Before the DRA driver ran, it reported NoNodesForAllocation, as expected. When the DRA devices appeared, all profiles showed dra: 1. Six minutes after that the service still showed Pending with the old message "(device-plugin nodes: 1, DRA nodes: 0)". An annotation change made it reconcile, and then it continued at once.

The code explains why. The service sets status.resolvedProfile only when profileReadyForService() holds (reconcile.go#L1893). That check now also needs a node for the allocation mode (reconcile.go#L1253-L1265). So a new service in NoNodesForAllocation has no resolved profile. findServicesForProfile finds services by spec.profile.name, by resolved profile, by spec.model.name, and by the selector's model or AIM ID, but not by spec.model.image. Only findServicesForModel uses ServiceModelImageIndex. The profile stays Ready while only its node counts change, so its model does not change either.

Could findServicesForProfile look up the profile's source model and fan out through ServiceModelImageIndex, as findServicesForModel does?

@pre

pre commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

This follows up on my first comment. The rest of the tests on the same node are done. They found one new problem with the DeviceClass mapping, and they confirmed both earlier problems in more cases. Most other cases passed; the list is at the end.

Important: with the DeviceClass mapping, a node that ran the device plugin gets no device-plugin match

When the device plugin stops, the kubelet keeps amd.com/gpu on the node. Allocatable went to "0" after 8 s and capacity after about 5 min, and the key stayed. I then set extendedResourceName: amd.com/gpu on the DeviceClass gpu.amd.com. The profiles kept devicePlugin: 0, dra: 1 for 5 minutes, also after the capacity went to "0". The scheduler serves the mapping on this node: a plain pod with amd.com/gpu: 1 started at once with an extended-resource claim.

So in the mapped setup, this PR treats the node as DRA-only:

  • An Auto service gets DRA.
  • A service with mode: DevicePlugin stays Pending with ProfileNotReady.
  • A service with amd.com/gpu in spec.resources is Failed with ProfileConfigInvalid.

The cause is in the node matching from #62. advertisesAMDGPUs treats "0" as no device plugin, so the node takes the mapped branch at node_match.go#L477-L489. That branch still runs resourceMismatchReasons, which finds the key and refuses the node with "requested 1, allocatable 0". The comment in that branch and profiles.md#L246 both expect no key on the node. In my mapped test on 2026-11-18, I had removed the key from the node status by hand, so that test missed this.

After I removed the key again with a node status patch, the profiles showed devicePlugin: 1 within 1.3 s, and the mapped cases passed. That includes the upgrade from #62 with a running mapped service, which kept the same pod and InferenceService.

Could the mapped branch skip the amd.com/gpu count check? advertisesAMDGPUs already treats "0" as no device plugin, and in that branch draMatch checks the GPU count against the DRA devices.

The mixed-model path moves running services onto busy GPUs too

upgrading.md#L333 says that in Auto mode, a service on a mixed-model node moves to DRA once only DRA nodes have its GPUs, for example after an administrator installs the DRA driver there. I had no node with two GPU models. Instead, I set the label feature.node.kubernetes.io/aim-accelerator.mixed-models.GPU=2 by hand on a node that ran both the device plugin and the DRA driver.

Within 3 s, all GPU profiles showed devicePlugin: 0, dra: 1, and a running Auto service moved to DRA. Its new claim got a GPU that the device-plugin pod of another service held. vLLM failed with the same free-memory error as before, and the rollout went to RolloutStalled. The old pod kept serving. Services with mode: DevicePlugin showed NoNodesForAllocation and kept serving.

When I removed the label, the profiles showed devicePlugin: 1 again within 2 s. The Auto service stayed on DRA with its crash-looping pod, because Auto keeps the running mode while that mode has nodes. The doc describes the reverse order, with the label first and the driver second. From the code, that order ends in the same move.

In every collision, the old pod got its GPU from the device plugin itself. The one old pod that got its GPU through the mapping caused no collision. After I removed the mapping, an Auto service moved to DRA, its new claim got a free GPU, and the rollout finished in 1 min 44 s. The old pod's GPU was in an extended-resource claim, so the allocator did not give it out again.

Recovery from the collision needs a manual delete and gives an outage

In my first comment, I said I was still testing whether deleting the old pod lets a stalled rollout finish. It does. The old ReplicaSet makes a replacement pod, which stays Pending because the node has no amd.com/gpu. The DRA pod keeps its claim, starts at its next restart, and the rollout finishes.

The service has no Ready pod from the delete until the DRA pod is Ready. For three services that took 5 min 27 s, 6 min 19 s and 6 min 50 s. Most of that time is the 5-minute CrashLoopBackOff wait, and vLLM then took 92 to 164 s to start.

One claim got the GPU of another service's pod, so I had to delete that pod as well. The service with that claim had no Ready pod for 10 min 10 s. The other service had amd.com/gpu in spec.resources and was already Failed after the device plugin stopped. Its replacement pod requests amd.com/gpu and stays Pending, so that service has no pod left.

So a documented workaround still costs each service an outage. That is a reason for the change I asked about in the first comment, to keep the running mode until no pod of that mode is left.

spec.model.image also stays stuck with mode: DevicePlugin

I tested the second problem of my first comment in the other direction. Two services had mode: DevicePlugin and the same user AIMModel and profile. One used spec.model.name, and the other used spec.model.image. Both showed NoNodesForAllocation while the node had only DRA.

When the device plugin came back, the profiles showed devicePlugin: 1 within 3 s. The spec.model.name service continued 3 s later. The spec.model.image service kept the old message "(device-plugin nodes: 0, DRA nodes: 1)" for 10 minutes, until an annotation change made it reconcile. Any spec.model.image service that has not bound yet therefore waits for an unrelated event.

The quota docs in security.md are wrong with the mapping

security.md#L105 says that a namespace with both limits can use up to 16 GPUs. It also says that DeviceClass quota is the only control for DRA devices. Both are true without the mapping, where a claim used only the DeviceClass key. With the mapping, Kubernetes also charges a DRA claim to requests.amd.com/gpu:

  • With requests.amd.com/gpu: "0", the quota refused the claim of a DRA service: "exceeded quota: gpu, requested: requests.amd.com/gpu=1".
  • With both limits at 2, the namespace got 2 GPUs, not 4. The quota refused the third claim with "requested: gpu.amd.com.deviceclass.resource.k8s.io/devices=1,requests.amd.com/gpu=1".

The PR description makes the same claim: "DRA allocations are not requests.amd.com/gpu".

When the quota refuses a claim, the service status does not name the quota. The service shows Pending and Ready False Progressing, "Waiting for components to become ready". Only the pod events have FailedResourceClaimCreation with the quota message. A device-plugin service whose pod the quota refuses gets Failed with PodCreationFailed. Could the DRA case show the claim error the same way?

Rollback to v0.2.7

I followed upgrading.md#L1235-L1241 with one running DRA service on a node with only DRA. The service used spec.model.image, so AIM Engine had created its model.

v0.2.7 moved the service back to amd.com/gpu, as the doc says. The new pod stayed Pending, and the old DRA pod kept serving. Then v0.2.7 found no node for the model's profiles and deleted all 8 of them. Kubernetes garbage collection then deleted the -dra ServingRuntime, its ConfigMap and the new base ServingRuntime, which the profiles owned. The service was Failed with ProfileNotFound, and its InferenceService named a ServingRuntime that no longer existed. Only the ResourceClaimTemplate and the claim stayed.

For an auto-created model on a node with only DRA, the -dra ServingRuntimes and ConfigMaps therefore do not stay behind. The doc says only that the new pods stay Pending, but the service itself goes to Failed. The old pod serves until it restarts. After I upgraded back to this PR, the service was Ready again in 21 s on the same DRA pod. I did not test a user AIMModel or a node without the amd.com/gpu key.

Smaller points

  • Reason for amd.com/gpu in spec.resources. The PR description says that such a DRA service gets AcceleratorAllocationUnsupported. It gets ProfileConfigInvalid, with Ready False InvalidSpec. composeAllocation builds that error with fmt.Errorf, and getConfigHealth uses AcceleratorAllocationUnsupported only for obs.allocation.err.
  • status.acceleratorAllocation shows the chosen mode, not the mode of the pods. A service with mode: DRA on a node without DRA devices showed DRA, while its only pod ran on a device-plugin GPU. The same happens during a stalled move. The field comment says it is "how the service's inference pods request GPUs". If this is intended, could the comment say so?
  • Missing RBAC is hard to find in the log. Without resourceclaimtemplates in the ClusterRole, the operator exits after 2 minutes, as CHANGELOG.md#L82 says. But the 35 cache-sync timeout lines name 16 other kinds, and the final error names *v1alpha2.AIMModel. Only the "Failed to watch ... forbidden" lines name ResourceClaimTemplate.
  • profiles.md and CHANGELOG.md disagree. profiles.md#L258, from Match profiles against AMD GPU DRA nodes and report them separately #62, says that the operator sets DRADevicesReady=False when its ClusterRole can't read the ResourceSlices. CHANGELOG.md says that it exits. From my reading of the code, it exits, because the ResourceSlice informer never syncs. On the node I tested only the ResourceClaimTemplate case.

What passed

  • A new DRA service on a node with only DRA was Ready in 132 s. Llama 3.3 70B on 2 GPUs and replicas: 2 also worked.
  • During a stalled rollout, the old ResourceClaimTemplate stayed, a recreated old pod got its claim from it, and the operator deleted the old template after the rollout.
  • A profile change with the same device request kept the template. A template deleted by hand came back at once.
  • These also worked: an operator restart, node taints and tolerations, a namespace that enforces Pod Security restricted, 60-character service names, and a delete and create again with the same name.
  • When I deleted a service with spec.model.image, its auto-created model, profiles and -dra ServingRuntimes went with it. With a user AIMModel, the -dra ServingRuntime and ConfigMap stay with the profile.
  • When I turned the mapping off and on while services ran, the profiles changed within 2 s, and the moves had no collision.
  • The upgrade from Match profiles against AMD GPU DRA nodes and report them separately #62 with a mapped service worked once I removed the key, as described above. The service kept its pod and InferenceService, and new services got DevicePlugin with extended-resource claims.
  • When I stopped the DRA driver under a running DRA pod, the pod kept serving. The service was Ready again 1 min 44 s after the driver came back. In between, it showed Failed with ProfileNotFound, because AIM Engine deleted the profiles of the auto-created model.

I did not test KEDA autoscaling, because KEDA was not installed. I also did not test CPX partitions, DRA device taints, which driver v1.0.1 does not publish, or a real node with two GPU models.

This branch has not been deployed

No deployments
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.

4 participants