Skip to content

feat(planner): power infrastructure — pod annotation, RBAC, config, Prometheus - #9683

Closed
kaim-eng wants to merge 27 commits into
mainfrom
pr1b/planner-infra
Closed

kaim-eng wants to merge 27 commits into
mainfrom
pr1b/planner-infra

Conversation

@kaim-eng

@kaim-eng kaim-eng commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Part of the [PR #9369 split plan]. PR 1b — Planner Power Infrastructure (Phase 1).

Predecessor: #9682 — Power Agent DaemonSet (landed on main).
Successor: #9684 (Draft) — Power budget enforcement.
Follow-up: #11491 — aggregate-planner startup/scaling resolution (pre-existing gap; see below).

Summary

Wires the planner from config to per-pod power annotation. Phase 1 only — it emits and observes power infrastructure; nothing here changes scaling policy to consume power (budget-gated scaling and the AIC closed loop are deferred to later PRs). Power-awareness is off by default.

17-file diff. Contents:

  • Config (6 fields): enable_power_awareness (default False), total_gpu_power_limit, prefill_engine_gpu_power_limit, decode_engine_gpu_power_limit, power_agent_safe_default_watts, power_annotation_interval_seconds (default 60s sweep throttle). Budget/safe-default are required only when enable_power_awareness=True; all watt/budget fields are ge=1 validated.
  • Annotation sweep (core/base.py): _apply_power_annotations() emits dynamo.nvidia.com/gpu-power-limit per worker pod; _publish_power_budget_metrics() exposes advisory Phase-1 gauges. Guarded behind enable_power_awareness + non-advisory mode + Kubernetes connector; advisory mode is a hard no-op for pod mutation; steady-state sweeps are throttled with a scale-up force window; blocking K8s calls run via asyncio.to_thread. The sweep resolves aggregate (mode=agg) workers via agg_worker_k8s_name.
  • Kubernetes helpers: patch_pod_annotation, list_pods_by_label, get_component_pods, plus frontend admission helpers (list_frontend_pods, resolve_frontend_http_port, post_busy_threshold).
  • Prometheus/DCGM: advisory get_total_dgd_power() query (Phase-3 support, not yet wired) + a NaN-filter fix in the increase query.
  • Operator-chart RBAC: planner ServiceAccount granted pods [get, list, patch] in namespace and cluster-wide modes. Platform chart stays at the main baseline.
  • Tests: unit coverage for validators, annotation patch/no-op/stale + throttle/force-window + agg fallback, label selectors, and Prometheus/DCGM query shape; plus the opt-in single-DGD live suite.

Deferred to the feature-complete PR

To avoid showing external users docs/examples for not-yet-shipped Phase 2/3 behavior:

  • docs/design-docs/multi-tenant-test.md (design / test-plan doc)
  • examples/multi-dgd-live-test/ (multi-DGD testbed manifests + README)
  • components/src/dynamo/planner/tests/integration/test_multi_dgd_live.py (and the multi_dgd_live / power_agent pytest markers)

The powerplanner-design.md / dpp-dev-env.md reviewer-context docs land later in the stack; in-code references to them were made self-contained.

Known limitation (pre-existing — tracked in #11491)

The annotation sweep is agg-aware, but the planner's broader decode-role resolution (validate_deployment, worker-counts/scaling via decode_worker_info.k8s_name, get_model_name) still uses decode_worker_k8s_name for mode=agg — unchanged main behavior, a pre-existing aggregate-planner gap, not a regression from this PR.

Validation (current head 5ffdf9c3ee)

  • WSL planner unit suite: 193 passed
  • Single-DGD live test: skips outside the in-cluster dev pod (by design)
  • Pytest marker report: 3693 checked, 0 missing sets
  • Helm: dependency update + template + unittest (18/18) pass
  • Pre-commit over PR files passes; git diff --check clean; DCO signed
  • Current-head GitHub checks green (changed-files, docs/Fern/lychee, copyright, operator, DCO)

Env-only caveats (not from this patch; green in CI + project venv): the isolated pre-commit pytest-marker-report hook fails on untouched files due to Linux-only fcntl (Windows host) and a missing uvloop in the isolated hook env.

Merge

Squash-and-merge (the main ruleset permits squash only). #9682 has landed; this PR is up to date with main.

Summary by CodeRabbit

  • New Features
    • Added power-aware planning support, including power limits, annotation updates on worker pods, and related monitoring metrics.
    • Added Kubernetes helpers for discovering pods and sending frontend busy-threshold updates.
    • Added live multi-DGD example manifests and teardown scripts for power-aware cluster testing.
  • Bug Fixes
    • Improved metric handling to ignore invalid NaN values and return stable results.
    • Updated URL/regex patterns to be safer and more reliable.
  • Documentation
    • Expanded setup and usage docs for the platform chart and multi-DGD live test workflow.

@kaim-eng
kaim-eng requested review from a team as code owners May 18, 2026 15:54
@copy-pr-bot

copy-pr-bot Bot commented May 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added feat documentation Improvements or additions to documentation deployment::k8s Relates to dynamo deployment in kubernetes planner actions labels May 18, 2026
@kaim-eng
kaim-eng force-pushed the pr1a/power-agent branch from 3cde449 to 1338028 Compare May 18, 2026 16:03
@kaim-eng
kaim-eng force-pushed the pr1b/planner-infra branch from 2222dbf to 1d7b243 Compare May 18, 2026 16:03
@kaim-eng
kaim-eng force-pushed the pr1a/power-agent branch from 1338028 to ec21081 Compare May 19, 2026 12:54
@kaim-eng
kaim-eng force-pushed the pr1b/planner-infra branch 2 times, most recently from 8126b1a to f7f3226 Compare May 19, 2026 15:54
kaim-eng added a commit that referenced this pull request May 22, 2026
Cross-DGD complement to test_actuation_knobs_live.py (the single-DGD live
test that already ships with this PR). Validates invariants that
single-DGD tests structurally cannot reach:

  - A2  Three planners patch DISJOINT pod sets in one namespace
  - A3  AggPlanner-C uses only the DECODE branch (no PREFILL calls)
  - B2  Power Agent applies 8 distinct caps on one tick
  - B4  Happy-path zero-counter invariant
  - B5  Multi-pod conflict + safe-default behaviour (skipped pending
        Finding #7 — CDI-safe bystander rewrite tracked separately)
  - 8.5.6 / 8.6.2  NVML / DCGM cap-application proven by reading the
                   live driver state (not via mocks)

Layout introduced by this commit:

  components/src/dynamo/planner/tests/integration/test_multi_dgd_live.py
      ~1000 LoC pytest module. Opt-in via RUN_MULTI_DGD_LIVE=1 +
      TEST_NODE=<8-GPU node> env vars; auto-detects Path A (production
      shape: 3 real DGDs + power-aware planner) vs Path B (5 stub-worker
      pods with hardcoded annotations) and skips Path-A-only tests
      cleanly when running Path B. DCGM tests gated by
      DCGM_HOSTENGINE_AVAILABLE=1.

  examples/multi-dgd-live-test/
      Manifests + helm values overrides + teardown script + README
      walk-through that an operator applies before running the test:
        00-namespace.yaml                 — namespace + pull secret
        10-power-agent-values-nvml.yaml   — Power Agent NVML helm values
        11-power-agent-values-dcgm.yaml   — Power Agent DCGM helm values
        20-nvidia-dcgm-standalone-ds.yaml — DCGM 4.5.1 hostengine DS
        30/31/32-vllm-dgd-{A,B,C}.yaml    — three DGDs (Path A)
        40-conflict-bystander-pod.yaml    — multi-pod conflict fixture
        50-stub-workers.yaml              — Path-B stub workers
        99-teardown.sh                    — idempotent cleanup w/ cap-
                                            restore verification
        README.md                         — full reproduction playbook
                                            including a 2026-05-21 live
                                            run record + 11 findings

  docs/design-docs/multi-tenant-test.md
      Design doc (§8 — multi-DGD test plan) that establishes the
      ground-truth topology, the planner / agent contract under test,
      and the rationale for the artifact split above.

  pyproject.toml
      Registers two new test markers consumed by the live test's
      `pytestmark`:
        multi_dgd_live  — scenario selector for this specific file
        power_agent     — shared with components/power_agent/tests/

Module-level gating fails fast on misconfiguration (missing TEST_NODE,
missing kubeconfig) with actionable error messages, and skips silently
when RUN_MULTI_DGD_LIVE is unset — so this file is a no-op under the
default unit-test invocation. Verified: pytest --collect-only is a
clean no-op without the env vars, and full-import works under
RUN_MULTI_DGD_LIVE=1 (collection fails cleanly on absent k8s creds, not
ImportError).

Refs: docs/design-docs/multi-tenant-test.md §8, PR #9683 review.
Signed-off-by: Kai Ma <[email protected]>
kaim-eng added a commit that referenced this pull request May 22, 2026
…nd DCGM 4.5

Two stacked defects surfaced on the 2026-05-21T20:11Z Path-B re-run
caused `test_dcgm_per_gpu_cap_matches_topology` and
`test_dcgm_target_config_registered` to skip silently when they should
have PASSED:

1. **`kubernetes-client>=35.0.0` mangles JSON pod-exec stdout.**
   `kubernetes.stream.stream(..., _preload_content=True)` sniffs
   JSON-shaped stdout, parses it client-side, and returns `str(dict)`.
   That means `printf '%s' '{"a":1}'` comes back as the literal 8-char
   string `{'a': 1}` (single quotes, Python-dict repr), which then
   trips `json.loads` at every read-back site — including the four
   inside `test_dcgm_*`. The intended-as-defensive
   "did not return JSON" skip branch fired instead.

2. **DCGM 4.5+ rotated the `dcgmi config --get -g <id> -j` JSON shape.**
   Pre-4.5: `body` is a list of per-GPU entries keyed by `"Power Limit (W)"`
   with flat `{"Current": "...", "Target": "..."}` children.
   4.5+:    `body` is a dict of fields keyed by `"Power Limit"`
            (no `(W)` suffix) with a `"children"` wrapper whose leaves
            are `{"value": "..."}` objects.
   Three breaking changes in one upgrade — `body` flipped list→dict,
   the field name lost its suffix, the leaves gained a `value` wrapper.

The previous implementation handled neither, so even if defect (1)
were absent, the strict per-field reader would still skip.

This commit lands a single combined fix:

- **`_exec_in_pod`**: switch from `_preload_content=True` (default) to
  `_preload_content=False` + raw stdout/stderr accumulation off the
  `WSClient` via `peek_stdout`/`read_stdout`. Bypasses the mangling
  regardless of which `kubernetes-client` version is installed, and is
  the documented "I want bytes back" pattern in the kubernetes-client
  examples.

- **New `_extract_power_limit_from_dcgmi_body(body)` helper**: walks
  both shapes uniformly and returns `(current_w, target_w)` ints or
  `(None, None)` if neither shape matches. Both DCGM read-back tests
  (`test_dcgm_per_gpu_cap_matches_topology` and
  `test_dcgm_target_config_registered`) now consume this helper
  instead of inlining duplicated nested-`dict.get` chains.

Verified locally:
  - synthetic 4.0-shape payload `[{"Power Limit (W)": {"Current": "350",
    "Target": "350"}}]`  → `(350, 350)` ✓
  - synthetic 4.5-shape payload `{"Power Limit": {"children":
    {"Current": {"value": "375"}, "Target": {"value": "375"}}}}`
      → `(375, 375)` ✓
  - missing field, wrong types, partial children: graceful `(None, None)`
    / `(int, None)` returns ✓
  - test module still collects cleanly (`pytest --collect-only`)

`examples/multi-dgd-live-test/README.md` Finding #11 updated to
"Status: fixed" with a cross-reference to this commit and the expected
SKIPPED→PASSED flip on the next live re-run.

Refs: PR #9683 review (Finding #11 in
examples/multi-dgd-live-test/README.md).

Signed-off-by: Kai Ma <[email protected]>
@kaim-eng
kaim-eng requested a review from a team May 22, 2026 14:23
kaim-eng added a commit that referenced this pull request May 22, 2026
`TestMultiPodConflict` previously created a bystander pod with
`NVIDIA_VISIBLE_DEVICES=<gpu-uuid>` to pin it to a specific GPU. AKS
clusters running the NVIDIA Container Toolkit in CDI device mode (the
dpp-dev-env default, and the direction NVIDIA is pushing for newer
operator releases) reject that with
`unresolvable CDI devices management.nvidia.com/gpu=*` and refuse to
admit the pod — so the test class was carrying a
`@pytest.mark.skip(_CDI_CONFLICT_SKIP_REASON)` decorator that disabled
the whole §8.5.7 contract on every run.

This commit lands the CDI-mode-safe rewrite:

  - Bystander now claims `nvidia.com/gpu: 1` from the device plugin
    (both `requests` and `limits` per K8s extended-resource rules).
    CDI-mode-agnostic — the device plugin owns the actual GPU wiring
    via its own machinery.

  - `examples/multi-dgd-live-test/40-conflict-bystander-pod.yaml`
    mirrors the inline Python manifest exactly so YAML-debugging and
    test-debugging agree (the README explicitly calls this out).

  - New helper `_per_gpu_compute_pids()` snapshots
    `nvmlDeviceGetComputeRunningProcesses` across all 8 GPUs from the
    agent pod (which has hostPID + NVML access) and returns
    `{gpu_idx: {pid, ...}}`. The test polls this until it sees a new
    PID on some index after the bystander reaches Running — that
    index IS the GPU the device plugin assigned, no NVIDIA_VISIBLE_DEVICES
    pin needed.

  - Test renamed `test_conflict_triggers_safe_default_on_gpu0_only` →
    `test_conflict_triggers_safe_default_on_assigned_gpu` to reflect
    the index-agnostic contract. Blast-radius / recovery asserts key
    off the discovered `assigned_gpu`; the loop over the other GPUs
    iterates `range(8)` and skips that index instead of hard-coding
    `range(1, 8)`.

  - Class-level `@pytest.mark.skip` decorator removed. The supporting
    `_CDI_CONFLICT_SKIP_REASON` constant is dropped too — kept neither
    in code nor as a runtime branch, since neither path is needed
    once the CDI-safe flow works.

  - `bystander_uuid` class fixture removed (no longer needed — the
    UUID/index discovery is post-creation, not pre).

`examples/multi-dgd-live-test/README.md` updated:
  - Finding #7 marked **Status: fixed** with cross-reference to this
    commit and an explicit description of the new (a)/(b)/(c) flow.
  - Expected-outcome counts updated: Path B now expects 5 PASSED /
    2 SKIPPED (was 4 PASSED / 3 SKIPPED — multi-pod conflict moves
    from SKIP to PASS); DCGM pass expects 7 PASSED / 2 SKIPPED on the
    next live run.
  - Live-run record row updated to note the rewrite and expected
    PASS outcome.

Verified locally: test module compiles + collects cleanly. The
end-to-end CDI-vs-non-CDI assignment behaviour is by construction the
device plugin's responsibility, so the failure mode of this rewrite
is bounded to "device plugin returns no GPU within 90 s" — handled
with a clear pytest.fail message that includes a before/after PID
snapshot for debugging.

Refs: PR #9683 review (Finding #7 in
examples/multi-dgd-live-test/README.md).

Signed-off-by: Kai Ma <[email protected]>
kaim-eng added a commit that referenced this pull request May 22, 2026
…dd SPDX header

Two follow-up fixes to commit 552be92 caught in PR #9683 review.

1. Bystander cannot schedule. The previous CDI-safe rewrite swapped
   `NVIDIA_VISIBLE_DEVICES=<uuid>` for a `nvidia.com/gpu: 1` device-
   plugin claim, expecting the plugin to allocate a free GPU. But
   the 5 stub workers in `50-stub-workers.yaml` already claim every
   `nvidia.com/gpu` slot on the test node (1+1+2+2+2 = 8 of 8), so
   the bystander's claim sits Pending forever and the conflict never
   materialises.

   Switch to the same pattern the Power Agent itself uses
   (`deploy/helm/charts/power-agent/values.yaml`):
   `NVIDIA_VISIBLE_DEVICES: "all"` exposes every GPU through the
   toolkit without consuming a device-plugin claim. The bystander
   pins itself to `cuda:0` (deterministically the first visible
   device — same NVML index 0 as the agent, since both have
   `NVIDIA_VISIBLE_DEVICES=all`). The existing PID-based discovery
   loop in the test still verifies which physical GPU the context
   landed on rather than trusting the mapping, so the test stays
   robust under future toolkit / CDI changes.

   Touches the inline `bystander_manifest` in
   `test_multi_dgd_live.py::TestMultiPodConflict` and the YAML
   companion `examples/multi-dgd-live-test/40-conflict-bystander-pod.yaml`,
   plus the README's Finding #7 status to document both
   non-options (the original `NVIDIA_VISIBLE_DEVICES=<uuid>` CDI
   rejection AND the `nvidia.com/gpu: 1` over-subscription) and
   the surviving fix-shape.

2. Copyright check failed. `40-conflict-bystander-pod.yaml` was
   imported from `.aic_sandbox/` in commit 004df25 without the
   standard two-line SPDX header that every other YAML in
   `examples/multi-dgd-live-test/` carries (00-namespace through
   50-stub-workers — verified via head-of-file scan). Add the
   header.

Signed-off-by: Kai Ma <[email protected]>
kaim-eng added a commit that referenced this pull request May 22, 2026
… lychee

Lychee on PR #9683 fails on 5 URLs that aren't really URLs (caught
in review). All five are inherited from f7f3226 (the original
"feat(planner): power infrastructure …" commit on this branch) but
block #9683 from going green either way.

