Skip to content

Add a KWOK lane with fake AMD GPU nodes for e2e tests - #61

Open
salexo wants to merge 6 commits into
mainfrom
feature/kwok-fake-gpu-nodes
Open

salexo wants to merge 6 commits into
mainfrom
feature/kwok-fake-gpu-nodes

Conversation

@salexo

@salexo salexo commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

Kind has no GPUs, and the labelled worker nodes in hack/kind/config.yaml advertise no amd.com/gpu. Pods that request GPUs therefore never schedule in e2e, profile capacity checks are skipped, and there is no way to exercise DRA at all. This adds fake AMD GPU nodes that exist only in the API, run by KWOK, which the scheduler treats like real GPU nodes. It is the test harness for the upcoming DRA work, and is useful on its own for device-plugin placement tests.

What changes

  • hack/fakegpu: a small Go generator. It reads a fleet file (hack/fakegpu/fleet.yaml) of node groups and prints:
    • KWOK Node objects with the AMD GPU Operator's node-labeller labels, the AcceleratorDetector's labels, an amd.com/gpu:NoSchedule taint, and capacity.
    • For device-plugin groups, allocatable amd.com/gpu, one per GPU or compute partition (resource_naming_strategy: single).
    • For dra groups, a gpu.amd.com ResourceSlice in the AMD GPU DRA driver's format: one device per GPU or partition, with type, deviceID, productName, partitionProfile, numaNode, PCI attributes and memory/computeUnits/simdUnits capacities.
    • Optionally, the gpu.amd.com DeviceClass, for clusters without the driver.
  • Default fleet (hack/fakegpu/fleet.yaml): device-plugin and DRA nodes with whole GPUs and CPX partitions; two GPU models on one node (4 x MI350P and 2 x Radeon AI PRO R9700) in both modes; and a DRA node whose MI300X GPUs are in two partition modes (SPX-NPS1 and CPX-NPS1). The generator rejects mixed partition modes on device-plugin nodes, which the AMD device plugin supports only with its mixed resource naming. MI350P comes from AMD's specifications and is modelled as not partitionable until checked against hardware.
  • Fidelity check: the generator's unit tests compare its devices with ResourceSlices that the driver's v1.0.1 discovery code computes for the same node shapes (hack/fakegpu/testdata): 8 x MI300X on two NUMA nodes, 2 x MI300X in CPX-NPS4, and a mixed MI210 + W7900 node. That code ran on sysfs trees written from the GPU models' specifications, not on real nodes.
  • hack/kwok/install.sh: installs a pinned KWOK release (v0.8.0) and its fast stages.
  • Make targets: kwok-install, fake-gpu-fleet, fake-gpu-fleet-delete and test-chainsaw-kwok.
  • Selectors: tests labelled requires=kwok are excluded from every other selector, because the fleet's GPU-labelled nodes change the node counts other tests assert on.
  • kind config: enables the ExtendedResourceToleration admission plugin. Pods requesting amd.com/gpu, such as inference pods, then tolerate the fake nodes' taint without changes, and other pods stay off them.
  • tests/e2e/kwok: device-plugin placement (whole node, CPX partitions, unsatisfiable request, a mixed-model node as one amd.com/gpu pool) and DRA placement (whole GPUs by device ID, CPX partitions by partitionProfile, one model of a mixed-model node, a whole GPU plus partitions from a mixed-partition node in one claim, and a model the node doesn't have).
  • Docs: a "Fake GPU nodes (KWOK)" section in docs/docs/contributing/testing.md.

Notes for reviewers

  • The slices follow the driver's documented attribute schema rather than being computed by the driver's code; the fixtures check them against the driver's code. They show that the generator publishes what the driver would for those sysfs trees, not that the trees match real hardware. The test compares PCI addresses, which follow the trees, so checking against a real node's slice would need the test to skip them.
  • DRA pods request no amd.com/gpu, so the admission plugin doesn't add a toleration for them. The DRA tests carry their own. AIM Engine currently has no way to give inference pods tolerations, which the DRA work will need to address.
  • Clusters running HAMi's scheduler send amd.com/gpu pods to HAMi, which rejects nodes it didn't register. This is documented, with the namespace label that bypasses it.

Testing

  • go test ./hack/fakegpu/ passes, including the fixture comparison. gofmt and vet are clean, and golangci-lint 2.5.0 reports 0 issues.
  • On a Kubernetes 1.37 kind cluster with KWOK, the generated 10-node fleet creates and becomes Ready, with amd.com/gpu capacity kept on creation.
    • kwok-dra-placement passes as committed.
    • kwok-device-plugin-placement passes with tolerations added to its pods, because that cluster lacks the admission plugin (and runs HAMi, which had to be bypassed).
  • Not verified: the ExtendedResourceToleration patch in hack/kind/config.yaml, and kwok-device-plugin-placement without tolerations. Creating a fresh kind cluster failed on the host's inotify instance limit, which is unrelated to this change.

@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: Approve, with one small ask before merge

Before merge

  1. Guard the make targets against the wrong kube context. The fake-fleet targets act on whatever context is current. Run from a terminal pointed at the shared GPU vcluster, they would add ten fake GPU nodes there. A check that the context is a kind cluster, or an explicit override variable, would prevent that.

Kind has no GPUs and its labelled workers advertise no amd.com/gpu, so
e2e tests cannot check where GPU workloads are scheduled, and there is no
way to exercise DRA. This adds fake AMD GPU nodes that exist only in the
API, run by KWOK, that the scheduler treats like real GPU nodes.

hack/fakegpu generates them from a fleet file: Node objects with the AMD
GPU Operator's and the AcceleratorDetector's labels, an amd.com/gpu taint,
and either allocatable amd.com/gpu (device-plugin groups) or a gpu.amd.com
ResourceSlice in the AMD GPU DRA driver's format (dra groups), including
compute partitions. Its unit tests compare the devices with ResourceSlices
the driver's own discovery code published for the same node shapes.

- hack/kwok/install.sh installs a pinned KWOK release.
- make kwok-install, fake-gpu-fleet, fake-gpu-fleet-delete and
  test-chainsaw-kwok run the lane. Tests labelled requires=kwok are
  excluded from every other selector, because the fleet's GPU-labelled
  nodes change other tests' node counts.
- The kind config enables the ExtendedResourceToleration admission
  plugin, so pods requesting amd.com/gpu tolerate the fake nodes' taint.
- tests/e2e/kwok checks device-plugin and DRA placement, including CPX
  partitions and unsatisfiable requests.
The fleet now has the node shapes the DRA work needs to test against:

- dp-mixed-models and dra-mixed-models: 4 x MI350P and 2 x Radeon AI PRO
  R9700 on one node. The device-plugin node advertises them as one
  amd.com/gpu pool; on the DRA node each device carries its own deviceID.
- dra-mixed-partitions: 4 x MI300X in SPX-NPS1 and 4 in CPX-NPS1 on one
  node.

The generator gains the MI350P (from AMD's specifications; not
partitionable until checked against hardware) and rejects device-plugin
groups whose GPUs are in different partition modes, which the AMD device
plugin supports only with its mixed resource naming. The KWOK tests check
that a claim on the mixed-model node gets only the model it selects, that
one claim can take a whole GPU and partitions from the mixed-partition
node, and that the device-plugin mixed node is a single pool.
Adds a test-e2e-kwok job that creates a kind cluster from
hack/kind/config.yaml, installs KWOK and the fake GPU fleet, and runs
make test-chainsaw-kwok. It runs on its own cluster because the fleet's
GPU-labelled nodes would change the node counts the main e2e suite
asserts on, and it is the first check of the kind config's
ExtendedResourceToleration admission plugin.
kind v0.31 generates a kubeadm v1beta3 ClusterConfiguration and skips
patches with another apiVersion, so the v1beta4 patch was never applied
and the KWOK lane's device-plugin test stayed Pending without its
toleration. Use the v1beta3 form, and check in the KWOK CI job that the
API server runs with the plugin before the tests start.
kwok-install, fake-gpu-fleet and fake-gpu-fleet-delete act on the current
kubectl context. From a terminal pointed at a shared GPU cluster they would
add fake GPU nodes to it. They now refuse non-kind contexts unless
FAKE_GPU_CONTEXT names the current one.
@salexo
salexo force-pushed the feature/kwok-fake-gpu-nodes branch from b724674 to 9d7cae8 Compare December 1, 2026 08:45
@salexo

salexo commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Done in 9d7cae8: kwok-install, fake-gpu-fleet and fake-gpu-fleet-delete now refuse any context that isn't kind-*, unless FAKE_GPU_CONTEXT names the current context. The testing docs describe the override. The branch is also rebased onto main.

The fixtures are what the AMD GPU DRA driver's discovery code computes on
sysfs trees written from the GPU models' specifications, not slices taken
from real nodes. Their PCI addresses follow those trees and the test
compares them, so the old advice to refresh them from a real node would
make the test fail.

@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.

lgtm!

@williamanzen williamanzen 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.

LGTM

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.

3 participants