This specification is maintained by the AgentRules Working Group. Have enhancements or want to claim maintainership?Submit Specification →
devopscritical PriorityID: k8s-dra-numa-gpu-slicing-topology-alignment

Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant

Enforces strict PCIe and NUMA node topology alignment for containerized fractional accelerator workloads via Kubernetes Dynamic Resource Allocation (DRA). Prevents cross-socket interconnect latency penalties by guaranteeing that sliced GPU instances, container CPU affinity, and pinned memory allocations share the exact same NUMA domain.

Prohibited Anti-Pattern: Cross-NUMA Sliced GPU Allocation Inducing Cross-Socket Interconnect Bottlenecks

Export Ready-to-Drop Configuration

Select format below to copy code or download file directly.

---
description: Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant - Enforces strict PCIe and NUMA node topology alignment for containerized fractional accelerator workloads via Kubernetes Dynamic Resource Allocation (DRA). Prevents cross-socket interconnect latency penalties by guaranteeing that sliced GPU instances, container CPU affinity, and pinned memory allocations share the exact same NUMA domain.
globs: deploy/**/*.{yaml,yml}, charts/**/*.{yaml,yml}, k8s/**/*.{yaml,yml}, manifests/**/*.{yaml,yml}
alwaysApply: true
verified_by: "agentrules.org"
license: "CC-BY-4.0"
source: "https://agentrules.org/rules/k8s-dra-numa-gpu-slicing-topology-alignment"
---

# Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant

> **Severity**: CRITICAL | **Category**: devops
> **Anti-Pattern Warning**: Cross-NUMA Sliced GPU Allocation Inducing Cross-Socket Interconnect Bottlenecks

## System Constraints
You are a Principal Infrastructure Architect enforcing strict Kubernetes Dynamic Resource Allocation (DRA) NUMA-aware invariants. When configuring or generating manifests for accelerated workloads, you MUST enforce exact NUMA and PCIe topology co-location between container CPU sets, pinned host memory, and fractional GPU slices (e.g., NVIDIA MIG, Intel Gaudi, or AMD ROCm partitions). Never allow fractional GPU allocations that rely on default kubelet scheduling without strict DRA CEL selector expressions or ResourceClaim constraints matching the host Topology Manager policy.

## Strict Guidelines
- Engineers MUST ALWAYS declare accelerator requirements via `resource.k8s.io` ResourceClaims or ResourceClaimTemplates rather than untracked opaque integer resources when fractional slicing is required.
- Engineers MUST ALWAYS enforce `same-numa-node` or strict selector constraints in DRA ResourceClaims matching the node's Kubelet Topology Manager `single-numa-node` policy.
- Engineers MUST NOT allow ResourceClaim selectors to match GPU devices whose root PCIe switch reports an alternate NUMA node ID relative to allocated CPU cores.
- Workload specifications MUST specify Guaranteed QoS (equal CPU limits and requests with integer CPU count) alongside DRA ResourceClaims to activate Kubelet CPU Manager static policy pinning.
- DeviceClass configurations MUST enforce device selector CEL expressions evaluating `device.attributes['gpu.vendor.com/numaNode'].numeric` equality against the scheduled pod's target NUMA zone.
- Configurations NEVER permit fallback to cross-socket UPI/QPI/Infinity Fabric traversal for GPU memory copies in latency-sensitive inference or distributed training workloads.

## Bad vs Good Implementations
### Unconstrained Fractional GPU Allocation via Legacy Opaque Resources vs. Strict DRA NUMA-Pinned Claim

#### Bad Antipattern (AI Common Hallucination)
> **Why it fails**: Using legacy opaque integer resources (`nvidia.com/mig-3g.40gb`) decouples GPU allocation from Topology Manager decisions. If CPU Manager pins the worker to NUMA node 0 and the device plugin yields a MIG slice wired to NUMA node 1, every tensor transfer traverses the high-latency CPU inter-socket bus, degrading inference throughput by up to 40%.
```yaml
apiVersion: v1
kind: Pod
metadata:
  name: inference-worker-bad
spec:
  containers:
  - name: llama-inference
    image: vllm/vllm-openai:latest
    resources:
      limits:
        cpu: "8"
        memory: 32Gi
        # FLUID TOPOLOGY BUG: Opaque resource permits kubelet to assign
        # a MIG slice on PCIe Bus of NUMA Node 1 while CPU Manager pins
        # cores on NUMA Node 0, throttling memory bandwidth over cross-socket UPI.
        nvidia.com/mig-3g.40gb: 1
      requests:
        cpu: "8"
        memory: 32Gi
```

