Skip to content

feat: use MIG profile layout for partitioning - #9129

Open
Karen Chen (karenychen) wants to merge 15 commits into
mainfrom
codex/mig-profile-layout-runtime
Open

feat: use MIG profile layout for partitioning#9129
Karen Chen (karenychen) wants to merge 15 commits into
mainfrom
codex/mig-profile-layout-runtime

Conversation

@karenychen

Copy link
Copy Markdown
Contributor

What this PR does

Completes the runtime half of the MIG profile layout contract introduced by #9081.

  • treats either MIGProfileLayout or legacy GPUInstanceProfile as a MIG node in classic CSE and aks-node-controller
  • makes a non-empty MIGProfileLayout authoritative when both fields are populated
  • maps the ordered layout directly to NVIDIA profile IDs without sorting, capacity expansion, or MigStrategy interpretation
  • retains legacy uniform expansion when only GPUInstanceProfile is populated
  • propagates failures from both nvidia-smi mig -cgi and nvidia-smi mig -cci
  • keeps MigStrategy solely for nvidia-device-plugin advertisement behavior
  • adds focused ShellSpec coverage plus Single, Mixed, and legacy GPU e2e coverage

This supersedes the runtime/test portion of closed #8869. AKS RP layout calculation remains out of scope.

Validation

  • make generate regenerated Go test data and the manifest without changes; its repository-wide ShellCheck tail stops on the existing POSIX SC3014 baseline
  • go test ./pkg/agent/... -count=1
  • go test ./parser/... -count=1 from aks-node-controller
  • go test . -run '^$' -count=1 from e2e
  • focused ShellCheck for mig-partition.sh and its ShellSpec
  • focused ShellSpec: 15 examples, 0 failures
  • Buf lint
  • Buf breaking check against Azure/AgentBaker main
  • git diff --check

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedAug 21, 2026, 9:14 PM

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   13 suites   39s ⏱️
404 tests 404 ✅ 0 💤 0 ❌
407 runs  407 ✅ 0 💤 0 ❌

Results for commit 133c697.

♻️ This comment has been updated with latest results.

Copilot AI 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.

Pull request overview

