Skip to content

fix(vllm): warm up eager shapes before FPM self-benchmark measurement - #12176

Merged
tedzhouhk merged 3 commits into
mainfrom
yuanli/fpm-eager-warmup
Sep 1, 2026
Merged

tedzhouhk merged 3 commits into
mainfrom
yuanli/fpm-eager-warmup

Conversation

@liyuanzhe1991

@liyuanzhe1991 liyuanzhe1991 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Overview:

Self-benchmark points whose shapes fall outside the cudagraph capture range pay a ~1s
first-execution one-off — five consecutive repeats of decode batch 513 read
[1126, 147, 147, 144, 144] ms. Captured shapes are immune because capture itself
executes them at startup; eager shapes get no such implicit warmup, and a
single-sample sweep books the one-off as the point's latency, permanently poisoning
that database row (up to 8x on the affected points).

This PR pre-warms every eager shape with a discarded warmup replica, putting eager
and captured points on the same footing.

Details:

  • _bench_build_grid prepends one discarded warmup replica per eager shape,
    deduped by the shape driver (token count for prefill, batch size for decode) —
    typically a handful of replicas ≈ +10s bring-up. Replicas run the normal
    injection/lockstep/validation path on every rank, so attention-DP grids stay
    identical by construction, and results are dropped at save time.
  • Each warmup block stays contiguous with its phase's real block
    ([prefill warmups, prefill points, decode warmups, decode points]):
    _bench_pop_next() treats a type mismatch at the queue front as "phase
    complete", so mixed-type warmups prepended as a single run would end
    PREFILL_SWEEP at the first decode warmup and silently drop every real point in
    agg mode. Covered by test_agg_eager_warmups_stay_contiguous_with_their_phase,
    which drains the grid exactly as the phase machine does.
  • Real points are numbered 1..N first so published benchmark IDs stay
    contiguous (native-artifact contract); warmup replicas take IDs after the real
    range. counter_id stamping uses point.benchmark_id directly, so execution
    order and ID order are independent.

Validation (GLM-5.2-NVFP4, 4×B200 attention-DP=4, vLLM 0.25.1)

  • The two eager decode points (B=513 / B=1024, min-KV) read 190 / 185 ms (warm)
    vs 1216 / 1184 ms first-touch before; an independent re-collection reproduced
    189 / 185 ms on a coordinate-identical grid.
  • Whole-DB curve-neighbor outlier scan (>3× neighborhood median): 0 rows.
  • No sweep-duration regression; warmup replicas verified discarded from published
    artifacts with contiguous real IDs.

Where should the reviewer start?

  • components/src/dynamo/vllm/instrumented_scheduler.py —
    _bench_eager_warmup_points (docstring carries the rationale), the grid
    regrouping + ID numbering in _bench_build_grid, and the save-time discard
  • components/src/dynamo/vllm/tests/test_vllm_instrumented_scheduler.py —
    test_agg_eager_warmups_stay_contiguous_with_their_phase,
    test_eager_warmup_points_dedupe_and_flag, and the warmup-ID grid-test
    adaptations

Related Issues

🚫 This PR is NOT linked to an issue:

  • Confirmed — no related issue

Open in Devin Review

Summary by CodeRabbit

  • Bug Fixes
    • Improved benchmark startup by warming up replicas for eager-shaped workloads.
    • Prevented warmup-only measurements from being included in benchmark results.
    • Preserved correct phase ordering and timeout handling during benchmark execution.
    • Improved benchmark ID tracking so measurable results remain sequential and accurate.
  • Tests
    • Added coverage for warmup grouping, deduplication, filtering, and result handling.

@liyuanzhe1991
liyuanzhe1991 requested review from a team as code owners July 26, 2026 05:47
@github-actions github-actions Bot added fix backend::vllm Relates to the vllm backend labels Jul 26, 2026

@devin-ai-integration devin-ai-integration 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.

Devin Review found 2 potential issues.

Open in Devin Review

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Benchmark warmup handling