#### Production Standard (Correct)
> **Standard**: Uses Kubernetes Dynamic Resource Allocation (DRA) `resource.k8s.io/v1beta1` with a ResourceClaim specifying a device selector CEL expression. The accelerator claim guarantees the allocated GPU partition resides on the exact PCIe bus and NUMA node (node 0) aligned with the integer CPU allocations under the kubelet's static CPU Manager and single-numa-node Topology Manager policies.
```yaml
apiVersion: resource.k8s.io/v1beta1
kind: ResourceClaimTemplate
metadata:
  name: numa-aligned-gpu-slice
spec:
  spec:
    devices:
      requests:
      - name: sliced-gpu
        deviceClassName: gpu.nvidia.com
        selectors:
        - cel:
            expression: >-
              device.capacity['gpu.nvidia.com/memory'].inRange('40Gi', '80Gi') &&
              device.attributes['gpu.nvidia.com/numaNode'].numeric == 0
---
apiVersion: v1
kind: Pod
metadata:
  name: inference-worker-good
spec:
  resourceClaims:
  - name: gpu-claim
    resourceClaimTemplateName: numa-aligned-gpu-slice
  containers:
  - name: llama-inference
    image: vllm/vllm-openai:latest
    resources:
      claims:
      - name: gpu-claim
      limits:
        # Guaranteed QoS triggers static CPU pinning
        cpu: "8"
        memory: 32Gi
      requests:
        cpu: "8"
        memory: 32Gi
```

Recommended MCP Servers (mcp-serverlist.com)

Equip agent with system tools to verify code for this stack.

Recommended Agent Skills (askills.dev)

Ready-to-use executable skill functions tailored to this stack.

Architectural Specification & Invariant Rationale

Architectural Invariant Design: Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant

Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant defines an industrial-grade behavioral standard for devops engineering. Enforces strict PCIe and NUMA node topology alignment for containerized fractional accelerator workloads via Kubernetes Dynamic Resource Allocation (DRA). Prevents cross-socket interconnect latency penalties by guaranteeing that sliced GPU instances, container CPU affinity, and pinned memory allocations share the exact same NUMA domain. Modern software architectures require strict adherence to deterministic patterns to guarantee high availability, maintainability, and zero security vulnerabilities.

Framework Paradigm Shift & Drift MechanicsLLMs are trained on millions of open-source repositories containing outdated code, legacy idioms, and unpatched antipatterns. When coding assistants generate implementations for this stack, they default to common statistical tokens: Cross-NUMA Sliced GPU Allocation Inducing Cross-Socket Interconnect Bottlenecks Without an explicit system instruction file, developers spend hours debugging silent failures.
Failure Modes & Production Blast Radius

Hazard Analysis: What Breaks Without This Rule

The following failure modes have been cataloged from hundreds of hours of production code reviews where AI assistants produced non-compliant implementations:

Failure ModeAI Symptom (The Anti-Pattern)SeverityProduction Impact & Remedy
AI Hallucination & Deprecation DriftCross-NUMA Sliced GPU Allocation Inducing Cross-Socket Interconnect BottlenecksCritical
Violating this industrial standard introduces regression bugs, security risks, and unexpected runtime failures in production.
Enforce explicit behavioral system directives across all AI coding assistants in your repository.
Silent Architecture InconsistencyAI assistants produce mixed paradigms across files, creating fragmented codebase conventions.Medium
Increases cognitive load during code reviews and leads to maintenance debt across engineering teams.
Pin project conventions in .cursor/rules, CLAUDE.md, and AGENTS.md so all team agents follow identical guardrails.
Architectural Directives in Detail

Step-by-Step Production Directives

Each rule constraint below is injected into the AI agent's system prompt to establish deterministic boundaries:

1

Engineers MUST ALWAYS declare accelerator requirements via `resource.k8s.io` ResourceClaims or ResourceClaimTemplates rather than untracked opaque integer resources when fractional slicing is required.

