From 5390783232767b0236063c924918630010c5840f Mon Sep 17 00:00:00 2001 From: hsliuustc0106 Date: Mon, 13 Apr 2026 13:47:41 +0800 Subject: [PATCH] delete review-PR Signed-off-by: hsliuustc0106 --- .claude/skills/review-pr/SKILL.md | 259 ------ .../review-pr/references/architecture.md | 431 ---------- .../review-pr/references/blocker-patterns.md | 752 ------------------ .../references/diffusion-checklist.md | 505 ------------ .../references/maintainer-style-study.md | 114 --- .../review-pr/references/perf-verification.md | 220 ----- .../review-pr/references/review-execution.md | 577 -------------- .../review-pr/references/review-routing.md | 93 --- .../references/test-quality-evaluation.md | 170 ---- .../references/tests-docs-checklist.md | 111 --- .../skills/review-pr/scripts/check_replies.sh | 85 -- .../review-pr/scripts/run_perf_comparison.sh | 275 ------- .../review-pr/scripts/run_test_analysis.sh | 232 ------ .../skills/review-pr/scripts/select_prs.sh | 71 -- .../review-pr/scripts/verify_line_numbers.sh | 59 -- 15 files changed, 3954 deletions(-) delete mode 100644 .claude/skills/review-pr/SKILL.md delete mode 100644 .claude/skills/review-pr/references/architecture.md delete mode 100644 .claude/skills/review-pr/references/blocker-patterns.md delete mode 100644 .claude/skills/review-pr/references/diffusion-checklist.md delete mode 100644 .claude/skills/review-pr/references/maintainer-style-study.md delete mode 100644 .claude/skills/review-pr/references/perf-verification.md delete mode 100644 .claude/skills/review-pr/references/review-execution.md delete mode 100644 .claude/skills/review-pr/references/review-routing.md delete mode 100644 .claude/skills/review-pr/references/test-quality-evaluation.md delete mode 100644 .claude/skills/review-pr/references/tests-docs-checklist.md delete mode 100644 .claude/skills/review-pr/scripts/check_replies.sh delete mode 100755 .claude/skills/review-pr/scripts/run_perf_comparison.sh delete mode 100755 .claude/skills/review-pr/scripts/run_test_analysis.sh delete mode 100644 .claude/skills/review-pr/scripts/select_prs.sh delete mode 100644 .claude/skills/review-pr/scripts/verify_line_numbers.sh diff --git a/.claude/skills/review-pr/SKILL.md b/.claude/skills/review-pr/SKILL.md deleted file mode 100644 index 96e3e7849..000000000 --- a/.claude/skills/review-pr/SKILL.md +++ /dev/null @@ -1,259 +0,0 @@ ---- -name: review-pr -description: Review PRs on vllm-project/vllm-omni by routing to the right domain skills, checking critical evidence, and focusing comments on blocking issues. Use when reviewing pull requests or local branches, triaging review depth, running detailed or default review, or checking tests, benchmarks, and breaking changes in vllm-omni. ---- - -# vLLM-Omni PR Review - -## Overview - -Review PRs like a real maintainer — direct, selective, and focused on high-signal issues. Prioritize 2-3 real problems per PR over exhaustive coverage. Most PRs should get 1-5 short comments; some just get an empty APPROVE. - -Use this skill as a router for `vllm-project/vllm-omni` pull request reviews. Keep the default context small, load only the references that match the diff, and prioritize high-confidence findings over coverage theater. - -## Usage modes - -Inspired by common PR-review skill patterns (e.g. explicit modes + tool choice); **repo is always `vllm-project/vllm-omni`** unless the user says otherwise. - -| Mode | What to do | -|------|------------| -| **No PR / branch given** | Do not start a full review. Ask for a **PR number or URL**, or **local branch** review vs `main` (or named base). | -| **PR number or URL** | Use `gh` against this repo: `gh pr view --repo vllm-project/vllm-omni`, `gh pr diff --repo vllm-project/vllm-omni`. Commands and JSON fields: [references/review-execution.md](references/review-execution.md). | -| **Local branch** | No GitHub PR yet: `git fetch` if needed, then `git diff ...HEAD`, `git diff --stat ...HEAD`, `git log ..HEAD --oneline`. Use branch name instead of PR # in the review header; same blocker scan and routing. | -| **Pre-filled prompt** | If the prompt already includes PR title/body, checks, or thread summaries (e.g. from GitHub), **do not re-fetch metadata** unless something is missing; still obtain the **diff** if not present (`gh pr diff` or `git diff` against merge base). | - -**Depth:** **Default** = maintainer-style brevity ([comment budget](references/review-execution.md)). If the user asks for **detailed** / **in-depth** / **line-by-line**, add a **Specific comments** list with `path:line` items; do not duplicate those points as long prose in the review body. Still respect the usual inline ceiling unless the user explicitly wants an audit-style pass. - -## What to prioritize (CI-complement) - -- **Investigate, don’t guess** — If a checklist item might apply (e.g. connector lifecycle, diffusion cache), read surrounding code or use **parallel subagents** for independent areas. A wrong guess is worse than silence. -- **Focus on what automation doesn’t prove** — Design, API contracts, stage/connector invariants, test adequacy for omni paths, breaking behavior. Do not re-argue formatting or issues **pre-commit / CI already failed** (point at the gate instead). -- **Structured notes** — If you produce a multi-section writeup for the **user**, **omit sections with no findings** (no “No issues” padding). - -**Parallel investigation:** Large diffs or multiple subsystems (e.g. `entrypoints/` + `engine/` + `diffusion/`) → split by directory or concern and investigate **in parallel** when subagents exist. - -## Which reference to load (do not load everything) - -| Situation | Open | -|-----------|------| -| Every review | [references/review-execution.md](references/review-execution.md) — gates, `gh` commands, comment budget, tone, batch/CI triage, Python style flags | -| Prefix / multi-skill / hardware guess | [references/review-routing.md](references/review-routing.md) | -| Blocker scan details + merge-blocking patterns | [references/blocker-patterns.md](references/blocker-patterns.md) — Part 1 patterns; **Part 2** = former “pitfalls” (footguns, MRO, connectors, async, etc.) | -| System layout + **code-pattern review** (async, connectors, validation, …) | [references/architecture.md](references/architecture.md) — includes “Code patterns for review” at the end | -| Diffusion / image / video model PRs | [references/diffusion-checklist.md](references/diffusion-checklist.md) | -| High-risk change; need coverage matrix / docs sync | [references/tests-docs-checklist.md](references/tests-docs-checklist.md) | -| PR has perf/accuracy claims or `[Performance]` prefix | [references/perf-verification.md](references/perf-verification.md) — claim detection, hardware-aware benchmark verification, graceful degradation | -| PR adds/modifies tests or touches core code without tests | [references/test-quality-evaluation.md](references/test-quality-evaluation.md) — assertion quality, anti-patterns, hardware-aware test execution | -| Calibrating phrasing from real maintainers | [references/maintainer-style-study.md](references/maintainer-style-study.md) | - -**Legacy paths (do not load — content merged):** `pitfalls.md` → [blocker-patterns.md](references/blocker-patterns.md) **Part 2**; `code-patterns.md` → [architecture.md](references/architecture.md) **Code patterns for review**; `python-style-guide.md` → [review-execution.md](references/review-execution.md) **Python style (review flags)**; batch/CI triage → [review-execution.md](references/review-execution.md) (Batch / CI sections). - -## Priority Hierarchy Under Context Pressure - -If context is limited, prioritize: blocker scan → evidence → perf verification → test quality → domain routing → verdict. - -Always run the blocker scan. Under context pressure, do a shallow scan of the most critical categories (Correctness, Security) and flag that the scan was incomplete. - -## Core Workflow - -Check whether this PR is still a draft or WIP in the PR title, if so, end the review process. - - -### Step 0: Verify Review Gates First - -If this is a ready-to-review PR, check the mergeability and required checks (DCO, pre-commit, mergeability). If failing, stop and ask the author to fix gates before proceeding. - -For gate commands, review submission, and comment style, see [references/review-execution.md](references/review-execution.md). - -Then continue with the workflow below. - -### Step 1: Gather Minimal Context - -Fetch: -- PR metadata and changed files -- The diff -- Linked issues for `[Bugfix]` and `[Feature]` PRs only when conventions are unclear -- Related PRs only when conventions or prior decisions are unclear - -Group changes mentally by **kind** (runtime code, tests, docs, configs) to see where risk sits, then fetch only the minimum extra context needed for the areas touched. - -Do not fetch broad extra context unless the diff leaves real ambiguity. - -### Step 2: Blocker Scan (Required First) - -Execute this scan before any other review activity. For each category, explicitly mark PASS or list blocking issues found. - -``` -BLOCKER scan: -| Category | Result | -|---------------------|-----------------------------------------| -| Correctness | PASS / ISSUES: (list) | -| Reliability/Safety | PASS / ISSUES: (list) | -| Breaking Changes | PASS / (check PR description first) | -| Test Coverage | PASS / (check PR desc for evidence) / needs tests | -| Documentation | PASS / ISSUES: (list) | -| Security | PASS / ISSUES: (list) | -``` - -**Blocker categories:** - -| Category | Flag These Patterns | -|----------|---------------------| -| **Correctness** | Silent exception swallows, uninitialized variables, off-by-one errors, logic inversions, missing returns | -| **Reliability/Safety** | Unclosed resources, race conditions, missing None checks, hardcoded timeouts, silent fallbacks | -| **Breaking Changes** | Signature changes without compat, removed public APIs, changed defaults, config removals | -| **Test Coverage** | Bug fix without regression test, new API without tests, performance claims without benchmarks | -| **Documentation** | New public API without docs, breaking changes without migration guide, new config without docs | -| **Security** | Hardcoded secrets, user input in eval/format strings, insecure deserialization | - -**Evidence standard:** Code inspection suffices for code-level blockers. For test coverage, require CI logs or PR description evidence. - -**Confidence threshold:** Flag obvious cases only. For suspicious but uncertain cases, add a non-blocking comment. - -**Special cases:** -| PR Type | Action | -|---------|--------| -| Doc-only PRs | Skip categories 1-4 and 6, proceed to 5 (Documentation) | -| Config-only PRs | Focus on Breaking Changes + Documentation | -| Test-only PRs | Focus on Correctness of test logic | -| Draft PRs | Do not block; add a single non-blocking comment: "Ready for full review when draft status removed. Preliminary scan available on request." | - -For detailed anti-patterns with code examples, see [references/blocker-patterns.md](references/blocker-patterns.md). - -**If blockers found:** Track issues internally (category + file + line). Do not paste structured `BLOCKING ISSUES:` templates into the review body (see Step 7). - -**If no blockers:** List non-blocking suggestions and proceed to Step 3. - -### Step 3: Route to the Right Skill - -Use the title prefix and changed directories to decide whether a domain skill is required. Doc-only, config-only, and test-only PRs usually skip domain skills unless the diff crosses into model or API areas. - -**Full prefix table, multi-skill combos, hardware detection, and delegation triggers:** [references/review-routing.md](references/review-routing.md). - -### Step 4: Ask for Concrete Validation Evidence - -When tests or benchmarks are missing **and PR description evidence is insufficient**, ask for specific evidence: - -| Change Type | Minimum Evidence to Request | -|-------------|-----------------------------| -| API behavior | Functional tests covering success + invalid input + response contract | -| Model execution | Inference correctness tests comparing outputs against baseline | -| Performance optimization | Benchmark showing before/after latency on stated hardware | -| New feature (performance-affecting) | Performance comparison test: baseline vs. with change (latency, throughput, VRAM) | -| Memory management | Peak memory measurement showing no regression | -| Bug fixes | Regression test that reproduces the original bug | - -For `[Feature]` PRs affecting performance or `[Performance]` PRs, use the checklist in [references/tests-docs-checklist.md](references/tests-docs-checklist.md) section 5. - -Be explicit in review comments. Treat "manual verification only" as insufficient unless automation is genuinely impossible. - -### Step 5: Verify Perf/Accuracy Claims (Blocking) - -**When to activate:** PR has `[Performance]` prefix, or PR body contains quantitative perf/accuracy claims (latency, throughput, VRAM, speedup, accuracy metrics), or Step 4 flagged missing benchmarks. - -**Load** [references/perf-verification.md](references/perf-verification.md). - -**Workflow:** - -1. Detect claims — extract numbers from PR body using regex patterns -2. Detect hardware — run hardware detection to determine available GPU/VRAM/platform -3. Check feasibility — compare estimated model size (weights + KV cache + overhead) against available VRAM -4. Generate benchmark plan — map PR type to appropriate benchmark runner -5. **Pre-execution gate** — present benchmark plan, estimated duration, and model/hardware to user; ask for confirmation before executing -6. Execute (if confirmed) — run before/after benchmarks via git worktrees, with a **20-minute hard timeout** per run -7. Report — produce Claimed vs Measured table with CONFIRMED / NOT_CONFIRMED verdict - -**Graceful degradation:** - -| Level | Condition | What happens | -|-------|-----------|-------------| -| Full verification | GPU available, model fits | Run before/after benchmarks | -| Partial verification | GPU available, model needs offload | Run with `--cpu-offload-gb`, note in report | -| Static-only | No GPU or model too large | Analyze benchmark scripts in diff for correctness, flag implausible claims | -| Skip | No relevant perf claims | Do not activate | - -**Delivery:** Local report first, ask user before posting as PR comment. If verification reveals a confirmed NOT_CONFIRMED for accuracy or VRAM regression, escalate to REQUEST_CHANGES via Step 7. - -### Step 6: Evaluate Test Quality (Blocking) - -**When to activate:** PR adds or modifies test files, or PR touches core code (`engine/`, `stages/`, `connectors/`) without adding tests, or PR is test-only. - -**Load** [references/test-quality-evaluation.md](references/test-quality-evaluation.md). - -**Workflow:** - -1. Static analysis (always runs) — check assertion quality, anti-patterns, marker compliance, edge case coverage -2. Detect hardware — same detection as Step 5 (cross-referenced from `perf-verification.md`) -3. Find affected tests — map changed source files to test files via grep (not path convention) -4. Filter by hardware — skip tests requiring unavailable resources -5. Run tests — `pytest` with `--run-level core_model` by default; use `advanced_model` only if hardware is sufficient -6. Categorize failures — test bug / code bug / infrastructure / flaky -7. Assess quality — score assertion quality, edge case coverage, marker compliance, anti-patterns (A-D grades for internal analysis) - -**Graceful degradation:** - -| Level | Condition | What happens | -|-------|-----------|-------------| -| Full analysis | Hardware matches test markers | Static + runtime execution | -| Static-only | Hardware doesn't match or no GPU | Static analysis only; report which tests were skipped | - -**Delivery:** Local assessment first, ask user before posting. Convert worst 1-2 findings to inline comments (counts against comment budget). If D-grade dimension or code bug found, escalate to REQUEST_CHANGES via Step 7. - -### Step 7: Final Verdict - -Post inline comments directly to GitHub as you find them. Do **not** submit a review event (APPROVE / COMMENT / REQUEST_CHANGES) — leave the verdict decision to the user. - -Summarize locally: -- What was validated -- What still lacks evidence -- Recommended verdict (local presentation only) - -Recommended verdict mapping: - -- `APPROVE` — no blockers; body optional (empty is fine). -- `COMMENT` — suggestions only; body optional (~50% should be empty). -- `REQUEST_CHANGES` — genuine blocking issues only (crashes, data loss, security, policy gates). - -For tone and inline style, see [references/review-execution.md](references/review-execution.md). For maintainer phrasing samples, see [references/maintainer-style-study.md](references/maintainer-style-study.md). - -## Review Heuristics - -Trust PR description and CI evidence before demanding new tests. Prefer regression tests for `[Bugfix]`, contract tests for API changes, and scan engine → connectors → stages → entrypoints before peripheral files. Skip style nits unless they mask correctness. - -## When to Fetch More Context - -Fetch more context when: -- The diff snippet hides lifecycle or cleanup behavior -- A config key or API field is introduced without nearby validation -- A benchmark claim references unseen measurement code -- The PR appears to rely on prior design discussion - -Keep additional fetches narrow and tied to a specific uncertainty. - -## Diffusion Model PR Review - -**When:** Title prefix `[Model]`, `[New Model]`, `[Image]`, `[ImageGen]`, `[Video]`, `[VideoGen]`, or `[Diffusion]`, or a new diffusion model path under `vllm_omni/diffusion/`. - -**Load** [references/diffusion-checklist.md](references/diffusion-checklist.md) instead of expanding the full workflow here: Dimensions 1–4 (including optional canonical PR body template + measurement guidance for Dimension 1), `gh`/`grep` detection commands, **Quick Red Flags**, combined-feature rules. - -**Gate order before approve:** PR body evidence (script, samples, latency, VRAM) → offline **and** online paths → at least one acceleration **and** one memory optimization (new models) → docs tables + usage examples → required e2e online test → offline test if no e2e → combined test when 2+ accel/memory features. - -Use Quick Red Flags actions for comment severity; write human-shaped GitHub comments, not giant pasted templates. - -## Batch Review Session - -For daily sessions (reply-first, PR selection, pacing, re-review): [references/review-execution.md](references/review-execution.md) — sections **Batch and daily review sessions** and related scripts. - -## References - -All paths are under `skills/vllm-omni-review/references/`. There is **no** `pitfalls.md`, `code-patterns.md`, or `python-style-guide.md` — see the legacy map in **Which reference to load** above. - -- [Review execution](references/review-execution.md) — Gates, `gh` fetch/submit, comment budget, tone, **Python style (review flags)** (imports, naming, common flags — use to avoid nit wars), batch session, CI log triage -- [Review routing](references/review-routing.md) — Prefix → domain skill, hardware, multi-skill -- [Blocker patterns](references/blocker-patterns.md) — Part 1: merge-blocking patterns; Part 2: MRO/mixins, connectors, async/sync, diffusion latents, API validation, tensor parallel, mocks (former pitfalls content) -- [Architecture](references/architecture.md) — Layers and critical paths; end section **Code patterns for review** = async, distributed, KV cache, validation, connectors, errors, logging (former code-patterns content) -- [Diffusion checklist](references/diffusion-checklist.md) — Diffusion PR dimensions, PR body template, Quick Red Flags -- [Tests & docs checklist](references/tests-docs-checklist.md) — High-risk coverage matrix and docs sync -- [Perf verification](references/perf-verification.md) — Reviewer-side claim detection, hardware-aware benchmark verification, graceful degradation -- [Test quality evaluation](references/test-quality-evaluation.md) — Assertion quality, anti-patterns, hardware-aware test execution, quality scoring -- [Maintainer style study](references/maintainer-style-study.md) — Example maintainer phrasing diff --git a/.claude/skills/review-pr/references/architecture.md b/.claude/skills/review-pr/references/architecture.md deleted file mode 100644 index bee58674e..000000000 --- a/.claude/skills/review-pr/references/architecture.md +++ /dev/null @@ -1,431 +0,0 @@ -# vLLM-Omni Architecture - -## Overview - -vLLM-Omni extends vLLM for omni-modal (multi-modal) model serving, supporting text, image, video, and audio generation. It provides a unified inference engine with OpenAI-compatible APIs for both LLM and diffusion models. - -**Key Differentiators from vLLM:** -- Multi-stage pipeline architecture (e.g., Thinker → Talker → Code2Wav) -- Diffusion Transformer (DiT) model support -- Inter-stage communication via shared memory connectors -- Stage-level concurrency control - ---- - -## Five-Layer Architecture - -``` -┌─────────────────────────────────────────────────────┐ -│ 1. User Interface Layer │ -│ OpenAI-compatible API, CLI, Python SDK │ -├─────────────────────────────────────────────────────┤ -│ 2. Orchestration Layer │ -│ Omni, AsyncOmni - coordinates stages │ -├─────────────────────────────────────────────────────┤ -│ 3. Engine Layer │ -│ ModelExecutor, Scheduler, KV cache management │ -├─────────────────────────────────────────────────────┤ -│ 4. Execution Layer │ -│ Workers (GPUARWorker, GPUGenerationWorker) │ -├─────────────────────────────────────────────────────┤ -│ 5. Model Layer │ -│ OmniLLM, OmniDiffusion, model implementations │ -└─────────────────────────────────────────────────────┘ -``` - ---- - -## Key Directories - -| Directory | Purpose | Critical? | Review Focus | -|-----------|---------|-----------|--------------| -| `vllm_omni/entrypoints/` | API server, CLI | High | Input validation, error handling | -| `vllm_omni/engine/` | Engine, scheduler | **Critical** | Concurrency, state management | -| `vllm_omni/model_executor/` | Model execution | **Critical** | Weight loading, memory | -| `vllm_omni/diffusion/` | Diffusion support | High | Latent cache, generation | -| `vllm_omni/connectors/` | Inter-stage IPC | High | Shared memory, cleanup | -| `vllm_omni/stages/` | Stage definitions | High | Lifecycle, state | -| `vllm_omni/config/` | Configuration | Medium | Validation, defaults | -| `vllm_omni/utils/` | Utilities | Low | Test coverage | - ---- - -## Core Components - -### Entry Points - -**Synchronous:** `Omni` class -```python -from vllm_omni import Omni -llm = Omni(model="Qwen/Qwen2.5-Omni-7B") -outputs = llm.generate("Hello") -``` - -**Asynchronous:** `AsyncOmni` class -```python -from vllm_omni import AsyncOmni -llm = AsyncOmni(model="Qwen/Qwen2.5-Omni-7B") -outputs = await llm.generate("Hello") -``` - -### Stage Types - -| Type | Worker Classes | Use Case | -|------|---------------|----------| -| `llm` | `GPUARWorker`, `GPUGenerationWorker` | Text generation, multimodal understanding | -| `diffusion` | Diffusion-specific workers | Image/video generation | -| `audio` | Audio workers | TTS, audio synthesis | - -### Connectors - -| Connector | Use Case | Performance | -|-----------|----------|-------------| -| `OmniShmConnector` | Same-machine inter-process | Fastest | -| `OmniZmqConnector` | Distributed/multi-node | Network-capable | - ---- - -## Multi-Stage Pipeline - -### Example: Qwen-Omni Audio Generation - -``` -┌─────────┐ ┌─────────┐ ┌───────────┐ -│ Thinker │ ──▶ │ Talker │ ──▶ │ Code2Wav │ -│ (LLM) │ │ (LLM) │ │ (Audio) │ -└─────────┘ └─────────┘ └───────────┘ - │ │ │ - Text/Audio Text Code Audio Output - Understanding Generation Synthesis -``` - -### Configuration (YAML) - -```yaml -stages: - - name: thinker - type: llm - - name: talker - type: llm - - name: code2wav - type: audio -``` - ---- - -## Data Flow - -``` -Request → API Layer → AsyncOmni/Omni - │ - ▼ - Stage Coordinator - (YAML config) - │ - ┌──────────────┼──────────────┐ - ▼ ▼ ▼ - Stage 1 Stage 2 Stage N - (Worker) (Worker) (Worker) - │ │ │ - └──────────────┴──────────────┘ - │ - OmniConnector - (Shm/Zmq) - │ - ▼ - Response -``` - ---- - -## Memory Management - -### KV Cache (LLM Stages) -- Paged attention inherited from vLLM -- Block-based memory allocation -- Prefix caching for repeated contexts - -### Diffusion Latent Cache -- Intermediate latent storage -- Timestep-based scheduling -- Memory-pressure aware - ---- - -## Supported Models - -### Omni-Modal Models -- Qwen3-Omni -- Qwen2.5-Omni -- Qwen3-TTS (CustomVoice, VoiceDesign, Base) -- MiMo-Audio -- Bagel - -### Diffusion Models -- Z-Image -- Qwen-Image -- Wan2.2 (video) -- FLUX - ---- - -## Review Considerations - -### Critical Paths (High Impact) -- `vllm_omni/engine/` — scheduler changes affect all workloads -- `vllm_omni/model_executor/` — model loading bugs break inference -- `vllm_omni/connectors/` — communication bugs cause hangs/crashes - -### High-Risk Patterns -1. **Stage coordination changes** — can break multi-stage pipelines -2. **Memory management in connectors** — shared memory leaks -3. **Worker lifecycle changes** — affect tensor parallelism -4. **Input validation gaps** — engine crashes instead of 400 errors - -### Testing Requirements -| Component | Test Requirement | -|-----------|------------------| -| LLM stages | Actual model inference | -| Diffusion stages | Generation quality | -| Connectors | Load testing, memory leak check | -| Multi-stage | End-to-end pipeline | -| API endpoints | Input validation, error responses | - ---- - -## Code patterns for review - -*This section holds the former standalone `code-patterns.md` material (async, validation, connectors, logging, etc.).* - -### Async Function Complexity - -**Guidelines:** -- Each `await` is a potential failure point and state transition -- Consider splitting long async chains into smaller helpers -- Watch for race conditions in complex async flows -- Use `return_exceptions=True` for parallel operations - -**Good:** -```python -async def process_batch(requests: list[Request]) -> list[Response]: - validated = [_validate_request(r) for r in requests] - results = await asyncio.gather( - *[_process_single(r) for r in validated], - return_exceptions=True - ) - return [_handle_result(r) for r in results] -``` - -**Bad:** -```python -async def process_batch(requests: list[Request]) -> list[Response]: - results = [] - for r in requests: - results.append(await _process_single(r)) # Sequential, no error handling - return results -``` - ---- - -### Distributed Execution Patterns - -**When complexity is justified:** -- Tensor parallelism synchronization across workers -- Pipeline parallelism stage coordination -- Distributed KV cache management -- Multi-node communication patterns - -**Critical questions:** -- Is distributed complexity isolated from business logic? -- Are distributed failure modes handled? -- Is there a clear fallback for single-device execution? - -**Pattern:** -```python -def get_world_size() -> int: - """Returns 1 if not in distributed mode.""" - if not dist.is_initialized(): - return 1 - return dist.get_world_size() -``` - ---- - -### KV Cache Management - -**Guidelines:** -- Ensure clear separation between allocation, update, and cleanup -- Document invariants and assumptions -- Use type system to enforce valid states -- Always handle cleanup in error paths - -**Pattern:** -```python -class KVCache: - def allocate(self, num_blocks: int) -> None: - assert self._state == CacheState.UNINITIALIZED - self._blocks = [Block() for _ in range(num_blocks)] - self._state = CacheState.ALLOCATED - - def update(self, block_id: int, kv_data: Tensor) -> None: - assert self._state == CacheState.ALLOCATED - self._blocks[block_id].update(kv_data) - - def free(self) -> None: - self._blocks = [] - self._state = CacheState.UNINITIALIZED -``` - ---- - -### Input Validation Pattern - -**Guidelines:** -- Validate early (API layer, not engine) -- Return actionable error messages -- Use clean HTTP status codes (400 for client errors) - -**Pattern:** -```python -def _validate_request(self, request: Request) -> str | None: - """Returns error message or None if valid.""" - if not request.input: - return "Input cannot be empty" - - if request.param and request.param not in VALID_PARAMS: - return f"Invalid param '{request.param}'. Valid: {VALID_PARAMS}" - - return None - -def handle_request(self, request: Request) -> Response: - error = self._validate_request(request) - if error: - return Response(status_code=400, content={"error": error}) - return self._process(request) -``` - ---- - -### Connector Communication - -**Guidelines:** -- Use context managers for resource cleanup -- Handle timeouts explicitly -- Implement proper error propagation - -**Pattern:** -```python -async def send_to_next_stage(self, data: Tensor) -> None: - try: - async with self.connector.acquire(timeout=30.0) as channel: - await channel.send(data) - except TimeoutError: - logger.error("Stage communication timeout") - raise StageError("Downstream stage unavailable") - except Exception as e: - logger.error(f"Stage communication failed: {e}") - raise -``` - ---- - -### Stage Lifecycle - -**Guidelines:** -- Stages are configured at init time -- Runtime reconfiguration requires full teardown -- State must be properly managed across stage boundaries - -**Pattern:** -```python -class Stage: - def __init__(self, config: StageConfig): - self._validate_config(config) - self.config = config - self._state = StageState.INITIALIZED - - async def start(self) -> None: - assert self._state == StageState.INITIALIZED - await self._allocate_resources() - self._state = StageState.RUNNING - - async def stop(self) -> None: - if self._state == StageState.RUNNING: - await self._release_resources() - self._state = StageState.STOPPED -``` - ---- - -### Test Coverage Requirements - -| Code Type | Requirement | -|-----------|-------------| -| New features | Happy path + edge cases + error handling | -| Bug fixes | Regression test + edge cases around fix | -| Performance | Benchmarks with before/after measurements | -| Distributed | Must test in distributed mode | -| Quantization | Memory savings + quality impact measured | -| API endpoints | Input validation + error responses | - ---- - -### Code Quality Thresholds - -| Metric | Threshold | Action | -|--------|-----------|--------| -| Function length | 100+ lines | Review for split opportunities | -| Complexity | 11+ | Requires refactoring | -| Nesting depth | 4+ levels | Requires refactoring | -| Parameters | 7+ | Consider parameter object | - ---- - -### Error Handling Pattern - -**Guidelines:** -- Use specific exception types -- Include actionable context in messages -- Don't silently swallow errors - -**Pattern:** -```python -class ValidationError(Exception): - """Raised when input validation fails.""" - pass - -class EngineError(Exception): - """Raised when engine operation fails.""" - pass - -def process(self, request: Request) -> Response: - try: - return self._process_internal(request) - except ValidationError as e: - logger.warning(f"Validation failed: {e}") - return Response(status_code=400, content={"error": str(e)}) - except EngineError as e: - logger.error(f"Engine error: {e}") - return Response(status_code=500, content={"error": "Internal error"}) -``` - ---- - -### Logging Pattern - -**Guidelines:** -- Use appropriate log levels -- Include relevant context -- Avoid logging sensitive data - -```python -# Good -logger.info(f"Processing request {request_id} with model {model_name}") -logger.warning(f"Slow response time: {elapsed_ms}ms for {endpoint}") -logger.error(f"Failed to load model {model_path}: {e}") - -# Bad -logger.info("Processing request") # No context -print(f"Error: {e}") # Wrong logging method -logger.debug(f"User token: {token}") # Sensitive data -``` diff --git a/.claude/skills/review-pr/references/blocker-patterns.md b/.claude/skills/review-pr/references/blocker-patterns.md deleted file mode 100644 index d6edd3288..000000000 --- a/.claude/skills/review-pr/references/blocker-patterns.md +++ /dev/null @@ -1,752 +0,0 @@ -# Blocker Patterns Library - -Each pattern includes: the anti-pattern, why it's dangerous, and required fix. - -Cross-references point to [architecture.md](architecture.md) (section **Code patterns for review**) for "how to fix" guidance. - -## Exception Handling - -### Pattern: Silent Swallow -```python -# BLOCKER: Silent exception swallow -try: - result = risky_operation() -except: - pass # or: except Exception: pass -``` - -**Why dangerous:** Hides all failures, makes debugging impossible. - -**Required fix:** At minimum, log the exception. Better: catch specific exceptions. - -**Cross-ref:** See [Error Handling Pattern](architecture.md#error-handling-pattern) for proper exception handling with logging. - ---- - -### Pattern: Broad Catch with Continue -```python -for item in items: - try: - process(item) - except Exception: - continue # silently skips -``` - -**Why dangerous:** Partial failure with no visibility. - -**Required fix:** Log failure, increment counter, or fail fast. - -**Cross-ref:** See [Error Handling Pattern](architecture.md#error-handling-pattern) for proper exception handling with logging. - ---- - -### Pattern: Uninitialized Variable -```python -result = obj.method().nested.value # potential AttributeError -``` - -**Why dangerous:** Crashes with `AttributeError` if any step returns `None`. - -**Required fix:** Add explicit None guards before accessing attributes. - -```python -if obj is not None and obj.method() is not None: - result = obj.method().nested.value -``` - -**Cross-ref:** See [None Safety](architecture.md#input-validation-pattern) for guard patterns. - ---- - -## Resource Management - -### Pattern: Unclosed Resource -```python -f = open(path) # no 'with' statement -content = f.read() -# f never closed -``` - -**Why dangerous:** Resource leaks, especially in long-running servers instances. - -**Required fix:** Use context managers (`with open(...) as f:`). - -**Cross-ref:** See [Connector Communication](architecture.md#connector-communication) for proper connector usage with context managers. - ---- - -### Pattern: Shared Mutable State -```python -shared_list = [] # modified by concurrent coroutines -async def append(item): - shared_list.append(item) -``` - -**Why dangerous:** Race conditions, corrupted state. - -**Required fix:** Use `asyncio.Lock` or thread-safe structures. - -**Cross-ref:** See [Distributed Execution Patterns](architecture.md#distributed-execution-patterns) for thread safety alternatives. - ---- - -## None Safety - -### Pattern: Unchecked Chain -```python -result = obj.method().nested.value # no None checks -``` - -**Why dangerous:** `AttributeError` if any step returns `None`. - -**Required fix:** Add explicit None guards before each access, or use `getattr()` with defaults. - -```python -# Option 1: Explicit None checks -if obj is not None: - method_result = obj.method() - if method_result is not None: - result = method_result.nested.value - -# Option 2: getattr with default -result = getattr(getattr(obj, "method", lambda: None)(), "nested", None) -``` - -**Cross-ref:** See [Input Validation Pattern](architecture.md#input-validation-pattern) for early validation guidance. - ---- - -### Pattern: Missing None Check -```python -def process(data): - if data is None: - return None - # Missing None check! - result = process(data) # Silent failure - return True -``` - -**Why dangerous:** Hides bugs, makes debugging impossible. - -**Required fix:** Add explicit None check and log a warning. Better: `return None`. - -**Cross-ref:** See [Input Validation Pattern](architecture.md#input-validation-pattern) for validation guidance. - ---- - -## Breaking Change Detection - -### Pattern: Function Signature Change -```python -# BLOCKER: No backward compatibility -# Old signature: def get_user(user_id: int): -# New signature adds a non-optional parameter: -def get_user(user_id: int, include_profile: bool): # Breaking change! - pass -``` - -**Why dangerous:** Breaks existing code that depends on this function. - -**Required fix:** Add deprecation path or maintain backward compatibility for 1-2 releases. Document migration. - -**Cross-ref:** See [API Endpoints](architecture.md#connector-communication) for API compatibility guidance. - ---- - -### Pattern: Removed Public API -```python -# BLOCKER: No deprecation path -def remove_feature(name): - pass -``` - -**Why dangerous:** Breaks existing code that depends on this function. -**required fix:** If removal is necessary, provide replacement. Otherwise, document breaking change and deprecation timeline. -**Cross-ref:** See [API Endpoints](architecture.md#connector-communication) for OpenAI compatibility guidance ---- - -### Pattern: Changed Default -```python -class Config: - def __init__(self): - self.default_value = "on" # Was "off" - breaking change! -``` - -**Why dangerous:** Breaks existing code that depends on this default. - -**Required fix:** Document the change clearly. If intentional, provide rollback code or migration script. - -**Cross-ref:** See [API Endpoints](architecture.md#connector-communication) for API compatibility guidance. - ---- - -## Memory Management - -### Pattern: Unbounded Latent Cache -```python -class DiffusionModel: - def generate(self, prompt): - self.latent_cache.append(create_latents()) # Never cleared! - return decode(self.latent_cache[-1]) -``` - -**Why dangerous:** Memory leaks accumulate across generations. -**required fix:** Explicitly clear latent cache after generation. Add memory-pressure handling. -**Cross-ref:** See [Memory Management in Diffusion](blocker-patterns.md#memory-management-in-diffusion) for latent cache lifecycle guidance ---- - -## Async Safety - -### Pattern: Blocking Call in Async -```python -# BLOCKER: Blocking call blocks event loop -async def process(self, request): - result = blocking_call() # Blocks event loop! - return result -``` - -**Why dangerous:** Blocks event loop, prevents concurrent requests. -**required fix:** Use `asyncio.to_thread()` or await pattern. -**Cross-ref:** See [Async Function Complexity](architecture.md#async-function-complexity) for async patterns ---- - -### Pattern: Hardcoded Timeout -```python -def connect(url): - response = requests.get(url, timeout=30.0) # Hardcoded - no flexibility! -``` - -**Why dangerous:** No flexibility, hides issues in testing. - -**Required fix:** Make timeout configurable or add timeout parameter to CLI flags. - -**Cross-ref:** See [Connector Communication](architecture.md#connector-communication) for proper connector usage. - ---- - -### Pattern: Hardcoded Retry Count -```python -MAX_RETRIES = 3 # No justification, no backoff - -for attempt in range(MAX_RETRIES): - try: - response = requests.get(url, timeout=5) - except TimeoutError: - pass # Silent retry, no logging -``` - -**Why dangerous:** Can cause infinite retry loops or delays without visibility. - -**Required fix:** Use exponential backoff with configurable max retries or circuit breaker pattern. - -**Cross-ref:** See [Stage Lifecycle](architecture.md#stage-lifecycle) for lifecycle management. - ---- - -### Pattern: Sequential Async in Loop -```python -# BLOCKER: No parallelism -results = [] -for r in requests: - result = await _process_single(r) # Sequential, slow - return results -``` - -**Why dangerous:** Poor throughput, no parallelism benefits. - -**Required fix:** Use `asyncio.gather()` with `return_exceptions=True` for parallel execution. - -**Cross-ref:** See [Async Function Complexity](architecture.md#async-function-complexity) for proper async patterns. - ---- - -### Pattern: Device-Specific Code -```python -# BLOCKER: No non-CUDA fallback -if torch.cuda.is_available(): - x = x.to(device) -else: - x.cpu() # Missing non-CUDA path! -``` - -**Why dangerous:** Crashes on non-CUDA systems. - -**Required fix:** Check `torch.cuda.is_available()` first and use appropriate fallback. - -**Cross-ref:** See [Distributed Execution Patterns](architecture.md#distributed-execution-patterns) for distributed patterns. - ---- - -## API Boundaries - -### Pattern: Unsafe Parameter Passthrough -```python -# BLOCKER: No validation before passing to API -user_input = request.json.get("model") -response = model.generate(request.json["prompt"]) -``` - -**Why dangerous:** Arbitrary code execution, model injection. - -**Required fix:** Validate all user inputs before passing to model. - -**Cross-ref:** See [Input Validation Pattern](architecture.md#input-validation-pattern) for validation guidance. - ---- - -### Pattern: Missing Response Validation -```python -# BLOCKER: No validation after calling API -async def create_item(self, request): - # Missing: validation - # Could return invalid responses - return {"error": "Internal server error"} -``` - -**Why dangerous:** API contract violations. - -**Required fix:** Validate responses match schema and handle errors explicitly. - -**Cross-ref:** See [Error Handling Pattern](architecture.md#error-handling-pattern) for proper error handling patterns. - ---- - -## Security - -### Pattern: Hardcoded Secrets -```python -# BLOCKER: Hardcoded credentials -API_KEY = "sk-abc123" -DATABASE_PASSWORD = "secret123" -``` - -**Why dangerous:** Credential exposure in logs, git history. - -**Required fix:** Use environment variables or secret management systems. - -**Cross-ref:** See [Logging Pattern](architecture.md#logging-pattern) for proper logging practices. - ---- - -### Pattern: Insecure Deserialization -```python -import pickle # DANGEROUS: loading untrusted data -data = pickle.loads(user_input) -``` - -**Why dangerous:** Remote code execution (RCE). - -**Required fix:** Never use `pickle.loads()` on untrusted data. Use safe deserialization libraries. - -**Cross-ref:** See [Error Handling Pattern](architecture.md#error-handling-pattern) for safe error handling patterns. - ---- - -### Pattern: SQL Injection -```python -# BLOCKER: No parameterized queries -cursor.execute(user_input) # Direct string interpolation -``` - -**Why dangerous:** Data breach. - -**Required fix:** Use parameterized queries (prepared statements, ORM). - -**Cross-ref:** See [Input Validation Pattern](architecture.md#input-validation-pattern) for validation guidance. - ---- - -### Pattern: Unsafe String Formatting with User Input -```python -# BLOCKER: User-controlled format string enables code injection -user_template = request.args.get("template") # e.g., "{user.__class__.__mro__}" -msg = user_template.format(user=current_user) # Can leak internal state! - -# BLOCKER: eval/exec with user input -result = eval(user_expression) # Remote code execution! -query = f"SELECT * FROM {user_table}" # SQL injection via string formatting -``` - -**Why dangerous:** `str.format()` with user-controlled templates can access object attributes. `eval()`/`exec()` execute arbitrary code. String formatting into SQL/HTML enables injection. - -**Required fix:** -- For templates: use sandboxed template engines (Jinja2 with autoescape) or whitelist allowed placeholders -- For SQL: use parameterized queries, never string interpolation -- For code execution: never pass user input to `eval()`/`exec()` - -**Note:** Normal f-strings like `f"Hello, {name}!"` are safe - they don't execute code, just interpolate. - -**Cross-ref:** See [Input Validation Pattern](architecture.md#input-validation-pattern) for validation guidance. - ---- - -## Test Coverage - -### Pattern: Missing Regression Test -```python -# BLOCKER: Bug fix without regression test -def fix_bug(): - pass # Bug fixed -``` - -**Why dangerous:** Bug may resurface in future PRs. - -**Required fix:** Add a regression test that reproduces the original bug. - -**Cross-ref:** See [Test Coverage Requirements](architecture.md#test-coverage-requirements) for test coverage requirements. - ---- - -### Pattern: Weak Assertions -```python -# BLOCKER: Assertion too weak -def test_result(): - result = compute() - assertTrue(result) # Passes even if result is wrong! -``` - -**Why dangerous:** False confidence in test results. - -**Required fix:** Use meaningful assertions that verify actual behavior. - -**Cross-ref:** See [Test Coverage Requirements](architecture.md#test-coverage-requirements) for test coverage requirements. - ---- - -### Pattern: Mock Mismatch -```python -# Production -class Model(nn.Module, Mixin): - pass - -# Test mock - different Mro -class MockModel(Mixin): # Missing nn.Module - pass -``` - -**Why dangerous:** Tests pass but hide real bugs. - -**Required fix:** Ensure mocks match production inheritance hierarchy. - -**Cross-ref:** See [Test Mock Mismatches](blocker-patterns.md#test-mock-mismatches) for mock testing guidance. - ---- - -### Pattern: Only Happy Path Test -```python -# BLOCKER: No edge case tests -def process(self, data): - result = self._process(data) - # Happy path only - return result -``` - -**Why dangerous:** Edge cases not tested, bugs only surface in production. - -**Required fix:** Add tests for error handling, edge cases (empty, null, boundary). - -**Cross-ref:** See [Test Coverage Requirements](architecture.md#test-coverage-requirements) for test coverage requirements. - ---- - -### Pattern: No Performance Benchmark -```python -# BLOCKER: Performance optimization without benchmark data -def optimize(): - pass # Faster! - return data -``` - -**Why dangerous:** Claims without evidence. - -**Required fix:** Run benchmarks with `pytest` or manual timing, document results. - -**Cross-ref:** See [Test Coverage Requirements](architecture.md#test-coverage-requirements) for test coverage requirements. - ---- - -### Pattern: Missing Memory Measurement -```python -# BLOCKER: Memory optimization without memory measurement -pass -``` - -**Why dangerous:** Cannot verify memory savings. - -**Required fix:** Use memory profiling tools and report peak and delta. - -**Cross-ref:** See [Memory Management in Diffusion](blocker-patterns.md#memory-management-in-diffusion) for latent cache lifecycle guidance. - ---- - -### Pattern: No Distributed Test -```python -# BLOCKER: Distributed changes without distributed test -def test_distributed(self): - pass -``` - -**Why dangerous:** Distributed bugs only surface in distributed environments, not unit tests. - -**Required fix:** Test in distributed mode with `torchrun`. - -**Cross-ref:** See [Tensor Parallelism Edge Cases](blocker-patterns.md#tensor-parallelism-edge-cases) for distributed testing guidance. - ---- - -## Documentation - -### Pattern: Missing Migration Guide -```python -# BLOCKER: Breaking change without migration guide -def migrate_config(): - pass -``` - -**Why dangerous:** Users unable to upgrade. - -**Required fix:** Document breaking changes in RELEASE_NOTES.md. Provide migration instructions. - -**Cross-ref:** See [API Endpoints](architecture.md#connector-communication) for OpenAI compatibility guidance. - ---- - -### Pattern: Missing Usage Examples -```python -# BLOCKER: New feature without usage examples -def add_feature(): - pass -``` - -**Why dangerous:** Users can't understand how to use the feature. - -**Required fix:** Add usage examples, docstrings. - -**Cross-ref:** See [Comment Style](review-execution.md#comment-style) for review comment guidance. - ---- - -## Part 2: Common pitfalls (footguns and review prompts) - -*This part holds the former standalone `pitfalls.md` material (MRO, connector state, async vs sync, diffusion memory, API validation, tensor parallel, test mocks).* - -### Mixin + nn.Module MRO Issue - -**Problem:** -When a mixin class is listed **after** `nn.Module` in inheritance, the mixin's `__init__` will **not** be called because `nn.Module.__init__()` doesn't call `super().__init__()`. - -```python -# BROKEN - Mixin's __init__ won't be called -class MyModel(nn.Module, SomeMixin): - def __init__(self): - super().__init__() # Only calls nn.Module.__init__! - self.mixin_method() # CRASH: mixin attributes not initialized -``` - -**Solution - Lazy Initialization:** -```python -class SomeMixin: - @property - def _internal_state(self) -> set: - if not hasattr(self, '_internal_state_storage'): - self._internal_state_storage = set() - return self._internal_state_storage -``` - -**Red Flag in Tests:** -If test mocks inherit only from the mixin (not `nn.Module`), they won't catch this bug because the test's `super().__init__()` WILL call the mixin's `__init__`. - -**Review Action:** -- Check inheritance order when you see mixins -- If mixin has `__init__` that sets attributes, flag it -- Verify tests use realistic class hierarchy - ---- - -### Connector State Management - -**Problem:** -Connectors use shared memory. Improper cleanup leads to leaks and crashes. - -```python -# BROKEN - No cleanup on error -def send_data(self, data): - self.shm_buffer.write(data) - raise ValueError("oops") # Buffer never released! -``` - -**Solution - Context Managers:** -```python -def send_data(self, data): - with self.shm_buffer.acquire() as buf: - buf.write(data) - # Automatically released even on error -``` - -**Review Action:** -- Check error paths in connector code -- Look for `try/finally` or context managers -- Verify cleanup in all branches - ---- - -### Async vs Sync Path Differences - -**Problem:** -`AsyncOmni` and `Omni` have different code paths. Changes may work in one but not the other. - -```python -# Works in sync path -def process(self, request): - result = blocking_call() # OK in sync - return result - -# Breaks in async path -async def process(self, request): - result = blocking_call() # Blocks event loop! - return result -``` - -**Solution:** -```python -async def process(self, request): - result = await asyncio.to_thread(blocking_call) - return result -``` - -**Review Action:** -- Check if PR modifies shared code paths -- Verify both sync and async are tested -- Look for blocking calls in async code - ---- - -### Stage Configuration Validation - -**Problem:** -Stage configs are loaded at init time. Invalid configs may not fail until runtime. - -```python -# Config loaded but not validated -config = load_yaml("stages.yaml") -# ... much later ... -stage = create_stage(config["unknown_stage"]) # Crash! -``` - -**Solution - Eager Validation:** -```python -config = load_yaml("stages.yaml") -validate_stage_config(config) # Fail fast -``` - -**Review Action:** -- Check for config validation at load time -- Verify all required fields are checked -- Look for defaults that mask invalid configs - ---- - -### Memory Management in Diffusion - -**Problem:** -Diffusion models manage large latent caches. Memory leaks accumulate across generations. - -```python -# BROKEN - Latent cache grows unbounded -class DiffusionModel: - def generate(self, prompt): - self.latent_cache.append(create_latents()) # Never cleared! - return decode(self.latent_cache[-1]) -``` - -**Solution:** -```python -class DiffusionModel: - def generate(self, prompt): - latents = create_latents() - try: - return decode(latents) - finally: - del latents # Explicit cleanup -``` - -**Review Action:** -- Check latent cache lifecycle -- Verify cleanup in generation loops -- Look for memory-pressure handling - ---- - -### Input Validation in API Layer - -**Problem:** -Invalid requests that reach the engine can cause crashes instead of clean errors. - -```python -# BROKEN - Validation happens in engine -def create_speech(self, request): - # Missing validation here - return self.engine.generate(request) # Engine crashes! -``` - -**Solution - Validate Early:** -```python -def create_speech(self, request): - error = self._validate_request(request) - if error: - return BadRequest(error) # Clean 400 response - return self.engine.generate(request) -``` - -**Review Action:** -- Check validation before engine calls -- Verify all parameters are validated -- Ensure error messages are actionable - ---- - -### Tensor Parallelism Edge Cases - -**Problem:** -Code may work single-GPU but break with tensor parallelism. - -```python -# Works on single GPU -def forward(self, x): - return self.layer(x) + self.bias # bias not replicated! -``` - -**Solution:** -```python -def forward(self, x): - return self.layer(x) + self.bias.data # Explicitly access data -``` - -**Review Action:** -- Check if changes affect distributed execution -- Verify tensor parallel tests exist -- Look for rank-specific logic - ---- - -### Test Mock Mismatches - -**Problem:** -Tests may mock classes differently from production, hiding bugs. - -```python -# Production -class Model(nn.Module, Mixin): - pass - -# Test mock - different MRO! -class MockModel(Mixin): # Missing nn.Module - pass -``` - -This hides the MRO bug described above. - -**Review Action:** -- Compare mock inheritance to production -- Check if mocks skip critical base classes -- Verify mock behavior matches production diff --git a/.claude/skills/review-pr/references/diffusion-checklist.md b/.claude/skills/review-pr/references/diffusion-checklist.md deleted file mode 100644 index c3c18a9ef..000000000 --- a/.claude/skills/review-pr/references/diffusion-checklist.md +++ /dev/null @@ -1,505 +0,0 @@ -# Diffusion Model Contribution Review Checklist - -Single reference for diffusion PRs: PR body criteria (including optional canonical template and measurement guidance), code/docs/tests dimensions, and Quick Red Flags. Use after reading the PR diff and body. - ---- - -## Dimension 1: PR Body Completeness - -### 1.1 Required Evidence (Table A) - -| Item | What to Check | Missing → Action | -|------|---------------|------------------| -| **vLLM-Omni generation script** | Runnable Python or bash snippet using `Omni` / `vllm serve` that produces output | Request script | -| **Generated sample outputs** | At least 1 image / video / audio sample attached or linked | Request sample | -| **vLLM-Omni e2e latency** | Wall-clock time from request to output, with GPU model, count, resolution, steps | Request measurement | -| **vLLM-Omni VRAM usage** | Peak VRAM in GB during generation, with resolution / steps | Request measurement | - -- [ ] **vLLM-Omni generation script present** - - Must use `Omni(model=...)` for offline, or `vllm serve ... --omni` for online - - Script must be runnable (no pseudocode, no placeholder ``) - - If only offline or only online is shown, note which is missing - -- [ ] **Sample output attached or linked** - - Image PR: at least 1 image (PNG/JPEG), ideally multiple prompts - - Video PR: at least 1 video clip or animated GIF - - Audio PR: audio file or spectrogram + waveform visualization - - Resolution and generation parameters must be visible (caption or table) - -- [ ] **vLLM-Omni e2e latency recorded** - - Wall-clock time from request submission to final output received - - Must include: GPU model, GPU count, resolution (H×W), `num_inference_steps` - - Single measurement is acceptable; batch=1 is the baseline - -- [ ] **vLLM-Omni peak VRAM recorded** - - Peak GPU memory in GB - - Measurement method noted (e.g., `torch.cuda.max_memory_allocated()`, `nvidia-smi`) - - Must match the hardware spec reported with latency - -### 1.2 Recommended Evidence (Table B) - -| Item | Why It Matters | -|------|----------------| -| **diffusers generation script** | Reproducible baseline for quality and speed comparison | -| **diffusers sample outputs** | Side-by-side quality comparison demonstrates parity | -| **diffusers e2e latency** | Quantifies vLLM-Omni speedup relative to reference | -| **diffusers VRAM usage** | Quantifies memory reduction or overhead | - -- [ ] **diffusers generation script** - - Same prompt, same resolution, same number of steps as vLLM-Omni script - - Uses `diffusers` library directly (not wrapped in vllm-omni) - -- [ ] **diffusers sample output** - - Side-by-side or clearly labeled comparison with vLLM-Omni output - - Same prompt used for both - -- [ ] **diffusers e2e latency** - - Recorded under same hardware conditions as vLLM-Omni measurement - - Speedup ratio (vLLM-Omni latency / diffusers latency) stated or calculable - -- [ ] **diffusers VRAM usage** - - Peak VRAM under same conditions - - Delta (VRAM_vllm_omni − VRAM_diffusers) highlighted if significant - - -### 1.3 Canonical PR body template (gold standard) - -Contributors can paste this structure into the PR description. Reviewers use it as the reference for what “complete” means for Dimension 1. - -````markdown -## Summary - -[One paragraph: what model is being added, architecture type (DiT / AR+DiT / etc.), -and which capabilities are introduced (text-to-image / video / editing / etc.)] - -**Model:** `org/model-id` -**Architecture:** DiT / AR+DiT / other -**Modality:** text-to-image / text-to-video / image-editing - ---- - -## vLLM-Omni Generation - -### Offline Inference - -```python -from vllm_omni.entrypoints.omni import Omni - -omni = Omni(model="org/model-id") -outputs = omni.generate("a cup of coffee on a wooden table, photorealistic") -outputs[0].request_output[0].images[0].save("output.png") -``` - -### Online Serving - -```bash -# Start server -vllm serve org/model-id --omni --port 8091 - -# Generate -curl -s http://localhost:8091/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{ - "messages": [{"role": "user", "content": "a cup of coffee on a wooden table"}], - "extra_body": {"height": 1024, "width": 1024, "num_inference_steps": 50, "seed": 42} - }' | jq -r '.choices[0].message.content[0].image_url.url' \ - | cut -d',' -f2 | base64 -d > output.png -``` - -### Sample Outputs - -| Prompt | Output | -|--------|--------| -| "a cup of coffee on a wooden table, photorealistic" | ![sample1](./assets/sample1.png) | -| "a futuristic city at night, neon lights" | ![sample2](./assets/sample2.png) | - -### Performance Measurements - -**Hardware:** 1× NVIDIA A100 80GB -**Resolution:** 1024×1024 -**Steps:** 50 - -| Metric | Value | -|--------|-------| -| e2e latency | X.X s | -| Peak VRAM | XX.X GB | - ---- - -## diffusers Baseline (Recommended) - -### Script - -```python -from diffusers import StableDiffusionXLPipeline -import torch - -pipe = StableDiffusionXLPipeline.from_pretrained("org/model-id", torch_dtype=torch.float16) -pipe = pipe.to("cuda") -image = pipe("a cup of coffee on a wooden table, photorealistic", - num_inference_steps=50, height=1024, width=1024).images[0] -image.save("output_diffusers.png") -``` - -### Comparison - -| | vLLM-Omni | diffusers | -|-|-----------|-----------| -| e2e latency | X.X s | X.X s | -| Peak VRAM | XX.X GB | XX.X GB | -| Sample | ![vllm_omni](./assets/sample_vllm.png) | ![diffusers](./assets/sample_diffusers.png) | - ---- - -## Acceleration Features - -### Supported Features - -| Feature | Supported | CLI Flag / Config Key | -|---------|----------|----------------------| -| Sequence Parallel | ✅ | `--sequence-parallel-size N` | -| CFG Parallel | ❌ | — | -| VAE Patch Parallel | ✅ | `vae_patch_parallel: true` | -| Tensor Parallel | ✅ | `--tensor-parallel-size N` | -| TeaCache | ✅ | `--teacache-thresh 0.15` | - -### Acceleration Demo - -```bash -# Tensor Parallel across 2 GPUs -vllm serve org/model-id --omni --tensor-parallel-size 2 - -# TeaCache for 1.5× speedup -vllm serve org/model-id --omni --teacache-thresh 0.15 -``` - -| Config | Latency | VRAM/GPU | -|--------|---------|---------| -| Baseline (1 GPU) | X.X s | XX GB | -| TP=2 | X.X s | XX GB | -| TeaCache | X.X s | XX GB | -| TP=2 + TeaCache | X.X s | XX GB | - ---- - -## Memory Optimization Features - -### Supported Options - -| Feature | Supported | CLI Flag / Config Key | -|---------|----------|----------------------| -| CPU Offload | ✅ | `--enable-cpu-offload` | -| FP8 Quantization | ✅ | `--quantization fp8` | -| VAE Tiling | ✅ | `vae_tiling: true` | - -### Memory Reduction Demo - -```bash -# CPU offload (reduces VRAM from XX GB to YY GB) -vllm serve org/model-id --omni --enable-cpu-offload - -# FP8 quantization -vllm serve org/model-id --omni --quantization fp8 -``` - -| Config | Peak VRAM | Latency | -|--------|----------|---------| -| Baseline (BF16) | XX.X GB | X.X s | -| CPU Offload 10 GB | XX.X GB | X.X s | -| FP8 Quantization | XX.X GB | X.X s | - ---- - -## Combined Feature Validation - -```bash -# CPU offload + TeaCache + Tensor Parallel -vllm serve org/model-id --omni \ - --tensor-parallel-size 2 \ - --teacache-thresh 0.15 \ - --cpu-offload-gb 5 -``` - -| Config | Latency | VRAM/GPU | Quality Notes | -|--------|---------|---------|--------------| -| All features combined | X.X s | XX GB | No visible quality degradation | - -Sample output with combined config: ![combined](./assets/sample_combined.png) - ---- - -## Documentation Updates - -- [ ] `docs/models/supported_models.md` — model row added -- [ ] `docs/features/feature_support.md` — feature row added -- [ ] `docs/features/compatibility.md` — compatibility table updated (if applicable) -- [ ] `docs/models/.md` — usage example doc added - ---- - -## Test Coverage - -- [ ] `tests/e2e/online_serving/test__expansion.py` — online serving e2e test -- [ ] `tests/models/test_.py` — offline inference test -```` - ---- - -#### Measurement guidelines - -##### How to measure e2e latency - -**Offline:** -```python -import time -from vllm_omni.entrypoints.omni import Omni - -omni = Omni(model="org/model-id") - -# Warm-up (1 run, not measured) -omni.generate("warm-up prompt") - -# Timed run -start = time.perf_counter() -outputs = omni.generate("a cup of coffee on a wooden table") -end = time.perf_counter() -print(f"e2e latency: {end - start:.2f}s") -``` - -**Online (using `curl` with timing):** -```bash -time curl -s http://localhost:8091/v1/chat/completions \ - -H "Content-Type: application/json" \ - -d '{"messages": [{"role": "user", "content": "a cup of coffee"}], ...}' -``` - -##### How to measure peak VRAM - -```python -import torch -torch.cuda.reset_peak_memory_stats() - -# Run generation here - -peak_mb = torch.cuda.max_memory_allocated() / 1024**2 -print(f"Peak VRAM: {peak_mb / 1024:.1f} GB") -``` - -Or via `nvidia-smi`: -```bash -nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits -l 1 -``` - -##### What “same conditions” means for diffusers comparison - -When comparing vLLM-Omni vs diffusers: -- Same GPU model and count -- Same prompt -- Same resolution (H × W) -- Same `num_inference_steps` -- Same `seed` -- Same data type (both BF16 or both FP16) -- Both measured after one warm-up run - ---- - -#### Common PR body mistakes - -| Mistake | Correct Approach | -|---------|-----------------| -| Using a tiny resolution (256×256) for latency measurement | Use the model's recommended resolution (typically 512×512 minimum, 1024×1024 for flagship models) | -| Reporting latency without warm-up run | Always warm up the model first; measure on the second+ run | -| Showing only one sample image | Show 2–3 samples with diverse prompts to demonstrate quality | -| Only demonstrating offline mode | Include both offline (`Omni`) and online (`vllm serve`) | -| Reporting VRAM from `nvidia-smi` at idle | Measure peak VRAM during active generation | -| Listing features as "planned" in the support table | Only mark ✅ for features that are implemented and tested in this PR | - ---- - -## Dimension 2: Code Checks - -### 2.1–2.2 Inference Mode Coverage (both required) - -| Check | Pass Condition | Flag | -|-------|----------------|------| -| **Offline inference** | `Omni` / `OmniLLM` integration exists; model can be instantiated and called | Missing offline path | -| **Online serving** | `vllm serve` or `AsyncOmni` handles the model; API routes return correct responses | Missing online path | - -### 2.1 Offline Inference - -- [ ] `Omni` or `OmniLLM` can instantiate the model (`model=""`) -- [ ] `.generate()` returns a valid output object with images/video/audio fields -- [ ] Default stage config YAML exists under `vllm_omni/configs/` or equivalent -- [ ] Model is registered in the model registry (import path resolvable) - -### 2.2 Online Serving - -- [ ] `AsyncOmni` or API server route handles the model -- [ ] `vllm serve --omni` startup does not error -- [ ] `/v1/chat/completions` or appropriate endpoint returns correct response schema -- [ ] Input validation rejects malformed requests with 400, not engine crash - -### 2.3 Diffusers Mixin Cleanup - -- [ ] No `DiffusionPipelineMixin` in added/modified code -- [ ] No `SchedulerMixin` in added/modified code -- [ ] No `ConfigMixin` (diffusers) in added/modified code -- [ ] No direct `diffusers.pipelines.*` import in production model code - - Exception: `diffusers` may appear in test files or benchmark scripts - -**Detection command:** -```bash -gh pr diff --repo vllm-project/vllm-omni \ - | grep -E '^\+' \ - | grep -E 'DiffusionPipelineMixin|SchedulerMixin|ConfigMixin|from diffusers\.pipelines' -``` - -### 2.4 Acceleration Features - -At least one of the following must be implemented and demonstrably working: - -| Feature | Detection Pattern | Notes | -|---------|------------------|-------| -| **Sequence Parallel** | `sequence_parallel`, `sp_group`, `ring_attn` | For transformer attention | -| **CFG Parallel** | `cfg_parallel`, `cfg_group`, dual-batch guidance | Splits positive/negative across devices | -| **VAE Patch Parallel** | `vae_patch_parallel`, `patch_parallel` | For high-res VAE decoding | -| **Tensor Parallel** | `tp_group`, `ColumnParallelLinear`, `RowParallelLinear` | Linear layer sharding | -| **TeaCache / Step Cache** | `teacache`, `cache_dit`, `cache_interval` | Skip redundant denoising steps | - -- [ ] At least one acceleration feature implemented -- [ ] Feature can be enabled via config or CLI flag (not hardcoded) -- [ ] PR body or docs show the speedup from enabling the feature - -### 2.5 Memory Optimization Features - -At least one of the following must be implemented: - -| Feature | Detection Pattern | Notes | -|---------|------------------|-------| -| **CPU Offload** | `cpu_offload`, `offload_to_cpu`, `--enable-cpu-offload` | Move weights to CPU when idle | -| **Quantization** | `quantization`, `int8`, `fp8`, `bnb`, `bitsandbytes` | Reduced precision weights | -| **VAE Tiling** | `vae_tiling`, `tile_size`, `tiled_decode` | Decode VAE in spatial tiles | - -- [ ] At least one memory optimization feature implemented -- [ ] Feature can be enabled via config or CLI flag -- [ ] PR body or docs show VRAM reduction from enabling the feature - ---- - -## Dimension 3: Documentation - -**Find doc files:** -```bash -gh pr view --repo vllm-project/vllm-omni \ - --json files --jq '.files[].path' | grep -E '\.md$|docs/' -``` - -| Doc Artifact | Required | What to Check | -|--------------|----------|---------------| -| **Model support table** | Yes | Row added: model name, architecture, HF model ID, modality, min VRAM | -| **Feature support table** | Yes | Row showing which acceleration and memory features are supported | -| **Usage example doc** | Yes | Runnable offline + online example for the new model | -| **Feature compatibility table** | Optional | If multiple features: matrix showing validated combinations | - -### 3.1 Model Support Table - -- [ ] Table updated in `docs/models/supported_models.md` (or equivalent) -- [ ] New row contains: Model Name, Architecture, HF Model ID, Modality, Min VRAM -- [ ] Modality correctly labeled (text-to-image / text-to-video / image-editing / etc.) - -### 3.2 Feature Support Table - -- [ ] Table updated showing which features apply to the new model -- [ ] Each column maps to a specific feature (Seq Parallel, CFG Parallel, VAE Patch, TP, CPU Offload, Quantization) -- [ ] Cells use consistent notation (✅ supported / ❌ not supported / 🔄 planned) - -### 3.3 Feature Compatibility Table (Optional) - -Only checked when model supports multiple features: - -- [ ] Compatibility matrix exists showing which feature combinations are validated -- [ ] Untested combinations marked clearly (e.g., `❓`) - -### 3.4 Usage Example Doc - -- [ ] Example doc added or updated for the new model -- [ ] Offline inference example present (with `Omni`) -- [ ] Online serving example present (with `vllm serve` + `curl`) -- [ ] At least one acceleration feature example shown -- [ ] At least one memory optimization example shown -- [ ] Generation parameters documented (resolution, steps, guidance scale) - ---- - -## Dimension 4: Test Coverage - -**Find test files:** -```bash -gh pr view --repo vllm-project/vllm-omni \ - --json files --jq '.files[].path' | grep '^tests/' -``` - -| Test Type | Location | Required | What to Verify | -|-----------|----------|----------|----------------| -| **e2e online serving test** | `tests/e2e/online_serving/` | Yes | Start server, send request, assert output shape / non-null | -| **Offline inference test** | `tests/` or `tests/models/` | No (if e2e test exists) | Instantiate `Omni`, call `.generate()`, assert output | -| **Acceleration / memory feature test** | Alongside above | Recommended | Enable each supported feature, verify output and speed | -| **Combined feature test** | Alongside above | Required if 2+ features | Enable multiple features together, assert output + VRAM + latency | - -### 4.1 e2e Online Serving Test (Required) - -Location: `tests/e2e/online_serving/test_.py` - -- [ ] Test file exists in `tests/e2e/online_serving/` -- [ ] Test starts the server (or uses a fixture that does) -- [ ] Test sends a generation request to the API endpoint -- [ ] Test asserts response is non-null and output has correct shape/type -- [ ] Test includes at least one functional scenario (basic generation) -- [ ] Test includes at least one negative case (invalid input → 400 error) - -### 4.2 Offline Inference Test (Recommended; required only when no e2e test is present) - -- [ ] Test instantiates `Omni(model="")` -- [ ] Test calls `.generate()` with at least one prompt -- [ ] Test asserts output is a valid image/video/audio -- [ ] Test covers at least one edge case (empty prompt, special characters, max resolution) - -### 4.3 Acceleration and Memory Feature Tests (Recommended) - -- [ ] Test enables each acceleration feature and asserts output validity -- [ ] Test enables each memory optimization and asserts output validity + VRAM within budget - -### 4.4 Combined Feature Test (Required when 2+ features implemented) - -Only checked when the PR implements **two or more** acceleration or memory features: - -- [ ] Test (or an extended e2e test case) enables multiple features simultaneously -- [ ] Output under combined config is asserted as valid (quality preserved) -- [ ] Latency under combined config is reported -- [ ] VRAM under combined config is reported -- [ ] Any quality degradation under combination is explicitly documented - ---- - -## Quick Red Flags Summary - -Flag immediately and post a blocking comment if any of these are true: - -| Red Flag | Severity | Action | -|----------|---------|--------| -| No generation script in PR body | 🔴 Blocking | Request before review proceeds | -| No sample output in PR body | 🔴 Blocking | Request before review proceeds | -| No latency or VRAM measurements | 🔴 Blocking | Request before review proceeds | -| Online serving not implemented | 🔴 Blocking | Must implement both modes | -| Offline inference not implemented | 🔴 Blocking | Must implement both modes | -| Diffusers mixin still in code | 🔴 Blocking | Must remove before merge | -| No acceleration feature | 🔴 Blocking | Must implement at least one | -| No memory optimization | 🔴 Blocking | Must implement at least one | -| No e2e online serving test | 🔴 Blocking | Must add test | -| No offline inference test (and no e2e test) | 🔴 Blocking | Must add at least one test | -| No offline inference test (e2e test exists) | 💡 Recommended | Suggest, do not block | -| Model support table not updated | 🔴 Blocking | Must update docs | -| Feature support table not updated | 🔴 Blocking | Must update docs | -| No diffusers comparison | 💡 Recommended | Suggest, do not block | -| No combined feature test (2+ features) | ⚠️ Conditional | Required when 2+ features implemented | -| No usage example doc | 🔴 Blocking | Must add example | diff --git a/.claude/skills/review-pr/references/maintainer-style-study.md b/.claude/skills/review-pr/references/maintainer-style-study.md deleted file mode 100644 index 5fd51062e..000000000 --- a/.claude/skills/review-pr/references/maintainer-style-study.md +++ /dev/null @@ -1,114 +0,0 @@ -# Maintainer Review Style Study - -Calibration data from **200 DarkLight1337 (Cyrus Leung) reviews** on vllm-project/vllm plus **400+ comments** from 12 other core maintainers across vllm and vllm-omni. Use this as ground truth for how real reviews should look. - -## Reviewers Studied - -| Reviewer | Role | Sample Size | -|----------|------|-------------| -| DarkLight1337 | Core maintainer (multimodal) | ~200 reviews deep dive | -| njhill | Core maintainer (engine/perf) | ~24 inline + replies | -| jeejeelee | Model reviewer | ~11 inline | -| hmellor | Core maintainer (models/transformers) | ~9 inline | -| ProExpertProg | Core maintainer (compilation/IR) | ~14 inline | -| mgoin | Quantization/eval | ~9 inline + replies | -| WoosukKwon | Project lead | Few but high-signal | -| varun-sundar-rabindranath | Kernel reviewer | ~27 inline | -| AndreasKaratzas | ROCm CI | ~23 inline + many replies | - -## DarkLight1337 Review Body Stats - -| Pattern | Frequency | -|---------|-----------| -| Empty body (just inline comments or silent APPROVE) | ~60% | -| Ultra-short ("Thanks", "LGTM", "Some more nits") | ~25% | -| One-sentence architectural point | ~10% | -| Multi-sentence design discussion | ~5% | - -## DarkLight1337 Inline Comment Distribution - -| Type | Frequency | Examples | -|------|-----------|---------| -| Direct imperative | ~35% | "Move imports to the top", "Please keep in alphabetical order", "Revert changes to this file", "Fix this" | -| Direct question | ~25% | "Is this really needed?", "Why change this?", "Where is this defined?", "Does X not work here?" | -| Suggestion blocks | ~15% | Code fix with zero explanation text | -| "Can you/we" requests | ~10% | "Can you move X to Y?", "Can you address this?", "Can we cache this?" | -| Soft opinion | ~8% | "Tbh I think...", "I prefer...", "IMO...", "I don't like how..." | -| Ultra-short | ~7% | "Ditto", "Same", "No need", "Good catch", "Seems unused" | - -## DarkLight1337 Stock Phrases - -These are real phrases used repeatedly across 200 reviews: - -- "Is this really needed?" -- "Can you address this?" / "Please address this" -- "Seems unused" / "Looks unused" -- "Is this change related?" -- "Please keep in alphabetical order" -- "Please fix pre-commit" -- "Move imports to the top" / "Import from the top" -- "Remove the commented out code" -- "Let's keep things simple" -- "Any update?" -- "Tbh I think..." -- "I don't quite understand this" -- "Hmm... that's true, OK then" -- "Sorry for the delay!" -- "Thanks for your patience!" - -## Things DarkLight1337 Never Does - -- Never prefixes with "Nit:" -- just states the issue -- Never says "left a few comments inline" -- Never praises code structure inline ("Good placement", "Nice refactor") -- Never over-explains obvious suggestion blocks -- Never uses structured review templates (## Summary, BLOCKER tables) -- Never uses dramatic emphasis ("CRITICAL", "BREAKING") - -## Other Maintainer Patterns - -### Comment Length -- **Ultra-short (1-5 words):** "ditto", "DITTO", "Done", "Fixed", "Good catch", "nope" -- **Short (1 line):** "Can we fuse this add into norm?", "Why not use field(default_factory=...)?" -- **Medium (2-4 lines):** Typical for suggestions with brief rationale -- **Long (5+ lines):** RARE -- only for architectural discussions - -**Distribution:** ~50% ultra-short/short, ~30% medium, ~20% long - -### Reply Thread Patterns - -**Acknowledgments:** -- "Done" / "Fixed" / "Oops, fixed" -- DarkLight1337 -- "Makes sense" -- jeejeelee -- "Good catch" -- multiple reviewers - -**Pushback (direct, not hedged):** -- "This is pre-existing behavior" -- AndreasKaratzas -- "We cannot do that because of [link]" -- DarkLight1337 -- "I think you misunderstood this" -- njhill - -**Concessions:** -- "Alright, thanks for explaining" -- DarkLight1337 -- "Yeah that's fair, I didn't notice that initially" -- ProExpertProg - -### PR-Level Comments -- "cc @X" -- extremely common for tagging area owners -- "@X PTAL." -- (Please Take A Look) - -### Review Body Patterns -- "LGTM." / "Looks good." -- "this is consistent with our other models. thanks!" -- "I assume you have tested this locally." - -## Key Gaps Between AI Reviews and Real Maintainers - -| Aspect | Real Maintainers | Common AI Pattern | Fix | -|--------|-----------------|-------------------|-----| -| Review body | ~60% empty | Always writes a body | Skip body ~50% | -| "Nit:" prefix | Rarely used | Overused | Drop it -- just state the issue | -| "left X comments" | Never | Common preamble | Never say this | -| Hedging | ~15% of comments | ~50%+ | Be direct by default | -| Empty APPROVE | ~30% of approvals | Rare | Use more silent approves | -| Depth variation | 0-15 comments | Consistently 3-5 | Vary more | -| Structured templates | Never | Common (## Summary, tables) | Drop all templates | -| Inline praise | Never | Occasional | Never do it | diff --git a/.claude/skills/review-pr/references/perf-verification.md b/.claude/skills/review-pr/references/perf-verification.md deleted file mode 100644 index ffc23438b..000000000 --- a/.claude/skills/review-pr/references/perf-verification.md +++ /dev/null @@ -1,220 +0,0 @@ -# Performance & Accuracy Claim Verification - -Reviewer-side verification of contributor perf/accuracy claims. This is **blocking**: must complete before issuing a verdict. - -**Key distinction:** `tests-docs-checklist.md` Section 5 defines what the *contributor* must provide. This file defines how the *reviewer* can independently verify those claims. - -**Requires a local clone** of `vllm-project/vllm-omni`. If no clone exists, skip to static-only analysis. - ---- - -## 1. Claim Detection - -Extract quantitative claims from PR body and comments. - -### Regex patterns - -| Claim type | Pattern | Captures | -|-----------|---------|----------| -| Latency | `(\d+(?:\.\d+)?)\s*(ms|s|sec)` | value, unit | -| Throughput | `(\d+(?:\.\d+)?)\s*(tok/s|tokens/s|req/s|iters/s|qps)` | value, unit | -| VRAM | `(\d+(?:\.\d+)?)\s*(GB|MB)\s*(?:VRAM|memory|GPU)` | value, unit | -| Speedup | `(\d+(?:\.\d+)?)\s*%?\s*(?:faster|slower|speedup|reduction|improvement)` | value, direction | -| Accuracy | `(?:FID|F1|BLEU|WER|CER|psnr|ssim|accuracy|pass@k)\s*[:=]?\s*([\d.]+)` | metric, value | - -**When to activate:** PR has `[Performance]` prefix, or PR body contains 2+ matches from the patterns above, or Step 5 (Evidence) flagged missing benchmarks. - ---- - -## 2. Hardware Detection (single source of truth) - -This section is the canonical hardware detection logic. Cross-referenced by `test-quality-evaluation.md`. - -### Detection sequence - -```bash -# CUDA -if command -v nvidia-smi &>/dev/null; then - GPU_INFO=$(nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null) - if [ -n "$GPU_INFO" ]; then - GPU_COUNT=$(echo "$GPU_INFO" | wc -l | tr -d ' ') - GPU_MODEL=$(echo "$GPU_INFO" | head -1 | cut -d',' -f1 | xargs) - VRAM_PER_GPU_GB=$(echo "$GPU_INFO" | head -1 | cut -d',' -f2 | tr -d ' MiB' | awk '{printf "%.1f", $1/1024}') - PLATFORM="CUDA" - fi -fi - -# ROCm (if no CUDA) -if [ -z "$PLATFORM" ] && command -v rocm-smi &>/dev/null; then - GPU_INFO=$(rocm-smi --showmeminfo vram 2>/dev/null | grep -E "GPU|VRAM" | head -1) - # Parse ROCm output — model and VRAM extraction varies by version - PLATFORM="ROCm" -fi - -# NPU (torch-based) -if [ -z "$PLATFORM" ]; then - python3 -c "import torch_npu; print('NPU')" 2>/dev/null && PLATFORM="NPU" -fi - -# XPU (Intel) -if [ -z "$PLATFORM" ]; then - python3 -c "import torch.xpu; print('XPU')" 2>/dev/null && PLATFORM="XPU" -fi - -# CPU-only fallback -if [ -z "$PLATFORM" ]; then - PLATFORM="CPU" - GPU_COUNT=0 - VRAM_PER_GPU_GB=0 -fi -``` - -**Output variables:** `PLATFORM`, `GPU_COUNT`, `GPU_MODEL`, `VRAM_PER_GPU_GB` - ---- - -## 3. Feasibility Check - -Compare model requirements against available hardware. - -### Model size estimation - -Do NOT use parameter count × dtype bytes alone — this significantly underestimates actual VRAM: - -``` -estimated_vram_gb = ( - model_weights_gb # param_count × dtype_bytes / 1e9 - + kv_cache_gb # sequence_length × num_layers × 2 × hidden_size × dtype_bytes × batch_size / 1e9 - + activation_overhead_gb # ~20-30% of model weights for inference - + framework_overhead_gb # ~1-2 GB for CUDA context, fragmentation -) -``` - -For quick estimation when KV cache size is unknown, use a multiplier: - -| Model size | Quick estimate | -|-----------|---------------| -| < 7B params | weights × 1.5 | -| 7-14B params | weights × 2.0 | -| 14-70B params | weights × 2.5 | -| 70B+ params | weights × 3.0 | - -### Verdict - -| Condition | Verdict | -|-----------|---------| -| `estimated_vram_gb ≤ VRAM_PER_GPU_GB × GPU_COUNT` | `VERIFIABLE` | -| `estimated_vram_gb ≤ VRAM_PER_GPU_GB × GPU_COUNT × 1.5` and `--cpu-offload-gb` available | `NEEDS_OFFLOAD` | -| Otherwise | `CANNOT_VERIFY` | - -**CPU-only path:** Can verify latency/accuracy for small models (< 2B params) that fit in system RAM. Cannot measure peak VRAM. - -**No GPU path:** Cannot execute benchmarks. Proceed to static-only analysis. - ---- - -## 4. Benchmark Plan Generation - -Map PR type to benchmark runner. - -| PR type | Benchmark runner | Notes | -|---------|-----------------|-------| -| Omni models (LLM) | `Omni(model=...).generate()` with `--log-stats` | Offline; or `vllm bench serve --omni` for online | -| Diffusion models | `benchmarks/diffusion/diffusion_benchmark_serving.py` | From vllm-omni repo | -| Accuracy (GEBench/GEdit-Bench) | `benchmarks/accuracy/` scripts | From vllm-omni repo | - -### Execution strategy - -1. Create git worktrees at `.claude/perf-worktrees/base` and `.claude/perf-worktrees/pr` -2. Install vllm-omni in each worktree (or share the install if dependencies are identical) -3. Run benchmark in base worktree, capture JSON results -4. Run benchmark in PR worktree, capture JSON results -5. Compare results - ---- - -## 5. Tolerance Thresholds - -These are **configurable defaults**. Adjust based on benchmark type, model size, and input variability. - -| Metric | Default tolerance | When to tighten | When to loosen | -|--------|------------------|-----------------|----------------| -| Latency | ±10% | Microbenchmarks (< 100ms): ±20% | Large models with high variance: ±15% | -| Throughput | ±10% | High-concurrency benchmarks: ±15% | Single-request: ±20% | -| VRAM | ±5% | Small models (< 4GB): ±10% | Multi-GPU: ±10% | -| Accuracy | ±1% (absolute) | FID/SSIM: ±2% | Perplexity: ±0.5% | - -**Disclaimer:** These thresholds assume controlled benchmark conditions (same hardware, same inputs, warm-up run completed). Results outside tolerance do not automatically mean NOT_CONFIRMED — check for measurement noise, input variability, or warm-up issues first. - ---- - -## 6. Execution Limits - -- **Hard timeout:** 20 minutes per benchmark run (base or PR). If exceeded, kill the process and report partial results with a `TIMEOUT` flag. -- **Pre-execution gate:** Before starting benchmark execution, present the plan to the user: - - What benchmark will run - - Estimated duration - - Which model and hardware - - Ask for explicit confirmation -- **No confirmation or timeout:** Fall back to static-only analysis. - ---- - -## 7. Report Format - -### Claimed vs Measured table - -```markdown -## Perf Verification Report - -**Reviewer hardware:** {GPU_MODEL} × {GPU_COUNT} ({VRAM_PER_GPU_GB} GB each), {PLATFORM} -**Verification mode:** {full | partial (offload) | static-only} -**Benchmark:** {type} - -| Claim | Claimed | Measured | Delta | Verdict | -|-------|---------|----------|-------|---------| -| e2e latency | X ms | Y ms | +Z% | CONFIRMED / NOT_CONFIRMED / TIMEOUT | -| throughput | X tok/s | Y tok/s | -Z% | CONFIRMED / NOT_CONFIRMED / TIMEOUT | -| peak VRAM | X GB | Y GB | +Z GB | CONFIRMED / NOT_CONFIRMED / CANNOT_VERIFY | -``` - -### Verdict values - -| Verdict | Meaning | -|---------|---------| -| `CONFIRMED` | Measured value within tolerance of claimed | -| `NOT_CONFIRMED` | Measured value outside tolerance | -| `CANNOT_VERIFY` | Hardware insufficient (model too large, no GPU) | -| `TIMEOUT` | Benchmark exceeded 20-min limit | -| `NOT_RUN` | Benchmark not executed (user declined or no clone) | - ---- - -## 8. Graceful Degradation - -| Level | Conditions | What runs | -|-------|-----------|-----------| -| **Full verification** | GPU available, model fits in VRAM | Before/after benchmarks, full comparison | -| **Partial verification** | GPU available, model needs offload | Benchmarks with `--cpu-offload-gb`, noted in report | -| **Static-only** | No GPU or model too large | Claim detection, analyze benchmark scripts in diff for correctness, flag implausible claims (e.g., "50% speedup" from a single-threaded loop change) | -| **Skip** | No relevant perf claims in PR | Do not activate this step | - -### Static-only analysis checklist - -When benchmarks cannot run, apply these checks to the benchmark/test code in the diff: - -- [ ] Benchmark uses warm-up runs (at least 1) before timed runs -- [ ] Measurement uses `time.perf_counter()` or equivalent (not `time.time()`) -- [ ] VRAM measured via `torch.cuda.max_memory_allocated()` (not `nvidia-smi` at idle) -- [ ] Same hardware, model, inputs for before/after (not different machines) -- [ ] Multiple iterations reported (not single-run claims) -- [ ] No cherry-picked metrics (e.g., reporting best-of-5 without mentioning variance) - ---- - -## 9. Delivery - -1. **Local report first** — output the Claimed vs Measured table to the user -2. **Ask before posting** — "Post this as a PR comment? (y/n)" -3. If posting, use the existing review comment workflow (`gh api`) — this counts against the comment budget -4. If verification reveals a blocker (confirmed NOT_CONFIRMED for accuracy or VRAM regression), escalate to REQUEST_CHANGES via the normal verdict workflow diff --git a/.claude/skills/review-pr/references/review-execution.md b/.claude/skills/review-pr/references/review-execution.md deleted file mode 100644 index a1aecb622..000000000 --- a/.claude/skills/review-pr/references/review-execution.md +++ /dev/null @@ -1,577 +0,0 @@ -# Review Execution - -Use this file when you are actively running the review and need the gate checks, concrete `gh` commands, or comment-writing rules. - -## Review Gates - -Check these before deep review. If any fail, stop and post a short comment instead of doing a full review. - -| Check | Passing State | Action if Failed | -|-------|---------------|------------------| -| DCO | `SUCCESS` | Ask for signed commits with `git commit -s` | -| pre-commit | `SUCCESS` | "Please fix pre-commit" | -| mergeable | `MERGEABLE` | Ask the author to rebase and resolve conflicts | - -Command: - -```bash -gh pr view --repo vllm-project/vllm-omni --json mergeable,statusCheckRollup --jq '{mergeable, checks: [.statusCheckRollup[] | {name, conclusion}]}' -``` - -Gate-failure comment -- keep it short, no template: - -```text -DCO / pre-commit / merge conflict needs fixing before review. -``` - -## Minimal Fetch Sequence - -```bash -gh pr view --repo vllm-project/vllm-omni --json title,body,author,state,files,closingIssuesReferences -gh pr diff --repo vllm-project/vllm-omni -``` - -For linked issues: - -```bash -gh pr view --repo vllm-project/vllm-omni --json closingIssuesReferences --jq '.closingIssuesReferences[] | {number, title, body}' -gh issue view --repo vllm-project/vllm-omni --json title,body,labels,state,comments -``` - -For more code context: - -```bash -gh api repos/vllm-project/vllm-omni/contents/?ref= -gh search code --repo vllm-project/vllm-omni "class " -gh search code --repo vllm-project/vllm-omni "" --extension yaml -``` - -## Comment Budget - -| PR Shape | Inline Comments | -|----------|-----------------| -| docs-only or tiny fix | 0 -- empty APPROVE or "LGTM" | -| medium bug fix | 1-3 | -| large feature or risky refactor | 3-5 | -| **hard ceiling** | **6** | - -Budget rules: - -- Cap normal reviews at 5 inline comments. Never exceed 6. -- Merge related issues into one comment -- Skip low-confidence speculation -- If domain review already surfaced issues, skip extra comments -- **~50% of comments should be 1-line** -- suggestion blocks, "Seems unused", "ditto" -- When you have many findings, drop the least important ones - -## Comment Style (Calibrated from 200 DarkLight1337 Reviews) - -Real maintainer reviews are **direct, short, and varied**. The following rules are calibrated from a deep analysis of DarkLight1337 (Cyrus Leung) -- vllm's most active reviewer -- plus 12 other core maintainers. See [maintainer-style-study.md](maintainer-style-study.md) for the raw data. - -### Review Body - -- **~50% of reviews should have NO body** -- just inline comments with empty body string. -- When present, one line max. Vary: - - "LGTM." / "Looks good." - - "Thanks" / "Thanks for fixing!" - - "Some more nits" - - "Please fix pre-commit" - - Sometimes just a high-level architectural point with no preamble -- **Do NOT say "left a few comments" or "left a couple comments"** -- the inlines speak for themselves. -- Skip "thanks" sometimes. Lowercase is fine. - -### Inline Comment Tone - -**Default: DIRECT.** Hedging should be ~15% of comments. - -**For clear issues:** -- Direct statement: "This won't work when X is None." / "Seems unused" -- Direct question: "Is this really needed?" / "Where is this defined?" -- Imperative: "Please keep in alphabetical order" / "Move imports to the top" -- "Can you..." request: "Can you address this?" / "Can you move X to Y?" - -**For uncertain findings only:** -- "Tbh I think..." / "Not sure if this is intentional --" - -**For trivial issues:** -- Do NOT prefix with "Nit:" -- just state it. "Extra whitespace." not "Nit: extra whitespace." -- "ditto" / "same" when repeating -- suggestion block with no explanation text - -**Recurring patterns (from DarkLight1337):** - -| Context | Phrase | -|---------|--------| -| Imports | "Move imports to the top" | -| Ordering | "Please keep in alphabetical order" | -| Dead code | "Seems unused" / "Remove the commented out code" | -| Scope creep | "Is this change related?" | -| Pre-commit | "Please fix pre-commit" | -| Follow-up | "Can you address this?" / "Any update?" | -| Design | "Let's keep things simple" / "I prefer X" / "IMO..." | - -### Banned Patterns - -- Generic praise: "Good placement", "Well structured", "Nice refactor" -- Sycophantic openers: "Thanks for tackling this", "Great work" -- Dramatic emphasis: "CRITICAL", "BREAKING", all-caps -- Over-hedged: "I noticed X -- would it perhaps make sense to consider Y instead?" -- Structured templates in comment body (## Summary, bullet-point verdicts) -- "left a few comments inline" (unnecessary preamble) -- "Nit:" prefix (just state the issue directly) - -### Good Examples - -**Ultra-short (~50% of comments):** - -``` -Seems unused. -``` - -``` -ditto -``` - -``` -Is this really needed? -``` - -**Direct:** - -``` -This won't work for multimodal models -- `get_text_config()` accesses `text_config` during `super().__init__()`. -``` - -``` -Why not use `field(default_factory=...)` here? -``` - -**Imperative:** - -``` -Please fix pre-commit -``` - -``` -Revert changes to this file -``` - -**Soft opinion (for design):** - -``` -Tbh I think we can replace this whole block with cached_feature_extractor_from_config. -``` - -### Follow-Up Replies - -When a contributor replies, **always reply back**. Silence is the #1 giveaway of a non-human reviewer. - -- Acknowledge: "Makes sense" / "Fixed" / "Done" / "thanks!" -- Concede: "Hmm... that's true, OK then" / "Fair enough" -- Push back: "This is pre-existing behavior" / "We cannot do that because of [link]" -- Self-correct: "Oops, fixed" / "Good catch" - -Keep replies to 1 sentence. Never a paragraph. - -## Review Submission - -Post inline comments directly to GitHub as you find them. Do **not** submit a review event (APPROVE / COMMENT / REQUEST_CHANGES) — leave the verdict decision to the user. Present the recommended verdict locally in the conversation instead. - -Post review with inline comments. The `body` field can be empty string for ~50% of reviews. - -```bash -gh api repos/vllm-project/vllm-omni/pulls//reviews --method POST --input - <", - "event": "COMMENT", - "body": "", - "comments": [ - {"path": "", "line": , "side": "RIGHT", "body": ""} - ] -} -EOF -``` - -### Inline Comment Line Accuracy - -**Comments MUST land on the exact line they discuss.** Off-by-2-5 errors look sloppy. - -How to get the correct line number: -1. Fetch the diff: `gh pr diff {N} --repo vllm-project/vllm-omni` -2. Read the hunk header: `@@ -old_start,old_count +new_start,new_count @@` -3. Count from `new_start`: context lines increment both counters, `+` lines increment new only, `-` lines increment old only -4. The `line` parameter = **new-file line number** of the exact line you're commenting on -5. **Verify:** grep the diff for the exact code string and confirm the line number matches - -Common mistakes: -- Using diff sequential position instead of new-file line number -- Estimating from nearby code instead of counting exactly -- Commenting about `clamp()` but landing on `offsets =` two lines above - -### Review Event - -- `COMMENT` for most reviews -- `APPROVE` when code is clean -- use empty body for ~30% of approvals -- `REQUEST_CHANGES` only for genuine blocking bugs (crashes, data loss, security) - ---- - -## Batch and daily review sessions - - -How to run a review session: select PRs, review them with varied depth, track state, and follow up on replies. - -### Daily Review Session - -### 1. Check replies first (highest priority) - -Before reviewing new PRs, check for unanswered contributor replies: - -```bash -./scripts/check_replies.sh --reviewer --days 14 -``` - -Reply to each one. Keep replies short: -- "Makes sense" / "Fixed" / "Done" / "thanks!" -- "Hmm... that's true, OK then" / "Fair enough" -- "This is pre-existing behavior" - -Silence after engagement is the #1 giveaway of a non-human reviewer. - -### 2. Select PRs to review - -```bash -./scripts/select_prs.sh --days 7 --limit 5 --reviewer -``` - -This gives you 3-5 PRs prioritized by zero reviews. Adjust `--days` and `--limit` as needed. - -Manual filtering -- skip these: -- `[WIP]` / `[Draft]` / `[Don't merge]` in title -- Pure CI config / docs-only changes (unless they're substantial) -- PRs with 3+ existing reviews from maintainers -- Your own PRs - -### 3. Review with varied depth - -NOT every PR gets the same treatment. Vary intentionally: - -| PR Type | Depth | Example | -|---------|-------|---------| -| Obvious small fix | Empty APPROVE | Click approve, no text | -| Clean bug fix | "LGTM" + 0-1 inline | One-liner body, maybe one nit | -| Medium feature | 2-3 inlines, no body | Just the inline comments | -| Large/risky change | 3-5 inlines + short body | "a few questions about X" | -| Copy-paste new model | REQUEST_CHANGES with specifics | Flag missing tests, broken weights | - -**Target distribution per session:** -- 1-2 PRs: empty or near-empty APPROVE -- 2-3 PRs: 2-4 inline comments -- 0-1 PRs: 5+ comments (only for genuinely complex changes) - -### 4. Post reviews with line verification - -Before posting each review, verify line numbers: - -```bash -echo "$REVIEW_JSON" | ./scripts/verify_line_numbers.sh -``` - -This catches off-by-N errors where comments land on the wrong line. - -### 5. Log what you reviewed - -Keep a simple log for dedup and follow-up tracking: - -``` -## 2026-04-02 -| PR | Author | Comments | Event | -|----|--------|----------|-------| -| #2433 | alex-jw-brooks | 1 | APPROVE | -| #2399 | oscardev256 | 5 | REQUEST_CHANGES | -| #2390 | bjf-frz | 4 | REQUEST_CHANGES | -``` - -### Pacing Rules - -- **Max 3-5 PRs per day.** 34 PRs in 3 days was flagged as suspicious. -- Space reviews out -- not all in one burst. -- Some days, just do reply follow-ups with no new reviews. -- Skip days occasionally -- real reviewers don't review every day. - -### Re-Review Protocol - -When a contributor pushes new commits or asks for re-review: - -1. Check if they addressed your previous comments (read thread replies + new commits) -2. If all resolved: APPROVE. Body: "LGTM" or "looks good now" or empty. -3. If some remain: comment only on unresolved items. Don't re-review from scratch. -4. If new code added: review only the new changes. - -Re-reviews should almost always be shorter than the initial review. - -### Staleness Rules - -- **Contributor stops responding (>7 days):** One ping: "Any updates on this?" -- **PR stale (>14 days):** Move on. -- **PR superseded:** "Looks like this is superseded by #X?" -- **PR closed:** No action. - ---- - -## CI failure and duration triage - -### Quick Start - -When a user reports CI is **failing (red) / flaky / noticeably slower** and provides logs: - -1. Focus only on the **first error** (the earliest fatal signal). Don’t get distracted by cascading follow-up errors. -2. Extract: job name/level, the stage/step where the first error occurs, exit code/exception stack, whether it’s a timeout, and per-stage durations (if available). -3. Classify into one of five categories: **build/install**, **test failure**, **infrastructure**, **timeout/perf regression**, **config/environment**. -4. Provide **1–3** root-cause hypotheses. Each must include an **exact log evidence excerpt**, and hypotheses must be ordered **from lowest verification cost to highest**. -5. Provide a **≤5-minute** minimal verification for **Hypothesis 1** only. Specify **environment + commands + expected result** (must not require running the full pipeline). - -### Log-reading guardrail (must follow) - -Do **not** triage by reading only the log tail. Many CI logs end with teardown noise, process-kill cascades, or warning lines that are not the first failure. - -Required sequence: - -1. Fetch the **full raw log** first (or confirm whether the current log view is truncated). -2. Locate pytest failure anchors before reading linearly: - - `=========== FAILURES ===========` - - `short test summary info` - - first `FAILED tests/...` or first `Traceback` with assertion details -3. If you must inspect by line number, jump to the user-provided line and then read **both directions** (at least ±100 lines). -4. Treat warning-only lines (e.g., ffmpeg options, deprecation warnings) as non-fatal unless they are immediately followed by a fatal exit/assertion. -5. Report the **earliest fatal signal** (assertion/exception/exit reason), not the last error-looking line in teardown. - -If only a partial/truncated log is available, explicitly state: -- “cannot attribute from current logs: raw log appears partial/truncated” -- and request the raw/full log or the missing window around the first failure block. - -### Required inputs (list what’s missing if not provided) - -- Job name and type (deploy / L1–L5 / other) -- Logs: **50–100 lines before and after the first error** (or the full log) -- Change: PR link or commit SHA (if unknown, explicitly mark as “unknown”) -- CI environment info (runner/image/Python/CUDA, etc.; cite from logs if present) - -### Decision tree (branch on the first error) - -- **Build/install failures** - - Common signals: `SyntaxError`, compiler `error:`, `ld:`/`linker`, `undefined reference`, `CMake Error`, `nvcc fatal`, `ModuleNotFoundError`, `ImportError`, `pip install` failures, `Failed building wheel`, `No matching distribution found` -- **Test failures** - - Common signals: pytest `FAILED`, `AssertionError`, `E assert ...`, traceback pointing to a `tests/...` line, or still failing after flaky retries - - Sub-classify the test failure as one of: - - **Functional test** (feature behavior, API contract, workflow correctness, edge/error handling) - - **Performance test** (latency/throughput/runtime/memory regression, perf guardrails) - - **Accuracy test** (model output quality, numerics, golden outputs, tolerance) -- **Infrastructure issues** - - Common signals: `Timeout`/`timed out`, `Killed`/`SIGKILL`, `OOM`/`Out of memory`, `No space left on device`, `Disk quota exceeded`, `Connection reset`, `TLS handshake`, `503`/`429`, image pull failures -- **Timeout/performance regressions** - - Common signals: a stage/step duration increases significantly in logs/summary; approaches timeout threshold; or long periods with no output -- **Configuration/environment issues** - - Common signals: `Permission denied`, `AccessDenied`, `401/403`, `missing required env`, `KeyError: `, secrets/tokens not injected, `could not read credentials` - -### Test failure sub-classification: functional vs performance vs accuracy - -When classification is **test failure**, you must add a sub-type: **functional**, **performance**, or **accuracy**. - -### Functional test - -Use **functional** when the first failure is about expected behavior, API contract, control flow, or error handling correctness. - -Common signals (look for these near the first error): - -- API/contract behavior mismatches: wrong status/code/message, missing keys/fields, schema mismatches -- Workflow/logic mismatches: branch conditions, retries/fallbacks/tool calls, state transitions not matching expected behavior -- Edge/error path checks: invalid input handling, exception type/message mismatch, timeout/error propagation assertion failures -- Integration behavior checks: mocked dependency interactions, call order/count assertions, side-effect checks (file/db/message) - -Evidence pattern: - -- The failure line typically includes **behavioral assertions** (state/output/exception/call sequence), not metric thresholds. -- The traceback points into tests validating endpoint behavior, pipeline flow, or business logic expectations. - -### Accuracy test - -Use **accuracy** when the first failure is an assertion about output quality, score, or numeric tolerance. - -Common signals (look for these near the first error): - -- Golden / expected output mismatches: `expected`, `got`, `mismatch`, `diff`, `golden`, `baseline`, `reference`, `snapshot` -- Numeric tolerance issues: `atol`, `rtol`, `tolerance`, `allclose`, `max_abs_err`, `cosine`, `psnr`, `ssim` -- Quality metric regressions: `accuracy`, `bleu`, `rouge`, `wer`, `cer`, `mAP`, `F1`, `pass@k` (or similar task metrics) -- Determinism drift often shows up as: `seed`, `random`, `nondeterministic`, `torch.backends.cudnn.deterministic` - -Evidence pattern: - -- The failure line typically includes **an assertion and compared values/metrics**, not runtime thresholds. -- The traceback points into a test that computes a metric or compares outputs against a known-good reference. - -### Performance test - -Use **performance** when the first failure is a regression check on runtime/throughput/latency/memory, or when the test is explicitly a perf guardrail. - -Common signals: - -- Runtime thresholds: `took`, `elapsed`, `timeout`, `exceeded`, `slower`, `regression`, `p95`, `p99`, `latency`, `throughput`, `tok/s`, `tokens/s`, `iters/s`, `qps` -- Benchmark-style naming: `benchmark`, `perf`, `performance`, `microbench`, `speed`, `profile` -- Resource guardrails: `peak memory`, `RSS`, `VRAM`, `cuda memory`, `OOM` *inside the test assertion* (not runner OOM) - -Evidence pattern: - -- The failure line usually includes a **measured value vs threshold/baseline**, e.g. “X is 1.4× slower than baseline” or “p95 latency > limit”. - -### Tie-breakers (when logs are ambiguous) - -- If the first error references **time/throughput/memory limits**, treat as **performance**. -- If the first error is about **quality scores, numeric tolerance, or golden/reference output**, treat as **accuracy**. -- If the first error is about **API contract, workflow logic, exception handling, or integration behavior**, treat as **functional**. -- If the job fails by **global timeout** (no assertion, runner killed), classify as `timeout/perf regression` (not test failure). - -### Output (must use this template) - -Rules: - -- Hypotheses must be grounded in log facts. If there’s no evidence, write “cannot attribute from current logs” and list what additional info is needed. -- For duration issues, explicitly state: **stage name + baseline vs current run**. -- If there are multiple hypotheses, mark priority (usually ordered by verification cost from low to high). - -```markdown -## CI Triage Report - -- **Job**: / / -- **Change**: -- **Classification**: -- **Test sub-type (only if test failure)**: - -### First error - -- **Location**: -- **Excerpt**: -``` - -``` - -### Duration (if relevant) - -- **Anomalous stage**: -- **Baseline vs current**: or -- **Notes**: - -### Root-cause hypotheses (ordered by verification priority) - -**Hypothesis 1 (verify first)** -- **Description**: -- **Evidence**: -``` - -``` - -**Hypothesis 2** -- **Description**: … -- **Evidence**: … - -(Optional hypothesis 3) - -### Minimal verification plan (for Hypothesis 1) - -- **Environment**: -- **Steps**: - 1. `` - 2. `` -- **Expected result**: - -### Recommended actions - -- If verification **confirms**: -- If verification **does not confirm**: -- If it’s **infra/environment**: -``` - -### Linking CI failures to a specific change - -When you triage a CI failure from Buildkite (for example -`https://buildkite.com/...`), you should -always first identify **which change** the build is running: - -- **Branch / commit**: at the top of the Buildkite job page you will see something like - `Example:main / xxxx (#xxxx)`. - - `Example:main` is the branch. - - `xxxx` is the short commit SHA. - - `#xxxx` is the PR number. -- Use these links to decide whether the failure is: - - **Change-induced**: the failure only appears on this PR/commit, and does not - reproduce on the current `main` (or the base branch). - - **Pre‑existing or infra**: the same job is already red/flaky on `main` or on - unrelated PRs. - -Recommended checks: - -1. Open the **commit link** and quickly scan the diff for files directly related to the - failing job (e.g., TTS tests vs. engine code). -2. Open the **PR link** to see title, description, and any explicit claims (perf, - correctness, infra, etc.). -3. Optionally compare with a recent **green run on `main`** for the same job to see - whether the failure pattern is new. - -When you fill in the triage template above, use: - -- `Change`: set to the PR or full SHA (e.g. `#xxxx / xxxx`). -- In **Recommended actions**, explicitly say whether the evidence points to “regression - introduced by this PR/commit” vs. “likely pre‑existing / infra issue”. - -### Additional resources - -- L1–L5 levels and directory conventions: `https://github.com/vllm-project/vllm-omni/blob/main/docs/contributing/ci/CI_5levels.md` - - ---- - -## Python style (review flags) - -*This section replaces the former standalone `python-style-guide.md` — use it for consistent style nits (imports, naming, bare `except`, etc.).* - -Key rules to check when reviewing Python code in vLLM-OMNI. Based on Google Python Style Guide. - -### Imports -- Group order: `__future__` > stdlib > third-party > repo sub-packages -- Sort lexicographically within groups -- Use `import x` for packages/modules, `from x import y` for specific names -- No relative imports; use full package paths -- Never `import x, y` on one line - -### Naming -- Modules/packages: `lower_with_under` -- Classes/Exceptions: `CapWords` -- Functions/methods/variables: `lower_with_under` -- Constants: `CAPS_WITH_UNDER` -- No type info in variable names (no `id_to_name_dict`) - -### Formatting -- Max line length: 80 chars (exceptions: imports, URLs) -- 4 spaces indent, never tabs -- Use implicit line joining inside `()`, `[]`, `{}` -- Trailing commas when closing bracket is on separate line - -### Common Review Flags -- `import math` inside function body -- "Move imports to the top" -- Imports not in alphabetical order -- "Please keep in alphabetical order" -- Mutable default arguments (`def f(x=[])`) -- always flag -- Bare `except:` or `except Exception: pass` -- always flag -- `logger.info(f"...")` -- should use `logger.info("...: %s", val)` for lazy formatting -- `+=` in loops for string concat -- use `''.join()` or `io.StringIO` -- `if len(seq):` -- should be `if seq:` -- `if x == None:` -- should be `if x is None:` - ---- - -## Specialized Verification References - -For PRs that require deeper automated verification beyond the standard blocker scan and evidence request: - -- **Perf/Accuracy claim verification:** [perf-verification.md](perf-verification.md) — Detects quantitative claims in PR body, checks hardware feasibility, runs before/after benchmarks via git worktrees, produces Claimed vs Measured comparison. Graceful degradation to static-only when hardware is insufficient. Used in Step 6 of the main workflow. - -- **Test quality evaluation:** [test-quality-evaluation.md](test-quality-evaluation.md) — Evaluates test assertion quality, anti-patterns, marker compliance, and edge case coverage. Runs affected tests with hardware-aware filtering. Produces internal quality assessment (not posted to PR). Used in Step 7 of the main workflow. diff --git a/.claude/skills/review-pr/references/review-routing.md b/.claude/skills/review-pr/references/review-routing.md deleted file mode 100644 index 373a5fe9d..000000000 --- a/.claude/skills/review-pr/references/review-routing.md +++ /dev/null @@ -1,93 +0,0 @@ -# Review Routing - -Use this file when the main review skill needs help deciding which domain skill, secondary skill, or optional specialized reviewer to involve. - -## Prefix Routing - -| PR Prefix | Primary Skill | Main Review Focus | -|-----------|---------------|-------------------| -| `[Image]`, `[ImageGen]` | `vllm-omni-image-gen` | Generation quality, diffusion settings, VRAM use | -| `[Video]`, `[VideoGen]` | `vllm-omni-video-gen` | Temporal consistency, throughput, frame pipeline | -| `[Audio]`, `[TTS]` | `vllm-omni-audio-tts` | Audio quality, latency, streaming behavior | -| `[Multimodal]` | `vllm-omni-multimodal` | Cross-modal correctness, shared processor behavior | -| `[Distributed]` | `vllm-omni-distributed` | Scaling, OmniConnector, multi-node invariants | -| `[Quantization]` | `vllm-omni-quantization` | Quality loss, loader compatibility, memory claims | -| `[Performance]` | `vllm-omni-perf` | Benchmarks, latency, throughput, cache tuning | -| `[Hardware]` | `vllm-omni-hardware` | Backend compatibility, device guards, platform assumptions | -| `[API]` | `vllm-omni-api` | OpenAI compatibility, request validation, response behavior | -| `[CI]` | `vllm-omni-cicd` | Pipeline correctness, deployment safety | -| `[Model]` | `vllm-omni-contrib` | Model integration patterns, tests, config wiring | -| `[Bug]`, `[Bugfix]` | none by default | Use [tests-docs-checklist.md](tests-docs-checklist.md) for regression and coverage evidence | -| `[Refactor]` | none by default | Behavior preservation and invariant drift | -| `[Feature]` | none by default | Acceptance criteria, docs, tests | - -## Multi-Skill Routing - -Use one primary skill and add a secondary skill only when the diff crosses a true subsystem boundary. - -| Scenario | Primary | Secondary | -|----------|---------|-----------| -| `[Performance]` + `[Distributed]` | `vllm-omni-perf` | `vllm-omni-distributed` | -| `[Performance]` + `[Model]` | `vllm-omni-perf` | `vllm-omni-contrib` | -| `[Model]` + `[Quantization]` | `vllm-omni-contrib` | `vllm-omni-quantization` | -| `[Feature]` + `[API]` | `vllm-omni-api` | none in most cases | -| `[Distributed]` + `[Hardware]` | `vllm-omni-distributed` | `vllm-omni-hardware` | - -## Hardware Detection - -Load `vllm-omni-hardware` when the diff shows backend-specific code even if the title prefix does not. - -Patterns worth flagging: - -- `is_npu` -- `is_cuda` -- `torch.cuda` -- `torch_npu` -- device-specific literals such as `cuda:0` - -Review concerns: - -- missing non-CUDA fallback paths -- platform-specific ops without guards -- hardcoded device assumptions -- memory handling that differs across platforms - -## Delegation Triggers - -Treat specialized reviewers as optional integrations. If the runtime has no `Agent(...)` or subagent tool, do the same checks manually and do not block on delegation. - -| Trigger | Optional reviewer if available | Manual review focus | -|---------|--------------------------------|---------------------| -| new or changed `try/except` blocks | `pr-review-toolkit:silent-failure-hunter` | swallowed exceptions, empty fallbacks, missing logs, bad retry behavior | -| new `@dataclass` or `TypedDict` | `pr-review-toolkit:type-design-analyzer` | invariants, missing validation, unsafe defaults, optional-vs-required fields | -| test files changed | `pr-review-toolkit:pr-test-analyzer` | coverage gaps, unrealistic mocks, missing regression cases, weak assertions | -| `vllm_omni/entrypoints/` changes | `code-reviewer` | input validation, abuse resistance, unsafe parameter passthrough, bad error surfaces | -| config or validation code changes | `code-reviewer` | validation completeness, backward compatibility, edge cases, default handling | - -Delegation limits: - -- Max 2 delegated reviewers per PR -- Skip delegation for docs-only PRs -- Skip delegation for small PRs unless the risk is unusually high -- Delegated findings still count against the total comment budget - -If no delegation tool exists: - -- Apply the manual focus column directly during review -- Keep the same 5-comment budget -- Do not mention missing reviewer tooling in the PR unless the user explicitly asks - -## Context Expansion Rules - -Fetch more context when one of these is true: - -- linked issue contains the actual acceptance criteria -- the diff changes shared infrastructure with prior art in adjacent PRs -- three lines of diff do not show cleanup, lifecycle, or invariant handling -- benchmark or quality claims reference data not included in the PR - -Keep expansion bounded: - -- 2-3 linked issues max -- 5 related PRs per important file max -- 3-5 code context fetches per review diff --git a/.claude/skills/review-pr/references/test-quality-evaluation.md b/.claude/skills/review-pr/references/test-quality-evaluation.md deleted file mode 100644 index f55c828b5..000000000 --- a/.claude/skills/review-pr/references/test-quality-evaluation.md +++ /dev/null @@ -1,170 +0,0 @@ -# Test Quality Evaluation - -Reviewer-side evaluation of test quality in PRs. This is **blocking**: must complete before issuing a verdict. - -This is distinct from the blocker scan's binary "tests exist?" check. This evaluates *whether the tests would actually catch bugs*. - -**Requires a local clone** of `vllm-project/vllm-omni` for runtime analysis. Static analysis runs without a clone. - ---- - -## 1. Hardware Detection - -See [perf-verification.md](perf-verification.md) Section 2 for the canonical hardware detection logic. Same `PLATFORM`, `GPU_COUNT`, `GPU_MODEL`, `VRAM_PER_GPU_GB` variables are used here. - ---- - -## 2. Static Analysis (always runs) - -Runs on the diff itself — no clone or hardware required. - -### 2.1 Assertion Quality - -**Flag these:** - -| Anti-pattern | Example | Why it's a problem | -|-------------|---------|-------------------| -| `assert True` | `assert result is not None` | Passes for any non-None value, including wrong results | -| No assertion at all | Function called, return value discarded | Test never fails — it's dead code | -| Bare `pass` in test body | `def test_something(): pass` | Test does nothing | -| Asserts implementation detail | `assert len(internal_cache) == 3` | Breaks on refactors, tests coupling not behavior | -| Float equality | `assert output == 0.123` | Floating point noise causes flaky failures | - -### 2.2 Anti-Patterns - -| Pattern | Detection | Severity | -|---------|-----------|----------| -| No explicit assertions | Test function has no `assert`/`pytest.raises`/`AssertionError` | High | -| Swallowed errors | `try/except` in test without `pytest.raises` | High | -| Run-level conditional assertions | `if RUN_LEVEL > 1: assert ...` (test always passes at L1) | Medium | -| Hardcoded model names | `model = "Qwen/Qwen2.5-Omni-7B"` without fixture/parametrize | Low | -| Missing `xfail`/`skipif` for known failures | Test expected to fail but not marked | Medium | -| State leakage between tests | Shared mutable fixtures without cleanup | High | - -### 2.3 Marker Compliance - -Check that test markers match the repo's CI conventions. Reference: `https://docs.vllm.ai/projects/vllm-omni/en/latest/contributing/ci/tests_markers/` - -| Marker | Expected usage | -|--------|---------------| -| `@pytest.mark.core_model` | Tests using small/supported models that run in CI L1-L2 | -| `@hardware_test(res=..., num_cards=...)` | Tests requiring specific GPU resources | -| `@pytest.mark.huge_model` | Tests requiring large models (70B+) | -| `@pytest.mark.skipif(condition)` | Platform-specific skips | -| Custom run-level markers | Per CI level configuration | - -**Check:** New tests have appropriate markers. Unmarked tests with large models or multi-GPU will fail in CI. - -### 2.4 Edge Case Coverage - -Scan for coverage of: - -- Error paths: invalid inputs, wrong types, empty strings, None values -- Boundary conditions: batch_size=0, sequence_length=1, max dimensions -- Concurrent access: multiple simultaneous requests (for server/entrypoint tests) -- Cleanup: resources freed in error paths, no dangling connections - ---- - -## 3. Runtime Analysis (hardware-dependent) - -### 3.1 Find affected test files - -```bash -# Changed test files -CHANGED_TESTS=$(git diff --name-only ... -- 'tests/') - -# Source files that changed -CHANGED_SRC=$(git diff --name-only ... -- 'vllm_omni/' | grep -v '__pycache__') - -# Map source → test files via grep (more robust than path convention) -for src_file in $CHANGED_SRC; do - module=$(echo "$src_file" | sed 's|/|.|g; s|\.py$||; s|^vllm_omni\.||') - # Find test files that import this module - grep -rl "from vllm_omni\.$module\|import vllm_omni\.$module" tests/ 2>/dev/null -done | sort -u -``` - -### 3.2 Hardware-aware filtering - -Match test markers against available hardware (from [perf-verification.md](perf-verification.md) Section 2): - -| Marker requirement | Action when hardware unavailable | -|-------------------|--------------------------------| -| `num_cards=4` but reviewer has 2 | Skip, note in report | -| `@pytest.mark.H100` on non-H100 | Skip, note in report | -| `@hardware_test(res="1024x1024")` but insufficient VRAM | Skip, note in report | -| `@pytest.mark.core_model` | Always runnable (fits on any GPU) | -| `@pytest.mark.huge_model` | Skip unless 80GB+ GPU available | - -### 3.3 Run tests - -```bash -pytest \ - --run-level core_model \ - -v \ - --tb=short \ - --timeout=60 \ - -x 2>&1 | tee test_output.log -``` - -Use `core_model` by default. Use `advanced_model` only when hardware is sufficient and tests require it. - -### 3.4 Categorize failures - -| Category | Indicators | Action | -|----------|-----------|--------| -| **Test bug** | Test logic is wrong, assertion checks wrong value | Non-blocking suggestion | -| **Code bug** | Test reveals actual issue in PR code | Blocking — REQUEST_CHANGES | -| **Infrastructure** | Missing dependency, port conflict, GPU OOM | Skip, note in report | -| **Flaky** | Inconsistent pass/fail across runs | Note as flaky, do not block | - -### 3.5 Runtime signals - -- **Slow tests (>60s):** Flag — may indicate resource contention or inefficient test setup -- **GPU memory leaks:** Check `torch.cuda.max_memory_allocated()` trend across tests — if it grows monotonically, there's a leak -- **Skipped tests:** Report count and reasons (especially hardware-related skips) - ---- - -## 4. Quality Assessment (internal use) - -This assessment is for the **reviewer's internal analysis** — do not post the full assessment on the PR. Instead, flag the worst 1-2 issues as inline comments (counting against the comment budget). - -### Assessment dimensions - -| Dimension | A | B | C | D | -|-----------|---|---|---|---| -| **Assertion quality** | Asserts specific expected values with tolerances | Asserts output shape/type but not value | Only `assert not None` or `assertTrue(result)` | No assertions or bare `pass` | -| **Edge case coverage** | Error paths + boundary + concurrent | Error paths + boundary | Only error paths | Happy path only | -| **Marker compliance** | All tests properly marked | Minor gaps (1-2 unmarked) | Significant gaps | No markers or wrong markers | -| **Anti-patterns** | None found | Minor (1 non-critical) | Moderate (2-3 issues) | Severe (no assertions, swallowed errors) | - -### How to use - -1. Score each dimension A-D -2. Identify the worst dimension — that's the most actionable feedback -3. If any dimension is D, that's a blocker (tests won't catch real bugs) -4. Convert the worst 1-2 findings into specific inline comments for the PR - ---- - -## 5. When to Activate - -| PR characteristic | Action | -|-------------------|--------| -| Adds or modifies test files | Full analysis (static + runtime if hardware matches) | -| Touches core code (`engine/`, `stages/`, `connectors/`) without adding tests | Static analysis of existing tests for the changed area + flag missing coverage | -| Test-only PR | Full analysis — test quality IS the review | -| Doc-only PR | Skip | -| Config-only PR | Skip | - ---- - -## 6. Delivery - -1. **Local report first** — output assessment and findings to the user -2. **Ask before posting** — "Post test quality findings as PR comments? (y/n)" -3. If posting, convert findings to inline comments (max 2) — counts against comment budget -4. If a D-grade dimension or code bug is found, escalate to REQUEST_CHANGES via normal verdict workflow -5. Always report which tests were skipped due to hardware constraints diff --git a/.claude/skills/review-pr/references/tests-docs-checklist.md b/.claude/skills/review-pr/references/tests-docs-checklist.md deleted file mode 100644 index 7b94ec5ae..000000000 --- a/.claude/skills/review-pr/references/tests-docs-checklist.md +++ /dev/null @@ -1,111 +0,0 @@ -## PR Tests & Docs Review Addendum - -This reference adds two structured outputs for `vllm-omni-review`: - -- Coverage matrix (change point → existing tests → gap → minimal fix) -- PR description checklist (environment + runtime estimate + fill-in template) - -### 1) Coverage Matrix (required for high-risk changes) - -Use this format. Keep it short and actionable. - -- Change point: - - What changed: - - Risk if broken: - - Where it lives (paths/modules): -- Existing tests: - - Unit tests: - - E2E tests (`tests/e2e/`): - - Example/gate tests (if any): -- Gaps: - - Missing behavior coverage: - - Missing failure/boundary case: - - Missing regression (for bugfix): -- Minimal add: - - Suggested test file(s): - - Suggested test cases (1–3 bullets): - - Suggested assertions (stable, deterministic): - -### 2) Style / Tag / Stability Checklist (quick pass) - -- Markers/labels follow repository CI docs and are justified (no marker sprawl). -- Assertions are stable (avoid external network/time/randomness). -- Numeric assertions avoid direct float `==` / `!=` and use tolerances/approx checks. -- Test names and failure messages are readable and help locate the issue quickly. - -### Optional References (use as needed) - -- CI test levels: `https://docs.vllm.ai/projects/vllm-omni/en/latest/contributing/ci/CI_5levels/` -- Test markers: `https://docs.vllm.ai/projects/vllm-omni/en/latest/contributing/ci/tests_markers/` -- Tests entry point: `https://github.com/vllm-project/vllm-omni/tree/main/tests` -- For anything else, open the most relevant pages under `vllm-omni/docs` based on the PR's change points. - -### 3) Docs Sync Checklist (examples ↔ docs) - -- If `examples/` README/docs were changed, ensure the corresponding `docs/` entry points are updated (avoid stale user-facing docs). If the repository uses MkDocs, run `mkdocs serve` to preview the docs site locally and verify the navigation/entry pages reflect the changes. -- If a new model/feature/parameter/default changed, ensure `vllm-omni/docs` includes: - - What it is / how to use - - Constraints and known limitations - - Minimal runnable example (when appropriate) - -### 4) PR Description Checklist (environment + runtime) - -Ensure the PR description includes: - -- Required hardware/environment: - - CPU/GPU type, VRAM, CUDA/driver (or ROCm/NPU/XPU), OS - - Python/vllm/vllm-omni version, key package versions (if relevant) -- What was run: - - Commands (exact) - - Expected outputs (brief) -- Runtime estimate: - - Rough duration (order of magnitude is enough) - -Fill-in template (2–3 lines): - -``` -Test env: , , , Python -Commands: ; -Runtime: ~ min -``` - -### 5) Performance Comparison Test Checklist - -**Required for:** `[Feature]` PRs that affect performance characteristics, and all `[Performance]` PRs. - -Before approving, verify the PR includes performance comparison tests that measure the change against baseline (without the change). - -**Minimum Requirements:** - -- [ ] **Before/after benchmark** — Quantitative comparison on same hardware -- [ ] **Consistent environment** — Same GPU, driver, model, batch size, resolution/steps for both runs -- [ ] **Key metrics reported:** - - [ ] Latency (e2e generation time) - - [ ] Throughput (requests/sec or tokens/sec, where applicable) - - [ ] Peak memory usage (VRAM in GB) -- [ ] **Methodology documented** — Commands, parameters, prompts/dataset used - -**Evidence format to request when missing:** - -``` -⚠️ **Performance Comparison Test Required** - -This PR includes a [feature/performance enhancement] that may affect performance. -Please provide benchmark comparison: - -| Metric | Baseline (w/o change) | With Change | Delta | -|------------------|----------------------|-------------|-------| -| Latency (e2e) | ms | ms | +/- % | -| Throughput | req/s | | +/- % | -| Peak VRAM | GB | GB | +/- % | - -Test environment: , , , -Commands: -``` - -**Exceptions:** -- Doc-only or config-only changes without performance impact -- Bug fixes that only correct logic without changing performance characteristics -- Changes gated behind a new flag that defaults to disabled (document expected perf when enabled) - -**Reviewer-side verification:** For independently verifying contributor perf claims (running benchmarks yourself), see [perf-verification.md](perf-verification.md). This checklist defines what contributors must provide; that reference defines how reviewers can verify it. diff --git a/.claude/skills/review-pr/scripts/check_replies.sh b/.claude/skills/review-pr/scripts/check_replies.sh deleted file mode 100644 index acd7d9b7e..000000000 --- a/.claude/skills/review-pr/scripts/check_replies.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -# check_replies.sh — Find unanswered contributor replies to your review comments. -# -# Usage: ./check_replies.sh --reviewer lishunyang12 [--days 14] -# -# Scans PRs you've reviewed for threads where a contributor replied -# but you haven't responded yet. Outputs actionable list. - -set -euo pipefail - -REPO="vllm-project/vllm-omni" -REVIEWER="" -DAYS=14 - -while [[ $# -gt 0 ]]; do - case $1 in - --reviewer) REVIEWER="$2"; shift 2 ;; - --days) DAYS="$2"; shift 2 ;; - *) echo "Unknown arg: $1" >&2; exit 1 ;; - esac -done - -if [ -z "$REVIEWER" ]; then - echo "Usage: $0 --reviewer " >&2 - exit 1 -fi - -SINCE=$(date -d "-${DAYS} days" +%Y-%m-%d 2>/dev/null || date -v-${DAYS}d +%Y-%m-%d) - -echo "Scanning for unanswered replies to ${REVIEWER} (last ${DAYS} days)..." >&2 - -# Find PRs the reviewer has commented on recently -REVIEWED_PRS=$(gh api "search/issues?q=repo:${REPO}+reviewed-by:${REVIEWER}+is:pr+is:open+updated:>=${SINCE}&per_page=50" \ - --jq '.items[].number' 2>/dev/null) - -UNANSWERED=0 - -for PR_NUM in $REVIEWED_PRS; do - # Get all review comments on this PR - COMMENTS=$(gh api "repos/${REPO}/pulls/${PR_NUM}/comments" \ - --jq '[.[] | {id, user: .user.login, body: .body[:100], in_reply_to_id, created_at, path, url: .html_url}]' 2>/dev/null) - - # Find threads: reviewer's comments that got a reply, but reviewer didn't reply back - # 1. Get reviewer's comment IDs - REVIEWER_IDS=$(echo "$COMMENTS" | jq -r --arg r "$REVIEWER" '[.[] | select(.user == $r) | .id]') - - # 2. Find replies to reviewer's comments (from others) - REPLIES=$(echo "$COMMENTS" | jq -c --arg r "$REVIEWER" --argjson rids "$REVIEWER_IDS" ' - [.[] | - select(.user != $r) | - select(.in_reply_to_id != null) | - select([.in_reply_to_id] | inside($rids)) - ] - ') - - REPLY_COUNT=$(echo "$REPLIES" | jq 'length') - if [ "$REPLY_COUNT" -eq 0 ]; then - continue - fi - - # 3. For each reply, check if reviewer replied after it - echo "$REPLIES" | jq -c '.[]' | while read -r reply; do - REPLY_ID=$(echo "$reply" | jq -r '.id') - REPLY_DATE=$(echo "$reply" | jq -r '.created_at') - REPLY_USER=$(echo "$reply" | jq -r '.user') - REPLY_URL=$(echo "$reply" | jq -r '.url') - - # Check if reviewer replied after this reply - FOLLOWUP=$(echo "$COMMENTS" | jq --arg r "$REVIEWER" --arg date "$REPLY_DATE" --argjson rid "$REPLY_ID" ' - [.[] | select(.user == $r) | select(.in_reply_to_id == $rid) | select(.created_at > $date)] | length - ') - - if [ "$FOLLOWUP" -eq 0 ]; then - REPLY_BODY=$(echo "$reply" | jq -r '.body') - echo "PR #${PR_NUM} | @${REPLY_USER} replied | ${REPLY_URL}" - echo " > ${REPLY_BODY}" - echo "" - UNANSWERED=$((UNANSWERED + 1)) - fi - done -done - -if [ "$UNANSWERED" -eq 0 ]; then - echo "No unanswered replies found." >&2 -fi diff --git a/.claude/skills/review-pr/scripts/run_perf_comparison.sh b/.claude/skills/review-pr/scripts/run_perf_comparison.sh deleted file mode 100755 index 959914d57..000000000 --- a/.claude/skills/review-pr/scripts/run_perf_comparison.sh +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env bash -# run_perf_comparison.sh — Before/after benchmark comparison for PR review. -# -# Usage: -# ./scripts/run_perf_comparison.sh --base --head --model --benchmark -# -# Benchmark types: omni_offline, omni_online, diffusion, accuracy -# -# Requirements: -# - Local clone of vllm-project/vllm-omni -# - Python environment with vllm-omni installed -# - Git worktree support - -set -euo pipefail - -TIMEOUT_SECONDS=1200 # 20 minutes hard limit per run -WORKTREE_BASE=".claude/perf-worktrees/base" -WORKTREE_PR=".claude/perf-worktrees/pr" -REPORT_FILE="" - -cleanup() { - echo "--- Cleaning up worktrees ---" - git worktree remove "$WORKTREE_BASE" --force 2>/dev/null || true - git worktree remove "$WORKTREE_PR" --force 2>/dev/null || true -} -trap cleanup EXIT INT TERM - -# --- Argument parsing --- -BASE_REF="" -HEAD_REF="" -MODEL="" -BENCHMARK_TYPE="" - -while [[ $# -gt 0 ]]; do - case "$1" in - --base) BASE_REF="$2"; shift 2 ;; - --head) HEAD_REF="$2"; shift 2 ;; - --model) MODEL="$2"; shift 2 ;; - --benchmark) BENCHMARK_TYPE="$2"; shift 2 ;; - --report) REPORT_FILE="$2"; shift 2 ;; - *) echo "Unknown arg: $1"; exit 1 ;; - esac -done - -if [[ -z "$BASE_REF" || -z "$HEAD_REF" || -z "$MODEL" || -z "$BENCHMARK_TYPE" ]]; then - echo "Usage: $0 --base --head --model --benchmark " - exit 1 -fi - -# --- Hardware detection --- -detect_hardware() { - PLATFORM="CPU" - GPU_COUNT=0 - GPU_MODEL="N/A" - VRAM_PER_GPU_GB=0 - - if command -v nvidia-smi &>/dev/null; then - local gpu_info - gpu_info=$(nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null || true) - if [[ -n "$gpu_info" ]]; then - GPU_COUNT=$(echo "$gpu_info" | wc -l | tr -d ' ') - GPU_MODEL=$(echo "$gpu_info" | head -1 | cut -d',' -f1 | xargs) - VRAM_MB=$(echo "$gpu_info" | head -1 | cut -d',' -f2 | tr -d ' MiB' | xargs) - VRAM_PER_GPU_GB=$(python3 -c "print(f'{$VRAM_MB/1024:.1f}')") - PLATFORM="CUDA" - return - fi - fi - - if [[ "$PLATFORM" == "CPU" ]] && command -v rocm-smi &>/dev/null; then - PLATFORM="ROCm" - GPU_MODEL="ROCm GPU" - VRAM_PER_GPU_GB="unknown" - GPU_COUNT=1 - fi - - if [[ "$PLATFORM" == "CPU" ]]; then - python3 -c "import torch_npu" 2>/dev/null && PLATFORM="NPU" || true - fi - if [[ "$PLATFORM" == "CPU" ]]; then - python3 -c "import torch; torch.xpu.device_count()" 2>/dev/null && PLATFORM="XPU" || true - fi -} - -# --- Feasibility check --- -estimate_model_size_gb() { - # Rough estimate: assume BF16 (2 bytes/param), add 50% overhead for KV cache + activations - # Caller can override with more specific estimates - local param_count="${1:-7000000000}" # default 7B - python3 -c "print(f'{$param_count * 2 / 1e9 * 1.5:.1f}')" -} - -check_feasibility() { - local estimated_gb="$1" - - if [[ "$PLATFORM" == "CPU" ]]; then - # CPU-only: can only verify very small models - local sys_ram_gb - sys_ram_gb=$(python3 -c " -import os -with open('/proc/meminfo' if os.path.exists('/proc/meminfo') else '/dev/null') as f: - for line in f: - if 'MemAvailable' in line: - print(int(line.split()[1]) / 1048576) - break -" 2>/dev/null || echo "16") - if (( $(echo "$estimated_gb < $sys_ram_gb * 0.5" | bc -l 2>/dev/null || echo 0) )); then - echo "VERIFIABLE (CPU-only, small model)" - return 0 - else - echo "CANNOT_VERIFY (CPU-only, model too large for RAM)" - return 1 - fi - fi - - local total_vram_gb - total_vram_gb=$(python3 -c "print(f'{$VRAM_PER_GPU_GB * $GPU_COUNT:.1f}')") - - if (( $(echo "$estimated_gb <= $total_vram_gb" | bc -l 2>/dev/null || echo 0) )); then - echo "VERIFIABLE" - return 0 - elif (( $(echo "$estimated_gb <= $total_vram_gb * 1.5" | bc -l 2>/dev/null || echo 0) )); then - echo "NEEDS_OFFLOAD" - return 0 - else - echo "CANNOT_VERIFY (model requires ~${estimated_gb}GB, available ${total_vram_gb}GB)" - return 1 - fi -} - -# --- Run benchmark with timeout --- -run_with_timeout() { - local label="$1" - shift - local start end duration - - echo "--- Running benchmark: $label ---" - start=$(date +%s) - - timeout "$TIMEOUT_SECONDS" "$@" 2>&1 | tee "${label}.benchmark.log" & - local pid=$! - wait "$pid" || local exit_code=$? - - end=$(date +%s) - duration=$((end - start)) - - if [[ ${exit_code:-0} -eq 124 ]]; then - echo "TIMEOUT: $label exceeded ${TIMEOUT_SECONDS}s limit (ran ${duration}s)" - echo '{"status": "TIMEOUT", "duration_s": '$duration'}' > "${label}.result.json" - return 1 - fi - - echo "--- Completed $label in ${duration}s ---" - echo "{\"status\": \"done\", \"duration_s\": $duration}" > "${label}.timing.json" - return ${exit_code:-0} -} - -# --- Setup worktrees --- -setup_worktrees() { - echo "--- Setting up worktrees ---" - mkdir -p .claude/perf-worktrees - git worktree add "$WORKTREE_BASE" "$BASE_REF" 2>/dev/null || git worktree add "$WORKTREE_BASE" "origin/$BASE_REF" - git worktree add "$WORKTREE_PR" "$HEAD_REF" 2>/dev/null || git worktree add "$WORKTREE_PR" "origin/$HEAD_REF" -} - -# --- Compare results --- -compare_results() { - local base_result="$1" - local pr_result="$2" - - echo "" - echo "========================================" - echo " PERF COMPARISON REPORT" - echo "========================================" - echo "Hardware: $GPU_MODEL x$GPU_COUNT ($VRAM_PER_GPU_GB GB each), $PLATFORM" - echo "Model: $MODEL" - echo "Base: $BASE_REF | Head: $HEAD_REF" - echo "----------------------------------------" - - if [[ ! -f "$base_result" || ! -f "$pr_result" ]]; then - echo "ERROR: Missing result files" - echo " Base result: $base_result ($( [[ -f "$base_result" ]] && echo EXISTS || echo MISSING ))" - echo " PR result: $pr_result ($( [[ -f "$pr_result" ]] && echo EXISTS || echo MISSING ))" - return 1 - fi - - # Tolerance defaults - LATENCY_TOL="${LATENCY_TOLERANCE:-10}" - THROUGHPUT_TOL="${THROUGHPUT_TOLERANCE:-10}" - VRAM_TOL="${VRAM_TOLERANCE:-5}" - - python3 - <+9.1f}% | {verdict:<12} |") - -print(f"\nTolerances: latency ±{tolerances['latency']}%, throughput ±{tolerances['throughput']}%, VRAM ±{tolerances['vram']}%") -PYEOF -} - -# --- Main --- -main() { - detect_hardware - echo "Detected: $PLATFORM | $GPU_MODEL x$GPU_COUNT | ${VRAM_PER_GPU_GB}GB VRAM/GPU" - - # Estimate model size (rough: use model name heuristics or default 7B) - local estimated_gb - estimated_gb=$(estimate_model_size_gb) - echo "Estimated model VRAM: ~${estimated_gb}GB" - - local feasibility - feasibility=$(check_feasibility "$estimated_gb") - echo "Feasibility: $feasibility" - - if [[ "$feasibility" == CANNOT_VERIFY* ]]; then - echo "" - echo "Cannot execute benchmarks. Falling back to static-only analysis." - echo "See references/perf-verification.md Section 8 for static analysis checklist." - exit 0 - fi - - setup_worktrees - - local extra_args=() - if [[ "$feasibility" == NEEDS_OFFLOAD* ]]; then - extra_args+=(--cpu-offload-gb 10) - echo "Running with CPU offload (feasibility: $feasibility)" - fi - - # Run benchmarks (caller should replace these with actual benchmark commands) - echo "" - echo "NOTE: Edit this script or set BENCH_CMD to the actual benchmark command." - echo "Example: BENCH_CMD='python3 -m vllm.entrypoints.openai.api_server' $0 ..." - echo "" - echo "Placeholder: running a basic timing check." - - # Placeholder — in practice, run the actual benchmark in each worktree - # run_with_timeout "base" bash -c "cd $WORKTREE_BASE && python3 -c 'import time; print(json.dumps({\"latency_ms\": 100.0, \"throughput_tps\": 50.0, \"vram_gb\": 8.0}))'" - # run_with_timeout "pr" bash -c "cd $WORKTREE_PR && python3 -c 'import time; print(json.dumps({\"latency_ms\": 95.0, \"throughput_tps\": 52.0, \"vram_gb\": 7.8}))'" - - echo "Worktrees ready at $WORKTREE_BASE and $WORKTREE_PR" - echo "Run your benchmark commands manually, or set BENCH_CMD env var." -} - -main "$@" diff --git a/.claude/skills/review-pr/scripts/run_test_analysis.sh b/.claude/skills/review-pr/scripts/run_test_analysis.sh deleted file mode 100755 index 1ee222dd7..000000000 --- a/.claude/skills/review-pr/scripts/run_test_analysis.sh +++ /dev/null @@ -1,232 +0,0 @@ -#!/usr/bin/env bash -# run_test_analysis.sh — Run affected tests with hardware-aware filtering. -# -# Usage: -# ./scripts/run_test_analysis.sh --base --head [--run-level core_model] -# -# Requirements: -# - Local clone of vllm-project/vllm-omni -# - pytest installed -# - Git worktree support - -set -euo pipefail - -BASE_REF="" -HEAD_REF="" -RUN_LEVEL="core_model" -TEST_TIMEOUT=60 - -while [[ $# -gt 0 ]]; do - case "$1" in - --base) BASE_REF="$2"; shift 2 ;; - --head) HEAD_REF="$2"; shift 2 ;; - --run-level) RUN_LEVEL="$2"; shift 2 ;; - --timeout) TEST_TIMEOUT="$2"; shift 2 ;; - *) echo "Unknown arg: $1"; exit 1 ;; - esac -done - -if [[ -z "$BASE_REF" || -z "$HEAD_REF" ]]; then - echo "Usage: $0 --base --head [--run-level core_model]" - exit 1 -fi - -# --- Hardware detection --- -detect_hardware() { - PLATFORM="CPU" - GPU_COUNT=0 - GPU_MODEL="N/A" - VRAM_PER_GPU_GB=0 - - if command -v nvidia-smi &>/dev/null; then - local gpu_info - gpu_info=$(nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null || true) - if [[ -n "$gpu_info" ]]; then - GPU_COUNT=$(echo "$gpu_info" | wc -l | tr -d ' ') - GPU_MODEL=$(echo "$gpu_info" | head -1 | cut -d',' -f1 | xargs) - VRAM_MB=$(echo "$gpu_info" | head -1 | cut -d',' -f2 | tr -d ' MiB' | xargs) - VRAM_PER_GPU_GB=$(python3 -c "print(f'{$VRAM_MB/1024:.1f}')" 2>/dev/null || echo "unknown") - PLATFORM="CUDA" - return - fi - fi - - if [[ "$PLATFORM" == "CPU" ]] && command -v rocm-smi &>/dev/null; then - PLATFORM="ROCm"; GPU_COUNT=1; GPU_MODEL="ROCm GPU" - fi - if [[ "$PLATFORM" == "CPU" ]]; then - python3 -c "import torch_npu" 2>/dev/null && PLATFORM="NPU" || true - fi - if [[ "$PLATFORM" == "CPU" ]]; then - python3 -c "import torch; torch.xpu.device_count()" 2>/dev/null && PLATFORM="XPU" || true - fi -} - -# --- Find affected test files --- -find_affected_tests() { - local base="$1" head="$2" - local changed_tests changed_src - - # Directly changed test files - changed_tests=$(git diff --name-only "$base...$head" -- 'tests/' 2>/dev/null | grep '\.py$' || true) - - # Source files that changed — map to tests via grep - changed_src=$(git diff --name-only "$base...$head" -- 'vllm_omni/' 2>/dev/null | grep '\.py$' | grep -v __pycache__ || true) - - local grep_tests="" - if [[ -n "$changed_src" ]]; then - while IFS= read -r src_file; do - # Convert file path to module: vllm_omni/engine/scheduler.py → engine.scheduler - local module - module=$(echo "$src_file" | sed 's|^vllm_omni/||; s|\.py$||; s|/|.|g') - # Find test files that import this module - local matches - matches=$(grep -rl "from vllm_omni\.\{0,1\}${module}\|import vllm_omni\.\{0,1\}${module}" tests/ 2>/dev/null || true) - grep_tests+="$matches"$'\n' - done <<< "$changed_src" - fi - - # Deduplicate and combine - { - echo "$changed_tests" - echo "$grep_tests" - } | grep '\.py$' | sort -u -} - -# --- Filter tests by hardware compatibility --- -filter_by_hardware() { - local test_files="$1" - local skipped_reasons=() - - echo "$test_files" | while IFS= read -r test_file; do - [[ -z "$test_file" ]] && continue - - # Check for multi-GPU requirements - if grep -q 'num_cards=[4-9]\|tensor_parallel_size=[4-9]\|world_size=[4-9]' "$test_file" 2>/dev/null; then - if [[ "$GPU_COUNT" -lt 4 ]]; then - echo "SKIP: $test_file (requires 4+ GPUs, have $GPU_COUNT)" - continue - fi - fi - if grep -q 'num_cards=2\|tensor_parallel_size=2\|world_size=2' "$test_file" 2>/dev/null; then - if [[ "$GPU_COUNT" -lt 2 ]]; then - echo "SKIP: $test_file (requires 2+ GPUs, have $GPU_COUNT)" - continue - fi - fi - - # Check for huge model markers - if grep -q 'huge_model\|HUGE_MODEL' "$test_file" 2>/dev/null; then - local vram_num - vram_num=$(echo "$VRAM_PER_GPU_GB" | grep -oE '[0-9.]+' | head -1 || echo "0") - if (( $(echo "$vram_num < 80" | bc -l 2>/dev/null || echo 0) )); then - echo "SKIP: $test_file (huge_model, need 80GB+ GPU, have ${VRAM_PER_GPU_GB}GB)" - continue - fi - fi - - # Check for platform-specific markers - if grep -q 'skipif.*npu\|mark.npu' "$test_file" 2>/dev/null && [[ "$PLATFORM" != "NPU" ]]; then - echo "SKIP: $test_file (NPU-only test, platform is $PLATFORM)" - continue - fi - - echo "RUN: $test_file" - done -} - -# --- Run tests --- -run_tests() { - local test_list="$1" - local runnable_tests - runnable_tests=$(echo "$test_list" | grep "^RUN:" | cut -d: -f2- | tr '\n' ' ' || true) - local skipped_tests - skipped_tests=$(echo "$test_list" | grep "^SKIP:" || true) - - echo "" - echo "========================================" - echo " TEST ANALYSIS REPORT" - echo "========================================" - echo "Hardware: $GPU_MODEL x$GPU_COUNT ($VRAM_PER_GPU_GB GB), $PLATFORM" - echo "Run level: $RUN_LEVEL" - echo "Base: $BASE_REF | Head: $HEAD_REF" - echo "----------------------------------------" - - if [[ -n "$skipped_tests" ]]; then - echo "" - echo "Skipped tests (hardware constraints):" - echo "$skipped_tests" - fi - - if [[ -z "$runnable_tests" ]]; then - echo "" - echo "No runnable tests (all skipped due to hardware constraints)." - echo "Proceed with static-only analysis." - echo "See references/test-quality-evaluation.md Section 2." - return 0 - fi - - echo "" - echo "Running tests:" - echo "$runnable_tests" - echo "" - - # Run pytest with timeout per test - pytest $runnable_tests \ - --run-level "$RUN_LEVEL" \ - -v \ - --tb=short \ - --timeout="$TEST_TIMEOUT" \ - 2>&1 | tee test_analysis_output.log - - local exit_code=${PIPESTATUS[0]} - - echo "" - echo "----------------------------------------" - echo "Results summary:" - # Parse pytest output - local passed failed skipped errors warnings - passed=$(grep -c ' PASSED ' test_analysis_output.log 2>/dev/null || echo "0") - failed=$(grep -c ' FAILED ' test_analysis_output.log 2>/dev/null || echo "0") - skipped=$(grep -c ' SKIPPED ' test_analysis_output.log 2>/dev/null || echo "0") - errors=$(grep -c ' ERROR ' test_analysis_output.log 2>/dev/null || echo "0") - - echo " Passed: $passed" - echo " Failed: $failed" - echo " Skipped: $skipped" - echo " Errors: $errors" - echo " Exit code: $exit_code" - - if [[ "$failed" -gt 0 ]]; then - echo "" - echo "Failed tests:" - grep ' FAILED ' test_analysis_output.log - fi - - return $exit_code -} - -# --- Main --- -main() { - detect_hardware - echo "Detected: $PLATFORM | $GPU_MODEL x$GPU_COUNT | ${VRAM_PER_GPU_GB}GB VRAM/GPU" - - local affected_tests - affected_tests=$(find_affected_tests "$BASE_REF" "$HEAD_REF") - - if [[ -z "$affected_tests" ]]; then - echo "No affected test files found in diff." - exit 0 - fi - - echo "" - echo "Affected test files:" - echo "$affected_tests" - - local filtered - filtered=$(filter_by_hardware "$affected_tests") - - run_tests "$filtered" -} - -main "$@" diff --git a/.claude/skills/review-pr/scripts/select_prs.sh b/.claude/skills/review-pr/scripts/select_prs.sh deleted file mode 100644 index 8a9b657d1..000000000 --- a/.claude/skills/review-pr/scripts/select_prs.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash -# select_prs.sh — Pick reviewable PRs from vllm-omni for a review session. -# -# Usage: ./select_prs.sh [--days 7] [--limit 5] [--reviewer lishunyang12] -# -# Filters: -# - Excludes your own PRs (--reviewer) -# - Excludes WIP / Draft / "Don't merge" PRs -# - Excludes pure docs/CI-only merged PRs -# - Excludes PRs you already reviewed -# - Prioritizes zero-review PRs -# -# Output: JSON array of {number, title, author, createdAt, reviewCount} - -set -euo pipefail - -REPO="vllm-project/vllm-omni" -DAYS=7 -LIMIT=5 -REVIEWER="" - -while [[ $# -gt 0 ]]; do - case $1 in - --days) DAYS="$2"; shift 2 ;; - --limit) LIMIT="$2"; shift 2 ;; - --reviewer) REVIEWER="$2"; shift 2 ;; - *) echo "Unknown arg: $1" >&2; exit 1 ;; - esac -done - -SINCE=$(date -d "-${DAYS} days" +%Y-%m-%d 2>/dev/null || date -v-${DAYS}d +%Y-%m-%d) - -echo "Fetching open PRs from last ${DAYS} days..." >&2 - -# Fetch all open PRs from the time range -ALL_PRS=$(gh pr list --repo "$REPO" --state open --limit 200 \ - --json number,title,author,createdAt,isDraft \ - --search "created:>=${SINCE}") - -# Filter in a single jq pass -FILTERED=$(echo "$ALL_PRS" | jq --arg reviewer "$REVIEWER" ' - [.[] | - # Skip own PRs - select(.author.login != $reviewer) | - # Skip drafts - select(.isDraft == false) | - # Skip WIP / Dont merge - select(.title | test("\[WIP\]|\[Draft\]|\[Don.t\]"; "i") | not) - ] -') - -# For each remaining PR, check review count and whether reviewer already reviewed -echo "Checking review status for $(echo "$FILTERED" | jq length) PRs..." >&2 - -echo "$FILTERED" | jq -c '.[]' | while read -r pr; do - NUM=$(echo "$pr" | jq -r '.number') - - # Get review count - REVIEW_COUNT=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" --jq 'length' 2>/dev/null || echo "0") - - # Check if reviewer already reviewed - if [ -n "$REVIEWER" ]; then - ALREADY=$(gh api "repos/${REPO}/pulls/${NUM}/reviews" \ - --jq "[.[] | select(.user.login==\"${REVIEWER}\")] | length" 2>/dev/null || echo "0") - if [ "$ALREADY" -gt 0 ]; then - continue - fi - fi - - echo "$pr" | jq --argjson rc "$REVIEW_COUNT" '. + {reviewCount: $rc}' -done | jq -s "sort_by(.reviewCount) | .[:${LIMIT}]" diff --git a/.claude/skills/review-pr/scripts/verify_line_numbers.sh b/.claude/skills/review-pr/scripts/verify_line_numbers.sh deleted file mode 100644 index 0f25cf900..000000000 --- a/.claude/skills/review-pr/scripts/verify_line_numbers.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env bash -# verify_line_numbers.sh — Verify inline comment line numbers before posting. -# -# Usage: echo '' | ./verify_line_numbers.sh -# -# Reads a review JSON (with comments array) from stdin, fetches the PR diff, -# and checks that each comment's line number points to a line in the diff -# that contains code related to the comment. -# -# Exits 0 if all lines are valid diff lines, 1 if any are outside diff hunks. - -set -euo pipefail - -REPO="vllm-project/vllm-omni" -PR_NUM="${1:?Usage: $0 }" - -REVIEW_JSON=$(cat) -DIFF=$(gh pr diff "$PR_NUM" --repo "$REPO") - -ERRORS=0 - -echo "$REVIEW_JSON" | jq -c '.comments[]' | while read -r comment; do - FILE=$(echo "$comment" | jq -r '.path') - LINE=$(echo "$comment" | jq -r '.line') - BODY=$(echo "$comment" | jq -r '.body[:60]') - - # Extract the file's diff - FILE_DIFF=$(echo "$DIFF" | sed -n "/^diff --git a\/${FILE//\//\/}/,/^diff --git/p" | head -n -1) - - if [ -z "$FILE_DIFF" ]; then - echo "ERROR: File not in diff: ${FILE}" >&2 - ERRORS=$((ERRORS + 1)) - continue - fi - - # Check if the line falls within any hunk - IN_HUNK=false - while IFS= read -r hunk_header; do - # Parse @@ -old_start,old_count +new_start,new_count @@ - NEW_START=$(echo "$hunk_header" | grep -oP '\+\K[0-9]+') - NEW_COUNT=$(echo "$hunk_header" | grep -oP '\+[0-9]+,\K[0-9]+' || echo "1") - NEW_END=$((NEW_START + NEW_COUNT - 1)) - - if [ "$LINE" -ge "$NEW_START" ] && [ "$LINE" -le "$NEW_END" ]; then - IN_HUNK=true - break - fi - done < <(echo "$FILE_DIFF" | grep '^@@') - - if [ "$IN_HUNK" = false ]; then - echo "ERROR: Line ${LINE} in ${FILE} is outside all diff hunks" >&2 - echo " Comment: ${BODY}..." >&2 - ERRORS=$((ERRORS + 1)) - else - echo "OK: ${FILE}:${LINE} — ${BODY}..." >&2 - fi -done - -exit $ERRORS