Layer / File(s) Summary
Generate and integrate eager warmup points
components/src/dynamo/vllm/instrumented_scheduler.py
Uncaptured benchmark points now produce deduplicated eager warmup replicas, which are ordered before real points and assigned IDs after the measurable range.
Discard warmup results while honoring stops
components/src/dynamo/vllm/instrumented_scheduler.py
Completed eager warmup points are excluded from benchmark results while requested point timeouts remain honored.
Validate IDs, phase ordering, and replica isolation
components/src/dynamo/vllm/tests/test_vllm_instrumented_scheduler.py
Tests cover identifier ranges, prefill/decode phase draining, replica deduplication, tagging, and preservation of original points.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: warming eager shapes before self-benchmark measurement.
Description check ✅ Passed The PR description includes all required sections and sufficiently explains the change, review focus, and issue linkage status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/src/dynamo/vllm/instrumented_scheduler.py (1)

3309-3334: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Warmup validation failures leak into _bench_skipped_points, corrupting usable/valid in the output artifact.

The EAGER_WARMUP_REASON discard branch (lines 3326-3334) runs after the validation_failure branch (lines 3309-3324). If a warmup replica's measured FPM shape doesn't exactly match the point (the same measured-shape mismatch class the check exists to catch for real points), it falls into _bench_skip_point() instead of being silently dropped. Since warmup replicas lose their "explicit" tag via replace(point, sample_reasons=[EAGER_WARMUP_REASON]), _bench_skip_point won't raise — it just appends to _bench_skipped_points. _bench_write_results then requires skipped_points == 0 for usable/valid, so a discarded, value-less warmup mismatch would incorrectly mark the whole published benchmark artifact as not usable/not valid and show a phantom skipped point, even though "Replicas run through the normal injection/lockstep/validation path ... and are dropped at save time" per the docstring. Move the warmup discard check before the validation-failure branch so warmup results are unconditionally dropped regardless of validation outcome.

No test in this PR exercises _bench_save_current_point for an EAGER_WARMUP_REASON-tagged point (success or validation-mismatch); consider adding one alongside the fix. Want me to draft it?

🐛 Proposed fix: discard warmups before validation is evaluated
                 reason = self._bench_fpm_validation_failure(point, fpm)
                 if reason is not None and validation_failure is None:
                     validation_failure = (dp_rank, reason)

+            if EAGER_WARMUP_REASON in point.sample_reasons:
+                logger.debug("Discarding eager-shape warmup result: %s", point)
+                self._bench_current_point = None
+                self._bench_current_fpms = []
+                self._bench_point_deadline = 0.0
+                if group_result.stop_requested:
+                    self._bench_request_timeout_stop(point)
+                return
+
             if validation_failure is not None:
                 dp_rank, reason = validation_failure
                 logger.warning(
                     "Skipping benchmark point after measured shape mismatch "
                     "on ADP rank %d: point=%s reason=%s",
                     dp_rank,
                     point,
                     reason,
                 )
                 self._bench_skip_point(point, reason)
                 self._bench_current_point = None
                 self._bench_current_fpms = []
                 self._bench_point_deadline = 0.0
                 if group_result.stop_requested:
                     self._bench_request_timeout_stop(point)
                 return

-            if EAGER_WARMUP_REASON in point.sample_reasons:
-                logger.debug("Discarding eager-shape warmup result: %s", point)
-                self._bench_current_point = None
-                self._bench_current_fpms = []
-                self._bench_point_deadline = 0.0
-                if group_result.stop_requested:
-                    self._bench_request_timeout_stop(point)
-                return
-
             self._bench_results.append(
🤖 Prompt for 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.

In `@components/src/dynamo/vllm/instrumented_scheduler.py` around lines 3309 -
3334, Move the EAGER_WARMUP_REASON check in _bench_save_current_point before the
validation_failure branch so eager-warmup results are always discarded without
calling _bench_skip_point, including measured-shape mismatches. Preserve the
existing cleanup and timeout-stop behavior, and add coverage for both successful
and validation-mismatch warmup points if tests are maintained here.
🤖 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 `@components/src/dynamo/vllm/tests/test_vllm_instrumented_scheduler.py`:
- Around line 2950-2958: Remove the in-function imports from
test_eager_warmup_points_dedupe_and_flag, including SimpleNamespace,
EAGER_WARMUP_REASON, BenchmarkPoint, and InstrumentedScheduler, and rely on
their existing module-level imports.

---

Outside diff comments:
In `@components/src/dynamo/vllm/instrumented_scheduler.py`:
- Around line 3309-3334: Move the EAGER_WARMUP_REASON check in
_bench_save_current_point before the validation_failure branch so eager-warmup
results are always discarded without calling _bench_skip_point, including
measured-shape mismatches. Preserve the existing cleanup and timeout-stop
behavior, and add coverage for both successful and validation-mismatch warmup
points if tests are maintained here.
🪄 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: CHILL

Plan: Enterprise

Run ID: e1fa8644-acfc-43cf-99d8-993959c3610f

📥 Commits

Reviewing files that changed from the base of the PR and between 769ee07 and a66d636.

📒 Files selected for processing (2)
  • components/src/dynamo/vllm/instrumented_scheduler.py
  • components/src/dynamo/vllm/tests/test_vllm_instrumented_scheduler.py

@datadog-official

This comment has been minimized.

@liyuanzhe1991
liyuanzhe1991 force-pushed the yuanli/fpm-eager-warmup branch from a66d636 to 911ad6d Compare July 29, 2026 13:55
@liyuanzhe1991
liyuanzhe1991 force-pushed the yuanli/fpm-eager-warmup branch 2 times, most recently from 7d85200 to 7d69413 Compare August 4, 2026 00:52

@tedzhouhk tedzhouhk 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.

One blocking warmup-discard path remains. Warmup replicas must never affect published skipped-point accounting, including failures that happen before FPM validation.

@liyuanzhe1991
liyuanzhe1991 force-pushed the yuanli/fpm-eager-warmup branch from d99990e to f47bf5b Compare August 12, 2026 00:28
liyuanzhe1991 and others added 3 commits August 28, 2026 10:15
Shapes beyond the cudagraph capture range pay a ~1s first-execution
one-off (measured 1126ms vs 147ms warm on decode batch 513); a
single-sample sweep books that cost as the point's latency. Captured
shapes are immune because capture itself executes them at startup.

- Prepend one discarded warmup replica per eager shape, deduped by the
  shape driver (token count for prefill, batch size for decode).
  Replicas run the normal injection/lockstep/validation path on every
  rank and are dropped at save time.
- Keep each warmup block contiguous with its phase's real block:
  _bench_pop_next() treats a type mismatch at the queue front as
  "phase complete", so mixed-type warmups prepended as a single run
  would silently drop every real point in agg mode.
- Number real points 1..N first so published benchmark IDs stay
  contiguous (native-artifact contract); warmup replicas take IDs
  after the real range.

Split from the combined noise-elimination PR; the CPython GC policy
lands separately.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: YZLi <[email protected]>
A warmup replica whose FPM fails shape validation was recorded as a
skipped point; the published artifact's usable/valid gates both require
skipped_points == 0, so one warmup hiccup invalidated an otherwise
complete run. Discard warmup replicas first (with a warning when their
shape mismatched) and only then convert validation failures of real
points into skips. Also drop the redundant function-local imports in
the relocated dedupe test.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: YZLi <[email protected]>
…ery failure path

A warmup replica that failed before FPM validation (fake-prefix
allocation, prefill/decode injection shortfall) still reached
_bench_skip_point and booked a skipped point, flipping the published
artifact to unusable/invalid even when every real measurement
succeeded. Move the EAGER_WARMUP_REASON exemption into
_bench_skip_point itself so every caller shares it; failed warmups are
logged and discarded.

Signed-off-by: YZLi <[email protected]>
@tedzhouhk
tedzhouhk merged commit 4e1f416 into main Sep 1, 2026
110 checks passed
@tedzhouhk
tedzhouhk deleted the yuanli/fpm-eager-warmup branch September 1, 2026 16:35
milesial pushed a commit to milesial/dynamo that referenced this pull request Sep 2, 2026
liyuanzhe1991 added a commit that referenced this pull request Sep 3, 2026
… landed)

Resolve the additive test-file conflict as the union of both sides; drop the
now-unused random import; annotate kvwarm bookkeeping for mypy; reference
EAGER_WARMUP_REASON now that the constant lives in the same module.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: YZLi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend::vllm Relates to the vllm backend fix size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants