Add validate-kernel-pr skill + structural D9 trigger for review-pr - #4870
Open
jhinpan wants to merge 3 commits into
Open
Add validate-kernel-pr skill + structural D9 trigger for review-pr#4870jhinpan wants to merge 3 commits into
jhinpan wants to merge 3 commits into
Conversation
…kernel PRs review-pr is static: it never builds and never runs. Three failure modes are invisible to it, and a 14-PR backtest of review-pr alone found 8 of 17 known defects, so the gap is real rather than theoretical. This skill produces validation_report.json as the evidence base: merge_sim -> gpu_claim -> runtime_compat -> test_policy -> correctness -> index_width_scan -> verdict Two stages exist because a green test suite is not evidence: - correctness runs the PR's own tests AND a shape grid this skill owns (non-toy, boundary/odd, long-context). Seeding a dropped tail guard into a FlyDSL softmax kernel leaves the repo's own suite green -- its non-aligned shapes are commented out, only one aligned shape runs -- while the grid at N=2000 / N=257 fails it. - test_policy compares tolerances head-vs-base before running anything. A change that widens a tolerance while leaving the kernel path unchanged makes the suite unable to fail, and pytest still reports green. Verified against three seeded mutants plus a clean baseline: baseline passes every stage; dropped tail guard blocks via the grid alone; loosened tolerance blocks via test_policy alone; wrong index unit blocks via the repo tests. The report states what it did not do, so it cannot overclaim by omission: arch_coverage marks each arch runtime or compile-only (a gfx950 host cannot validate a gfx942 claim), isolation records the real level, and degraded_mode marks COMPILE_ONLY when no GPU was claimable. runtime_compat exists because a pinned prebuilt runtime drifts behind the tree and the resulting ImportError otherwise reads as a defect in the PR. scan_index_width.py ships alongside it; see the review-pr D9 change.
…dation evidence Four changes, each from a measured failure in a 14-PR backtest of this skill. 1. D9 never fires. Its trigger was a list of variable names (token_id, seq_start, batch_offset, total_tokens). Three real 32-bit overflow defects used none of them -- stride_out_batch, block_id, physical_block, context_kv_idx -- and int32/int64/overflow appears zero times in the whole verdict card for aiter#1674, which carries two of them. The trigger is now structural: an index-shaped value multiplied by a stride-shaped value on a line with no 64-bit widening. scan_index_width.py is the mechanical pre-filter and flags all three; a bare model missed the same family, so this is not something to leave to recall. 2. REPO was hard-coded to ROCm/aiter, so the skill could not review a FlyDSL PR at all. It now takes a repository argument, or owner/repo#N. 3. FlyDSL/Triton kernel PRs now require a validation_report.json and load validate-kernel-pr. A kernel PR's own green suite is not evidence. 4. The verdict card caps at 5 findings, ordered most-severe first, and states its validation evidence. This skill averaged 7.1 findings per PR across the backtest; dropping everything judged noise still left 5.4, so the cap has to be explicit. Without a report the card says [static-only review], and no finding may then assert runtime behaviour as fact. Backtest numbers for the frozen version being changed here (blob 3fdb11a, 14 PRs, 17 provenance-checked labels): 76 of 100 findings useful, 0 factually wrong, 8/17 defects found.
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
The Invocation section showed `validate_pr.sh --pr 4394`, a flag the script does not implement -- it exits 2 with "unknown arg --pr". That is the hallucinated-API failure review-pr Step 6 exists to catch, shipped in the skill meant to catch it. Document the interface that is actually implemented and verified: the caller supplies the worktree and the pytest target. Every flag named in the doc is now present in the argument parser. Also declare what is absent rather than leaving it to be inferred: - no PR fetch orchestration; choosing the right --tests target from a diff is the unsolved part, and a wrong target produces a confident green - perf and claims stages are reserved in report_schema.json and emitted by nothing, so a report today carries no performance evidence and a review must not read a missing perf stage as "no regression"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
review-pris a static reviewer — it never builds and never runs. Two concrete gaps follow from that, both reproducible from this repo's own history.1. Rule D9 never fires. D9 covers 32-bit overflow in pointer arithmetic, and its trigger is a list of variable names (
token_id,seq_start,batch_offset,total_tokens). Three real defects in this repo used none of those names, so the rule stayed silent on all three:stride_out_batchnottl.int64block_id * stride, no.to(int64)INT32_MAXreturns logits of exactly0.0, silentlyArithValue(physical_block) * strideRunning the current skill over #1674 produces a verdict card in which
int32/int64/overflowappear zero times, despite that PR carrying two of the three.2. A green test suite is not evidence. Two failure modes are invisible to any static reviewer:
A backtest of the current skill over 14 merged PRs (labels derived from the later
[Fix]/revert PRs that repaired them) found 9 of 17 known defects, measured with each case pinned to its merge commit andghtime-boxed so the later fix PR is not visible to the reviewer. Its precision was good and its false-positive rate low; the gap was recall, and the misses clustered into the families above. That is why this PR adds a runtime layer and a mechanical scan rather than more prose rules.Technical Details
New skill
validate-kernel-pr—SKILL.md,validate_pr.sh,report_schema.json. Emitsvalidation_report.json:correctnessruns the PR's own tests and a shape grid the skill owns (non-toy, boundary/odd, long-context), reported separately — the informative case is when they disagree.test_policycompares tolerances head-vs-base before running anything, so a suite that can no longer fail is caught rather than reported green.gpu_claimpicks a GPU over a sampling window and holdsflockfor the run; the report records host, HIP index, BDF, arch and pre-run activity.runtime_compatdistinguishes "checkout does not match the installed runtime" from "the PR is broken", so a stale prebuilt runtime is not charged to the author.arch_coveragemarks each archruntimeorcompile-only,isolationrecords the real level,degraded_modemarksCOMPILE_ONLYwhen no GPU was claimable.scan_index_width.py— structural pre-filter for the D9 family: an index-shaped value multiplied by a stride-shaped value on a line with no 64-bit widening. Output is candidates for the reviewer to clear, not findings.review-prchanges — four:REPOwas hard-coded toROCm/aiter, so the skill could not review a FlyDSL PR at all; it now takes a repo argument orowner/repo#N.validation_report.json; without one the card marks itself[static-only review]and no finding may assert runtime behaviour as fact.Skills live under
.claude/, which.gitignoreexcludes; the seven existing skills are tracked anyway, so these are added the same way (git add -f).Test Plan
validate_pr.shagainst each plus a clean baseline.scan_index_width.pyfrom its shipped path against Support mqa_logits blocksize is multiple of ChunkK cases #1674 and Add fused QK/KV norm + RoPE + group-quant ops #3541.review-prStep 1 tells the agent to run.Test Result
Run on MI355X (gfx950). Each mutant is caught by a different stage, and the clean baseline stays green:
Row 2 is the case this skill exists for: the kernel writes out of bounds on unaligned
N, the repo's own suite reports green because its non-aligned shapes are commented out, and only the S1 grid (N=2000,N=257) fails it.scan_index_width.pyflags all three D9 defects above, including the one whose source comment already reads# i32: physical_block*kcache_block_stride + slot*kcache_token_stride. Scripts, schema and the Step 1 snippet all parse.Limitations
gfx942: compile-only. Nothing here claims gfx942 numerical validation.perforclaimsstage.report_schema.jsonreserves both; the script emits neither. A report carries no performance evidence today, and a missingperfstage must not be read as "no regression".ghtime-boxed — found the revised skill catching 0 of 3, the same as the unrevised skill. No run shows the scanner being invoked: the instruction to run it sits mid-checklist in Step 5, and only Step 1's bash block is reliably executed. The fix is to move the scan into Step 1 so the candidate list is in context before the rule pass; that is not in this PR. Treat the D9 edit as a corrected rule statement, not a demonstrated improvement.Out of scope
While backtesting #4394 the review found that its rebase reverted the
k_batch >= 2split-k guard added by #3997 — present atmerge^, absent at merge, and still absent onmaintoday (aiter/fused_moe.py:3703). Not touched by this PR; it wants its own fix.Submission Checklist