Repository navigation
[skills] Add kernel PR validation and structural D9 scanning (supersedes #4870) - #5142
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new deterministic “validate-kernel-pr” execution/validation layer (plus regression assets) and updates the existing review-pr skill to consume exact-head validation evidence and to run the index×stride scanner during the fetch step.
Changes:
- Adds
validate-kernel-prexecutor (validate_pr.sh) that applies a base→head patch in a clean worktree, claims a verified-idle GPU via AMD SMI, runs base/head targets with isolated caches, and emits a structuredvalidation_report.json. - Adds validator evidence utilities: pytest profiling plugin + receipt validator, runtime identity capture, JSON schema, and an index×stride “no 64-bit widening” scanner.
- Adds extensive regression coverage (synthetic tests + pinned FlyDSL mutant corpus replay harness) and updates
review-prto accept an explicit validation report and enforce its contract.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.claude/skills/validate-kernel-pr/validation_probe.py |
New validator-owned pytest plugin to profile specific routes and write an execution receipt. |
.claude/skills/validate-kernel-pr/validate_pr.sh |
New end-to-end deterministic validation script (patch apply/revert, GPU claim, baseline/head runs, policy checks, report emission). |
.claude/skills/validate-kernel-pr/validate_evidence.py |
New helpers to compute JUnit stats, validate execution receipts, and capture runtime/native artifact identity. |
.claude/skills/validate-kernel-pr/tests/test_validator.py |
New synthetic regression tests covering report contract and major degraded-mode behaviors. |
.claude/skills/validate-kernel-pr/tests/replay_mutants.sh |
New harness to replay pinned FlyDSL control + seeded defect patches and assert expected verdicts. |
.claude/skills/validate-kernel-pr/tests/mutants/manifest.json |
Defines the pinned FlyDSL base, target, grid, tolerances, and expected verdicts for mutant replay. |
.claude/skills/validate-kernel-pr/tests/mutants/m0-clean-control.patch |
Behavior-neutral control patch for the mutant corpus. |
.claude/skills/validate-kernel-pr/tests/mutants/m1-drop-tail-mask.patch |
Seeded correctness mutant (tail guard removal). |
.claude/skills/validate-kernel-pr/tests/mutants/m2-loosen-tolerance.patch |
Seeded policy mutant (tolerance widening without kernel change). |
.claude/skills/validate-kernel-pr/tests/mutants/m3-vector-vs-element-index.patch |
Seeded correctness mutant (vector-vs-element index addressing). |
.claude/skills/validate-kernel-pr/tests/mutants/.gitattributes |
Ensures patch whitespace handling for mutant artifacts. |
.claude/skills/validate-kernel-pr/SKILL.md |
Documentation for the validate-kernel-pr skill (stages, contracts, invocation, corpus). |
.claude/skills/validate-kernel-pr/scan_index_width.py |
New mechanical scanner for index×stride multiplies lacking explicit 64-bit widening. |
.claude/skills/validate-kernel-pr/report_schema.json |
JSON schema defining the validation report contract and PASS requirements. |
.claude/skills/validate-kernel-pr/production_scale.md |
Captures scale facts needed to judge index×stride overflow candidates. |
.claude/skills/validate-kernel-pr/pick-idle-gpu.py |
New AMD SMI-based idle GPU picker with activity+VRAM / VRAM-only basis reporting. |
.claude/skills/review-pr/SKILL.md |
Updates review-pr to be explicitly advisory, accept an explicit validation report, and run the index-width scan during fetch. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.
Suppressed comments (2)
.claude/skills/validate-kernel-pr/validate_evidence.py:68
validation_probe.pyallows--expected-routeto be a comma-separated list (it splits_VALIDATION_EXPECTED_ROUTE), and it writes the receipt'srouteas a sorted comma-join.validate_receipt()currently comparesreceipt['route']to the rawexpected_routestring and also checksexpected_route in kernel_symbols, which will incorrectly fail for multi-route expectations and for the same routes given in a different order/with whitespace.
if receipt.get("route") != expected_route:
return {
"status": "skip",
"note": (
f"expected route {expected_route!r}, "
f"observed {receipt.get('route')!r}"
),
}
.claude/skills/validate-kernel-pr/validate_pr.sh:35
- The script uses
$TARGET_PYTHONfor running the target, but most internal helpers are hard-coded topython3(e.g., report initialization and everyjset_*/stage_note/findingcall). If the environment provides onlypython/a venv interpreter (orPYTHON_BIN), this can either fail outright (nopython3on PATH) or run helpers under a different interpreter than the one executing tests, making the run non-reproducible.
TARGET_PYTHON="${PYTHON_BIN:-$(command -v python3 || command -v python || true)}"
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
995af8b to
6de48d6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Suppressed comments (3)
.claude/skills/validate-kernel-pr/validate_pr.sh:34
- The script selects TARGET_PYTHON but still invokes
python3directly throughout (e.g., for report helpers and probe generation). This breaks whenpython3is not on PATH (even ifpythonis), and it can also accidentally use a different interpreter than the one the caller selected via PYTHON_BIN/virtualenv.
PYLIB="${PYLIB:-}"
TIMEOUT="${TIMEOUT:-1800}"
TARGET_PYTHON="${PYTHON_BIN:-$(command -v python3 || command -v python || true)}"
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
.claude/skills/validate-kernel-pr/validation_probe.py:53
pytest_sessionfinish()currently serializesrouteas a join of observed routes. If the validator ever expands to multiple routes (or if ordering changes), this won’t match the single--expected-routestring that receipt validation compares against. Persist the expected route in the probe state and write that into the receipt, usingkernel_symbolsfor the observed proof.
config._validation_probe = {
"routes": routes,
"shape_vars": shape_vars,
"observed_routes": observed_routes,
"observed_shapes": observed_shapes,
"profile": profile,
}
.claude/skills/validate-kernel-pr/validation_probe.py:71
- The receipt writes
routeas a join of observed routes. That makes receipt validation fragile and (together with comma-splitting inpytest_configure) prevents multi-route expected values from ever validating. Prefer writing the single expected route and keep observed routes inkernel_symbols.
{
"schema_version": 1,
"route": ",".join(sorted(probe["observed_routes"])),
"kernel_symbols": sorted(probe["observed_routes"]),
"executed_shapes": probe["observed_shapes"],
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.
Suppressed comments (5)
Previously missed (2) — in code that hasn't changed since the last review.
.claude/skills/validate-kernel-pr/validation_probe.py:61
sys.setprofile()/threading.setprofile()overwrite any pre-existing profiler for the whole process and are later reset toNone, which can break other tooling that had installed a profile function before the validator plugin ran (including when this probe is reused outside the validator harness). Capture the previous profile hooks and restore them inpytest_sessionfinishinstead of blindly clearing them.
sys.setprofile(profile)
threading.setprofile(profile)
.claude/skills/validate-kernel-pr/validation_probe.py:72
- The receipt field name
pytest_exitstatusis now written for script targets too (viarun_script_with_probe.py), so the key is misleading. Prefer a generic name likeexitstatusto avoid implying the value is pytest-specific.
"kernel_symbols": sorted(probe["observed_routes"]),
"executed_shapes": probe["observed_shapes"],
"pytest_exitstatus": int(exitstatus),
"producer": "validate-kernel-pr.validation_probe",
.claude/skills/validate-kernel-pr/validate_evidence.py:65
validate_receiptcomparesreceipt['route']toexpected_routeas a raw string. The probe already supports comma-separated expected routes (it splits on,), and it also normalizes whitespace, but this validation step does not. Normalize both values (split/strip/sort/join) before comparing so ordering/whitespace don’t cause a falseskip.
if receipt.get("route") != expected_route:
return {
"status": "skip",
"note": (
f"expected route {expected_route!r}, "
.claude/skills/validate-kernel-pr/validate_evidence.py:83
- After normalizing
expected_route(potentially to a comma-separated list), the currentif expected_route not in symbols:check will always fail for multi-route cases becausesymbolsis a list of individual routes. Check that each expected route appears inkernel_symbolsinstead.
if expected_route not in symbols:
return {
"status": "skip",
"note": "expected route is absent from observed kernel_symbols",
}
.claude/skills/validate-kernel-pr/validate_pr.sh:34
TARGET_PYTHONfalls back topython, but the script invokespython3directly in multiple places (e.g. report initialization and JSON helpers). This means a host withpythonbut nopython3will pass the interpreter check and then fail later. Either requirepython3explicitly here or consistently use$TARGET_PYTHONeverywhere.
PYLIB="${PYLIB:-}"
TIMEOUT="${TIMEOUT:-1800}"
TARGET_PYTHON="${PYTHON_BIN:-$(command -v python3 || command -v python || true)}"
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
Reviewed the delta over For the description: 🔴
|
|
A separate note on why misses like these happen — not a merge blocker, and nothing here should hold up this PR. Step 3 already maps PR type to the exact rules that apply, but it is prose the model self-applies. Step 1 already runs bash — let it derive the type from the diff and emit only the matching rules. Paths give Triton / FlyDSL / tuning-config / tests-only, a grep of added lines gives new Two that pair with it for free: any aggregate ships with a sample of the underlying rows, and each rule returns Unmeasured, n=1 from one session. Worth scoring before acting on. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
.claude/skills/validate-kernel-pr/validate_evidence.py:65
validate_receipt()requires an exact string match betweenreceipt['route']and--expected-route. But the probe supports comma-separated routes and canonicalizes/sorts them when writing the receipt, so equivalent route sets can fail validation (andexpected_route not in kernel_symbolswill always fail when--expected-routeis a comma list). Normalize/split routes and validate set inclusion instead of raw string equality.
if receipt.get("route") != expected_route:
return {
"status": "skip",
"note": (
f"expected route {expected_route!r}, "
.claude/skills/validate-kernel-pr/validate_pr.sh:85
- This script validates
TARGET_PYTHON, but it still callspython3directly for report/stage helpers (e.g.,python3 - ...at line 94). On hosts wherePYTHON_BINpoints to a working Python butpython3is unavailable, the script will pass the interpreter check and then fail later. Either use$TARGET_PYTHONconsistently, or explicitly requirepython3up front so failures are immediate and actionable.
if [ -z "$TARGET_PYTHON" ] || [ ! -x "$TARGET_PYTHON" ]; then
echo "no executable target Python interpreter; set PYTHON_BIN" >&2
exit 2
fi
…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.
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"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
.claude/skills/validate-kernel-pr/validate_evidence.py:65
validate_receipt()treats--expected-routeas a single opaque string, but the probe splits it on commas and the receipt stores a comma-joined list of observed routes. If multiple routes are ever supplied (or if the expected routes are listed in a different order), receipt validation will incorrectly skip due to string mismatch and becauseexpected_route not in symbolswill always be true for a comma-separated value.
if receipt.get("route") != expected_route:
return {
"status": "skip",
"note": (
f"expected route {expected_route!r}, "
.claude/skills/validate-kernel-pr/run_script_with_probe.py:59
runpy.run_path()exceptions other thanSystemExitleavestatusat 0, so the receipt gets written withpytest_exitstatus: 0even though the process exits non-zero. This makes failing script runs look like clean exits in the receipt data.
try:
runpy.run_path(target, run_name="__main__")
except SystemExit as exit_request:
code = exit_request.code
if code is None:
.claude/skills/validate-kernel-pr/validate_evidence.py:156
runtime_identity()always reportssource_sha: null, but bothSKILL.mdand the report schema describeruntime_identity.source_shaas recorded evidence. Leaving it null makes the field non-actionable and contradicts the documentation expectations.
"python_executable": sys.executable,
"python_version": platform.python_version(),
"source_sha": None,
"native_artifacts": artifacts,
}
The perf stage landed six commits ago and its own skill still says it
does not exist: "the schema reserves both -- and the script emits
neither. A report today carries no performance evidence, and a review
must not read the absence of a `perf` stage as 'no regression'." That
instructs a reader to disbelieve a stage that now measures, gates, and
can turn a verdict into NEEDS_WORK. review-pr says the opposite in three
places, so the two skills contradicted each other on the one stage a
reviewer is most likely to act on.
Document `perf` where the implementation lives: the flag table gains
--perf-args and --no-perf, the env knobs gain PERF_TIMEOUT, PERF_REPEAT,
PERF_THRESHOLD and PERF_MIN_ROWS -- all of them ${VAR:-default}
overrides with their own argument validation, so they were public
already and only undocumented -- and the stage list gains a section that
says why best-of-N is what makes a 0.95 threshold usable and why every
non-measurement path reports `skip`. The verdict section now states that
PASS does not imply a timing comparison happened.
What remains genuinely unimplemented is narrower than the old bullet
claimed: reproducing the specific numbers a PR description states. That
is now what "Not implemented yet" says.
Three smaller corrections in the same vein:
- "review-pr never builds and never runs" has been false since review-pr
started invoking this script itself. The split is at judgement, not at
invocation, and the text now says so.
- The comment describing bin/validate-kernel-pr as an existing wrapper
outlived the wrapper; bin/ is not in the repository. The reasoning it
carried -- do not re-resolve a base that main can advance past -- is
worth keeping, so it stays, phrased about a front end that does not
exist rather than one that does.
- The mutant manifest's tolerance_table disagreed with the file it
describes: test_softmax.py at the pinned base uses f16=1e-2 and
bf16=2e-2, not 2e-3 and 1e-2. Inert today, because reference
tolerances are recorded and not compared, which is exactly how a wrong
number survives unnoticed until something starts reading it.
Co-Authored-By: Claude Fable 5 <[email protected]>
report_schema.json is the contract review-pr validates against, so a field declared there reads as a shipped capability. Three did not hold. `claims` declared a stage that reproduces the numbers in a PR description, with an `unreproducible` array. No producer writes it -- not validate_pr.sh, not validate_evidence.py, not scrape_perf.py. Its only other mention was an allowlist entry saying it may be absent. It is removed rather than left standing; the honesty rule that promised `[unreproducible]` tagging now describes what `stages.perf` actually carries. `source_sha` was hardcoded null while the same honesty rules listed source SHA as recorded evidence. It is fillable: the resolved module has a path, and that path is usually inside a checkout. Now it records that checkout's commit, suffixed `-dirty` when the tree has uncommitted changes -- which the head phase always does, since it runs with the candidate patch applied, so the bare commit would name the base and describe a tree that is not the one under test. A module resolved from an installed package stays null: attributing a commit to a prebuilt binary is precisely the provenance claim this skill refuses to make. `reference_tolerances` is recorded and never compared, so --tol-table influences no verdict. Wiring it up is not possible as the data stands -- the table is keyed by dtype while the scraped tolerances are a positional list, with nothing to join them on -- so the field now says that it is context and not a gate, rather than implying otherwise by sitting next to the comparison that is one. Also collapses the PASS gate's two byte-identical correctness blocks into definitions/passing_correctness_stage, and has its `stats` $ref the execution_stats definition that was already there instead of respelling it inline. 74 duplicated lines in the clause that decides what earns a clearance, where divergence between the copies would change the answer silently. Verified equivalent: a clean PASS report still validates, and executed=0, failures=1, errors=1, exit=1, status=skip, missing stats and a stats object missing `skipped` are each still rejected on both stages. Adds the fields the producers already emit but the schema never described -- gpu_claim.post_run_note and .requirement_note, perf.regressed_rows[].base_repeats and .head_repeats -- which passed only because additionalProperties defaults to true. Co-Authored-By: Claude Fable 5 <[email protected]>
--shape-arg was added so script targets could receive an S1 grid, but the code around it still assumed the grid could only be an environment variable. Three consequences, one of them visible in a report. GRID_HOOK_OK was assigned twice. The --shape-arg AST scan set it, then an unconditional second block re-derived it from the --shape-env scan. Supplying both flags therefore proved the env var while run_pytest put the shapes on argv -- the report attested a channel the run did not use. Only-one-flag runs worked, which is why this survived. The channel is now resolved once, before either scan, and --shape-arg wins for a script target because that is what run_pytest does. A --shape-arg naming a flag the target does not accept fell through to the branch that reports "no shape grid was configured". Both cases skip, so the reason is the only thing distinguishing a validator that could not find the hook from a caller who never asked for one -- and the wrong one of those is an environment fact standing in for a capability gap, which is the overclaim-by-omission this skill exists to prevent. The branch conditions now test whether a grid was requested at all, so the same input reports hook-not-found, names the flag, and records test_selection.grid_channel. --shape-arg on a pytest target gets its own answer rather than the same silence: argv never reaches it. The runtime skips likewise said "shape environment variable" whichever channel was in play. They name the real one now. run_pytest took "$SHAPE_ENV=$GRID" and re-split on the first `=`. For a CLI-only run that worked only because an unset SHAPE_ENV left a leading `=` the split then removed, so the shapes rode inside a string shaped like the channel they were not using. It takes the grid value directly and picks the channel from the same decision that credited the hook. Collapses the two grid-less branches, which were a 17-line receipt block duplicated verbatim with two different skip strings. The new test fails on the previous script for the reason that matters -- 'no configured shape override' unexpectedly found -- not merely on the field added to carry it, which is why the note assertions come before the grid_channel one. 40 pass. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.
Suppressed comments (3)
Previously missed (2) — in code that hasn't changed since the last review.
.claude/skills/validate-kernel-pr/validation_probe.py:62
- pytest_sessionfinish() clears sys/threading profiling hooks instead of restoring whatever was installed before the validator probe. If profiling was disabled (no expected routes) or another plugin/tool had set a profile hook, this will silently change global process state.
probe = session.config._validation_probe
sys.setprofile(None)
threading.setprofile(None)
receipt_path = _VALIDATION_RECEIPT_PATH
.claude/skills/validate-kernel-pr/validate_evidence.py:83
- The probe supports comma-separated expected routes (it splits on ',') and the receipt can contain multiple observed routes, but validate_receipt() compares the raw receipt 'route' string to --expected-route as a single string and then checks membership against kernel_symbols. This makes multi-route expectations brittle (ordering-dependent) and can incorrectly skip a valid receipt.
if receipt.get("route") != expected_route:
return {
"status": "skip",
"note": (
f"expected route {expected_route!r}, observed {receipt.get('route')!r}"
.claude/skills/validate-kernel-pr/validation_probe.py:56
- The probe unconditionally installs a global sys/threading profile hook and later clears it, which (a) adds overhead even when no expected route(s) were configured, and (b) can clobber an existing profiler that the test run may have installed. Store/restore the previous profiler and only enable profiling when there are expected route(s) to match.
config._validation_probe = {
"routes": routes,
"shape_vars": shape_vars,
"observed_routes": observed_routes,
"observed_shapes": observed_shapes,
"profile": profile,
}
sys.setprofile(profile)
threading.setprofile(profile)
The scanner matched a regex over raw diff text whose operand character class contains neither a comma nor a space, so it could not span a broadcast subscript -- and `ptr[:, None] * stride` is the standard Triton pointer-arithmetic idiom. It also matched operand names against two hard-coded lists. Measured on aiter#4978, the PR that introduced the moe_wgrad overflow later fixed by #5132: 390 candidates emitted, none of them the four real defect lines, and the single moe_wgrad candidate was `off_expert * stride_dwe` -- a line whose operand is widened with `.to(tl.int64)` forty rows earlier. Recall 0 of 4, on the defect family the rule is named for. The defect lived in the syntax tree; the scanner was reading text. Rewritten as an AST pass, taken from #5174. Both name lists are gone. A multiplication is a candidate when it feeds an addition chain, at least one operand derives from a non-constexpr parameter of the enclosing kernel, and no operand is widened -- counting a widening hoisted to an earlier line, which is how #5132 fixes it. Scope follows the scope chain rather than ast.walk, so a nested helper inherits its kernel's parameters instead of being scanned in the wrong frame. Post images come from --source-root or the diff's index blobs; a file whose post image cannot be recovered is reported as NOT SCANNED rather than dropped. It reports 4 of 4 on #4978 and 0 on #5132. Two defects fixed on top of what #5174 ships. AugAssign was never scanned. _scan_body matched ast.BinOp with an Add op, but `a_ptrs += BLOCK_K * stride_ak` is an ast.AugAssign, which is not a BinOp -- so the most common Triton pointer-advance idiom was a blind spot. The constexpr filter in _is_compile_time was written for exactly that expression and could never reach it. Adding it moves #4978 from 296 candidates to 306; the moe_wgrad four and the #5132 zero are unchanged. WIDEN_CALL_RE was left behind by the regex implementation this replaces and had no remaining reader. The --json path returned `0 if not unscanned else 0`. It stays 0, because both callers require that: #5174's own test asserts the plain and --json runs exit 0, and validate_pr.sh turns a non-zero exit into a skipped stage rather than a louder finding. Making the exit status honest needs validate_pr.sh to pass --source-root or to read the `unscanned` field, so the reason is recorded where the return is instead of a ternary whose two branches were the same value. Base's IndexScannerTests asserted the name-list contract that was deliberately removed, down to a JSON key that no longer exists; #5174's rewritten IndexScannerTests and ScannerScopeTests replace it. 48 pass. Co-Authored-By: Claude Opus 5 <[email protected]> Co-authored-by: Cursor <[email protected]>
The probe sampled a frame's f_locals on the `call` event only, so it saw parameters and nothing else. A route that derives its shapes in its body -- the common case for a kernel whose arguments are tensors -- could never satisfy --shape-vars, and the receipt published `pass` beside `executed_shapes: []`. Deciding status from "this code path completed" rather than "the evidence was collected" is the failure this skill argues against in its own text, and it was in the probe. From #5174: the frame is sampled again on return, keyed by the frame OBJECT rather than id(), whose values are reused once a frame is freed and would drop the second of two sequential calls to the same route. When capture was requested and produced nothing, the receipt now carries a shape_capture block saying it attests route execution and makes no claim about shapes, so no consumer can read the empty list as evidence that no shapes were needed. The evidence checker stops counting errors as executed tests. Errors are collection and fixture failures where the body never ran, so a target that failed to import was crediting arch_coverage with runtime coverage on the strength of the collection error itself. This also makes the checker agree with review-pr's ingestion gate, which already asserts `executed == tests - skipped - errors`: they disagree only when errors > 0, which is the shape of a report carrying a real runtime blocker, so the two had to be corrected together or a correct report would be rejected at the door. runtime_identity stops publishing `native_artifacts: []` as a measurement. The probe runs before the target and imports only the module under test, so an empty list describes that import's reach and not the kernel's; the basis string now says which. validate_receipt gains a `--grid-channel` argument, used to suppress the cross-namespace containment assertion when the grid travelled as pytest parameters. It defaults to empty and validate_pr.sh does not pass it on this branch, so that branch is inert until the pytest grid channel lands. 50 pass. Co-Authored-By: Claude Opus 5 <[email protected]> Co-authored-by: Cursor <[email protected]>
The picker returned a single device and the executor took a contended `flock -n` as a refusal. Concurrent validators therefore all selected the same GPU and all but one reported "no idle GPU" with seven sitting idle -- observed twice in one run with every lock free between attempts. A deterministic picker and a non-blocking lock are only safe together if the caller can fall through to the next candidate. From #5174: --all prints the eligible devices in ranking order rather than the top one. The executor side of this, walking that ranking until a lock is taken, lives in validate_pr.sh and is not in this commit, so nothing consumes --all yet; the default single-device output is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Co-authored-by: Cursor <[email protected]>
This branch was based at 6fef3e8/dd6ff6a71 and #5142 has moved on. The two sides independently rewrote the same files, so this is a semantic merge with four decisions worth recording: `scan_index_width.py` -- took #5142's rewrite. Both sides independently turned D9 into an AST pass, and measured against ground truth they are equivalent: on aiter#4978 (which introduced the moe_wgrad overflow) both report exactly the 4 lines aiter#5132 later fixed (moe_wgrad.py:117,118,128,129), and both report 0 on #5132 itself. They differ only in noise: 296 vs 286 candidates, 285 vs 282 unannotated parameters. With detection identical, the tie-breaker is review cost, and taking the target branch's version leaves that file unchanged by this merge. Its tests came across with it. Grid channel -- took this branch's design. #5142 resolves to exactly one channel and adds a `cli-flag-unusable` state; this branch probes three channels independently, adds the pytest `--shape-argnames` channel, and reports `grid_channel_reason` naming each channel tried and what was found. Both fixed the same GRID_HOOK_OK overwrite bug. The third channel is a capability #5142 does not have and `grid_channel_reason` already expresses what `cli-flag-unusable` was for, so the more expressive side wins. `grid_channel` consequently means "the channel that carried the grid" and is empty when none did, which is why one #5142 test now asserts "" plus a reason. `run_pytest`'s second argument -- took #5142's convention. It passes the grid VALUE, not `VAR=value`; #5142's own comment explains that the old assignment form only worked for a CLI-only run because an unset SHAPE_ENV left a leading `=` that the split then removed. The pytest-plugin generator and the CLI/env dispatch were rewired onto it, and dispatch now keys off the channel that probed positive rather than off which flag was supplied. The perf stage -- taken whole from #5142; this branch predates it. Its head timing run and this branch's causality guard on the invalid-grid probe (which requires the unpoisoned head run to have passed first) both apply, in that order. Merged structurally rather than textually: concatenating the test files put #5142's 13 perf tests inside this branch's IndexScannerTests, where they would have run without a fixture. Merging by definition boundary gives 70 tests, all green: 55 from here, 50 from #5142, 35 shared.
Applying validate-kernel-pr to #4538 (a rewritten gfx950 FP8 MQA logits kernel) returned PASS in 93 seconds. The PR has a reproducible correctness failure -- flydsl_fp8_mqa_logits asserts at num_heads=16 on gfx950, where the pre-PR base computes it correctly -- and its central performance claim went unmeasured. Every gap below was found by running the tool, and each fix owns a generic invariant rather than that PR's shape. A shape grid that duplicates the target's own defaults is not a control. All three requested cells were already in the target's `--shapes` default, so the "independent" grid re-ran a strict subset of correctness_repo_tests and was credited `pass` -- the exact duplication SKILL.md says the stage exists to prevent. Grid cells are now compared against the flag's declared default; `test_selection.grid_independence` reports the outcome, and a passing duplicate is downgraded to `skip`. A duplicate that FAILS keeps its `fail`. A coverage axis the shape flag cannot reach could not be requested at all. `--grid` is one ordered tuple on one channel. A target whose head counts, dtypes or window modes live on separate flags had entire configurations unreachable however the grid was spelled. `--axis NAME=FLAG:v1;v2` adds them, under the same burden of proof as `--shape-arg`: the flag must be declared in the target's own argparse AND observed refusing a deliberately invalid value. An axis that fails either is dropped and NAMED, never dropped quietly. A script target's `executed: 1` stood for 56 graded cases. It is the same number a silently-returning target produces, and it earned the same `arch_coverage: runtime` on basis `script-exit-zero-with-output` -- a statement about the process, not the kernel. `stats.observed_work` now carries route calls counted in that run's own receipt, and a script run that observed no work earns no architecture credit. head-repo and head-grid shared one execution receipt. The second erased the first, and with the grid cells a subset of the defaults a receipt written by either run satisfied `--grid`. One receipt per run; `execution_receipt.receipt_scope` names the one that was published. "The PR adds this target, so base has nothing to time against" is not true. The file being new does not make the code it drives new. When the target only exercises an entry point that exists on base, the target is transplanted into the base tree and times the pre-PR implementation through the same harness. Because that spans two trees, `--perf-control-column` names a column the patch does not touch and the stage skips unless it reproduces within PERF_CONTROL_TOL. On #4538 this yields 56 matched rows, the kernel column 1.29x faster on head, and the untouched Triton control within 0.0%. scrape_perf matched 0 of 56 comparable rows. A header with no recognised unit was treated as identifying, but aiter bench tables print unlabeled MEASUREMENTS (`flydsl rel`, `triton err`, `speedup`) that differ between base and head by construction. The strict key is still tried first; only if it matches nothing is a relaxed key used, dropping identity columns whose cells are non-integral. `row_key_basis` records which. The target ran with the reviewer's environment attached. `env VAR=... cmd` adds to the inherited environment, so unmerged third-party code could read every token in the calling shell -- reproduced, with real credentials reaching a stage log. The target now runs under `env -i` plus a name/prefix allowlist and a secret-shaped denylist, and `isolation.target_environment` reports what was passed through. The exit code was read back out of `--out`. That made a previous run's report a fallback source of truth: a run killed before finish_report exited on the earlier run's verdict. `--out` is removed at startup and the code comes from a verdict file inside this run's own $WORK. Ten regression tests, each verified to fail against a8d46dc and pass here; the suite is 62 and green. The synthetic picker moved off a real device index, which was making the suite contend with genuine validations on the same host.
The driver reverse-applied each case's patch unconditionally after the run. But validate_pr.sh already hands the worktree back with the patch reversed, so that second reverse-apply failed with "patch does not apply" on EVERY case, and under `set -euo pipefail` it aborted the driver before the summary block that compares each verdict against the manifest. The mutants were being discriminated correctly the whole time -- m0 PASS, m1 and m3 BLOCK in correctness, m2 BLOCK in test_policy -- but the suite could not say so, and its exit status was 1 regardless of the result. A regression asset that cannot report itself green is not one. Reverse only when `git apply -R --check` says the patch is still applied. End to end on ROCm/FlyDSL@421935cc with the installed flydsl 0.3.1 (verified identical to that commit's python/flydsl tree), the replay now prints "mutant replay matched all expected verdicts". Found by running the committed replay as a held-out case, not by reading it.
Three defects that only appeared on #5172, a fresh held-out PR frozen before any of this work started and never looked at while fixing. A requested axis vanished from the report when it could not be honoured. #5172's target is collected by pytest, so argv-borne axes cannot reach it and axis_state became "unusable" - correct - but test_selection.axes was published as [], so a reader could not see that an axis had been requested at all. An empty list beside a non-"none" state loses the request itself, which is exactly the silently narrowed test space these fields exist to make visible. Axes are now recorded as asked for, with hook_proof "not-evaluated" when the run never got far enough to scan the target for the flag. grid_independence published a false statement about the target. Its default reason, "the channel exposes no declared defaults to compare against", was emitted whenever the comparison did not happen - including when the channel had been demoted for an unrelated reason. On #5172 that is untrue: the target's -c flag does declare a default list, and all three requested cells were outside it. The reason now names which of the several skip paths applied. "Red on both baseline and head" is an attribution, not an explanation. #5172's target defines pytest nodes AND parses argv in its module body, so pytest imports it at collection with its own argv and argparse exits. The file is green run as a script - the perf stage in the SAME run proves it, three times per side. The report said the target was red and gave no hint that the runner selection was the cause. test_selection.runner_risk now names that structurally, and a run that executes nothing under the selected runner cites it. Thirteen new regression tests in all, each verified to fail against a8d46dc; the suite is 63 and green.
A second script-target case, #5081, was picked after the first held-out round showed that the mechanisms added here had only ever executed their positive path on #4538. Selection was structural and outcome-blind ("an aiter PR that ADDS an op_tests script target with a shape flag and a sibling axis flag"); it immediately produced a false blocker. "Defines a test* function" is not "pytest can collect it". aiter's dominant op_tests convention is a SCRIPT whose worker happens to be named test_<op>(m, d, dtype) and is called from main() with real arguments. pytest collects it, cannot supply the parameters, errors -- and the validator published "the PR adds this test target and it fails on head" against an author whose target is green as a script with the very shapes the run had requested (verified by hand: -m 97 513 -n 512, all checkAllclose passed). A test* function is now only counted as a pytest node when it takes no required positional parameters or carries a parametrize/fixture decorator. #5081 selects `script`, the grid and the axis reach it, and no blocker is raised. `--runner` lets a caller settle the case the classifier still gets wrong, recording both the forced choice and what selection had said. A route behind functools.wraps could never be observed. A frame's identity is f_globals["__name__"] + ":" + f_code.co_name, and wraps copies __name__ onto the wrapper object while leaving co_name alone -- so aiter's whole @compile_ops family executes as `aiter.jit.core:wrapper` and naming the op matched nothing. The probe now resolves the declared route to code objects through the __wrapped__ chain; the string match remains as a fallback for a module that cannot be imported. On #5081 the receipt goes from observed '' to a real observed route, and INCONCLUSIVE now rests on the honest remaining gap (a (*args, **kwargs) dispatch wrapper binds no shape locals, so the receipt reports missing shapes rather than passing). Two fields answered the same question differently. When a proven axis rescues a duplicate shape grid, the override reached stages.correctness_s1_grid.independence but not test_selection, which had been written earlier -- so one report said "duplicates-target-defaults" and "adds-coverage" at once. Both are now written from the same decision. A control-gated perf stage still published the numbers it had rejected. `status: skip` beside a median_ratio and a regressed_rows list reads as a regression that was merely not acted on. When the control column moves outside PERF_CONTROL_TOL the ratio fields are dropped. Verified on #5081 end to end: novel grid -> grid_independence adds-coverage with axis `-n` proven (target_defaults 384/768/1024/4224, novel 512/1536); duplicate grid + no axis -> the stage downgrades to skip and both fields agree; duplicate grid + proven axis -> rescued, and they still agree. Seventeen new regression tests, all verified to fail against a8d46dc; the suite is 68 and green.
|
Re-reviewed at Don't merge ahead of #5174. Please freeze this branch until #5174 lands on it. #5174 has gone dirty twice: its base is Four Copilot comments are false positives, resolvable as-is:
|
Rebase onto #5142, and stop the validator reporting coverage it did not obtain
There was a problem hiding this comment.
🟡 Changes recommended
The report schema contains a duplicate key and the receipt validator has a concrete multi-route verification bug, both of which can break or mislead evidence consumption.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 18/20 changed files
- Comments generated: 4
- Review effort level: Lite
|
Re-reviewed at The remaining blocker is mechanical: 15 unresolved Copilot threads and no approving review. Here is where each thread stands, so they can be cleared without re-deriving the analysis. Safe to resolve — verified false positives (4):
Safe to resolve — fixed or harmless (2):
Real, not fixed, and not carried by #5174 (2). Neither affects whether the validator reaches a correct PASS, so I do not think they should hold this PR — but they should not be lost either:
Not yet verified (7) — multi-route Suggest merging on the strength of the above and opening one follow-up PR for the two confirmed defects plus whatever survives review of the seven. Two rebase races have already cost this branch a day; a third to land two evidence-quality fixes is a bad trade. |
|
It can be merged once the required CI passes. |
Supersedes #4870. Same skill, plus the fixes found in the review rounds since.
Why a new PR rather than more commits on #4870: #4870's head lives on
jhinpan:skill/validate-kernel-pr, a fork, so fixes found during review cannot be pushed there by the people finding them. This branch iszhiding512/validate-kernel-pr-amdsmi-fixin ROCm/aiter, so review rounds land directly. Nothing about the design is being relitigated here.Authorship: 12 of the 23 commits are @jhinpan's, preserved unmodified with their original authorship and messages —
342ffd0ethrougha7f52abc, identical to #4870's head. The 11 on top are review-round fixes. @jhinpan, this is yours to close #4870 in favour of, or to reject if you would rather carry these on your own branch instead.The review history is on #4870 and is not reproduced here: @zufayu's two acceptance-bar reviews (including the held-out run against #5089 on MI308X/gfx942), @zhiding512's end-to-end report, and @jhinpan's replies. Read that thread for the reasoning behind the current design; #5128 tracks the measurement work agreed there.
What the 11 commits on top do
Round 1 — portability and evidence gaps found by held-out validation
79c62806— treat GPU activity as optional, and hand the worktree back clean.amdsmi_get_gpu_activitywas a hard dependency at three call sites, so a host where that single query fails degraded the whole run toNO_GPUeven with idle GPUs available. Hit on MI308X / ROCm 7.0, where the call returnsAMDSMI_STATUS_UNEXPECTED_DATA (43)while enumeration, BDF, ASIC and VRAM queries all work. Activity is now optional andgpu_claim.idleness_basisnames the evidence the claim rests on:activity+vram, orvram-only. Unknown stays distinct from zero — the previousgfx if isinstance(gfx, int) else 0reported an unavailable metric as a measured idle GPU. Separately,merge_simapplied the patch but only the baseline path setBASE_ACTIVE, so any run that skipped correctness exited with the candidate patch still applied, and the next run in that worktree blamed the caller for it.d02515f6— let script targets carry grid and receipt evidence. A target driven by a__main__guard could reach neithercorrectness_s1_gridnorexecution_receipt, soINCONCLUSIVEwas the hard ceiling for every aiterop_tests/*.py— the repository's standard test shape. Neither skip described a property of the target: the route profiler issys.setprofileplus a receipt write and pytest was only where the hook happened to be installed, while the grid was injected solely through an environment variable.run_script_with_probe.pyruns the file underrunpywithrun_name="__main__", calling the probe's own hooks soproducerstays truthful.--shape-argnames the target's own CLI flag, held to the same standard of proof as the env channel: the flag must appear in anadd_argumentcall, and the invalid-grid probe must still make the target fail. This is the commit that relaxesreport_schema.json'sPASSconstrainttest_selection.runnerfromconst "pytest"toenum ["pytest", "script"]— the constraint encoded exactly the assumption being removed, and the schema is what caught the violation when the first scriptPASSwas produced.f8904577— ask the target whether it needs a GPU, and name what that answer rests on. When no GPU was claimed, the target is run once with no visible device;gpu_requirementbecomesnot-requiredonly if it passes and executes at least one test, because a suite guarded byskipif(not torch.cuda.is_available())also exits 0 while proving nothing.PASSstill requiresgpu_claim: pass, so this reaches no clearance that was previously unreachable.Round 2 — review-pr's side of the contract
73e6f575,2a6f4857,493f769f,dd6ff6a7state the promotion bar in review-pr's header, let it accept a script target'sPASS, have it triage whether a PR changes runtime surface at all and run the validator itself when it can, and call the validator directly rather than through abin/wrapper. A PR with no runtime surface is now reportedN/Arather than unvalidated.27b7033d— measure a kernel PR's cost, not just its correctness. A kernel PR could pass every stage while running slower, because nothing timed it. Theperfstage benches the target with the patch reversed and with it applied, inside the base phase's lock on the same GPU. Three choices, each forced by a measurement rather than by taste: minimum over per-column medians (a mean lets an untouchedtorch avgreference column bury the regression next to it); best-of-3 per cell (five warm runs of unchangedtest_layernorm2d.pygaveck avg13.10/20.98/20.70/13.28/13.17 — 1.60x and bimodal, so single-shot at a 0.95 threshold would call unchanged code a regression about half the time; best-of-3 brings the same data to 1.014x); and a worktree snapshot around the timing run, because a bench that dropstuned_op_bench.csvin the repo root otherwise fails the baseline cleanliness check and skips the entire head correctness phase.Round 3 — this round: the skill's own honesty rules, applied to itself
The three commits below came out of reviewing this branch for stale and redundant content. Each is a case of the skill making a claim its code does not support — the failure mode it exists to catch.
4e053e43— describe the validator this branch actually ships.perflanded in27b7033dand its own skill still said it did not exist, instructing a reader to disbelieve a stage that now measures and gates, whilereview-prsaid the opposite in three places.perfis now documented where the implementation lives, including--perf-args,--no-perfand the fourPERF_*env knobs, which were public already and only undocumented. Also: "review-pr never builds and never runs" has been false since493f769f; thebin/validate-kernel-prcomment outlived the wrapper; and the mutant manifest'stolerance_tabledisagreed with the file it describes (test_softmax.pyat the pinned base usesf16=1e-2,bf16=2e-2).b03d15a2— stop the report schema promising evidence nothing produces.report_schema.jsonis the contractreview-prvalidates against, so a declared field reads as a shipped capability.claimsdeclared a stage no producer writes — removed.source_shawas hardcoded null while the honesty rules listed source SHA as recorded evidence — now the resolved module's checkout commit,-dirtywhen the tree has uncommitted changes, which the head phase always does; null for an installed package, because attributing a commit to a prebuilt binary is the provenance claim this skill refuses to make.reference_tolerancesis recorded and never compared, and cannot be as the data stands (dtype-keyed table, positional scraped list, nothing to join on), so the field now says it is context rather than implying it is a gate. Separately, the PASS gate's two byte-identical correctness blocks collapse into one$ref— 74 duplicated lines in the clause that decides what earns a clearance.b3532864— name the channel the shape grid actually travelled on.--shape-argwas added ind02515f6, but the code around it still assumed the grid could only be an environment variable.GRID_HOOK_OKwas assigned twice, so supplying both flags proved the env var whilerun_pytestput the shapes on argv — the report attested a channel the run did not use. A--shape-argnaming a flag the target does not accept fell through to the branch reporting "no shape grid was configured", which is an environment fact standing in for a capability gap. Andrun_pytesttook"$SHAPE_ENV=$GRID"and re-split on the first=, so a CLI-only run worked only because an unsetSHAPE_ENVleft a leading=the split then removed.Verification
Round 3 (this round), on the checked-in regression suite:
tests/test_validator.py'no configured shape override' unexpectedly found, i.e. on the reported reason, not merely on the field added to carry it$refcollapsePASSreport validates;executed=0,failures=1,errors=1,exit=1,status=skip, missingstats, andstatsmissingskippedare each still rejected on both correctness stagesgrid_channeland a nullsource_shastill validatesblack/ruff checkRound 1, on #4538 (gfx950, MI355 OAM), base
89178864:--shape-arg -sPASS9/9, exit 0, review-pr consumable,idleness_basis: activity+vram…fp8_mqa_logits:_auto_variantover the four injected production shapes--shape-argnaming a flag the target does not acceptcorrectness_s1_grid: skip, receipt stillpass-inffill dropping[e, seq_len_kv))BLOCK, exit 1, withcorrectness_s1_gridfailing independently of the PR's own suiteThe seeded-defect row is the one that matters: the injected grid caught the defect on its own, so the stage has real discriminating power rather than being decoration. Note that round 3 found the "flag the target does not accept" row above was reporting the right verdict for the wrong stated reason — the run skipped, but told the reader no grid had been configured. That is fixed in
b3532864, and the new test pins it.Known gaps, not addressed here
amdsmiimport fallback covers/usr/lib/python3/dist-packagesand/usr/lib/python3.X/dist-packages, but not/usr/local/lib/python3.*/dist-packages, where ROCm 7.2.4 ships the bindings — so from inside a virtualenv the picker can exit 2 unlessPYTHONPATHorPYTHON_BINis set.AITER_TRITON_ONLY=1, which guaranteesnative_artifacts: []for aiter and excludes the CK/HIP op path from every run. Fine for FlyDSL/Triton PRs; a scope limit that belongs in "What this skill does not do" and is not yet written there.--targetfrom a diff is still the unsolved part. An irrelevant target can still producePASS; the report names the target so a reviewer can reject that evidence, but the executor cannot decide relevance itself.tests/test_validator.pycopy-pastes a 12-line git-commit block seven times and builds the sameSCALE=1.25perf patch three times while bypassing the helper that exists for it;validate_pr.shhas twoelif/elsebranches with identical bodies and extracts one JSON field three times in two styles;--testsis an alias with no in-tree caller.Two earlier known gaps are now closed:
pick-idle-gpu.pyhas its shebang, andvalidate_evidence.pyno longer hardcodessource_sha: None.