This PR completes the runtime support for the ordered MIGProfileLayout contract (introduced in #9081) across classic CSE and aks-node-controller, enabling MIG partitioning based on an explicit ordered layout while preserving legacy GPUInstanceProfile uniform expansion behavior.

Changes:

  • Treats nodes as MIG-enabled when either MIGProfileLayout or legacy GPUInstanceProfile is populated, with MIGProfileLayout taking precedence when non-empty.
  • Updates mig-partition.sh to map the ordered layout directly to NVIDIA profile IDs (preserving order/duplicates) and to propagate failures from nvidia-smi mig -cgi and nvidia-smi mig -cci.
  • Adds/updates focused ShellSpec coverage and GPU e2e coverage for legacy, Single, and Mixed MIG scenarios, plus additional validators for exact advertised resources and MIG strategy.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/parts/linux/cloud-init/artifacts/mig_partition_spec.sh Adds ShellSpec coverage for legacy and layout-driven MIG partitioning behavior and failure propagation.
pkg/agent/variables.go Sets MIG_NODE based on either legacy scalar or layout being populated.
pkg/agent/datamodel/helper.go Extends IsMIGNode to consider both legacy and layout inputs.
pkg/agent/baker.go Uses the shared IsMIGNode logic when templating MIG enablement.
pkg/agent/baker_test.go Updates tests to assert MIG env vars for legacy and layout-driven cases.
parts/linux/cloud-init/artifacts/mig-partition.sh Implements authoritative ordered layout parsing and legacy uniform expansion; propagates nvidia-smi failures.
e2e/validators.go Adds validators for MIG strategy, exact GPU resource advertisement, and exact MIG instance profile counts.
e2e/scenario_gpu_managed_experience_test.go Adds/updates Ubuntu 24.04 MIG scenarios for legacy field, layout+Single, and layout+Mixed with stricter validation.
e2e/node_config.go Propagates MIG-related fields (instance profile, strategy, layout) into AKS node config v1 for e2e.
aks-node-controller/proto/aksnodeconfig/v1/gpu_config.proto Clarifies MIG strategy semantics when MIG is enabled via either legacy scalar or layout.
aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go Regenerates Go bindings reflecting the updated proto comment/metadata.
aks-node-controller/parser/parser.go Sets MIG_NODE based on either legacy scalar or layout being populated.
aks-node-controller/parser/parser_test.go Updates parser tests to assert MIG env vars and MIG enablement for layout-only inputs.
aks-node-controller/parser/helper.go Extends MIG enablement helper to consider both legacy and layout inputs.
Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file

Comment thread parts/linux/cloud-init/artifacts/mig-partition.sh
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 4, 2026 18:09

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file
Suppressed comments (2)

pkg/agent/datamodel/helper.go:131

  • IsMIGNode treats any non-empty migProfileLayout slice as enabling MIG, but the layout is serialized via strings.Join. A slice like []string{""} makes MIG_NODE true while NVIDIA_MIG_PROFILE_LAYOUT becomes an empty string, causing mig-partition.sh to treat the layout as unset and fail with the misleading "neither ... is set" path. Consider only returning true when the layout contains at least one non-empty element (or trim-space non-empty) so MIG_NODE aligns with the serialized env var.
// IsMIGNode check if the node should be partitioned.
func IsMIGNode(gpuInstanceProfile string, migProfileLayout []string) bool {
	return gpuInstanceProfile != "" || len(migProfileLayout) > 0
}

aks-node-controller/parser/helper.go:255

  • getIsMIGNode uses len(migProfileLayout)>0, which can make MIG_NODE true even when the serialized NVIDIA_MIG_PROFILE_LAYOUT ends up empty (e.g., []string{""}). That leads to inconsistent behavior (MIG_NODE true, but mig-partition.sh sees no layout). Consider requiring at least one non-empty profile entry before enabling MIG based on migProfileLayout.
func getIsMIGNode(gpuInstanceProfile string, migProfileLayout []string) bool {
	return gpuInstanceProfile != "" || len(migProfileLayout) > 0
}

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file

Comment thread parts/linux/cloud-init/artifacts/mig-partition.sh
Copilot AI review requested due to automatic review settings August 18, 2026 19:02

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file
Suppressed comments (1)

parts/linux/cloud-init/artifacts/mig-partition.sh:60

  • parse_mig_profile_layout uses local, which will fail the repo’s POSIX ShellCheck pass (shellcheck --shell=sh runs on all *.sh except the small BASH_ONLY_LIST in .pipelines/scripts/verify_shell.sh). Since mig-partition.sh isn’t in that allowlist, please avoid bash-only syntax here so CI doesn’t break.
    local profiles_csv="$1"
    local layout=""
    local is_last_profile
    local profile
    local profile_id

@karenychen

Copy link
Copy Markdown
Contributor Author

the agentbaker GPU E2E fails because this change requires rebuilding VHDs. Here is the passed GPU E2E run with VHD built from this branch: https://dev.azure.com/msazure/CloudNativeCompute/_build/results?buildId=177161624&view=results

Copilot AI review requested due to automatic review settings August 19, 2026 18:46

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file
Suppressed comments (1)

parts/linux/cloud-init/artifacts/mig-partition.sh:60

  • verify_shell.sh runs an additional ShellCheck pass with --shell=sh for all scripts not in BASH_ONLY_LIST. mig-partition.sh is not in that list, so using local here will likely fail the POSIX ShellCheck gate (e.g., SC3043). Either keep this script POSIX-compatible or explicitly exclude it from the POSIX pass.

A minimal fix is to remove local and use plain assignments (the rest of the script is already POSIX-friendly).

    local profiles_csv="$1"
    local layout=""
    local is_last_profile
    local profile
    local profile_id

@karenychen Karen Chen (karenychen) left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code review

Found 1 issue:

  1. High Risk - Backward Compatibility: datamodel.IsMIGNode is an exported API in current published AgentBaker module tags, and changing it from IsMIGNode(string) to IsMIGNode(string, []string) breaks existing downstream callers at compile time. Preserve the one-argument function and add a new layout-aware helper (or another backward-compatible API). This is also tracked by the unresolved inline review thread on this line.

// IsMIGNode check if the node should be partitioned.
func IsMIGNode(gpuInstanceProfile string, migProfileLayout []string) bool {
return gpuInstanceProfile != "" || len(migProfileLayout) > 0
}

Copilot AI review requested due to automatic review settings August 19, 2026 20:04

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file
Suppressed comments (2)

parts/linux/cloud-init/artifacts/mig-partition.sh:61

  • parse_mig_profile_layout uses local, but the repo’s validate-shell gate runs an additional ShellCheck pass with --shell=sh for all *.sh not in the small BASH_ONLY_LIST (see .pipelines/scripts/verify_shell.sh:28-35,99-103). Since parts/linux/cloud-init/artifacts/mig-partition.sh is not listed there, these local declarations will be flagged as non-POSIX (e.g., SC2039) and can break CI. Please either make the function POSIX-clean or explicitly exempt this script.
    local profiles_csv="$1"
    local layout=""
    local is_last_profile
    local profile
    local profile_id

e2e/validators.go:3164

  • Pod names must be a DNS-1123 label (<= 63 chars). s.Runtime.VM.KubeName is a Kubernetes node name derived from a VMSS name that is already capped at 57 chars (e2e/vmss.go:1140-1142), so appending -<resourceID>-test can push the pod name over the 63-char limit and cause pod creation to fail in e2e. Consider truncating the generated name (similar to the existing truncation helper used in kata validators).
	// Create a GPU test pod using the same pattern as podRunNvidiaWorkload
	resourceID := strings.ReplaceAll(strings.TrimPrefix(resourceName, "nvidia.com/"), ".", "-")
	pod := &corev1.Pod{
		ObjectMeta: metav1.ObjectMeta{
			Name:      fmt.Sprintf("%s-%s-test", s.Runtime.VM.KubeName, resourceID),
			Namespace: "default",

@@ -2,26 +2,104 @@

#NOTE: Currently, Nvidia library mig-parted (https://github.com/NVIDIA/mig-parted) cannot work properly because of the outdated GPU driver version

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.

still the case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I took a look at this before but not sure if it's the path we want to go: this would require us introducing a new dependency for the nvidia-mig-parted tool. Also I am not sure if it is as helpful with our mixed MIG model since it would require us to deliberately define all possible MIG profile combinations. I am okay with replacing this TODO with a comment

esac
}

# TODO: Support GPU models with fewer than seven total partitions.

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.

Which GPU instances are those?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops I meant to remove this comment since the new GPUProfileLayout should already support it (we will compute the exact layout on RP side).

There are a few GPUs that support != 7 partitions documented on the official MIG user guide https://docs.nvidia.com/datacenter/tesla/mig-user-guide/latest/supported-mig-profiles.html

In Azure, we currently don't support any of these. However, I have spoken with Sachi and we want to maintain the flexibility to support them

Copilot AI review requested due to automatic review settings August 21, 2026 21:13

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file

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