Skip to content

fix(saturation): log actual analyzer mode instead of hardcoded value#1334

Open
Goutham-Annem wants to merge 2 commits into
llm-d:mainfrom
Goutham-Annem:fix/962-log-actual-analyzer-mode
Open

fix(saturation): log actual analyzer mode instead of hardcoded value#1334
Goutham-Annem wants to merge 2 commits into
llm-d:mainfrom
Goutham-Annem:fix/962-log-actual-analyzer-mode

Conversation

@Goutham-Annem

Copy link
Copy Markdown
Contributor

Fixes #962

Proposed Changes

  • 🐛 Fix bug

  • The "Optimization completed successfully" log entry in internal/engines/saturation/engine.go always hardcoded mode=saturation-only, regardless of whether the queueing-model, V2 saturation, or V1 (legacy saturation-only) analyzer path actually ran.

  • Extracted modeLabelForAnalyzer(analyzerName string) string, which maps the resolved analyzerName to the same label used by the switch that selects the optimize path, and used it for the completion log instead of the literal string.

Pre-review Checklist

  • E2E tests for any new behavior — N/A, this is a logging-correctness fix with no behavioral change to scaling decisions
  • Docs PR for any user-facing impact — N/A, internal log field only
  • Proposal PR for any new enhancement or change to existing behavior — N/A, bug fix

Release Note


Docs

N/A — internal log field, no user-facing documentation impact.

How tested

  • Added TestModeLabelForAnalyzer (table-driven, internal/engines/saturation/mode_label_test.go) covering all three modes plus the empty/unset and unrecognized fallback cases.
  • go test ./internal/engines/saturation/... passes (61.4% coverage maintained).
  • make test run locally: only pre-existing, unrelated failure in internal/engines/analyzers/throughput (a flaky degenerate-input case in itl_model_test.go), confirmed present on main without this change too.
  • gofmt/go vet clean.

The 'Optimization completed successfully' log entry always reported
mode=saturation-only, even when the queueing-model or V2 saturation
analyzer path was actually selected. Extract a small helper that maps
the resolved analyzerName to its log label, and use it for the
completion log instead of the hardcoded string.

Fixes llm-d#962

Signed-off-by: Goutham Annem <Goutham-Annem@users.noreply.github.com>

@ev-shindin ev-shindin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, there are sime comments to address.

Comment thread internal/engines/saturation/engine.go Outdated
Comment thread internal/engines/saturation/engine.go
Address ev-shindin review suggestions on PR llm-d#1334:
- Fold the modeLabelForAnalyzer helper into optimize's existing switch so
  the mode label is set in the same case that selects the optimize path,
  eliminating a second switch that had to stay in lockstep.
- Rename log labels: "saturation" → "saturation-v2" and
  "saturation-only" → "saturation-v1" for unambiguous mode identification.
- Update mode_label_test.go to mirror the new inline switch logic and
  expected label values.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@ev-shindin ev-shindin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Please sign-off your last commit, and either open follow-up issue to improve test (see comment below), or fix test in this PR

t.Run(tt.name, func(t *testing.T) {
// Reproduce the same switch logic as optimize() so the expected labels
// are verified without needing a full engine instance.
var mode string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-vlocking: The test body re-implements the optimize() switch rather than invoking it, so it can't catch the regression its doc comment promises. Rename "saturation-v2""saturation-v3" in engine.go and forget the test, and it still passes (its private copy and wantMode both still say "saturation-v2"). Extract a helper in engine.go and call it from both sides — this also removes the duplicated "saturation-vN" literals and the style asymmetry (queueing uses a constant, V1/V2 use literals):

func analyzerModeLabel(analyzerName string) string {
    switch analyzerName {
    case interfaces.QueueingModelAnalyzerName: return interfaces.QueueingModelAnalyzerName
    case interfaces.SaturationAnalyzerName:    return "saturation-v2"
    default:                                   return "saturation-v1"
    }
}

// - Queueing model: QueueingModelAnalyzer → AnalyzerResult → Optimizer.Optimize → Enforcer bridge
// V1 will be deprecated once V2 is fully validated.
// Queueing model is activated by presence of wva-queueing-model-config ConfigMap.
var mode string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: The mode label is assigned inline across the three switch arms, with one arm using the interfaces.QueueingModelAnalyzerName constant and the other two using raw "saturation-vN" literals. Replacing the inline assignments with mode := analyzerModeLabel(analyzerName) (above) keeps the path-selection switch and puts all three labels in one place, making the asymmetry intentional and the test meaningful in one move.

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.

Remove hardcoding of analyzer mode

2 participants