The 5 cited locations and fix shape:

- `components/src/dynamo/planner/config/defaults.py:48`
- `components/src/dynamo/planner/config/planner_config.py:147`
  In-cluster Prometheus URL
  `http://prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090`.
  `*.svc.cluster.local` is the canonical Kubernetes-internal DNS
  suffix and is not externally resolvable. Add an ignore entry for
  the suffix so any cluster-internal default URL passes lychee.

- `components/src/dynamo/planner/config/planner_config.py:317`
  Docstring placeholder `http://host:port/`.
- `deploy/helm/charts/platform/README.md:118-119`
  Helm-rendered Format hints `"nats://hostname:port"` /
  `"http://hostname:port"` / `"https://hostname:port"`.
  Add three anchored ignore entries for these exact placeholder
  forms (kept narrow so a real `*.com` hostname can't accidentally
  slip past as `hostname:port`).

- `deploy/helm/charts/platform/Chart.yaml:23`
  `home: https://nvidia.com`. The same file already uses
  `https://www.nvidia.com` on line 19 for `url:` and that one passes
  lychee, so the bare-apex form on line 23 must be hitting a 4xx
  (Cloudflare bot challenge, redirect-loop, etc.). Canonicalise to
  the `www.` form so the two `nvidia.com` URLs in the same file
  agree, and no ignore entry is needed.