Engineers MUST ALWAYS declare accelerator requirements via `resource.k8s.io` ResourceClaims or ResourceClaimTemplates rather than untracked opaque integer resources when fractional slicing is required.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
2

Engineers MUST ALWAYS enforce `same-numa-node` or strict selector constraints in DRA ResourceClaims matching the node's Kubelet Topology Manager `single-numa-node` policy.

Engineers MUST ALWAYS enforce `same-numa-node` or strict selector constraints in DRA ResourceClaims matching the node's Kubelet Topology Manager `single-numa-node` policy.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
3

Engineers MUST NOT allow ResourceClaim selectors to match GPU devices whose root PCIe switch reports an alternate NUMA node ID relative to allocated CPU cores.

Engineers MUST NOT allow ResourceClaim selectors to match GPU devices whose root PCIe switch reports an alternate NUMA node ID relative to allocated CPU cores.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
4

Workload specifications MUST specify Guaranteed QoS (equal CPU limits and requests with integer CPU count) alongside DRA ResourceClaims to activate Kubelet CPU Manager static policy pinning.

Workload specifications MUST specify Guaranteed QoS (equal CPU limits and requests with integer CPU count) alongside DRA ResourceClaims to activate Kubelet CPU Manager static policy pinning.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
5

DeviceClass configurations MUST enforce device selector CEL expressions evaluating `device.attributes['gpu.vendor.com/numaNode'].numeric` equality against the scheduled pod's target NUMA zone.

DeviceClass configurations MUST enforce device selector CEL expressions evaluating `device.attributes['gpu.vendor.com/numaNode'].numeric` equality against the scheduled pod's target NUMA zone.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
6

Configurations NEVER permit fallback to cross-socket UPI/QPI/Infinity Fabric traversal for GPU memory copies in latency-sensitive inference or distributed training workloads.

Configurations NEVER permit fallback to cross-socket UPI/QPI/Infinity Fabric traversal for GPU memory copies in latency-sensitive inference or distributed training workloads.

Rationale:AI models frequently generate unconstrained code here because statistical language distributions lack project-specific architectural context. Mandating this directive ensures that generated code adheres to verified industrial production requirements.
Enforcement:Integrated into the Agent Pack rule file. When Cursor, Claude Code, or Codex processes this prompt, it applies this constraint before emitting syntax.
Technical Questions & Answers

Frequently Asked Technical Questions

Common questions developers face when configuring AI coding assistants for this stack:

Q:Why is Kubernetes DRA NUMA-Aware GPU Slicing & Topology Alignment Invariant critical for AI coding assistants?

Enforces strict PCIe and NUMA node topology alignment for containerized fractional accelerator workloads via Kubernetes Dynamic Resource Allocation (DRA). Prevents cross-socket interconnect latency penalties by guaranteeing that sliced GPU instances, container CPU affinity, and pinned memory allocations share the exact same NUMA domain. Without explicit behavioral boundaries, AI coding assistants (Cursor, Claude Code, Windsurf, Codex) rely on training data averages, which frequently produce deprecated, inefficient, or vulnerable code patterns.

Q:How does adopting this rule prevent AI hallucinations?

This rule explicitly declares what the AI must avoid (Cross-NUMA Sliced GPU Allocation Inducing Cross-Socket Interconnect Bottlenecks) and prescribes verified positive examples. Grounding the LLM with negative and positive pairs eliminates guesswork.

Q:Which AI coding environments are supported?

This specification is multi-platform compatible: Cursor (.cursor/rules/*.mdc & .cursorrules), Anthropic Claude Code (CLAUDE.md), Windsurf (.windsurfrules), Codex / Cline (AGENTS.md), and GitHub Copilot (.github/copilot-instructions.md).

Q:Can I combine this rule with other technology stacks?

Yes. Use the Interactive Stack Builder or download an Agent Pack to merge this rule with other frontend, backend, database, security, and DevOps rules without syntax collision.

Open Specification · CC BY 4.0·Free for Personal, Team & Commercial In-Repo Use

Citation & Open Source Attribution Guidelines

This specification is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0). You are completely free to adapt and share this rule in your workspace. If citing, including in public AI benchmark datasets, or redistributing, attribution to AgentRules.org is required.

1 Rule in Stack

Kubernetes