Skip to content

feat(validator): configurable inference-perf router mode - #1745

Merged
mchmarny merged 1 commit into
NVIDIA:mainfrom
yuanchen8911:feat/issue-1374-router-mode-knob
Jul 14, 2026
Merged

mchmarny merged 1 commit into
NVIDIA:mainfrom
yuanchen8911:feat/issue-1374-router-mode-knob

Conversation

@yuanchen8911

@yuanchen8911 yuanchen8911 commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds AICR_INFERENCE_PERF_ROUTER_MODE so the inference-perf validator's Dynamo frontend routing strategy (DYN_ROUTER_MODE) can be selected per run — replacing the hardcoded value in the deployment template — following the existing AICR_INFERENCE_PERF_* methodology-knob pattern.

Motivation / Context

Dynamo v1.2 ships several frontend routing strategies (kv, round-robin, random, power-of-two, least-loaded, device-aware-weighted; upstream's direct is deliberately excluded — it needs per-request worker IDs the benchmark never sends), but the benchmark workload's strategy was compiled into the validator image, so characterizing an alternative required an image rebuild. The default remains least-loaded (the shipped default since #1399 / #1197); this knob only changes how a characterization run can deviate from it.

Fixes: #1374
Related: #1399, #1197

Type of Change

  • New feature (non-breaking change that adds functionality)
  • Bug fix (non-breaking change that fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Build/CI/tooling

Component(s) Affected

  • Validator (pkg/validator)
  • Docs/examples (docs/, examples/)
  • CLI (cmd/aicr, pkg/cli)
  • API server (cmd/aicrd, pkg/server)
  • Recipe engine / data (pkg/recipe)
  • Bundlers (pkg/bundler, pkg/component/*)
  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)
  • Core libraries (pkg/errors, pkg/k8s)
  • Other: validators/performance

Implementation Notes

  • resolveRouterMode() resolves env > compiled default (least-loaded) and validates against the Dynamo frontend enum; an unknown value fails closed with ErrCodeInvalidRequest in validatePerfTuningEnvs, before the multi-minute workload deploys — consistent with the other perf knobs.
  • The dynamo-router deployment template's DYN_ROUTER_MODE value became a ${ROUTER_MODE} placeholder, substituted per run. The gateway-epp template intentionally carries no placeholder: in that mode EPP performs endpoint selection and worker frontend sidecars run in direct mode, so the knob has no effect there.
  • Knob values are enum-constrained, so no quoting/scalar hazards in the template (unlike ${MODEL}).
  • Docs: new row in the docs/contributor/validator.md env-knob table.

Testing

go test -race ./validators/performance/   # ok
golangci-lint run -c .golangci.yaml ./validators/performance/...   # 0 issues
yamllint -c .yamllint.yaml validators/performance/testdata/inference/dynamo-deployment.yaml   # clean

New coverage: table-driven TestResolveRouterMode (defaults, all six supported modes, trimming, unknown/direct/case-sensitivity fail-closed), TestValidatePerfTuningEnvs router-mode subtests, and TestParseDynamoTemplate_RouterModeSubstituted guarding the template placeholder.

WIP: full make qualify and the coverage-gate comparison against main have not run yet — will complete before marking ready for review.

Risk Assessment

  • Low — Isolated change, well-tested, easy to revert
  • Medium — Touches multiple components or has broader impact
  • High — Breaking change, affects critical paths, or complex rollout

Rollout notes: No behavior change when the env var is unset (default identical to current hardcoded value). Catalog/env-only knob; no recipe or API surface change.

Checklist

  • Tests pass locally (make test with -race)
  • Linter passes (make lint)
  • I did not skip/disable tests to make CI green
  • I added/updated tests for new functionality
  • I updated docs if user-facing behavior changed
  • Changes follow existing patterns in the codebase
  • Commits are cryptographically signed (git commit -S) — GPG signing info

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The inference performance validator adds AICR_INFERENCE_PERF_ROUTER_MODE, defaulting to least-loaded and validating supported Dynamo strategies. The resolved value is stored in workload configuration and substituted into the Dynamo frontend’s DYN_ROUTER_MODE. Invalid values return ErrCodeInvalidRequest. Tests cover defaults, trimming, valid and invalid values, environment isolation, and template substitution. Catalog and contributor documentation describe the configuration.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: area/validator

Suggested reviewers: ayuskauskas, mchmarny

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR meets the core issue goals by adding the env knob, validating allowed router modes, templating DYN_ROUTER_MODE, and limiting impact to dynamo-router.
Out of Scope Changes check ✅ Passed The changes stay within the validator, docs, tests, and catalog updates needed for the new router-mode knob and add no unrelated behavior.
Title check ✅ Passed The title clearly summarizes the main change: making the inference-perf router mode configurable.
Description check ✅ Passed The description is directly related to the changeset and accurately explains the new router-mode knob and its behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@validators/performance/inference_perf_constraint.go`:
- Around line 715-718: The inference performance validation currently rejects
invalid router settings even for gateway-EPP workloads. Update the call site
around resolveRouterMode at
validators/performance/inference_perf_constraint.go:715-718 to invoke it only
when routingMode is inferenceRoutingModeDynamoRouter, and make the preflight
validation at validators/performance/inference_perf_constraint.go:2834-2836
routing-mode-aware or defer it to the mode-gated configuration path; gateway-EPP
must bypass router-mode validation.

In `@validators/performance/inference_perf_test.go`:
- Around line 1207-1224: Refactor the router-mode cases in
validatePerfTuningEnvs tests into one table-driven subtest containing each mode
and expected outcome. Iterate over the cases, apply clearTuningEnvs and
envRouterMode per case, then assert ErrCodeInvalidRequest for invalid modes and
no error for valid modes while preserving the existing test names or descriptive
case labels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 2dc46476-4236-478a-a38d-929fd61d77ff

📥 Commits

Reviewing files that changed from the base of the PR and between 3b3e3a3 and 7b94c84.

📒 Files selected for processing (4)
  • docs/contributor/validator.md
  • validators/performance/inference_perf_constraint.go
  • validators/performance/inference_perf_test.go
  • validators/performance/testdata/inference/dynamo-deployment.yaml

@yuanchen8911
yuanchen8911 force-pushed the feat/issue-1374-router-mode-knob branch from 7b94c84 to 29e94da Compare July 14, 2026 18:40

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@validators/performance/inference_perf_constraint.go`:
- Around line 2661-2680: Update the comment above resolveRouterMode to remove
the claim that it is consulted only on the dynamo-router path. Clarify that the
resolved value is consumed only by Dynamo routing, while explicitly set invalid
values are still validated when processing gateway-epp configuration through
buildInferenceConfig and validatePerfTuningEnvs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: d78a81b3-7851-419a-aa84-63ccc53b1c7b

📥 Commits

Reviewing files that changed from the base of the PR and between 7b94c84 and 29e94da.

📒 Files selected for processing (4)
  • docs/contributor/validator.md
  • validators/performance/inference_perf_constraint.go
  • validators/performance/inference_perf_test.go
  • validators/performance/testdata/inference/dynamo-deployment.yaml

@yuanchen8911
yuanchen8911 force-pushed the feat/issue-1374-router-mode-knob branch from 29e94da to d620b01 Compare July 14, 2026 19:02
…#1374)

Add AICR_INFERENCE_PERF_ROUTER_MODE to select the Dynamo frontend routing
strategy (DYN_ROUTER_MODE) for the benchmark workload, following the
existing AICR_INFERENCE_PERF_* methodology-knob pattern. Default stays
least-loaded (the shipped default since NVIDIA#1399); the value is validated
against the Dynamo frontend enum (kv, round-robin, random, least-loaded,
device-aware-weighted) and fails closed with ErrCodeInvalidRequest on a
typo, up front in validatePerfTuningEnvs. The knob only affects the
dynamo-router routing path; the gateway-epp template carries no
placeholder.

Signed-off-by: Yuan Chen <[email protected]>
@yuanchen8911
yuanchen8911 force-pushed the feat/issue-1374-router-mode-knob branch from d620b01 to a32df1f Compare July 14, 2026 19:15
@github-actions

Copy link
Copy Markdown
Contributor

Recipe evidence check

No leaf overlays affected by this PR.

This gate is warning-only and never blocks merge.

@yuanchen8911

Copy link
Copy Markdown
Contributor Author

Follow-up: the shared CI gap that excludes validators/** unit tests from make test and coverage is tracked in #1752. This covers the regression tests added here and in #1748.

@yuanchen8911 yuanchen8911 mentioned this pull request Jul 14, 2026
10 of 25 tasks
@yuanchen8911 yuanchen8911 changed the title WIP: feat(validator): configurable inference-perf router mode feat(validator): configurable inference-perf router mode Jul 14, 2026
@yuanchen8911
yuanchen8911 marked this pull request as ready for review July 14, 2026 22:25
@yuanchen8911
yuanchen8911 requested review from a team as code owners July 14, 2026 22:25

@mchmarny mchmarny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clean knob addition following the established AICR_INFERENCE_PERF_* pattern. Enum validation fails closed with ErrCodeInvalidRequest up front in validatePerfTuningEnvs (and deliberately not mode-gated — the rationale in the envRouterMode comment is sound), the gateway-epp template correctly keeps direct hardcoded since EPP owns endpoint selection there, and TestParseDynamoTemplate_RouterModeSubstituted guards against the placeholder being hardcoded again. Docs and catalog comments updated. CI is green.

One non-blocking note: the PR body still says "WIP: full make qualify and the coverage-gate comparison against main have not run yet" — CI Test/Lint/E2E are all green, so consider dropping that line before merge.

@njhensley njhensley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Multi-persona review + adversarial verification — Approve ✅

Reviewed by an independent 3-lens panel (correctness · Dynamo/inference domain · test-coverage), then every safety claim was re-derived from the code by an adversarial meta-reviewer. Fail-closed enum validation, dual-path validation, and the direct-exclusion all hold — and are corroborated by the gateway-epp template itself (--router-mode direct only on internal worker sidecars). Template substitution is injection-safe because the value is enum-constrained to 6 YAML-safe tokens; the resolveRouterMode call on both validatePerfTuningEnvs and buildInferenceConfig is the same belt-and-suspenders pattern the other knobs use (not redundant). Strong table-driven coverage.

Non-blocking follow-ups (tiered 🟡 Minor / 🔵 Nitpick):

  • 🟡 No test guards the gateway-epp mode-isolation invariant. The "validated in both modes, consumed only in dynamo-router" design is only half-tested — nothing asserts dynamo-deployment-gateway-epp.yaml has no ${ROUTER_MODE}/DYN_ROUTER_MODE. A future accidental placeholder there would silently break isolation with no failing test. Consider a test rendering the gateway-epp template and asserting the env is absent.
  • 🟡 Override is env-only — sibling knobs (model, concurrency-per-gpu) also support a per-accelerator recipe constraint that outranks the env var. If env-only is intentional for A/B characterization (#1374), a one-line "env-only by design" note would settle it.
  • 🔵 ${ROUTER_MODE} is interpolated unquoted while sibling ${MODEL} is deliberately quoted — safe today (all enum tokens are YAML-safe), but quoting would be consistent/defense-in-depth (testdata/inference/dynamo-deployment.yaml).
  • 🔵 routerMode is logged even under gateway-epp where it's unused (paired with routingMode, so still disambiguable).

No blockers or majors.

@mchmarny
mchmarny merged commit ae4c014 into NVIDIA:main Jul 14, 2026
184 of 311 checks passed
mohityadav8 added a commit to mohityadav8/aicr that referenced this pull request Jul 25, 2026
…ge gate

Makefile excluded /validators from 'go list ./...' in make test, so
regression suites added in NVIDIA#1745/NVIDIA#1748 (and the older nvidia-smi,
inference-perf, nccl, conformance tests) never ran in CI.

- Drop -e /validators from the make test package filter.
- Exclude validators/ from the test-coverage threshold calc (its
  package coverage is 41-92%, pulling aggregate from 80.0% to 75.7%
  and breaking the 80% gate) while still running its tests.

Fixes NVIDIA#1752

Signed-off-by: Mohit Yadav <[email protected]>
@yuanchen8911
yuanchen8911 deleted the feat/issue-1374-router-mode-knob branch August 19, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs area/recipes size/L theme/validation Constraint evaluation, health checks, and conformance evidence

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(validator): make inference-perf routing strategy configurable (AICR_INFERENCE_PERF_ROUTER_MODE)

3 participants