Verified all 5 URLs match the new ignore patterns via local regex
spot-check; `https://www.nvidia.com` (existing line 19 + line 23 fix)
deliberately does NOT match any ignore pattern.

Signed-off-by: Kai Ma <[email protected]>
@kaim-eng
kaim-eng force-pushed the pr1a/power-agent branch 2 times, most recently from 1e1ef6f to 29f0831 Compare May 25, 2026 13:46
kaim-eng added a commit that referenced this pull request May 25, 2026
Cross-DGD complement to test_actuation_knobs_live.py (the single-DGD live
test that already ships with this PR). Validates invariants that
single-DGD tests structurally cannot reach:

  - A2  Three planners patch DISJOINT pod sets in one namespace
  - A3  AggPlanner-C uses only the DECODE branch (no PREFILL calls)
  - B2  Power Agent applies 8 distinct caps on one tick
  - B4  Happy-path zero-counter invariant
  - B5  Multi-pod conflict + safe-default behaviour (skipped pending
        Finding #7 — CDI-safe bystander rewrite tracked separately)
  - 8.5.6 / 8.6.2  NVML / DCGM cap-application proven by reading the
                   live driver state (not via mocks)

Layout introduced by this commit:

  components/src/dynamo/planner/tests/integration/test_multi_dgd_live.py
      ~1000 LoC pytest module. Opt-in via RUN_MULTI_DGD_LIVE=1 +
      TEST_NODE=<8-GPU node> env vars; auto-detects Path A (production
      shape: 3 real DGDs + power-aware planner) vs Path B (5 stub-worker
      pods with hardcoded annotations) and skips Path-A-only tests
      cleanly when running Path B. DCGM tests gated by
      DCGM_HOSTENGINE_AVAILABLE=1.

  examples/multi-dgd-live-test/
      Manifests + helm values overrides + teardown script + README
      walk-through that an operator applies before running the test:
        00-namespace.yaml                 — namespace + pull secret
        10-power-agent-values-nvml.yaml   — Power Agent NVML helm values
        11-power-agent-values-dcgm.yaml   — Power Agent DCGM helm values
        20-nvidia-dcgm-standalone-ds.yaml — DCGM 4.5.1 hostengine DS
        30/31/32-vllm-dgd-{A,B,C}.yaml    — three DGDs (Path A)
        40-conflict-bystander-pod.yaml    — multi-pod conflict fixture
        50-stub-workers.yaml              — Path-B stub workers
        99-teardown.sh                    — idempotent cleanup w/ cap-
                                            restore verification
        README.md                         — full reproduction playbook
                                            including a 2026-05-21 live
                                            run record + 11 findings

  docs/design-docs/multi-tenant-test.md
      Design doc (§8 — multi-DGD test plan) that establishes the
      ground-truth topology, the planner / agent contract under test,
      and the rationale for the artifact split above.

  pyproject.toml
      Registers two new test markers consumed by the live test's
      `pytestmark`:
        multi_dgd_live  — scenario selector for this specific file
        power_agent     — shared with components/power_agent/tests/

Module-level gating fails fast on misconfiguration (missing TEST_NODE,
missing kubeconfig) with actionable error messages, and skips silently
when RUN_MULTI_DGD_LIVE is unset — so this file is a no-op under the
default unit-test invocation. Verified: pytest --collect-only is a
clean no-op without the env vars, and full-import works under
RUN_MULTI_DGD_LIVE=1 (collection fails cleanly on absent k8s creds, not
ImportError).

Refs: docs/design-docs/multi-tenant-test.md §8, PR #9683 review.
Signed-off-by: Kai Ma <[email protected]>
@kaim-eng
kaim-eng force-pushed the pr1b/planner-infra branch from 7696f3f to 8f47413 Compare May 25, 2026 14:17
kaim-eng added a commit that referenced this pull request May 25, 2026
…nd DCGM 4.5

Two stacked defects surfaced on the 2026-05-21T20:11Z Path-B re-run
caused `test_dcgm_per_gpu_cap_matches_topology` and
`test_dcgm_target_config_registered` to skip silently when they should
have PASSED:

1. **`kubernetes-client>=35.0.0` mangles JSON pod-exec stdout.**
   `kubernetes.stream.stream(..., _preload_content=True)` sniffs
   JSON-shaped stdout, parses it client-side, and returns `str(dict)`.
   That means `printf '%s' '{"a":1}'` comes back as the literal 8-char
   string `{'a': 1}` (single quotes, Python-dict repr), which then
   trips `json.loads` at every read-back site — including the four
   inside `test_dcgm_*`. The intended-as-defensive
   "did not return JSON" skip branch fired instead.

2. **DCGM 4.5+ rotated the `dcgmi config --get -g <id> -j` JSON shape.**
   Pre-4.5: `body` is a list of per-GPU entries keyed by `"Power Limit (W)"`
   with flat `{"Current": "...", "Target": "..."}` children.
   4.5+:    `body` is a dict of fields keyed by `"Power Limit"`
            (no `(W)` suffix) with a `"children"` wrapper whose leaves
            are `{"value": "..."}` objects.
   Three breaking changes in one upgrade — `body` flipped list→dict,
   the field name lost its suffix, the leaves gained a `value` wrapper.

The previous implementation handled neither, so even if defect (1)
were absent, the strict per-field reader would still skip.

This commit lands a single combined fix:

- **`_exec_in_pod`**: switch from `_preload_content=True` (default) to
  `_preload_content=False` + raw stdout/stderr accumulation off the
  `WSClient` via `peek_stdout`/`read_stdout`. Bypasses the mangling
  regardless of which `kubernetes-client` version is installed, and is
  the documented "I want bytes back" pattern in the kubernetes-client
  examples.

- **New `_extract_power_limit_from_dcgmi_body(body)` helper**: walks
  both shapes uniformly and returns `(current_w, target_w)` ints or
  `(None, None)` if neither shape matches. Both DCGM read-back tests
  (`test_dcgm_per_gpu_cap_matches_topology` and
  `test_dcgm_target_config_registered`) now consume this helper
  instead of inlining duplicated nested-`dict.get` chains.

Verified locally:
  - synthetic 4.0-shape payload `[{"Power Limit (W)": {"Current": "350",
    "Target": "350"}}]`  → `(350, 350)` ✓
  - synthetic 4.5-shape payload `{"Power Limit": {"children":
    {"Current": {"value": "375"}, "Target": {"value": "375"}}}}`
      → `(375, 375)` ✓
  - missing field, wrong types, partial children: graceful `(None, None)`
    / `(int, None)` returns ✓
  - test module still collects cleanly (`pytest --collect-only`)

`examples/multi-dgd-live-test/README.md` Finding #11 updated to
"Status: fixed" with a cross-reference to this commit and the expected
SKIPPED→PASSED flip on the next live re-run.

Refs: PR #9683 review (Finding #11 in
examples/multi-dgd-live-test/README.md).

