Skip to content

feat: add MIG profile layout configuration - #9081

Merged
awesomenix merged 7 commits into
mainfrom
codex/mig-profile-layout-contract
Jul 31, 2026
Merged

feat: add MIG profile layout configuration#9081
awesomenix merged 7 commits into
mainfrom
codex/mig-profile-layout-contract

Conversation

@karenychen

@karenychen karenychen commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Adds the inert AgentBaker contract plumbing for an ordered MIG execution plan:

  • NodeBootstrappingConfiguration.MIGProfileLayout []string
  • GpuConfig.mig_profile_layout (field 9)
  • NVIDIA_MIG_PROFILE_LAYOUT in classic CSE and aks-node-controller
  • focused tests proving order and duplicates are preserved

Deliberate split boundary

This PR does not change mig-partition.sh, activate partitioning for layout-only input, or add GPU e2e scenarios. MIG_NODE remains driven by the legacy GPUInstanceProfile until the follow-up runtime PR lands. This prevents the existing script from being started with an empty legacy scalar while RP begins populating the new field.

After this merges, a second PR will atomically:

  • treat either MIGProfileLayout or legacy GPUInstanceProfile as a MIG node
  • make a non-empty layout authoritative in mig-partition.sh
  • retain legacy uniform expansion
  • propagate both NVIDIA command failures
  • add ShellSpec and GPU e2e coverage

Supersedes #8869.

Validation

  • go test ./pkg/agent/... -count=1
  • go test ./parser/... -count=1 (aks-node-controller)
  • go test -run '^$' ./... (e2e compile)
  • buf lint
  • buf breaking against Azure/AgentBaker/main
  • focused ShellCheck for changed shell files
  • cse_config_spec.sh: 145 examples, 0 failures

make generate regenerated Go test data successfully, then the repository-wide POSIX ShellCheck phase hit the existing SC3014 baseline in unrelated scripts.

@github-actions

github-actions Bot commented Jul 30, 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✅ passedJul 31, 2026, 6:02 PM

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Windows Unit Test Results

  3 files   12 suites   50s ⏱️
389 tests 389 ✅ 0 💤 0 ❌
392 runs  392 ✅ 0 💤 0 ❌

Results for commit 2dff429.

♻️ 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

Adds “layout-only” contract plumbing for an ordered NVIDIA MIG partition execution plan across the classic AgentBaker path and the aks-node-controller path, without changing runtime partitioning behavior yet (keeps MIG_NODE driven by legacy GPUInstanceProfile).

Changes:

  • Adds NodeBootstrappingConfiguration.MIGProfileLayout []string and exposes it to templates as NVIDIA_MIG_PROFILE_LAYOUT (comma-joined, order/duplicates preserved).
  • Extends aks-node-controller GPU proto contract with repeated string mig_profile_layout = 9 and propagates it into the generated CSE env.
  • Adds focused unit tests validating order + duplicates are preserved and that layout-only input does not flip MIG_NODE yet.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/agent/variables.go Adds a MIG layout variable to the CSE variables map (currently unused by templates).
pkg/agent/datamodel/types.go Adds MIGProfileLayout []string to NodeBootstrappingConfiguration.
pkg/agent/baker.go Adds GetMIGProfileLayout template func (comma-joins layout).
pkg/agent/baker_test.go Adds test ensuring layout is propagated but MIG_NODE remains false.
parts/linux/cloud-init/artifacts/cse_config.sh Writes NVIDIA_MIG_PROFILE_LAYOUT into mig-partition systemd drop-in.
parts/linux/cloud-init/artifacts/cse_cmd.sh Exports NVIDIA_MIG_PROFILE_LAYOUT in classic CSE env vars.
aks-node-controller/proto/README.md Documents the new env var in GPUConfig field mapping table.
aks-node-controller/proto/aksnodeconfig/v1/gpu_config.proto Adds mig_profile_layout (field 9) to GPUConfig proto.
aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go Updates generated Go bindings for the new proto field.
aks-node-controller/parser/parser.go Populates NVIDIA_MIG_PROFILE_LAYOUT from proto into CSE env.
aks-node-controller/parser/parser_test.go Adds test verifying layout env propagation and MIG_NODE remains false.
Files not reviewed (1)
  • aks-node-controller/pkg/gen/aksnodeconfig/v1/gpu_config.pb.go: Generated file

Comment thread parts/linux/cloud-init/artifacts/cse_config.sh
Comment thread pkg/agent/variables.go
Copilot AI review requested due to automatic review settings July 30, 2026 21:16

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 10 out of 11 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
Comments suppressed due to low confidence (2)

parts/linux/cloud-init/artifacts/cse_config.sh:919

  • This change introduces new behavior in ensureMigPartition() (writing NVIDIA_MIG_PROFILE_LAYOUT into the systemd drop-in), but there is no ShellSpec coverage for ensureMigPartition in spec/parts/linux/cloud-init/artifacts/cse_config_spec.sh. Given the repo’s convention of adding ShellSpec coverage for shell script changes in parts/linux/, please add a focused test that asserts the generated drop-in includes the new environment line (and that order/format is preserved).
    tee /etc/systemd/system/mig-partition.service.d/10-mig-profile.conf > /dev/null <<EOF
[Service]
Environment="GPU_INSTANCE_PROFILE=${GPU_INSTANCE_PROFILE}"
Environment="NVIDIA_MIG_PROFILE_LAYOUT=${NVIDIA_MIG_PROFILE_LAYOUT}"
EOF

pkg/agent/variables.go:129

  • migProfileLayout is added to the CSE command variables map, but there are no template references to migProfileLayout (only GetMIGProfileLayout is used in cse_cmd.sh). Keeping an unused variable key increases contract surface area and can mislead future readers into thinking it is consumed somewhere. Consider removing it until there is an actual template consumer.
		"configGPUDriverIfNeeded":                config.ConfigGPUDriverIfNeeded,
		"enableGPUDevicePluginIfNeeded":          config.EnableGPUDevicePluginIfNeeded,
		"migNode":                                strconv.FormatBool(datamodel.IsMIGNode(config.GPUInstanceProfile)),
		"gpuInstanceProfile":                     config.GPUInstanceProfile,
		"migProfileLayout":                       strings.Join(config.MIGProfileLayout, ","),

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

RP dual-write will retain legacy path.
follow-up PR on make new layout authoritative while preserving legacy path

validator: func(cmd *exec.Cmd) {
vars := environToMap(cmd.Env)
assertHasKeyWithValue(t, vars, "NVIDIA_MIG_PROFILE_LAYOUT", "MIG3g,MIG2g,MIG1g,MIG1g")
// TODO: Make MIG_NODE true if either NVIDIA_MIG_PROFILE_LAYOUT or GPU_INSTANCE_PROFILE is set.

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.

so in this change, NVIDIA_MIG_PROFILE_LAYOUT does not activate MIG yet.

if RP sends only the new layout, AgentBaker does not apply it yet, if RP sends both fields, then legacy field activates MIG partitioning. so this ensure old VHDs are still supported.

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.

correct. this field is no-op right now. the new logic around it will be added in a follow-up PR

Copilot AI review requested due to automatic review settings July 31, 2026 17:59

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 11 out of 12 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/variables.go:130

  • The new template variable migProfileLayout is added to getCSECommandVariables, but there are no template references to it (no GetVariable "migProfileLayout" usage). This duplicates the GetMIGProfileLayout func-map logic and can mislead future changes (two encoding paths to keep in sync).
		"migNode":                                strconv.FormatBool(datamodel.IsMIGNode(config.GPUInstanceProfile)),
		"gpuInstanceProfile":                     config.GPUInstanceProfile,
		"migProfileLayout":                       strings.Join(config.MIGProfileLayout, ","),
		"windowsEnableCSIProxy":                  windowsProfile.IsCSIProxyEnabled(),

parts/linux/cloud-init/artifacts/cse_config.sh:919

  • This adds NVIDIA_MIG_PROFILE_LAYOUT propagation into the mig-partition systemd override, but there is currently no ShellSpec coverage validating ensureMigPartition writes this environment line. Since cse_config.sh is already covered by ShellSpec, adding a focused spec will help prevent regressions when the follow-up PR makes the layout authoritative.
    tee /etc/systemd/system/mig-partition.service.d/10-mig-profile.conf > /dev/null <<EOF
[Service]
Environment="GPU_INSTANCE_PROFILE=${GPU_INSTANCE_PROFILE}"
Environment="NVIDIA_MIG_PROFILE_LAYOUT=${NVIDIA_MIG_PROFILE_LAYOUT}"
EOF

@awesomenix
awesomenix enabled auto-merge (squash) July 31, 2026 20:25
@awesomenix
awesomenix merged commit 7fc6928 into main Jul 31, 2026
37 of 39 checks passed
@awesomenix
awesomenix deleted the codex/mig-profile-layout-contract branch July 31, 2026 20:56
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.

5 participants