Repository navigation
Conversation
[ghstack-poisoned]
PR Status: in progressA maintainer requested changes. Please address their feedback before the PR returns to maintainer review. To become ready for review, the change must pass automated review and every maintainer comment must be addressed, either with a code change or a reply explaining why no change is needed. Any running CI must finish and every failure must be classified as unrelated to your PR (see status below in this comment). To minimize iteration time, feel free to run the pr-review skill from the repo locally. If an automated review comment is irrelevant, react with 👎 on that specific comment to reject it, and leave a short reply explaining why. To trigger a fresh automated review, make a new push or comment 🟡 AUTOMATED REVIEW - Changes requested:
Findings (5): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202251
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit ccaf24c with merge base 33ce05e ( 🟡 GREEN LIGHT - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
… interface contracts, use path-less See Note pointers [ghstack-poisoned]
Any edit to a header, including a comment-only one, recompiles every translation unit that includes it. For widely included ATen headers that means long rebuilds for contributors and build cache misses in CI, so a wording tweak to a Note shouldn't live in a header. Add a coding style rule for agents: new or substantially rewritten comments in .h/.cuh/.hpp files stay short (at most a one-line description per declaration plus a `// See Note [Foo]` pointer), and long explanations, including `Note [...]` blocks and interface contracts, go in the source file that implements the op or uses the code, even when that code is a template or inline function defined in the header. Doxygen docs in the headers that docs/cpp/source/Doxyfile feeds to Doxygen (or their aten/src/ATen/templates/ sources), and header-only code with no natural source file, are exempt. Existing long comments in headers can stay and take small edits. Add a matching item to the pr-review skill's Code Clarity checklist so the automated reviewer checks for it. ghstack-source-id: 5c53194 Pull-Request: #202251
…files, caller-facing docs stay in headers [ghstack-poisoned]
Editing a header, even just a comment, rebuilds every translation unit that includes it. For widely included ATen headers that means long rebuilds for contributors, so a long Note explaining how a kernel works shouldn't live in a header where every wording tweak costs a rebuild. Add a coding style rule for agents: long explanations of how or why an implementation works (e.g. a `Note [...]`) go in the .cpp/.cu file that implements the logic, with a short `// See Note [...]` pointer in the header. Documentation callers need (API docs, interface contracts) stays in the header. The rule covers new or substantially rewritten comments; existing ones can stay. Add a matching item to the pr-review skill's Code Clarity checklist so the automated reviewer checks for it. ghstack-source-id: ab39cca Pull-Request: #202251
…ll-writer checklist update [ghstack-poisoned]
Rules in CLAUDE.md, skills and REVIEW.md files are applied literally by agents. When a rule tries to settle its edge cases with lists of paths, exemptions or hard limits, each entry is a factual claim that can be wrong or go stale, and every gap or counterexample then reads as a defect. On #202251 this led to a string of review rounds, each adding a more specific exemption that the next round found a counterexample to, until the rule was cut down to a short one. Add an "Agent Guidance" section to CLAUDE.md asking agents that add or rewrite instructions for agents to keep them short and state the intent, spelling out only the edge cases that are known pitfalls. It sits in its own section rather than in Coding Style Guidelines, which covers code changes. Update the skill-writer skill to match: its skeleton template asked for an "edge cases" step and its validation checklist for "edge cases handled". Drop the template step (the template's best practices already list common pitfalls) and make both of its validation checklists ask for stated intent, with edge cases only for known pitfalls. This only changes guidance for authors. The pr-review skill's own rules are unchanged: changing what the automated reviewer flags needs a maintainer's explicit approval and belongs in a separate PR. Test Plan: documentation-only change. Checked the other agent guidance that mentions edge cases for conflicts with the new rule: ``` git grep -n -i "edge case" -- CLAUDE.md '*REVIEW.md' .agents ``` This PR was authored with the help of an AI assistant (Claude). ghstack-source-id: ffacba2 Pull-Request: #202334
…ted (#202455) ✴️ iz2: Two prompt fixes to Stage B of the hardened PR review. In both cases a real blocking review was rejected by `extract_verdict.py` and nothing was posted. Part of pytorch/test-infra#9260. 1. **Needs Discussion with a blocker.** Stage A can recommend Needs Discussion while naming a defect that must be fixed. Stage B mapped Needs Discussion to `ready_for_human_review` and the defect to `major`, and the sanitizer refuses that combination. This happened on #202251 and #201766. Now such a defect is `major` and the verdict is `changes_requested`; open questions, requests for data or discussion, and unreviewed files are not such defects. The summary keeps the Recommendation and says when a defect overrode it. 2. **Findings on files with no anchorable line.** `/tmp/pr-files.txt` lists deletions, pure renames, mode-only changes and binary files, but their diffs show no added or context line, so a finding on one is discarded and a change request left with none is rejected (#201671). The prompt now names these and points Stage B at a changed line instead. This does not fix PRs whose every file is such a file, since they have no anchorable line at all. A separate change to the sanitizer covers that case. Test plan: `python3 -m unittest test_workflow_contract` in `scripts/pr_review` (174 pass). Two new tests pin both rules and fail on the old prompt. Pull Request resolved: #202455 Approved by: https://github.com/huydhn
…ted (pytorch#202455) ✴️ iz2: Two prompt fixes to Stage B of the hardened PR review. In both cases a real blocking review was rejected by `extract_verdict.py` and nothing was posted. Part of pytorch/test-infra#9260. 1. **Needs Discussion with a blocker.** Stage A can recommend Needs Discussion while naming a defect that must be fixed. Stage B mapped Needs Discussion to `ready_for_human_review` and the defect to `major`, and the sanitizer refuses that combination. This happened on pytorch#202251 and pytorch#201766. Now such a defect is `major` and the verdict is `changes_requested`; open questions, requests for data or discussion, and unreviewed files are not such defects. The summary keeps the Recommendation and says when a defect overrode it. 2. **Findings on files with no anchorable line.** `/tmp/pr-files.txt` lists deletions, pure renames, mode-only changes and binary files, but their diffs show no added or context line, so a finding on one is discarded and a change request left with none is rejected (pytorch#201671). The prompt now names these and points Stage B at a changed line instead. This does not fix PRs whose every file is such a file, since they have no anchorable line at all. A separate change to the sanitizer covers that case. Test plan: `python3 -m unittest test_workflow_contract` in `scripts/pr_review` (174 pass). Two new tests pin both rules and fail on the old prompt. Pull Request resolved: pytorch#202455 Approved by: https://github.com/huydhn
…ted (pytorch#202455) ✴️ iz2: Two prompt fixes to Stage B of the hardened PR review. In both cases a real blocking review was rejected by `extract_verdict.py` and nothing was posted. Part of pytorch/test-infra#9260. 1. **Needs Discussion with a blocker.** Stage A can recommend Needs Discussion while naming a defect that must be fixed. Stage B mapped Needs Discussion to `ready_for_human_review` and the defect to `major`, and the sanitizer refuses that combination. This happened on pytorch#202251 and pytorch#201766. Now such a defect is `major` and the verdict is `changes_requested`; open questions, requests for data or discussion, and unreviewed files are not such defects. The summary keeps the Recommendation and says when a defect overrode it. 2. **Findings on files with no anchorable line.** `/tmp/pr-files.txt` lists deletions, pure renames, mode-only changes and binary files, but their diffs show no added or context line, so a finding on one is discarded and a change request left with none is rejected (pytorch#201671). The prompt now names these and points Stage B at a changed line instead. This does not fix PRs whose every file is such a file, since they have no anchorable line at all. A separate change to the sanitizer covers that case. Test plan: `python3 -m unittest test_workflow_contract` in `scripts/pr_review` (174 pass). Two new tests pin both rules and fail on the old prompt. Pull Request resolved: pytorch#202455 Approved by: https://github.com/huydhn
There was a problem hiding this comment.
Automated review of ccaf24c: changes requested before human review.
The PR adds a rule to CLAUDE.md and the pr-review checklist: long implementation notes go in the source file that implements the logic, and the header keeps only a short See Note \[...\] pointer. Recommendation: Request Changes. A blocking finding from the previous review is still unaddressed: the rule has no carve-out for header-only code and names only .cpp/.cu. Three other points are non-blocking.
🔴 2 blocking findings are attached to the code below.
⚪ 3 non-blocking findings
Line 236 in ccaf24c
Non-blocking: no guidance for Notes that mix caller contracts with rationale (also review-checklist.md:39). The exemption covers "API docs, interface contracts" but does not say how to treat a Note that contains both. Example: torch/headeronly/cuda/Atomic.h:356-363 (Note [HIP unsafeAtomicAdd]) mostly explains the implementation choice, but it also says the caller must pass GPU memory, otherwise "the result is a silent no-op". An agent that substantially rewrites such a Note could move all of it, precondition included, out of the header. Suggest adding "preconditions/invariants callers rely on" to the parenthetical, which would also line up with the checklist's "Interface documentation" item (line 12).
Line 232 in ccaf24c
Non-blocking: unclear precedence over the "match existing patterns" rule. CLAUDE.md:217 ("Match existing code style and architectural patterns") points the other way when a new note is added to a header that keeps all its notes inline, such as Atomic.h or intrusive_ptr.h. A short clause like "even if the header already contains notes" would settle which rule wins.
Line 236 in ccaf24c
Non-blocking wording (also review-checklist.md:39): "Documentation callers need (API docs, ...) stays in the header" first reads as the noun phrase "Documentation callers". "Documentation that callers need" is clearer.
Please address the findings and push; a new commit normally gets a fresh automated review.
Disagree with a finding? Reply with your reasoning, then comment @pytorchbot review to request a re-review. This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
| - Don't put long explanations of how or why an implementation works (e.g. a | ||
| `Note [...]`) in C++/CUDA headers (`.h`, `.cuh`, `.hpp`): editing a header, | ||
| even just a comment, rebuilds every file that includes it. Put them in the | ||
| `.cpp`/`.cu` file that implements the logic and leave a short |
There was a problem hiding this comment.
🔴 Continuing, blocking: the rule has no answer for header-only code, and it names only .cpp/.cu. It sends notes to "the .cpp/.cu file that implements the logic", but when the header is the implementation, that file does not exist. torch/headeronly/ has no .cpp/.cu/.mm files, and torch/headeronly/cuda/Atomic.h already holds Notes (lines 279, 315, 356). torch/csrc/stable/ is also headers only. In c10/util/intrusive_ptr.h, the template logic and its Notes are in the header, while intrusive_ptr.cpp holds little more than a static_assert. torch/headeronly/REVIEW.md:24-25 asks for justification in code comments, and in that directory those can only go in headers. An agent following the rule has to put the note in an unrelated translation unit or drop it. The reviewer will also flag correctly placed header notes. Separately, .mm (MPS) is left out. Fix: name the target generically, as "the source file (.cpp, .cu, .mm, ...) that implements the logic", and add a carve-out: "If the logic lives only in headers (e.g. torch/headeronly/, torch/csrc/stable/, templates), the note stays in the header."
|
|
||
| - [ ] **Self-explanatory code** - Variable and function names convey intent; minimal comments needed | ||
| - [ ] **Useful comments only** - Comments explain non-obvious context that cannot be inferred locally. For large comment use the `# Note [Good note title]` and `See Note [Good note title]` to write larger comments that can be referenced from multiple places in the codebase. | ||
| - [ ] **Implementation notes out of headers** - New or substantially rewritten long explanations of how or why an implementation works (e.g. a `Note [...]`) go in the `.cpp`/`.cu` file that implements the logic, with a short `See Note [...]` pointer in the header, since any header edit rebuilds every includer. Documentation callers need (API docs, interface contracts) stays in the header; existing comments need not move |
There was a problem hiding this comment.
🔴 Continuing, blocking (same issue as CLAUDE.md:235): the checklist item sends notes to "the .cpp/.cu file that implements the logic". It has no carve-out for header-only code (torch/headeronly/, torch/csrc/stable/, template headers like c10/util/intrusive_ptr.h) and leaves out .mm. The automated reviewer will flag every new note correctly placed in a header-only header. Fix in the same edit as CLAUDE.md: name the target generically (.cpp, .cu, .mm, ...) and add a carve-out saying that when the logic lives only in headers, the note stays in the header.
Stack from ghstack (oldest at bottom):
Editing a header, even just a comment, rebuilds every translation unit
that includes it. For widely included ATen headers that means long
rebuilds for contributors, so a long Note explaining how a kernel works
shouldn't live in a header where every wording tweak costs a rebuild.
Add a coding style rule for agents: long explanations of how or why an
implementation works (e.g. a
Note [...]) go in the .cpp/.cu file thatimplements the logic, with a short
// See Note [...]pointer in theheader. Documentation callers need (API docs, interface contracts) stays
in the header. The rule covers new or substantially rewritten comments;
existing ones can stay.
Add a matching item to the pr-review skill's Code Clarity checklist so
the automated reviewer checks for it.