Signed-off-by: Kai Ma <[email protected]>
409 Conflict stays at debug (expected conflict, silent retry on next sweep).
429 TooManyRequests is raised back to warning with an explicit note that
no Retry-After backoff is implemented — the message makes the next-sweep
retry semantics unambiguous for operators reading logs.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

Follow-up correction to my earlier comment about the DCGM query label: after checking current upstream dcgm-exporter, pod labels are emitted as sanitized keys directly. The correct PromQL label is nvidia_com_dynamo_graph_deployment_name, not kubernetes_label_nvidia_com_dynamo_graph_deployment_name. The local follow-up updates the query/tests/docs to use nvidia_com_dynamo_graph_deployment_name=DGD_NAME and assumes DCGM exporter pod-label enrichment via kubernetes.enablePodLabels; no prefixed relabeling is assumed.

@kaim-eng

Copy link
Copy Markdown
Contributor Author

@sttts I replied on each currently unresolved review thread with either the commit that addressed it (1dbec038e8, 4dd8714323, 3e6f2b232e) or the grounded no-code rationale. Could you please resolve the threads you are satisfied with? The latest PR head is 3e6f2b232e.

@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 3e6f2b2

dgd_generation.py: replace VllmComponentName.agg_worker_k8s_name with the
literal "VllmWorker" — the attribute was removed when agg name resolution
moved into the DGD component resolver, but the profiler role-map still
referenced it, breaking planner CPU tests.

worker_info.py: annotate get_model_name_kwargs as dict[str, Any] so mypy
does not infer dict[str, bool] from the initial bool values and then reject
the subsequent str assignments for component name keys.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 88c5e9

@kaim-eng

Copy link
Copy Markdown
Contributor Author

@ai-dynamo/devops @ai-dynamo/dynamo-planner-codeowners @ai-dynamo/dynamo-observability-codeowners @ai-dynamo/dynamo-ops-codeowners — friendly ping for review. All CI checks are green, sttts has approved, and the PR is up to date with main. Squash-and-merge when ready.

@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 5ffdf9c

@copy-pr-bot

copy-pr-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

/ok to test 5ffdf9c

@kaim-eng, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 88c5e91

Bring the planner power-infrastructure branch up to date with main
(35 commits). Resolved one content conflict in
docs/features/disaggregated-serving/aiconfigurator.md in favor of main's
precise per-system CSV support-matrix path (OPS-7722, #11711).

Auto-merged files verified semantically:
- pyproject.toml: net change vs main is only the httpx>=0.27.0 addition;
  main's vllm==0.25.1 and aiconfigurator<0.10.0 pins retained (branch had
  stale fork-point values, not intentional changes).
- monitoring/traffic_metrics.py + tests/unit/test_prometheus.py: both
  main's admitted-router-demand logic and this branch's DGD power query +
  NaN filtering (and their tests) preserved.

Dropped deploy/helm/charts/platform/charts/dynamo-operator-1.3.0.tgz: a
gitignored (*.tgz) packaged-subchart build artifact never tracked on main
(which references the subchart via file://components/operator). The
planner RBAC change lives in the source template tree, so the archive was
redundant.

Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test a1d70b8

@kaim-eng

Copy link
Copy Markdown
Contributor Author

@ai-dynamo/dynamo-planner-codeowners @ai-dynamo/dynamo-ops-codeowners — friendly review nudge; this one is ready for your stamp.

Current state (head a1d70b8411):

  • Mergeable — merged up to date with main; the single aiconfigurator.md conflict was resolved to main's support-matrix path.
  • All review threads resolved (41/41).
  • CI green so far — full PR run is active with no failures; planner CPU Test + Compliance (amd64 & arm64) already passed. GPU runtime jobs still finishing.
  • DCO signed; pre-commit / formatters clean.
  • @sttts has approved (covers the operator-owned Helm template as an operator codeowner).

Outstanding CODEOWNER coverage is just:

  • planner — sole owner of the changed components/src/dynamo/planner/** files.
  • ops — owner of .lycheeignore and pyproject.toml (adds httpx>=0.27.0).

Please take a look when you have a moment — happy to address anything. Squash-and-merge once green. Thanks!

@dmitry-tokarev-nv dmitry-tokarev-nv 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.

Supplementary review pass (post-approval)

@sttts has already approved and 41 threads are resolved — this is an additional pass focused on things I don't think the earlier human/Codex/CodeRabbit rounds caught. Four inline comments below (two with committable suggestions):

  • [High] core/base.py — disabled/default power-awareness still runs a pod-listing removal sweep against the apiserver every interval, forever.
  • [Medium] connectors/kubernetes.py — the multinode get_total_gpu_count() fix silently changes the unit of the shared *_engine_num_gpu fields (GPU-hours, budget clamp, perf model), not just the power gauge.
  • [Medium] connectors/kubernetes_api.py — resource_version="0" + limit/_continue are contradictory; the continue path can be rejected by the apiserver.
  • [Low] planner.yaml — the ClusterRole comment overstates namespace isolation.

Minor items not worth their own threads (a couple already raised by CodeRabbit and consciously left):

  • connectors/kubernetes.py::post_busy_threshold — the try: import httpx / except ImportError guard is now dead code since httpx>=0.27.0 is a hard dependency in pyproject.toml; move import httpx to module scope.
  • core/base.py::_publish_power_budget_metrics — the "power_projected_watts will be zero" logger.warning fires on every tick when the feature is on and GPU counts are 0; log once or gate on change.
  • monitoring/traffic_metrics.py::get_total_dgd_power — except Exception: logger.debug(...) is broader than the ApiException/PlannerError narrowing applied elsewhere in this PR (defensible for an optional advisory query, just inconsistent).

Also worth weighing before merge: @tedzhouhk's deferred point that the per-GPU cap is engine config that should ship with the DGD rather than be planner-applied — if that lands, much of this sweep machinery (and the [High] cost above) may be replaced.

Nothing here is a blocker to the approval mechanics; I'd raise the [High] and first [Medium] on the thread rather than treat the approval as closing them.

@dmitry-tokarev-nv dmitry-tokarev-nv 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.

see comments by claude

Resolve Dmitry review threads: latch off disabled-mode annotation sweeps
after a clean pass, scope multinode GPU multiplication to power projection
only, fix pod-list pagination resource_version, and correct the ClusterRole
RBAC comment. Cache replica GPU totals at init so metric publication stays
off the apiserver hot path, and use strict component resolution so lookup
failures cannot permanently disable annotation cleanup.

Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

@dmitry-tokarev-nv Addressed all four review threads in bc4d10d (pushed to pr1b/planner-infra). Summary:

  1. Disabled-mode sweeps — latch off after a clean removal pass; strict=True component resolution so lookup failures do not permanently disable cleanup.
  2. GPU count semantics (Option A) — per-pod counts restored in get_gpu_counts(); multinode replica totals isolated to power projection, cached at init (no apiserver I/O on the tick loop).
  3. Pagination —
    esource_version=0 only on the first page.
  4. ClusterRole comment — cluster-wide scope noted.

Threads resolved with details. Ready for another look when you have a moment. /ok to test bc4d10d

Apply Black 23.1.0 via the repo pre-commit hook so local formatting
matches the CI pre-merge gate (pip black was a newer version).

Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 1c1a3f4

@dmitry-tokarev-nv dmitry-tokarev-nv 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.

Approving. All four threads from my supplementary pass are resolved and verified against source at 1c1a3f4fefa30ad468509787609a3f6fa923378a:

  • [High] disabled-mode removal now latches off after a clean pass (_disabled_power_removal_latched), with strict=True component resolution so a lookup failure retries instead of latching on a false-clean — default-off planners do zero steady-state apiserver work.
  • [Medium] the multinode fix is isolated to the power gauge (get_replica_gpu_counts_for_power_projection, resolved once at init and cached); get_gpu_counts() stays per-pod so budget / perf-model / GPU-hours are unchanged.
  • [Medium] pagination sets resource_version="0" on the first page only.
  • [Low] the ClusterRole comment states cluster-wide scope accurately.

New unit tests cover the latch, the strict-raise path, and the per-pod / replica-total projection split. You also picked up two of the minor nits (module-level httpx, once-only zero-projection warning). Thanks for the fast turnaround.

kaim-eng and others added 2 commits July 20, 2026 11:22
Merge origin/main into pr1b/planner-infra.  origin/main introduced a
PlannerEnvironment abstraction that replaced direct connector access; this
branch adds power-infrastructure (pod annotations, RBAC, Prometheus metrics).

Conflict resolution
- Imports: keep both sides — KubernetesConnector / POWER_ANNOTATION_KEY /
  ApiException from HEAD; PlannerEnvironment / DeploymentState / util from main
- __init__: keep HEAD power-annotation throttle fields
- _async_init: take main's environment.initialize() form; call
  _resolve_power_projection_gpu_counts when power-awareness is enabled
- Discovery refresh: take main's _refresh_and_update_capabilities
- run() loop: take main's _run_one_tick; wire power annotation sweep into
  _run_one_tick after _apply_effects
- Power methods: use duck typing (hasattr) instead of isinstance for
  _resolve_power_projection_gpu_counts; route self.connector references
  through getattr(self.environment, 'controller', None)
- virtual.py: take main's public async_init and new worker-count helpers
- kubernetes.py: forward prefill_component_name / decode_component_name
  through both get_model_name() and _get_gpu_counts_from_deployment(); remove
  duplicate keyword args introduced by the auto-merge

Audit fixes (post-conflict)
- base.py: read component names from environment.deployment_state() in
  _resolve_power_projection_gpu_counts instead of removed _prefill_k8s_name /
  _decode_k8s_name attributes (P1 startup crash)
- environment/base.py: restore k8s_name to _MDC_REFRESH_FIELDS; tighten
  stopping guard to require BOTH max_num_batched_tokens AND k8s_name so a
  transient-failure default can be repaired before power projection consumes it
- test_actuation_knobs.py: update _bare_planner to model environment.controller
  and async apply_scaling; fix stale kubernetes_api import path
- test_actuation_knobs_live.py, test_kube.py: fix stale kubernetes_api paths
  (module moved to connectors/clients/ in origin/main)
- test_metric_publication.py: migrate connector references to
  environment.controller; remove stale _prefill/_decode_k8s_name injections;
  add forwarding assertion for _resolve_power_projection_gpu_counts
- test_environment.py: add _refresh_component_worker_info coverage including
  k8s_name initial population, stale-name repair, and noop guard
- test_kubernetes_connector.py: add forwarding assertion for get_model_name()
- test_load_based_scaling.py: align test_noop_when_already_set with new guard

WSL pytest: 225 passed, 0 failed (fcntl hook not runnable on Windows)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Signed-off-by: Kai Ma <[email protected]>
…ath rename

isort reorders the deferred kubernetes_api import now that it lives under
connectors/clients/ instead of connectors/ directly.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Signed-off-by: Kai Ma <[email protected]>
@kaim-eng

Copy link
Copy Markdown
Contributor Author

/ok to test 21af34f

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed due to inactivity. If you believe this PR is still relevant, please feel free to reopen it with additional context or information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

actions deployment::k8s Relates to dynamo deployment in kubernetes documentation Improvements or additions to documentation feat planner size/XXL Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants