Skip to content

[CK] [fix] blockscale moe header: include moe_silu.hpp and <cmath> directly - #8305

Merged
yifehuan merged 1 commit into
mainfrom
zufayu/blockscale-moe-silu-include
Nov 26, 2026
Merged

yifehuan merged 1 commit into
mainfrom
zufayu/blockscale-moe-silu-include

Conversation

@zufayu

@zufayu zufayu commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

What this changes

Today _publish.py posts card.md as one top-level issue comment. This changes it to post a PR review — POST /repos/{owner}/{repo}/pulls/{pr}/reviews with event: "COMMENT", never APPROVE or REQUEST_CHANGES — with the findings that can be anchored attached to the lines they are about, and everything else left in the review body.

The mechanism is ported from ROCm/ATOM's feat/atom-review-bot. ATOM's bot has never posted successfully (its machine account is flagged), so this code has never run against live GitHub. aiter's bot is live, which is why this is a draft — see "What is not verified" below.

Why

Across the 61 real cards this bot has already published on this repo, there are 229 findings. 120 (52%) cite a file:line, and 65 of those lines are inside the PR's own diff. Those are findings a reader would rather meet next to the code than half-way down a wall of prose.

Measured on ten of those real cards, replayed against the diffs they were written for:

PR findings anchored left in summary card chars (today) summary chars (after) change
#5742 2 1 1 1878 1340 −538
#5767 3 0 3 2701 2341 −360
#5776 3 0 3 3249 2866 −383
#6184 5 3 2 4928 2908 −2020
#6188 5 0 5 4108 3752 −356
#6343 3 0 3 3094 2804 −290
#6364 1 1 0 1382 535 −847
#6442 5 2 3 3909 2632 −1277
#6756 4 3 1 3110 1635 −1475
#6815 5 1 4 4666 3360 −1306
total 36 11 25 33025 24173 −8852 (27%)

Every card gets shorter. But read the rows honestly: where nothing anchors (#5767, #6188, #6343, #5776) the card only loses ~300–400 characters, and that is the bold one-sentence PR summary the review body omits — not the mechanism working. The real win is the four rows with ≥2 anchors. On aiter, only 28% of findings anchor (65/229), against the ~50% ATOM measured, because aiter findings more often cite a line of context code the PR did not touch, or carry no file:line at all. 35 of 61 cards would get at least one inline comment; 26 would be unchanged in substance.

The index is not decoration

The review body ends with a one-line index of every finding that went inline:

**3 finding(s) posted inline, on the lines they are about:**
- `aiter/ops/shuffle.py:23` — imports `_FLYDSL_USE_HERD` without pinning it

Without it, a reader of the summary alone cannot tell whether three findings exist elsewhere or none do — and an invisible finding reads exactly like a finding that was never made.

Anchoring is a privilege a finding earns

check_citations.py comes across from ATOM and is wired in as run_one.sh step 3c. It writes citations.txt, _lib.py collects it into the report dir, and _publish.py refuses to anchor any finding carrying a citation the checker flagged — even if another citation in the same sentence would resolve. A top-level card that cites a wrong line is a flaw the reader works around; an inline comment on a wrong line lands in the author's working view and is visibly wrong, and a reviewer who gets burned once stops reading the rest.

With no citations.txt at all, nothing anchors and the whole card stays in the summary — i.e. exactly what this bot posts today. That is the intended degradation.

The checker never gates the run (|| true, not in _gates.py). It ran 1-for-2 on real cards; a 50%-precision heuristic that withholds correct reviews costs more than the defect it catches. It did earn its keep here: on #5776 it flagged aiter/mla.py:2693, and that finding correctly lost its inline slot.

Degrade-to-summary

A review is all-or-nothing: one comments[] entry naming a line GitHub will not accept fails the whole call, summary included — strictly worse than the issue comment this replaces. So a refusal retries the same endpoint with the anchors folded back into the body and says [ANCHORS REFUSED -- folded into summary]. A review that silently sheds half its findings reads exactly like a review that only had the other half. Two tests pin this.

Adapted, not transcribed

Where aiter differs from ATOM and what changed as a result:

  • Card shape. aiter's SKILL.md writes Review (advisory):, not ATOM's Review:, and adds a Perf (advisory|deterministic): line ATOM has no counterpart for. ATOM's literal "Review:" / "Validation" prefixes would have dropped all three status lines, leaving a summary with no verdict in it. The summary now matches on the bare word and keeps every one, in card order. Pinned by a test.
  • Dedup. aiter's BOT is overridable via AITER_BOT_NAME; the dedup marker is deliberately not derived from it, or a box with that var set would repost over every review the real bot already published. And already_posted() now searches both the issues-comments and the reviews endpoints — aiter's markers are sitting in live issue comments right now, and a check that only read reviews would repost on top of all of them. Both pinned by tests.
  • Env names. AITER_BOT_TOKEN(_FILE), AITER_BOT_REPO, repo default ROCm/aiter, status file .aiter-review-status, annotation title aiter-bot — all kept as aiter had them. _api_raw() (the .diff media type) is new; aiter had no caller for it.
  • check_citations.py provenance. Its measurements are ATOM's and have not been rerun on aiter's cards; the docstring now says so instead of presenting them as local facts. Its "ambiguous bare basename" comment was recounted against this tree (aiter has 8 utils.py, 7 quant.py).
  • _lib.py. citations.txt joins OPTIONAL, not REQUIRED: a run whose worker died before writing a card has no citations to check, and absence is not a defect.
  • No divergence was flattened. aiter's _publish.py was ATOM's minus the anchoring work, plus the env-overridable REPO/BOT; both overrides are kept.
  • Untouched: .github/scripts/pr_self_review.py is a separate system that PATCHes its own comment in place. It is not this skill and nothing here goes near it. The workflow YAML is also untouched.

Guards

check_prompts.py gains three checks:

  • check_publish_review_is_advisory — the event stays COMMENT, APPROVE/REQUEST_CHANGES appear nowhere in the file, and there is exactly one POST call site, pulls/{pr}/reviews.
  • check_publish_needs_post_flag — _publish.py falls back to ~/.git-credentials on the self-hosted box, a human PAT with write access, so GITHUB_TOKEN scoping does not stop it posting at all; the missing --post flag is the only closure. If the workflow ever grants issues: write or pull-requests: write, the invocation must pass --post explicitly.
  • check_anchoring_has_a_citation_check — run_one.sh → citations.txt → _lib.py → _publish.py cannot be half-removed in silence, because that degradation looks identical to a card whose findings simply cite nothing.

selftest.sh now runs _publish_test.py (35 cases: the --post closure, the anchoring rule, dedup, the degrade-to-summary fallback), and says out loud when pytest is absent rather than passing over it — a check that did not run is not a check that passed.

Verification, verbatim, on a clean tree built with git archive HEAD

$ bash .claude/skills/review-pr/selftest.sh | tail -1
=== 97 green / 0 red ===

$ python3 .claude/skills/review-pr/check_prompts.py | tail -1
OK: 0 drift(s)

$ python3 -m pytest .claude/skills/review-pr/_publish_test.py -q
.................                                                        [100%]
35 passed in 0.18s

(Baseline on origin/main was 93 green / 0 red and OK: 0 drift(s); the extra green is the new pytest block.)

preflight.sh on the same tree: 20 green / 1 red. The red is pre-existing and environmental — the self-hosted runner is not installed as a systemd service — and is untouched by this change.

What is verified live, and what still is not

A real review was posted by this code on 2026-11-03 —
pullrequestreview-5749640123,
this PR reviewing itself at 72d8c7c3baa9. What GitHub actually stored, read back
through the API:

state=COMMENTED  user=zufayu  commit=72d8c7c3baa9
.claude/skills/review-pr/_publish.py
  start_line=211  line=248  side=RIGHT  start_side=RIGHT  position=191   (not outdated)

That settles the three things the anchor rules were only reasoned about: the API
accepts the payload as built, a range anchor resolves to the span rather than its
first line, and event: "COMMENT" lands as COMMENTED — the bot cannot approve or
request changes. citations.txt was produced by a real run_one.sh in the same run
(CITATIONS: every cited file:line resolves (1 proximity note(s))), and the run
closed 7 gates green with 3 findings, all 3 surviving independent refutation.

Still not verified:

  • The degrade-to-summary fallback has never fired against the real API. The anchors
    were accepted, so the refusal path stayed on the stub that rejects any payload
    carrying comments[]. It is untested where it matters most, and a review is
    all-or-nothing, so this is the residual risk this PR carries.
  • AITER_BOT_TOKEN's scope is still unconfirmed by use. The live post was made with
    a classic PAT carrying repo (zufayu), not with the bot's token. Creating a review
    needs Pull requests: write where an issue comment needs only Issues: write, so a
    fine-grained PAT carrying only the latter would fail every review and lose the card —
    a regression the anchor fallback does not cover, because it handles a bad anchor,
    not a token that cannot create reviews at all. The first run under the bot's own token
    is the thing to watch.
  • The ten-card replay used each PR's head as it stands now, and only PRs whose head
    still matches the SHA in the card's marker, so those diffs are the ones the findings
    were written against. The 61-card population figures used current diffs, so for PRs
    that have moved since review they are an approximation.
  • A review is attached to the commit it read. Pushing between the review and the publish
    leaves the comment on the older commit — observed here, where the finding posted was
    already fixed at head. In production the window is one job; by hand it is as long as
    you take.

Landed checks

Done, in this order: _publish.py <pr> --payload on this PR and read the JSON, then
--post for real. Both outputs are quoted above. The remaining step for whoever merges
this is the first run under AITER_BOT_TOKEN rather than a personal PAT.

🤖 Generated with Claude Code


PR Self-Review

Reviewed revision

17936b2e7c56

Behavior and intent

_publish.py posted the review card as one top-level issue comment. On ten real
aiter-bot cards that comment averages 3300 characters of dense prose, and a single
finding averages ~900 — a paragraph each, in a wall nobody reads to the end. Half the
findings cite a file:line, so some of them can be attached to the code they are about
instead.

It now posts POST /pulls/{n}/reviews with event: "COMMENT" — never APPROVE or
REQUEST_CHANGES; this bot does not gate merges — anchoring the findings whose cited
line is inside the diff, and keeping the rest, plus a one-line index of the anchored
ones, in the review body. The index matters: without it a reader of the summary cannot
tell whether findings exist elsewhere or none do, and an invisible finding reads exactly
like one that was never made.

Anchoring is gated on check_citations.py, ported here from ATOM along with the
run_one.sh step and _lib.OPTIONAL entry that produce and collect citations.txt.
A finding whose citation the checker could not resolve is not anchored: an inline
comment on the wrong line lands in the author's working view and is visibly wrong, and
a reviewer burned once stops reading the rest.

Three further changes landed here because this PR's own review found them, and each is
the same defect wearing a different hat — a check that does not run looks exactly like
a check that passes
:

  • Rejected validation evidence used to abort the run under errexit, producing no card
    at all. One missing optional import took the whole review down, which reads to the
    person waiting on it like the bot being offline. The integrity checks stay fail-closed
    — evidence that does not match this PR's head, base or patch is still never used — but
    rejecting it now degrades the review and records why, instead of deleting it.
  • A dead fetch said nothing. errexit killed run_one.sh inside the fetch pipeline
    before the classification could run, and the exit trap wrote a status file while
    printing nothing, so the log ended mid-sentence. The traps now speak, and a spent
    GitHub quota is told apart from a token fault and from an account GitHub has
    restricted (60 core calls with GraphQL at 0), because only one of those is fixed by
    waiting.
  • flagged_citations() read a crashed checker as a clean verdict. check_citations.py
    raised NameError on every call, run_one.sh's || true swallowed it, and the
    traceback in citations.txt returned an empty flagged-set — "every citation checks
    out" — so findings anchored with no checking at all, which is precisely what the
    checker exists to prevent. Absence of a CITATIONS verdict line now means the checker
    did not run, matching the contract this module's own docstring already stated.

Validation and unverified scope

Validated, on a clean tree built with git archive HEAD:

bash .claude/skills/review-pr/selftest.sh | tail -1   → === 97 green / 0 red ===
python3 .claude/skills/review-pr/check_prompts.py     → OK: 0 drift(s)
python3 -m pytest .claude/skills/review-pr/_publish_test.py -q → 35 passed
ruff check . (skills tree)                            → 0 findings

Baseline on origin/main before the change: 93 green / 0 red, 0 drift;
_publish_test.py does not exist there, so all 35 cases are new. Measured on ten real
published cards replayed against the diffs they were written for: 36 findings, 11
anchored, summary 33025 → 24173 characters (−27%). The win is concentrated in the four
cards with ≥2 anchors; cards where nothing anchors barely shrink.

Validated against the live API, on this PR, 2026-11-03, hardware irrelevant (one
gh api call from a CPU box):

python3 _publish.py 7303 --payload   → event=COMMENT, body 1398 chars, 1 inline
python3 _publish.py 7303 --post      → ✅ pullrequestreview-5749640123
gh api .../pulls/7303/comments       → start_line=211 line=248 side=RIGHT
                                        start_side=RIGHT position=191 (not outdated)

The run that produced that card was a real run_one.sh against this repo: 7 gates
green, citations.txt a genuine verdict (every cited file:line resolves, 1 proximity
note), 3 findings, 3 surviving independent refutation.

Unverified, and listed above in full: the degrade-to-summary fallback has never fired
against the real API, because the anchors were accepted; AITER_BOT_TOKEN's scope is
still unconfirmed by use, since the live post used a personal PAT with repo; and the
61-card population figures use current diffs, so for PRs that moved after review they
are an approximation.

One honesty note on method: three of the defects fixed in this PR were found by this
bot reviewing this PR, and two of those were in code written the same day — including a
test suite that passed only because it ran the extracted shell region under bare
set -e while the real script runs set -euo pipefail, so every classification it
claimed to cover was unreachable in production.

PR-specific question

The boundary this introduces: a review is all-or-nothing. GitHub rejects the entire
call — summary included — if any single comments[] entry names a line it will not
accept. The old single comment either posted or did not; after this change, one bad
anchor could lose a whole review, findings and all. That is a strictly worse failure
than the one it replaces, so it is covered three ways:

  1. Anchors are computed from the diff's own hunk headers rather than guessed, and a
    finding only earns one if check_citations.py resolved its citation. A citation the
    checker could not vouch for — including one it never checked, because it crashed —
    forfeits the slot.
  2. On refusal, do_post retries the same endpoint with the anchors folded back into the
    body and says [ANCHORS REFUSED -- folded into summary]. Two tests pin that path,
    including that the folded body still carries the anchored finding's full text. A
    review that silently sheds half its findings reads exactly like one that only ever
    had the other half.
  3. The summary carries a one-line index of every anchored finding, so a reader of the
    summary alone can tell that findings exist elsewhere rather than inferring there are
    none.

The evidence is uneven, and the gap is in the most important place. Paths 1 and 3
are now covered by a live call: a range anchor was accepted and stored on the span
(start_line=211 line=248). Path 2 — the refusal — has only ever run against a stub
that rejects any payload with comments[], because the real API accepted ours. The
fallback is the thing standing between one bad anchor and a lost review, and it is the
one piece still unproven against the API it exists to survive.

Changed op tests

None — no op_tests/ file is touched. The change is confined to
.claude/skills/review-pr/.


Update — anchors point at the section, and what cannot be anchored gets a link

The anchoring above attaches a finding to one line. Two follow-on changes, both measured
on this bot's own archived cards.

1. Range anchors

25 of 221 archived findings cite a line range — layernorm.py:1002-1012 — and every
one was anchored to line 1002 alone, so the reader saw a comment pinned to one line of a
block the finding is about, which reads as a claim about that line. GitHub spells a span
as start_line + line with a start_side/side for each end; a cited range is now
anchored as one.

Both endpoints and every line between must be commentable. That is exactly "inside one
hunk" — commentable() holds one contiguous run per hunk — and checking the two endpoints
alone would accept a span across the gap between hunks, which is a malformed range, which
fails the whole review. When only part of the span is in the diff, the end that is takes
a single-line anchor rather than the finding being dropped.

The span pattern is deliberately tight — ASCII hyphen, no surrounding whitespace. A loose
one reads the real card sentence flash_kda.py:381 — 6 published tuning candidates as the
backwards span 381..6. Over 221 findings the tight form matched 25 spans and no false
positive; the loose form added that one sentence and nothing true.

2. Permalinks for what cannot be anchored

A citation whose line the diff does not reach cannot be anchored — GitHub is right to
refuse it — and used to sit in the summary as bare moe.py:5220 text the reader had to go
and find. It now also gets a blob permalink pinned to the head SHA, alone on its own
line, which is the only place GitHub expands one into the code it names. Pinned and not a
branch: a link that drifts off the code it was written about is a wrong anchor arriving
late. The finding's own path:line text is untouched — the link is in addition.

Neither is invented

Both run through the gate anchoring already had. A citation check_citations.py flagged,
or a card it never ran on, gets no anchor and no link. A path that does not resolve to
a file this PR touched gets no link either: a blob URL built from an unresolved basename is
a guess, and a link to the wrong code is worse than no link, for the same reason a wrong
anchor is.

Measured

Replaying eight real cards against the diffs they were written for — 37 findings:

count
span anchor 11
single-line anchor 16
permalink only 2
nothing 8

Auditing every span citation in the 57-card corpus: 23 of 35 span-anchor cleanly, 1
falls back to an endpoint (part of the span is outside the diff), and 11 resolve to no file
in the diff — a vLLM path, an ambiguous basename matching two changed files, context code
the PR does not touch — and so are correctly left alone. None was too wide for MAX_SPAN.

Replaying also found a defect this change introduced: when a span collapses to one endpoint
the summary index stripped path:563 and left the line opening with a bare -569. Fixed,
and pinned by a test.

The all-or-nothing boundary, again

A malformed span is a new way to fail the whole call. The degrade-to-summary fallback
covers it like any other refusal, and a test now pins that a refused range review degrades
with the span finding's text intact and folded as path:101-104, not as a bare line.

_publish_test.py is new in this PR and carries 35 cases. check_prompts.py gains two drift checks that
build a review over a synthetic two-hunk diff and assert the shape GitHub will take —
start_line < line, matching sides, span inside one hunk, permalinks gated — rather than
the source that produced it.

Verified against the real API

A range anchor was posted and read back: start_line=211 line=248 side=RIGHT start_side=RIGHT, stored on the span, not collapsed to its first line. The
hunk-containment rule held on a real diff. What remains untested is the refusal path —
the anchors were accepted, so the degrade-to-summary fallback has still only ever run
against a stub.

@zufayu
zufayu requested a review from a team November 19, 2026 13:19
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8305 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@github-actions github-actions Bot added the CK label Nov 19, 2026
@aiter-bot

aiter-bot commented Nov 19, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision ff27ce735741 · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

…rectly

gemm_moe_ck2stages_common_blockscale.cuh uses std::isfinite and
ck::MoeSilu::ValidRuntimeLimit at lines 45 and 50 but includes neither
<cmath> nor ck/tensor_operation/gpu/element/moe_silu.hpp. It compiled only
because the non-blockscale gemm_moe_ck2stages_common.cuh happens to pull
moe_silu.hpp in.

That is a latent build break: a generated instance includes exactly one
gemm_moe_ck2stages_common{quanttype}.cuh, so the blockscale TU never sees
the other header, and touching the includes of a sibling header takes the
per_1x128 blockscale instances down with:

  gemm_moe_ck2stages_common_blockscale.cuh:50:25: error: no member named
  'MoeSilu' in namespace 'ck'

Seen for real in #8294, where a revert dropped those two includes from the
non-blockscale header and broke module_moe_ck2stages_abi2_f8_f8_
preshuffle_on_b16_silu_per_1x128_mulWeightStage2_runtime_swiglu_limit.

Include what is used; no behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zufayu
zufayu force-pushed the zufayu/blockscale-moe-silu-include branch from 65f601d to ff27ce7 Compare November 20, 2026 09:02

@yifehuan yifehuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yifehuan
yifehuan merged commit f9268f5 into main Nov 26, 2026
61 checks passed
@yifehuan
yifehuan deleted the zufayu/blockscale-moe-silu-include branch November 26, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants