Add timing metrics to response regeneration pipeline#803
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesThe response regeneration pipeline now tracks request latency, queue wait, token usage, throughput, and conversation outcomes, displays live RPS/TPS progress metrics, and logs an aggregate summary after completion. Tests were updated for the expanded statistics structure. Response regeneration metrics
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Instrument the response regeneration script with performance timing: - Per-request latency tracking on each vLLM chat completion call - Live throughput in tqdm postfix (req/s, tok/s) - Queue wait time measurement (enqueue-to-dequeue delta) - Token counting from vLLM usage metadata - Final summary log with aggregate stats Uses plain logging + tqdm, not the speculators.metrics logger, consistent with the approach agreed in issue vllm-project#717. Closes: INFERENG-8704 (response regeneration portion) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: root <root@devenv-orestis-z.devenv-svc-orestis-z.machine-learning.svc.cluster.local>
be5588f to
1486eb6
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/unit/scripts/test_response_regeneration.py (1)
477-502: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winInclude
enqueued_atin the test item to exercise queue wait logic.The
workerfunction now popsenqueued_atfrom the queue item to calculatetotal_queue_wait_s. Since the mock_TWO_TURN_ITEMdoes not include this key, the wait-time calculation path is not exercised during tests. As per path instructions, check that new code paths introduced in the PR are covered. Consider injecting a timestamp before enqueuing.🧪 Proposed fix to cover queue wait logic
async def scenario(out_fh, err_fh): queue: asyncio.Queue = asyncio.Queue() - await queue.put(_TWO_TURN_ITEM) + item = dict(_TWO_TURN_ITEM) + item["enqueued_at"] = time.perf_counter() + await queue.put(item) await queue.put(None)🤖 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 `@tests/unit/scripts/test_response_regeneration.py` around lines 477 - 502, Update the test scenario using _TWO_TURN_ITEM to enqueue an item containing an enqueued_at timestamp, preserving the existing item fields and setting the timestamp before queue.put. Ensure worker exercises its queue-wait calculation and validates the resulting total_queue_wait_s path.Source: Path instructions
🤖 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 `@scripts/response_regeneration/script.py`:
- Around line 786-796: Update the stats parameter annotation in the worker
function to accept the float-valued fields initialized in the stats dictionary,
using dict[str, Any] or dict[str, int | float] while preserving the existing
worker behavior.
In `@tests/unit/scripts/test_response_regeneration.py`:
- Around line 521-523: Extend the assertions for the worker statistics in the
response regeneration test to cover the newly introduced metric fields,
including requests and total_request_s, using the expected values for this
scenario. Keep the existing ok, errors, and truncated assertions unchanged.
---
Outside diff comments:
In `@tests/unit/scripts/test_response_regeneration.py`:
- Around line 477-502: Update the test scenario using _TWO_TURN_ITEM to enqueue
an item containing an enqueued_at timestamp, preserving the existing item fields
and setting the timestamp before queue.put. Ensure worker exercises its
queue-wait calculation and validates the resulting total_queue_wait_s path.
🪄 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: Pro
Run ID: d53e770d-51df-47c4-8011-c99034f29ba2
📒 Files selected for processing (2)
scripts/response_regeneration/script.pytests/unit/scripts/test_response_regeneration.py
- Change worker stats annotation from dict[str, int] to dict[str, Any] - Add enqueued_at timestamp to test item to exercise queue wait path - Assert new metric fields (requests, total_request_s, total_queue_wait_s) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
speculatorsbot
left a comment
There was a problem hiding this comment.
LGTM. Clean, well-scoped instrumentation that matches the RFC #717 consensus (plain logging + tqdm). Agree with @WindChimeRan's three outstanding items (logging config, queue-wait denominator, dead prompt_tokens). Recommend approving once those are addressed.
🤖 Generated with Claude Code using the /pr-review skill
- Switch _log_summary from logger.info to print() so it actually outputs (script has no logging handler configured) - Remove prompt_tokens accumulation (never read) - Remove queue wait tracking (inflated denominator, questionable value) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Orestis Zambounis <orestis.zambounis@gmail.com>
Summary
time.perf_counter()rps= vLLM requests/s,tps= generated tokens/s) alongside existing ok/err/trunc countersspeculators.metrics), per the approach agreed in #717Companion to the offline data generation timing PR (#804). Both address INFERENG-8704.
Test plan
tests/unit/scripts/test_response_regeneration.py— 43 tests)_NullProgressstub and stats dict in tests to match new signatureruff checkandruff formatpass🤖 Generated with Claude Code