Skip to content

feat(gemm_fusion): route sp_qkv_fused v1; keep a reference native, implementation moves to a provider - #6689

Merged
zufayu merged 1 commit into
mainfrom
blyu/gemm-fusion-sp-qkv
Nov 12, 2026
Merged

zufayu merged 1 commit into
mainfrom
blyu/gemm-fusion-sp-qkv

Conversation

@demonsan

@demonsan demonsan commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR keeps the AITER-owned sp_qkv_fused v1 contract, routing and a slow
reference native
; the tuned gemm_fusion framework, kernels, profile configs and
evidence move to the out-of-tree plugin_poc provider. The reference native means a
call never becomes unroutable when no provider is installed; the provider is the fast
path. The reference models one rank's view: every source token block carries the
local rank's head shard, so with byte-identical inputs the blocks are value-neutral
(the invariant the node-58 GPU e2e compares).

What stays in AITER

  • aiter/ops/gemm_fusion/sp_qkv/op.py — the routed op on the existing flat
    15-positional + keyword-only signature: @route(op="sp_qkv_fused", version=1).
    If no provider serves, the native body runs a pure-PyTorch reference: dequantise
    x/w, undo the 16x16 weight preshuffle, GEMM, Gemma RMSNorm, partial NeoX RoPE, and
    write q/k/v (or index_q) plus golden-shuffle KV/index caches. It is correct
    but deliberately slow and models one rank's view (no SP exchange); it is not a tuned
    kernel.
  • aiter/ops/gemm_fusion/__init__.py + sp_qkv/__init__.py — minimal export shims.
  • aiter/ops/gemm_fusion/sp_qkv/CONTRACT.md — contract/provider model, native
    reference semantics and limits.
  • aiter/__init__.py — lazy sp_qkv_fused export.
  • tests/plugin_contracts.json — records the routed v1 signature so the stock-main
    interface contract test accepts the new route.
  • op_tests/test_gemm_fusion_sp_qkv_op.py — CPU torch tests: registration against the
    merged main interface, no provider runs native (q/caches written in place, pad
    slots untouched), fake provider wins and native is not called, decline and kill
    switch fall back native, wrong op version rejected, invalid mode/shape/dtype errors,
    unsupported native case NotImplementedError, determinism, indexer path, and a
    block-invariance/local-shard test that fails on the old block s -> shard s mapping
    (15 CPU tests).

What was removed, and where it went

Removed from AITER:

  • aiter/gemm_fusion/** (tuned framework, profile/match/spec/plan/resources/prebuild);
  • aiter/ops/gemm_fusion/sp_qkv/{runtime,jit,variants*,specs,inputs,small_rt,large_rt,r18_gemm,prebuild,gen_profile,p1_sweep,test_utils}.py;
  • csrc/gemm_fusion/**;
  • aiter/configs/gemm_fusion/**;
  • implementation/tuning/bench tests and scripts;
  • implementation-only docs.

They now live in the plugin_poc repository on branch
feat/sp-qkv-aiter-provider: provider PR
https://github.com/coderfeli/plugin_poc/pull/1. GPU correctness/evidence and the tuned
kernels belong there; this repo keeps the contract and the reference fallback.

Provider interface

This PR relies on aiter.plugin as merged on main (#7465 / #7466); no interface
files are added by this PR
. The op uses the merged route / configure API and
registers sp_qkv_fused v1 against it, so the contract is exercised on stock main.

Native reference limits

  • One rank's view: T = 4*M rows are four source token blocks; t // M selects
    the source block, t % M the local token row in x used to compute it. Every block
    carries the local rank's q/k/v/index head shard, and ik is replicated. The
    reference performs no SP exchange; with byte-identical inputs across ranks all blocks
    are value-identical, which is the property the GPU e2e compares.
  • Not graph-capture aware and not a performance path.
  • fp8 is dequantised before the reference matmul (CPU torch has no portable fp8
    matmul); the provider keeps the native fp8 kernels.

Revision matrix

component revision
AITER base 023a9d147 (current origin/main)
provider interface merged on main (#7465 / #7466); no overlay in this PR
this PR head bdd5c6816
previous tuned implementation head 582d19d0 (and refactor a3cf2502f)
provider repository plugin_poc feat/sp-qkv-aiter-provider @ 38fd0c11, PR https://github.com/coderfeli/plugin_poc/pull/1

CPU-only verification

Local Windows CPU run:

pytest op_tests/test_gemm_fusion_sp_qkv_op.py -q   -> 15 passed
pytest tests/test_plugin.py tests/test_plugin_contracts.py \
       tests/test_plugin_discovery.py tests/test_plugin_overhead.py -q
                                                    -> 107 passed
python -c "import aiter; aiter.sp_qkv_fused"        -> resolves
black --check changed files                         -> clean
ruff check changed files                            -> clean

The op tests exercise the native reference on ordinary torch CPU tensors; no GPU was
used. The block-invariance/local-shard test constructs distinct per-shard weights so
the old mapping would fail on CPU. Provider discovery uses a synthesized .dist-info plus the stock-main
interface's _reset_for_testing(); no private interface records are injected.

Not run

  • GPU numerics/perf of the native reference path.
  • Provider-serving end-to-end (plugin_poc provider).
  • Multi-rank / graph-capture behaviour of this branch.
  • ATOM end-to-end integration.

GPU smoke / known issue

Node-58 GPU e2e found two issues in the reference native and drove this correction:

  • a device-placement bug: _qv_rows built index tensors on CPU and indexed CUDA
    tensors; every index tensor in the native path now uses the input device (with a
    strict fake-device regression test);
  • a mapping bug: the reference modelled block s -> shard s, while the fused exchange
    gives every source token block the local rank's shard. The old mapping made the
    own block match and peer blocks differ by the other q-head weights when compared with
    the provider; the corrected reference is block-invariant for byte-identical inputs.
    A CPU test with distinct per-shard weights covers the invariant.

Node-58 also ran the previous in-tree implementation on the same cases (Phase A/B
provenance) to confirm the provider comparison; full GPU native numerics/perf is still
not run/certified in this branch.

Risk

  • The native is a slow reference; tuned performance and GPU evidence require the
    provider to be installed. AITER callers that relied on the removed in-tree kernels
    must install the provider to keep their previous performance.
  • No GPU validation is claimed here; the provider repo owns it.
  • The reference is not an exchange: block-invariance holds only for byte-identical
    inputs across ranks; with rank-distinct inputs the provider's exchange is required
    for correct cross-rank values.
  • Revert is a branch revert (the previous tuned implementation is preserved in
    backup/gemm-fusion-sp-qkv-full on origin).

CI note: huge deletion vs previous head

Against the previous tuned implementation head 582d19d0 this is a large deletion
(thousands of files, including aiter/gemm_fusion, csrc/gemm_fusion, configs and
tests). Against current main the diff is:

7 files changed, 1016 insertions(+), 1 deletion(-)

That deletion is intentional: no tuned in-tree implementation remains; only the
contract, route and reference native stay.


GPU functional verification (2026-11-10, node 58 / AAC16 job 9381, MI355X x4)

Revision matrix of the verified stack: ATOM 2004ba6b7 (this PR), AITER e2e helper a6794ef4 (= #7346 SP APIs + the #6689 routing commit 2a4bbafb + main's aiter.plugin) and the provider coderfeli/plugin_poc 47c29e8e installed editable (entry point sp-qkv-provider = plugins.aiter:provider), image rocm/atom-dev:vllm-latest@sha256:885d0611..., FlyDSL 0.5.0.

  • Op level (4 ranks, 6 cells): PASS. dense m8/64/256, indexer m8, reuse m8 served by the provider; decline m512 -> AITER reference native; all four q blocks match the corrected reference (max-abs <= 0.125 bf16, <=2 ulp), KV/index caches 98.2-100% raw-equal within one e4m3 code step; inputs byte-identical across ranks; killswitch last_decision=None and native-identical q/k; routing/decision evidence green.
  • ATOM on-arm functional (eager mode): PASS. --enforce-eager --aiter-provider-enable sp-qkv-provider: server ready, enabled=('sp-qkv-provider',) routed=('sp_qkv_fused',), 472 rank-uniform provider gate ... fused (all ranks) and 0 fallbacks, 236 provider-served site lines, 0 tracebacks; one benchmark request set completed 8/8 with non-empty output.
  • Not supported / not run: CUDA-graph-capture mode is unsupported by the current lifecycle (without --enforce-eager the capture path sees a different baked tensor set than the eager prepare: moved=[w_scale, q_norm_w, k_norm_w, k_cache, v_cache, k_scale, v_scale]; re-preparing with capture-time buffers is future work). Performance was not measured in this round (out of scope by request); the eager path shows 545,844 binding rebinds in the run (functional only, an efficiency risk to address later).

Capture-mode GPU functional verification + one-round perf (2026-11-10, node 58)

Verified stack: ATOM 23a1520a (capture pre-bind at both seams), AITER e2e a6794ef4 (= #7346 SP APIs + the #6689 routing commit 2a4bbafb + main aiter.plugin), provider d4dbd6af (this PR / the provider PR #1 code + capture fixes), image rocm/atom-dev:vllm-latest@sha256:885d0611....

  • Capture mode (no --enforce-eager) functional PASS: 4 ranks, routed=('sp_qkv_fused',), capture prepare=True; 3360 provider capture ... fused (prepare) lines, 1680 rank-uniform provider gate ... fused (all ranks) / 0 fallback, 240 provider-served site lines, 0 binding rebinds / 0 moved / 0 traceback, SERVER_READY; one request set completed 8/8 with non-empty output.
  • Rebind storm eliminated: on-arm binding cache hit 0 / binding rebind 0 / cache evict 0 over the whole phase (previously ~545k rebinds in the eager run); capture prepares each cell once.
  • One-round off/on perf (capture mode, indicative only, 16 warmups, all completed==requested): b32k out tok/s 49.90 -> 49.91 (+0.03%), TTFT -0.07%, TPOT +0.02%, E2EL -0.03%; c16 out tok/s 1373.4 -> 1363.3 (-0.73%), TTFT +22.7% (single-round noise at this run size), TPOT -1.66%, E2EL +0.74%. Effectively flat-to-noise; no perf claim is made (one round, no repeats).
  • Unverified: perf certification (needs repeated rounds/variance), replay/byte-exactness, other models/TP-SP combos, Phase-2 large/16K band (by design on ATOM's non-fused path).

@demonsan
demonsan requested a review from a team October 19, 2026 23:55
@github-actions github-actions Bot changed the title gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 [HIP] gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 6689 --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.

@github-actions github-actions Bot added the HIP label Oct 19, 2026

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

requires: Tuple[str, ...] = () # ("mori_cco", "sdma", "gfx950_sc_bypass")


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

mutates: Tuple[str, ...] = () # caches written by the variant


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

stage_kinds: Tuple[str, ...] # the stage prefix this variant covers


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.FrozenSet is deprecated, use frozenset instead

from typing import FrozenSet, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import FrozenSet, Optional, Tuple


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use frozenset instead of FrozenSet for type annotation

available: FrozenSet[str] = frozenset() # {"mori_cco","sdma","gfx950_sc_bypass"}


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

spec: FusionSpec, ctx: MatchCtx, profile: Optional[str] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

) -> Tuple[Optional[object], int]:


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

) -> Tuple[Optional[object], int]:


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, List, Optional


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Dict, List, Optional


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

share: Optional[str] = None


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

min_bytes: Optional[int] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def resources(self) -> List[WindowReq]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def run(self, *, x, x_scale, w, w_scale, outs: Dict, meta: Dict, res, stream=None) -> None:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def run(self, *, x, x_scale, w, w_scale, outs: Dict, meta: Dict, res, stream=None) -> None:


⚠️ [ruff] <UP035> reported by reviewdog 🐶
Import from collections.abc instead: Callable, Sequence

from typing import Callable, Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Callable, Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Callable, Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Callable, Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

deps: Tuple[str, ...] = ()


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

tasks: List[Task]


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

finalize: Optional[Callable[[str, List[str]], None]] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

finalize: Optional[Callable[[str, List[str]], None]] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def priorities(self) -> Dict[str, float]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

succ: Dict[str, List[str]] = {t.name: [] for t in self.tasks}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

succ: Dict[str, List[str]] = {t.name: [] for t in self.tasks}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

memo: Dict[str, float] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

units: List[UnitReport] = field(default_factory=list)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

tasks: Dict[str, float] = field(default_factory=dict) # "<unit dirname>/<task>" -> wall seconds


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def keys(self) -> List[str]:


⚠️ [ruff] <ISC004> reported by reviewdog 🐶
Unparenthesized implicit string concatenation in collection

lines = [f"prebuild wall={self.wall_s:.1f}s jobs={self.jobs} units={len(self.units)} (built={len(built)} cached={sum(u.status == 'cached' for u in self.units)} "
f"waited={sum(u.status == 'waited' for u in self.units)}) task_cpu={cpu:.1f}s slowest_task={crit:.1f}s lower_bound={max(crit, cpu / max(1, self.jobs)):.1f}s"]


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

self.tmp: Optional[str] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self.pending: Dict[str, Task] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

self.log: List[str] = []


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self.prio: Dict[str, float] = {}


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def execute(units: Sequence[Unit], jobs: Optional[int] = None, *, runner: Optional[Runner] = None, stale_s: float = STALE_S,


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def execute(units: Sequence[Unit], jobs: Optional[int] = None, *, runner: Optional[Runner] = None, stale_s: float = STALE_S,


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

running: Dict[object, Tuple[_State, Task, float]] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

running: Dict[object, Tuple[_State, Task, float]] = {}


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

first_err: Optional[BaseException] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def ready() -> List[Tuple[float, _State, Task]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def ready() -> List[Tuple[float, _State, Task]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def plan_profile(profile, *, arch=None, cu=None, world=None, recipe=None, tool=None) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def plan_profile(profile, *, arch=None, cu=None, world=None, recipe=None, tool=None) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def plan_profile(profile, *, arch=None, cu=None, world=None, recipe=None, tool=None) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

by_vid: Dict[str, list] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

units: Dict[Tuple[str, str], Unit] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

units: Dict[Tuple[str, str], Unit] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

skipped: List[str] = []


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def prebuild_profile(profile, *, arch=None, cu=None, world=None, jobs=None, recipe=None) -> List[str]:


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Dict, Optional, Tuple


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def __init__(self, name: str, rows: Dict[Tuple, Row], meta: dict, path: str):


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def __init__(self, name: str, rows: Dict[Tuple, Row], meta: dict, path: str):


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def lookup(self, sig, arch, cu, world, m) -> Optional[Row]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

rows: Dict[Tuple, Row] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

rows: Dict[Tuple, Row] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

_CACHE: Dict[str, Profile] = {}


⚠️ [ruff] <UP037> reported by reviewdog 🐶
Remove quotes from type annotation

def window_budget_of(profile: "Profile") -> dict:


⚠️ [ruff] <UP037> reported by reviewdog 🐶
Remove quotes from type annotation

def resolve_profile(profile) -> "Profile":


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def load_profile(path: Optional[str] = None) -> Profile:


⚠️ [ruff] <UP035> reported by reviewdog 🐶
Import from collections.abc instead: Callable

from typing import Callable, Dict, List, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Callable, Dict, List, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Callable, Dict, List, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Callable, Dict, List, Optional, Tuple


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

arena_offset: Optional[int] = None # arena policies: this window is a VIEW at this byte offset inside the single registered arena window (handle = the view struct)


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def __init__(self, so_path: Optional[str] = None):


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

s = lambda v: v - (1 << 64) if v >= (1 << 63) else v # noqa: E731


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def resolve_wait_budget_us(profile=None) -> Tuple[int, str]:


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def __init__(self, rank: int, world: int, group=None, dist=None, backend=None, device: Optional[int] = None,


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

caps: frozenset = frozenset(), policy: Optional[str] = None, profile=None):


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

self.policy_fallback_reason: Optional[str] = None


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

self._reg_log: List[Tuple[str, str, int, int]] = [] # (owner, name, bytes, cumulative) in registration order


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

self._reg_log: List[Tuple[str, str, int, int]] = [] # (owner, name, bytes, cumulative) in registration order


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

self._regs: List[Window] = [] # every registered window exactly ONCE (the arena is the only one under the arena policy)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._shared: Dict[str, Window] = {} # share tag -> the one shared view (arena policy)


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

self._arena: Optional[Window] = None # the ONE registered window of the comm (arena policy)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

self._views: List[Window] = [] # every view struct handed out (freed before the arena is deregistered)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

self._unzeroed: List[Window] = [] # registered windows not yet zeroed (zeroed in finalize(), after ALL registrations + the devcomm)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self.windows: Dict[str, Dict[str, Window]] = {} # owner -> name -> Window


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self.windows: Dict[str, Dict[str, Window]] = {} # owner -> name -> Window


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._init_hooks: Dict[str, Callable[[], None]] = {} # owner -> control-block initializer (re-run after every zeroing)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._drain_hooks: Dict[str, Callable[[], None]] = {} # owner -> pre-reset SDMA drain


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._close_hooks: Dict[str, Callable[[], None]] = {} # owner -> free host/driver objects (L-5), run at release()


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._poison_info: Dict[str, tuple] = {} # owner -> (report reader, poison decoder), logging only


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._poison_hooks: Dict[str, Callable[[], int]] = {} # owner -> cheap poison word read (host, outside capture)


⚠️ [ruff] <S110> reported by reviewdog 🐶
try-except-pass detected, consider logging the exception

except Exception: # noqa: BLE001
pass


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def _arena_view(self, owner: str, name: str, kind: str, nbytes: int, share: Optional[str] = None) -> Window:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def _arena_ensure(self, owner: str, wreqs, wins: Dict[str, Window]):


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def ensure(self, owner: str, reqs: List[WindowReq]) -> Dict[str, Window]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def ensure(self, owner: str, reqs: List[WindowReq]) -> Dict[str, Window]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

wins: Dict[str, Window] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def _agree_registration(self, owner: str, wreqs: List[WindowReq]):


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def set_poison(self, owner: str, fn: Callable[[], int], report: Optional[Callable[[], dict]] = None, decode: Optional[Callable[[int], str]] = None):


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def set_poison(self, owner: str, fn: Callable[[], int], report: Optional[Callable[[], dict]] = None, decode: Optional[Callable[[int], str]] = None):


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Optional, Tuple, Union


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

fields: Tuple[Field, ...] = ()


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

drop: Tuple[str, ...] = () # fields not consumed downstream


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

index: Optional[str] = None # "fp8_unit_page128" or None


⚠️ [ruff] <UP007> reported by reviewdog 🐶
Use X | Y for type annotations

Stage = Union[SPExchange, HeadNormRopeCache]


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

stages: Tuple[Stage, ...] = ()


⚠️ [ruff] <UP037> reported by reviewdog 🐶
Remove quotes from type annotation

def prefix(self, n: int) -> "FusionSpec":


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from . import variants, variants_large
from aiter.gemm_fusion.resources import round_up


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, List, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Dict, List, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Dict, List, Tuple


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion.prebuild import BuildError # noqa: E402 (one error type for the legacy builds and the parallel engine)


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E402)

from aiter.gemm_fusion.prebuild import BuildError # noqa: E402 (one error type for the legacy builds and the parallel engine)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def small_defs(params: dict, mode: str) -> Tuple[List[str], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def small_defs(params: dict, mode: str) -> Tuple[List[str], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def small_defs(params: dict, mode: str) -> Tuple[List[str], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def cache_key(src: str, dev: List[str], host: List[str], tool: Dict[str, str]) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def cache_key(src: str, dev: List[str], host: List[str], tool: Dict[str, str]) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def cache_key(src: str, dev: List[str], host: List[str], tool: Dict[str, str]) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def toolchain() -> Dict[str, str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_cmd_one(src: str, dev_defs: List[str], tool: Dict[str, str], out: str, name: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def device_cmd_one(src: str, dev_defs: List[str], tool: Dict[str, str], out: str, name: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_cmd_one(src: str, dev_defs: List[str], tool: Dict[str, str], out: str, name: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_cmds(src: str, dev_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def device_cmds(src: str, dev_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_cmds(src: str, dev_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_cmds(src: str, dev_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_only_cmd(legacy_cmd: List[str], hsaco: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def device_only_cmd(legacy_cmd: List[str], hsaco: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_cmds(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def host_cmds(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_cmds(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_cmds(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_compile_cmd(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def host_compile_cmd(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_compile_cmd(src: str, host_defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def hashes_compile_cmd(tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def hashes_compile_cmd(tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def host_link_cmd(tool: Dict[str, str], out: str, objs: List[str], so: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_link_cmd(tool: Dict[str, str], out: str, objs: List[str], so: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def host_link_cmd(tool: Dict[str, str], out: str, objs: List[str], so: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def comm_cmd(tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def comm_cmd(tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def _run(cmd: List[str], log: List[str]):


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def _run(cmd: List[str], log: List[str]):


⚠️ [ruff] <PLW1510> reported by reviewdog 🐶
subprocess.run without explicit check argument

p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_small(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> SmallBuild:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def build_small(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> SmallBuild:


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_small(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> SmallBuild:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

log: List[str] = []


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def comm_key(tool: Dict[str, str]) -> str:


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_comm(tool: Dict[str, str] = None, recipe: str = None) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def build_comm(tool: Dict[str, str] = None, recipe: str = None) -> str:


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_comm(tool: Dict[str, str] = None, recipe: str = None) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_defs(params: dict, mode: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_cache_key(defs: List[str], tool: Dict[str, str]) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def large_cache_key(defs: List[str], tool: Dict[str, str]) -> str:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_device_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def large_device_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_device_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_host_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def large_host_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_host_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_device_only_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def large_device_only_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def large_device_only_cmd(defs: List[str], tool: Dict[str, str], out: str) -> List[str]:


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_large(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> LargeBuild:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def build_large(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> LargeBuild:


⚠️ [ruff] <RUF013> reported by reviewdog 🐶
PEP 484 prohibits implicit Optional

def build_large(params: dict, mode: str, tool: Dict[str, str] = None, recipe: str = None) -> LargeBuild:


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

mk = lambda d, sha="": LargeBuild(key, d, os.path.join(d, "img", "lg_gemm_quad_fp8_comm.hsaco"), sha, os.path.join(d, "liblg_comm.so")) # noqa: E731


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

log: List[str] = []


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

s = lambda v: v - (1 << 64) if v >= (1 << 63) else v # noqa: E731 (values are signed ints stored in u64)


⚠️ [ruff] <UP035> reported by reviewdog 🐶
Import from collections.abc instead: Sequence

from typing import Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Dict, List, Optional, Sequence, Tuple


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def row_mode(row) -> Optional[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def small_unit(params: dict, mode: str, tool: Dict[str, str], recipe: str) -> Unit:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

tasks: List[Task] = []


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def large_unit(params: dict, mode: str, tool: Dict[str, str], recipe: str) -> Unit:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def comm_unit(tool: Dict[str, str]) -> Unit:


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP045> reported by reviewdog 🐶
Use X | None for type annotations

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def units_for_rows(rows, *, recipe: Optional[str] = None, tool: Optional[Dict[str, str]] = None, large: bool) -> Tuple[List[Unit], List[str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

units: Dict[str, Unit] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

skipped: List[str] = []


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

sha = open(os.path.join(final, "BUILD_OK")).read().split()[-1]


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def elf_sections(path: str) -> Dict[str, Tuple[int, str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def elf_sections(path: str) -> Dict[str, Tuple[int, str]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

out: Dict[str, dict] = {}


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

cmd_fn = lambda tmp_: jit.large_device_cmd(u.meta["defs"], tool, tmp_) # noqa: E731


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

cmd_fn = lambda tmp_, n=name: jit.device_cmd_one(u.meta["src"], u.meta["dev"], tool, tmp_, n) # noqa: E731


⚠️ [ruff] <F841> reported by reviewdog 🐶
Local variable u64 is assigned to but never used

vp, u32, u64, i32 = C.c_void_p, C.c_uint32, C.c_uint64, C.c_int32


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from __future__ import annotations
from aiter.gemm_fusion.spec import FusionSpec, GemmSpec, HeadNormRopeCache, SPExchange, qkv_fields


⚠️ [ruff] <UP035> reported by reviewdog 🐶
Import from collections.abc instead: Callable

from typing import Callable, List, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Callable, List, Optional, Tuple


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Tuple is deprecated, use tuple instead

from typing import Callable, List, Optional, Tuple


⚠️ [ruff] <F401> reported by reviewdog 🐶
typing.Callable imported but unused

from typing import Callable, List, Optional, Tuple


⚠️ [ruff] <F401> reported by reviewdog 🐶
typing.Optional imported but unused

from typing import Callable, List, Optional, Tuple


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion.profile import parse_profile, resolve_profile, window_budget_of
from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def window_ranges(res, kinds=("p2p_window", "control")) -> List[Tuple[str, int, int]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use tuple instead of Tuple for type annotation

def window_ranges(res, kinds=("p2p_window", "control")) -> List[Tuple[str, int, int]]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def find_window_alias(res, obj, kinds=("p2p_window", "control")) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def sequence(name: str, mib: str = "", n: int = 39, window_mib: int = 164) -> List[int]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def run(seq: List[int], heap_bytes: int, rank: int, world: int, dist, backend, tag: str, stagger_ms: int = 0, sleep=None, device=None) -> bool:


⚠️ [ruff] <S110> reported by reviewdog 🐶
try-except-pass detected, consider logging the exception

except Exception: # noqa: BLE001
pass


⚠️ [ruff] <S110> reported by reviewdog 🐶
try-except-pass detected, consider logging the exception

except Exception: # noqa: BLE001
pass


⚠️ [ruff] <S110> reported by reviewdog 🐶
try-except-pass detected, consider logging the exception

except Exception: # noqa: BLE001
pass


⚠️ [ruff] <S110> reported by reviewdog 🐶
try-except-pass detected, consider logging the exception

except Exception: # noqa: BLE001
pass


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, List


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Dict, List


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from . import specs # noqa: E402
from .jit import build_small, small_defs
from . import small_rt as rt
from . import inputs


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E402)

from . import specs # noqa: E402


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

def small_window_bytes(mode: str) -> Dict[str, int]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def _diff_parts(old: dict, new: dict) -> List[str]:


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._bindings: Dict[tuple, object] = {}


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use dict instead of Dict for type annotation

self._parts: Dict[tuple, dict] = {} # key -> named components (for diffing a miss)


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def resources(self) -> List[WindowReq]:


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E402)

from . import variants_large # noqa: E402,F401 (registers sp_qkv.large.v1)


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.Dict is deprecated, use dict instead

from typing import Dict, List


⚠️ [ruff] <UP035> reported by reviewdog 🐶
typing.List is deprecated, use list instead

from typing import Dict, List


⚠️ [ruff] <F401> reported by reviewdog 🐶
typing.Dict imported but unused

from typing import Dict, List


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

got = hashlib.sha256(open(built.hsaco, "rb").read()).hexdigest()


⚠️ [ruff] <UP006> reported by reviewdog 🐶
Use list instead of List for type annotation

def resources(self) -> List[WindowReq]:


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

sha = hashlib.sha256(open(built.hsaco, "rb").read()).hexdigest()


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

hooks = dict(poison=lambda c=got: c.poison(stream_handle(None)), # cheap per-step check on the CURRENT torch stream (4-byte D2H + that stream sync)
drain=lambda c=got: c.drain_all(C.c_void_p(None)), # A2-H: quietQueue on all peer queues before any reset
init=got.init_control) # epoch=1 + magic; re-run after every reset


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from .small_rt import stream_handle
from .variants import _require_zeroed


⚠️ [ruff] <BLE001> reported by reviewdog 🐶
Do not catch blind exception: Exception

except Exception:


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E402)

from aiter.ops.gemm_fusion.sp_qkv import gen_profile # noqa: E402


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import json
import logging
import os
import sys
import shutil
import tempfile
import uuid
import types
from pathlib import Path
import pytest


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (unused: F401)

import aiter.gemm_fusion as gf # noqa: F401


⚠️ [ruff] <BLE001> reported by reviewdog 🐶
Do not catch blind exception: Exception

except Exception: # no torch / GPU: load the pure-Python subpackage without aiter/__init__


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion import (
Contract, ContractError, Field, FusionSpec, GemmSpec, HeadNormRopeCache, MatchCtx, Plan,
ProfileError, SPExchange, WindowReq, match_prefix, parse_profile, qkv_fields, register_variant,
)
from aiter.gemm_fusion import catalog, profile as profmod


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.Field imported but unused

Contract, ContractError, Field, FusionSpec, GemmSpec, HeadNormRopeCache, MatchCtx, Plan,


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.WindowReq imported but unused

ProfileError, SPExchange, WindowReq, match_prefix, parse_profile, qkv_fields, register_variant,


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.ops.gemm_fusion.sp_qkv.test_utils import clear_profile_cache; clear_profile_cache()


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

CTX = lambda m, avail=("mori_cco",): MatchCtx("gfx950", 256, 4, m, frozenset(avail)) # noqa: E731


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (unused: F401)

import aiter.gemm_fusion as gf # noqa: F401


⚠️ [ruff] <BLE001> reported by reviewdog 🐶
Do not catch blind exception: Exception

except Exception: # no torch / GPU: load the pure-Python subpackage without aiter/__init__


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (unused: F401)

import aiter.gemm_fusion as gf # noqa: F401


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion import ContractError, ProfileError, prebuild as engine
from aiter.ops.gemm_fusion.sp_qkv import jit, prebuild as pb, specs


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.ops.gemm_fusion.sp_qkv.specs imported but unused

from aiter.ops.gemm_fusion.sp_qkv import jit, prebuild as pb, specs


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

hdr = open(os.path.join(tmp, "gen", "sm_expected_hashes.h")).read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

gh, rh = (hashlib.sha256(open(os.path.join(tmp, "img", n + ".hsaco"), "rb").read()).hexdigest() for n in ("sm_gemm", "sm_ran"))


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(tmp, "gen", "sm_hashes.cpp")).read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

key, sha = open(os.path.join(tmp, "BUILD_OK")).read().split()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

assert key == u.key and sha == hashlib.sha256(open(os.path.join(tmp, "img", "lg_gemm_quad_fp8_comm.hsaco"), "rb").read()).hexdigest()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(u2.ok_path, "w").write("ok")


⚠️ [ruff] <BLE001> reported by reviewdog 🐶
Do not catch blind exception: Exception


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion import ContractError, MatchCtx, match_prefix, profile as profmod
from aiter.gemm_fusion.plan import WindowReq
from aiter.gemm_fusion.resources import FusionResources, ResourceError, round_up
from aiter.ops.gemm_fusion.sp_qkv import gen_profile, jit, specs
from aiter.ops.gemm_fusion.sp_qkv.test_utils import ( # noqa: E402
ArenaBackend, FakeBackend, FakeDist, FirstFitBackend, RealisticFirstFit, clear_profile_cache, log_capture as _log_capture, make_profile, make_res,
)


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, ResourceError, round_up


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E402)

from aiter.ops.gemm_fusion.sp_qkv.test_utils import ( # noqa: E402


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.ops.gemm_fusion.sp_qkv.test_utils.make_profile imported but unused

ArenaBackend, FakeBackend, FakeDist, FirstFitBackend, RealisticFirstFit, clear_profile_cache, log_capture as _log_capture, make_profile, make_res,


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

for line in open(os.path.join(base, "SOURCE_SHA256.txt")):


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

assert hashlib.sha256(open(os.path.join(base, f), "rb").read()).hexdigest() == h, f


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

for line in open(os.path.join(base, "SOURCE_SHA256.txt")):


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

assert hashlib.sha256(open(os.path.join(base, f), "rb").read()).hexdigest() == h, f


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (unused: F401)

import aiter.ops.gemm_fusion.sp_qkv.variants_large as vl # noqa: F401


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

sm = open(os.path.join(base, "sm_fusion_driver.cpp"), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

lg = open(os.path.join(base, "lg_fusion_driver.cpp"), encoding="utf-8").read()


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import types as _t
from aiter.gemm_fusion import catalog
from types import SimpleNamespace as NS


⚠️ [ruff] <F841> reported by reviewdog 🐶
Local variable blk is assigned to but never used

blk = plan._binding(x, xs, ws, outs, meta, res) # correct page -> reaches the driver bind


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

used |= set(re.findall(r"\bgf\.([A-Za-z_]\w*)", open(os.path.join(root, fn), encoding="utf-8").read()))


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.catalog imported but unused

from aiter.gemm_fusion import catalog


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources, heap_bytes_for


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, heap_bytes_for


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion import catalog
from types import SimpleNamespace as NS


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(jit.CSRC, "host", "lg_fusion_driver.cpp"), encoding="utf-8").read()


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

r = NS(**{**dict(rank=1, sdma_queues=1, devcomm_info=dict(good)), **kw})


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(jit.CSRC, "host", "lg_fusion_driver.cpp"), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

assert "gf_devcomm_info_v1" in open(os.path.join(jit.CSRC, "host", "gf_comm.cpp"), encoding="utf-8").read()


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

st = dict(x=_T((M, 6144), (6144, 1), "fp8"), xs=_T((M, 1), (1, 1)), ws=_T((n_rows,), (1,)), w=_w_ok(n_rows))


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, binds, _z = _binding_rig(monkeypatch)


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(jit.CSRC, "host", "sm_fusion_driver.cpp"), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

pysrc = open(os.path.join(os.path.dirname(rt.__file__), "variants.py"), encoding="utf-8").read()


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, binds, _z = _binding_rig(monkeypatch)


⚠️ [ruff] <F401> reported by reviewdog 🐶
types imported but unused


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable blk is never used

blk, a_ptr, w_ptr, stride_a, stream = calls[0]


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(os.path.dirname(specs.__file__), "large_rt.py"), encoding="utf-8").read()


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources, heap_bytes_for


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, heap_bytes_for


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F841> reported by reviewdog 🐶
Local variable r2 is assigned to but never used

r2 = make_res(dist=FakeDist(), backend=FirstFitBackend(0))


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(dp, fn), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

pr = open(os.path.join(root, "gemm_fusion", "resources.py"), encoding="utf-8").read()


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

import tempfile, uuid, shutil
from pathlib import Path


⚠️ [ruff] <RUF100> reported by reviewdog 🐶
Unused noqa directive (non-enabled: E731)

mk = lambda n, k, by, sh: Window("<shared>" if sh else plan.owner, plan.owner + n, k, by, 11, 4096, shared=sh) # noqa: E731


⚠️ [ruff] <FURB167> reported by reviewdog 🐶
Use of regular expression alias re.M

members = re.findall(r"^\s*(?:const\s+)?[\w:<>\*]+\s+\**(\w+)(?:\[\d+\])?\s*;", struct, re.M)


⚠️ [ruff] <FURB167> reported by reviewdog 🐶
Use of regular expression alias re.I

assert not [m for m in members if re.search(r"epoch|credit|arrival|^ep$|state", m, re.I)], members # no epoch/credit/arrival kernarg


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, binds, _z = _binding_rig(monkeypatch)


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

vl = open(os.path.join(os.path.dirname(specs.__file__), "variants_large.py"), encoding="utf-8").read()


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <RUF007> reported by reviewdog 🐶
Prefer itertools.pairwise() over zip() when iterating over successive pairs

assert all(a + n <= b for (a, n), (b, _m) in zip(spans, spans[1:])) # disjoint


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

dev += "".join(open(os.path.join(root, f), encoding="utf-8").read() for f in fns if f.endswith((".hpp", ".cu", ".h")))


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

dev += open(os.path.join(jit.CSRC, "small", "r18", "device", "sk_gemm_fp8.cu"), encoding="utf-8").read()


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable r is never used


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion.resources import DEFAULT_WAIT_BUDGET_US, FusionResources, ResourceError, resolve_wait_budget_us


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import DEFAULT_WAIT_BUDGET_US, FusionResources, ResourceError, resolve_wait_budget_us


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import DEFAULT_WAIT_BUDGET_US, FusionResources, ResourceError, resolve_wait_budget_us


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <RUF015> reported by reviewdog 🐶
Prefer next(m for m in pm if "owner=L" in m) over single element slice

L = [m for m in pm if "owner=L" in m][0]


⚠️ [ruff] <RUF015> reported by reviewdog 🐶
Prefer next(m for m in pm if "owner=S" in m) over single element slice

S = [m for m in pm if "owner=S" in m][0]


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

g = open(os.path.join(os.path.dirname(specs.__file__), "gen_profile.py"), encoding="utf-8").read()


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted

from aiter.gemm_fusion.resources import DEFAULT_POLICY, POLICIES, FusionResources, ResourceError


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import DEFAULT_POLICY, POLICIES, FusionResources, ResourceError


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import DEFAULT_POLICY, POLICIES, FusionResources, ResourceError


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources, ResourceError


⚠️ [ruff] <PLC3002> reported by reviewdog 🐶
Lambda expression called directly. Execute the expression inline instead.

be.win_info = lambda comm, w: (lambda t: (t[0] + 8, t[1], t[2]) if w in be.views else t)(orig(comm, w)) # from now on views read back shifted


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

g = open(os.path.join(os.path.dirname(specs.__file__), "gen_profile.py"), encoding="utf-8").read()


⚠️ [ruff] <F811> reported by reviewdog 🐶
Redefinition of unused FusionResources from line 24: FusionResources redefined here

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <F401> reported by reviewdog 🐶
aiter.gemm_fusion.resources.FusionResources imported but unused

from aiter.gemm_fusion.resources import FusionResources


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

code = open(f, encoding="utf-8").read()


⚠️ [ruff] <RUF012> reported by reviewdog 🐶
Mutable default value for class attribute


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

text = open(path, encoding="utf-8").read()


⚠️ [ruff] <FURB167> reported by reviewdog 🐶
Use of regular expression alias re.M


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

out[rel] = open(_repo(rel), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

called_elsewhere += open(os.path.join(base, fn), encoding="utf-8").read() + "\n"


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

kw = dict(x=st["x"], x_scale=st["xs"], w=st["w"], w_scale=st["ws"], outs=outs, meta=meta, res=res)


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, launches, binds = _small_ready(monkeypatch)


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

longer = dict(positions=_T((T + 64,), (1,), "i64"), slot_mapping=_T((T + 64,), (1,), "i64")) # a longer persistent buffer is safe: the kernel reads t < T


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x K-padded (shape[1]=6400)", dict(x=_T((16, 6400), (6400, 1), "fp8")), r"x K=6400 != 6144.*K-padded activation"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x K stride != 1", dict(x=_T((16, 6144), (6144, 2), "fp8")), r"x must be K-contiguous"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x row stride < K", dict(x=_T((16, 6144), (4096, 1), "fp8")), r"row stride >= 6144"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x not fp8", dict(x=_T((16, 6144), (6144, 1), "bf16")), r"x dtype bf16 is not float8_e4m3fn"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x 1-D", dict(x=_T((16,), (1,), "fp8")), r"x must be 2-D"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x_scale not fp32", dict(x_scale=_T((16, 1), (1, 1), "bf16")), r"x_scale dtype bf16 is not float32"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x_scale wrong length", dict(x_scale=_T((15, 1), (1, 1))), r"x_scale must be contiguous with exactly 16 elements"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("x_scale non-contiguous", dict(x_scale=_T((16, 2), (2, 1))), r"x_scale must be contiguous with exactly 16"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w_scale not fp32", dict(w_scale=_T((9216,), (1,), "bf16")), r"w_scale dtype bf16 is not float32"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w_scale short", dict(w_scale=_T((9215,), (1,))), r"w_scale must be contiguous \[N\] or \[N,1\] with N >= 9216"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w_scale [N,2]", dict(w_scale=_T((9216, 2), (2, 1))), r"w_scale must be contiguous \[N\] or \[N,1\]"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w_scale non-contiguous", dict(w_scale=_T((9216,), (2,))), r"w_scale must be contiguous"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w K-padded (shape[1]=6400)", dict(w=_w_ok(9216, 6400)), r"w K=6400 != 6144.*K-padded weight"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w shuffled with K padding (attrs)", dict(w=type("W", (_T,), {"aiter_padded_k": 6400, "aiter_original_k": 6144})((9216, 6144), (6144, 1), "fp8")),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w original K != 6144 (attrs)", dict(w=type("W", (_T,), {"aiter_original_k": 6000})((9216, 6144), (6144, 1), "fp8")), r"shuffled with K padding"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w unshuffled", dict(w=_w_ok(9216, shuffled=False)), r"is_shuffled=False"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w too few rows", dict(w=_w_ok(9200)), r"w has 9200 rows < N=9216"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w not fp8", dict(w=_T((9216, 6144), (6144, 1), "bf16")), r"w dtype bf16 is not float8_e4m3fn"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w non-contiguous", dict(w=_T((9216, 6144), (6144 * 2, 1), "fp8")), r"w must be contiguous"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("w 1-D", dict(w=_T((9216,), (1,), "fp8")), r"w must be 2-D"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("positions shorter than T (the pad_rows case: real tokens < padded)", dict(positions=_T((61,), (1,), "i64")), {}, r"positions has 61 entries but the kernel reads T = 4 x local M = 64: stage a T-long array"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("slot_mapping shorter than T", dict(slot_mapping=_T((63,), (1,), "i64")), {}, r"slot_mapping has 63 entries but the kernel reads T = 4 x local M = 64"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("positions int32", dict(positions=_T((64,), (1,), "i32")), {}, r"positions dtype i32 is not int64"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("slot_mapping int32", dict(slot_mapping=_T((64,), (1,), "i32")), {}, r"slot_mapping dtype i32 is not int64"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("q output too short", {}, dict(q=_T((60, 16, 128))), r"output 'q' has 60 rows but the kernel writes 64"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

("k output too short", {}, dict(k=_T((32, 1, 128))), r"output 'k' has 32 rows"),


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable launches is never used

plan, st, meta, outs, res, launches, binds = _small_ready(monkeypatch)


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable l2 is never used

plan2, st2, meta2, outs2, res2, l2, b2 = _small_ready(monkeypatch)


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable launches is never used

plan, st, meta, outs, res, launches, binds = _small_ready(monkeypatch, mode=mode)


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, launches, binds = _small_ready(monkeypatch, mode=mode)


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

st = dict(x=_T((M, 6144), (6144, 1), "fp8"), xs=_T((M, 1), (1, 1)), ws=_T((n_rows, 1), (1, 1)), w=_w_ok(n_rows))


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

kw = dict(x=st["x"], x_scale=st["xs"], w=st["w"], w_scale=st["ws"], res=res)


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(x=_T((M, 6400), (6400, 1), "fp8")), r"x K=6400 != 6144"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(x=_T((M, 6144), (6144, 2), "fp8")), r"x must be K-contiguous"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(x=_T((M, 6144), (6144, 1), "bf16")), r"x dtype bf16 is not float8_e4m3fn"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(x_scale=_T((M, 1), (1, 1), "bf16")), r"x_scale dtype bf16"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(x_scale=_T((M - 1, 1), (1, 1))), rf"exactly {M} elements"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w_scale=_T((9215, 1), (1, 1))), r"w_scale must be contiguous.*N >= 9216"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w_scale=_T((9216,), (1,), "bf16")), r"w_scale dtype bf16"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w=_w_ok(9216, 6400)), r"w K=6400 != 6144.*K-padded weight"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w=_w_ok(9216, shuffled=False)), r"is_shuffled=False"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w=_w_ok(9215)), r"w has 9215 rows < N=9216"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w=_T((9216, 6144), (6144, 1), "bf16")), r"w dtype bf16"),


⚠️ [ruff] <C408> reported by reviewdog 🐶
Unnecessary dict() call (rewrite as a literal)

(dict(w=_T((9216, 6144), (12288, 1), "fp8")), r"w must be contiguous"),


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable launches is never used

plan, st, res, launches = _large_ready(monkeypatch, mode="indexer", T=16384)


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

text = open(os.path.join(base, fname), encoding="utf-8").read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

src = open(os.path.join(base, "inputs.py"), encoding="utf-8").read()


⚠️ [ruff] <RUF059> reported by reviewdog 🐶
Unpacked variable binds is never used

plan, st, meta, outs, res, launches, binds = _small_ready(monkeypatch, mode=mode, T=T)


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

text = open(os.path.join(os.path.dirname(specs.__file__), "..", "..", "..", "..", "csrc", "gemm_fusion", "sp_qkv", "small", src, "device", "ran_kernel.cu"), encoding="utf-8").read()

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

⚠️ [ruff] <EXE001> reported by reviewdog 🐶
Shebang is present but file is not executable


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <F401> reported by reviewdog 🐶
itertools imported but unused


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(grid == (304 if ik else 276) and grid <= 512, '%-8s grid %d = push 24 + IK %d + self %d + B %d (<= 512 slots)' % (mode, grid, ik, selfw, bw))


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable UNITS

g0 = lambda w: (w * UNITS) // push


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable push

g0 = lambda w: (w * UNITS) // push


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(all(v == 1 for v in seen.values()) and len(seen) == 3 * upd * NPASS, '%-8s push: each (dst, unit, pass) pushed exactly once by the two halves (%d tuples)' % (mode, len(seen)))


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable g0

touch = lambda w, r: g0(w) < (r + 1) * upd and g0(w + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable upd

touch = lambda w, r: g0(w) < (r + 1) * upd and g0(w + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable g0

touch = lambda w, r: g0(w) < (r + 1) * upd and g0(w + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable upd

touch = lambda w, r: g0(w) < (r + 1) * upd and g0(w + 1) > r * upd


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(K == [8 + ik] * 3, '%-8s K per (src,dst) = unit pushers 8 + IK_WGS %d = %s' % (mode, ik, K))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(passes_cov == list(range(NPASS)), '%-8s IK owners cover passes %s once, each releases once per destination' % (mode, passes_cov))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(len(sc) == upd * NPASS and all(v == 1 for v in sc.values()), '%-8s self: each (head, pass) once by exactly one of 2 row-group WGs' % mode)


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

if seenb != want or any(v < 1 for v in acq.values()) or any(v < 1 for v in live.values()): chk(False, '%s m=%d rank %d B coverage/acquire' % (mode, m, rank))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(True, '%-8s B coverage: every (src, head, pass) exactly once on all 4 ranks; every (src,dst) pair has >=1 acquiring WG for m in {33,40,48,49,63,64} (dead passes acquire, live WGs >= 1)' % mode)


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(rx <= 4 * 1024 * 1024 and rx == (2359296 if mode == 'dense' else 2621440), '%-8s Rx window %d B <= 4 MiB (X-5 recomputed)' % (mode, rx))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(2 * mx + 16 <= rx, '%-8s X-5: highest Rx vector access %d B <= window %d' % (mode, 2 * mx + 16, rx))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(gemm_wgs <= 512, '%-8s GEMM grid %d x %d = %d WGs <= 512 slots; P = %d bytes' % (mode, NT, SK, gemm_wgs, SK * MP * N * 4))


⚠️ [ruff] <EXE001> reported by reviewdog 🐶
Shebang is present but file is not executable


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'\brelease_tagged\(a,', ks)) == 4, 'release_tagged at all 4 release sites (IK parallel, IK serial (=0), push, test-only ADD_BEFORE_RETIRE): %d' % len(re.findall(r'\brelease_tagged\(a,', ks)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(body.count('const uint32_t pz = ld_rlx32(ka.err);') == 4, 'ERR read in the entry round of IK, push, self, B: %d' % body.count('const uint32_t pz = ld_rlx32(ka.err);'))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'16u \* pass', body)) == 0 and len(re.findall(r'16u \* \(pbase \+ pass\)', body)) >= 14, 'every row-pass expression uses the global pass pbase + pass: %d sites, 0 raw' % len(re.findall(r'16u \* \(pbase \+ pass\)', body)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'const uint32_t pbase = ', body)) == 4, 'pbase defined in IK, push, self and B roles: %d' % len(re.findall(r'const uint32_t pbase = ', body)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'tag_store\(a,', body)) == 3 and len(early) == 2, 'F1: early tag stores are issued by the releasing thread itself (push tid 0, IK owner tid 0) in the data-store blocks: %d sites' % len(early))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

print('ALL PASS' if not fails else 'FAILED: %d' % len(fails)); sys.exit(1 if fails else 0)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <F401> reported by reviewdog 🐶
re imported but unused


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(p,encoding='utf-8',newline='').read(); nl='\r\n' if '\r\n' in t else '\n'; return t.replace('\r\n','\n'),nl


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

def wr(p,t,nl): open(p,'w',encoding='utf-8',newline='').write(t.replace('\n',nl))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

assert t.count(old)==cnt,('count %d != %d: '%(t.count(old),cnt))+old[:110]


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <F401> reported by reviewdog 🐶
re imported but unused


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(p,encoding='utf-8',newline='').read(); nl='\r\n' if '\r\n' in t else '\n'; return t.replace('\r\n','\n'),nl


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

def wr(p,t,nl): open(p,'w',encoding='utf-8',newline='').write(t.replace('\n',nl))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

assert t.count(old)==cnt,('count %d != %d: '%(t.count(old),cnt))+old[:110]


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(p,encoding='utf-8',newline='').read(); nl='\r\n' if '\r\n' in t else '\n'; t=t.replace('\r\n','\n')


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

assert t.count(old)==cnt,('count %d != %d: '%(t.count(old),cnt))+old[:110]


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(p,'w',encoding='utf-8',newline='').write(t.replace('\n',nl)); print('ran stage ok')


⚠️ [ruff] <EXE001> reported by reviewdog 🐶
Shebang is present but file is not executable


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <F401> reported by reviewdog 🐶
itertools imported but unused


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(grid == (608 if ik else 552), '%-8s grid %d = push 48 + IK %d + self %d + B %d (NOTE: > 256 CUs, WGs beyond residency start as earlier ones retire)' % (mode, grid, ik, selfw, bw))


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable UNITS

u0 = lambda wu: (wu * UNITS) // UNIT


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable UNIT

u0 = lambda wu: (wu * UNITS) // UNIT


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable u0


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable UNIT


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(all(v == 1 for v in seen.values()) and len(seen) == 3 * upd * NPASS, '%-8s push: each (dst, unit, pass) pushed exactly once (2 row groups of 24 unit WGs x 2 halves x 2 passes) (%d tuples)' % (mode, len(seen)))


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable g0

touch = lambda w, r: g0(w) < (r + 1) * upd and u0(w % UNIT + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable upd

touch = lambda w, r: g0(w) < (r + 1) * upd and u0(w % UNIT + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable u0

touch = lambda w, r: g0(w) < (r + 1) * upd and u0(w % UNIT + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable UNIT

touch = lambda w, r: g0(w) < (r + 1) * upd and u0(w % UNIT + 1) > r * upd


⚠️ [ruff] <B023> reported by reviewdog 🐶
Function definition does not bind loop variable upd

touch = lambda w, r: g0(w) < (r + 1) * upd and u0(w % UNIT + 1) > r * upd


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(K == [8 * RG + ik] * 3, '%-8s K per (src,dst) = unit pushers %d + IK_WGS %d = %s' % (mode, 8 * RG, ik, K))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(passes_cov == list(range(NPASS)), '%-8s IK owners cover passes %s once, each releases once per destination' % (mode, passes_cov))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(len(sc) == upd * NPASS and all(v == 1 for v in sc.values()), '%-8s self: each (head, pass) once by exactly one of 4 row-group WGs' % mode)


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

if seenb != want or any(v < 1 for v in acq.values()) or any(v < 1 for v in live.values()): chk(False, '%s m=%d rank %d B coverage/acquire' % (mode, m, rank))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(True, '%-8s B coverage: every (src, head, pass) exactly once on all 4 ranks; every (src,dst) pair has >=1 acquiring WG for m in {65,80,96,97,113,127,128} (dead passes acquire, live WGs >= 1)' % mode)


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(4 * 1024 * 1024 < rx <= 8 * 1024 * 1024 and rx == (4718592 if mode == 'dense' else 5242880), '%-8s Rx window %d B: needs the 8 MiB arena view (> 4 MiB, <= 8 MiB)' % (mode, rx))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(2 * mx + 16 <= rx, '%-8s X-5: highest Rx vector access %d B <= window %d' % (mode, 2 * mx + 16, rx))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

chk(gemm_wgs <= 512, '%-8s GEMM grid %d x %d = %d WGs <= 512 slots; P = %d bytes' % (mode, NT, SK, gemm_wgs, SK * MP * N * 4))


⚠️ [ruff] <EXE001> reported by reviewdog 🐶
Shebang is present but file is not executable


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'\brelease_tagged\(a,', ks)) == 3, 'release_tagged at all 3 remaining release sites (IK owners x destinations, push, test-only ADD_BEFORE_RETIRE): %d' % len(re.findall(r'\brelease_tagged\(a,', ks)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(body.count('const uint32_t pz = ld_rlx32(ka.err);') == 4, 'ERR read in the entry round of IK, push, self, B: %d' % body.count('const uint32_t pz = ld_rlx32(ka.err);'))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'16u \* pass', body)) == 0 and len(re.findall(r'16u \* \(pbase \+ pass\)', body)) >= 14, 'every row-pass expression uses the global pass pbase + pass: %d sites, 0 raw' % len(re.findall(r'16u \* \(pbase \+ pass\)', body)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

need(len(re.findall(r'const uint32_t pbase = ', body)) == 4, 'pbase defined in IK, push, self and B roles: %d' % len(re.findall(r'const uint32_t pbase = ', body)))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

print('ALL PASS' if not fails else 'FAILED: %d' % len(fails)); sys.exit(1 if fails else 0)


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(p,encoding='utf-8',newline='').read(); nl='\r\n' if '\r\n' in t else '\n'; return t.replace('\r\n','\n'),nl


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

def wr(p,t,nl): open(p,'w',encoding='utf-8',newline='').write(t.replace('\n',nl))


⚠️ [ruff] <UP031> reported by reviewdog 🐶
Use format specifiers instead of percent format

assert t.count(old)==cnt,('count %d != %d: '%(t.count(old),cnt))+old[:110]


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(r+'/device/layout/t1_roles.hpp','w',encoding='utf-8',newline='').write('''// SPDX-License-Identifier: MIT


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(r20+'/tests/check_r20_roles.py',encoding='utf-8').read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(r21+'/tests/check_r21_roles.py','w',encoding='utf-8',newline='').write(t); print('written')


⚠️ [ruff] <I001> reported by reviewdog 🐶
Import block is un-sorted or un-formatted


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

p=r21+'/tests/check_r21_roles.py'; t=open(p,encoding='utf-8').read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(p,'w',encoding='utf-8',newline='').write(t)


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

t=open(r20+'/tests/check_r20_static.py',encoding='utf-8').read()


⚠️ [ruff] <SIM115> reported by reviewdog 🐶
Use a context manager for opening files

open(r21+'/tests/check_r21_static.py','w',encoding='utf-8',newline='').write(t); print('ok')

@demonsan
demonsan force-pushed the blyu/gemm-fusion-sp-qkv branch from 75dabb5 to 36256e5 Compare October 26, 2026 12:53
@zufayu
zufayu self-requested a review October 28, 2026 05:17
@zufayu zufayu assigned valarLip and unassigned yifehuan Oct 28, 2026
@github-actions github-actions Bot changed the title [HIP] gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 [HIP] [Build] gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 Oct 29, 2026
@github-actions github-actions Bot added the Build label Oct 29, 2026
@aiter-bot

aiter-bot commented Oct 29, 2026 •

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision bdd5c6816ea9 · 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 exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?
  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 — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_gemm_fusion_sp_qkv_op.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

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

demonsan added a commit that referenced this pull request Nov 9, 2026
`aiter/ops/gemm_fusion/sp_qkv/runtime.py` is the AITER-owned native
implementation behind the P0 op contract (`op.py` / `CONTRACT.md`,
`sp_qkv_fused` v1). The op hands over one flat dict of contract tensors and the
runtime owns every policy that used to be caller state in the gemm_fusion
framework:

- profile selection: env AITER_GEMM_FUSION_PROFILE (name under
  aiter/configs/gemm_fusion/ or a path; default minimax_m3_sp4_gfx950_v1). The
  r19/16K alternate profile is reachable only this way, never as an op argument.
- one FusionResources session per (device, rank, world, group id), created on
  the first eager call or by open_session(); released by close_session().
- plan selection via match_padded(); the matched plan is prepared/bound once per
  bucket outside graph capture; a first call inside capture is refused, replays
  run the prepared binding. Bound pointers are checked for moves.
- R16 pad-M: a padded call (real local M below the matched bucket) binds
  bucket-sized staging outputs once and copies the real `T = 4*real M` rows back
  to the caller's public tensors after every launch (device-side, capturable).
- rank-uniform per-process call_ids: monotonic counter masked to the 18 low bits
  the R12 tag carries (non-zero); documented "all ranks issue the same call
  sequence" assumption.
- R12 ERR-page readback: one async readback per launch, a non-zero word raises
  a typed GemmFusionDeviceError instead of silently succeeding; check_errors()
  and close_session() surface the last step's error.
- optional native_stage callback on open_session(): the caller's post-prologue
  attention tail (the framework's stages_native.attend_after_prologue
  consumption of q/k/v/index_q + the caches the prologue wrote). No ATOM import
  ever; default None means the caller runs its tail after the op returns.

Coverage: coverage-limited native path (CONTRACT.md §8 option B). The runtime
serves the fused *prologue* cells: the two-stage plans that write
q/k/v/index_q and the KV/index caches (small band; exact buckets and the pad
hits that the framework's pad-M selection resolves into them). There is no
unfused fallback: uncovered calls raise match.ContractError listing
profile/mode/M/arch/cu/world/capabilities.
OPEN ITEM with the contract owner: CONTRACT.md §8 also lists the one-stage
large band (M 512..16384) as "fused native", but one-stage plans cover only
GEMM + SP exchange -- this payload contract carries prologue outputs, so the
large band needs a native post-exchange prologue stage (a new aiter kernel/op
that #6689 does not have) and currently raises the coverage error. Resolve by
narrowing §8 to the prologue cells (large band = provider/option-A follow-up)
or by scheduling that extra native stage as new scope.

CPU gate (this commit):
- op_tests/test_gemm_fusion_sp_qkv_runtime.py: 20 passed (payload validation,
  coverage errors, session cache/lifecycle, prepare-before-capture + replay,
  pad-bucket staging + copy-back, exact-bucket direct binding, call-id counter,
  profile env selection, ERR readback, native-stage callback, lazy imports).
- op_tests/test_gemm_fusion_sp_qkv_op.py: 14 passed.
- op_tests/test_gemm_fusion_profile_rules.py: 52 passed.
- black/ruff clean on both new files.

GPU-unverified (CPU-only implementation): real CCO comm/arena/ERR-page creation,
plan.prepare/run with the compiled r19 kernels, graph-capture replay, the
alternate r19 profile selection on GPU, brute-force byte equality against the
#6689 golden cells (including the pad-copy path), the ERR-page fail-stop path,
and the ATOM-parity native stage (the callback is exercised only with fakes
here).
demonsan added a commit that referenced this pull request Nov 9, 2026
Adds `runtime.sp_qkv_covers(payload) -> bool`, the session-independent static
coverage query the neutral op re-exports: the same payload validation, spec,
MatchCtx, profile and match_padded rule the native planner uses, but with **no
resource creation, no allocation, no build and no launch**, and without touching
the session cache. It never raises: an invalid payload, unavailable
framework/MORI/profile, world != 4 or an uncovered call returns False; True means
the planner would match a fused prologue plan (padded buckets included). It is
safe on a consumer's __init__ and cheap enough per call.

Wording follows the Lead decision (option (a)): the module doc and the
one-stage coverage error now state that CONTRACT.md §8 narrows fused-native
coverage to the prologue cells and that the one-stage large/r19 band is
**Phase-2** -- an aiter-owned native post-exchange prologue op (or a contract
split), not part of this runtime and not to be added here.

The optional `open_session(native_stage=...)` callback is documented as an
explicitly optional **consumer continuation, not part of the op contract**
(ATOM runs its attention tail after the op; default None; no ATOM import).

Tests: `op_tests/test_gemm_fusion_sp_qkv_runtime.py` grows to 23 (the new ones
assert `sp_qkv_covers` is True for the prologue cells m in {1,2,16,128,256} x
mode, False for the one-stage band (512/600/1024/8192/9216) and on unavailable
profile/bad payload, that no session/resource/allocation happens, and that the
one-stage ContractError names the Phase-2 reason).

Combined-tree gate: runtime tests 23, op tests 19 (integrator's new coverage
tests), profile_rules 52, black/ruff clean.

GPU-unverified (CPU-only implementation): real CCO comm/arena/ERR-page creation,
plan.prepare/run with the compiled r19 kernels, graph-capture replay, the
alternate r19 profile selection on GPU, byte-exactness against the #6689 golden
cells (incl. the pad-copy path and the coverage predicate's device-side
behaviour), the ERR-page fail-stop path, and the ATOM-parity consumer
continuation (faked only in CPU tests).
demonsan added a commit that referenced this pull request Nov 9, 2026
…e irrelevant

Output-binding rule change driven by the ATOM integration questions:

- `_prepare_bucket` now always binds bucket-sized **runtime staging outputs**
  and never the caller's tensors (`_ptr_tuple(include_outputs=False)`), so caller
  output buffers, slice views and per-layer row ranges no longer participate in
  the binding. The runtime then copies the real `T = 4*real local M` rows back
  into whatever output tensors the current call passed (same stream, capturable,
  captures fine). Exact buckets and pad hits share one binding per
  `(mode, bucket M)` per session, which is what lets ATOM share one bucket-sized
  output buffer across layers (or pass disjoint row-range views).
- The copy-back row count is now computed **per call** from the current
  payload's `x.shape[0]` instead of the prepare-time m; previously a second call
  hitting the same bucket with a different real m copied the wrong number of
  rows (and the first call's output tensors were stickily reused).
- Add `w_scale` to the bound-pointer check: the plan binds it by pointer (the
  kernels' Wscale); a moved `w_scale` was invisible to the runtime before.
- `sp_qkv_covers` doc: tensor payload only needs to be structurally valid
  (shape/dtype/numel and `w.is_contiguous` are read; no data/device/pointer
  access), so per-call tensors may be meta/empty placeholders while the bound
  weights/norm-weights/caches are real; a live GPU/ROCm/MORI context and a real
  SP group are required, and the answer is for `x.shape[0]` (a 0-row placeholder
  is rejected; a max-row placeholder answers only that max M).
- Tests: 25 (always-staging for exact + pad buckets, shared output buffer across
  layers, same bucket with different real m copying per call, moved bound pointer
  rejected, staging handed to the optional consumer continuation).

Combined-tree gate: runtime 25, op 19, profile_rules 52, black/ruff clean.

GPU-unverified (CPU-only implementation): real CCO/arena/ERR-page creation,
plan.prepare/run with the compiled r19 kernels (including the new always-staging
binding and copy-back path), graph-capture replay, alternate r19 profile
selection on GPU, byte-exactness against the #6689 golden cells, the ERR-page
fail-stop path, and the ATOM-parity consumer continuation.
@demonsan
demonsan force-pushed the blyu/gemm-fusion-sp-qkv branch from a3cf250 to 6eb97bb Compare November 10, 2026 02:33
@github-actions github-actions Bot changed the title [HIP] [Build] gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 Nov 10, 2026
@demonsan demonsan changed the title gemm_fusion: GEMM + epilogue fusion framework and sp_qkv kernels (FP8 QKV GEMM + Ulysses SP exchange + head norm/RoPE/KV-cache) for gfx950 Add the routed sp_qkv_fused v1 contract; the fusion implementation moves to an out-of-tree AITER provider Nov 10, 2026
@demonsan
demonsan force-pushed the blyu/gemm-fusion-sp-qkv branch 3 times, most recently from 62d6ac0 to 49a3205 Compare November 10, 2026 03:34
@demonsan demonsan changed the title Add the routed sp_qkv_fused v1 contract; the fusion implementation moves to an out-of-tree AITER provider feat(gemm_fusion): route sp_qkv_fused v1; keep a reference native, implementation moves to a provider Nov 10, 2026
@demonsan
demonsan force-pushed the blyu/gemm-fusion-sp-qkv branch 2 times, most recently from 00f3425 to 2a4bbaf Compare November 10, 2026 05:02
@zufayu

zufayu commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Heads-up on the tests/plugin_contracts.json conflict, plus the resolution, since the obvious one produces broken JSON.

Why it conflicts. Not with any particular PR — with main. #7484 landed five routed ops after this branch took its copy of the baseline, so the file has diverged. GitHub currently reports this PR as CONFLICTING for that reason alone.

Do not resolve it by hand. The baseline is a sorted JSON object and new entries land on adjacent lines, so the conflict markers cut through object bodies — each side ends up holding half a brace. Keeping both sides yields a file that fails json.loads, and the gate then reports a mismatch that points nowhere near the real problem. (Tried it; that is how I know.)

Regenerate instead. The gate ships its own scanner, so the baseline can be rebuilt from whatever the merged tree actually contains:

python -c "import sys, json, pathlib; sys.path.insert(0, \"tests\");
from test_plugin_contracts import routed_contracts, _BASELINE;
_BASELINE.write_text(json.dumps(routed_contracts(pathlib.Path(\".\")), indent=1, sort_keys=True) + chr(10))"

Then pytest -q tests/test_plugin_contracts.py. Because the scanner reads the code rather than the old file, the result cannot disagree with what is actually routed.

One more thing worth knowing: #7728 also touches this file (it routes seven DeepSeek V4.1 contracts). Whichever of the two lands second will hit this again — same fix. Nothing needs coordinating beyond that; the code files do not overlap at all.


Unrelated to the conflict, two observations from reading the diff, both offered as information rather than review asks:

  • Checked against the provider obligations added to RFC: Versioned Kernel Provider Interface for AITER #7240 yesterday — this does not trip any of them. No host-device readback in a lazy init path, no backend= parameter, flat positional contract. Useful signal for us: the RFC text was sufficient for the first reader outside the team who was not involved in writing it.
  • CONTRACT.md alongside the op is a better practice than what the twelve currently-routed ops do, which is leave the semantics to a docstring and the RFC. If it works out for you, it is worth proposing for aiter/plugin/README.md as the recommended shape.

… an out-of-tree provider

AITER keeps the op contract and the aiter.plugin routing surface; the gemm_fusion
framework, kernels, configs, runtime and evidence move to the plugin_poc provider.
The plugin interface is staged byte-identically from PR #7484 so this branch is
testable before #7484 lands.

- aiter/plugin/: staged #7484 interface.
- aiter/ops/gemm_fusion/sp_qkv: route-only neutral op (route(op=..., version=1))
  on the existing flat 15-arg signature; native body raises NoKernelProviderError;
  CONTRACT.md rewritten for the contract/provider model.
- aiter/__init__.py: lazy sp_qkv_fused export; sp_qkv_covers removed.
- op_tests/test_gemm_fusion_sp_qkv_op.py: CPU-only registration/no-provider/fake-
  provider/kill-switch/contract-mismatch/decline tests.
- Removed from aiter (now in plugin_poc feat/sp-qkv-aiter-provider): aiter/gemm_fusion,
  aiter/ops/gemm_fusion/sp_qkv implementation, csrc/gemm_fusion, configs and the
  implementation docs/tools/tests.

CPU gate: pytest op_tests/test_gemm_fusion_sp_qkv_op.py -q -> 7 passed.
@demonsan
demonsan force-pushed the blyu/gemm-fusion-sp-qkv branch from 2a4bbaf to bdd5c68 Compare November 11, 2026 07:52
@demonsan

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (023a9d147); the tests/plugin_contracts.json conflict was resolved by taking main's file as the base and regenerating it with the gate's own scanner (not hand-resolved). python -c "import json;json.load(open('tests/plugin_contracts.json'))" validates; pytest -q tests/test_plugin_contracts.py -> 8 passed; pytest op_tests/test_gemm_fusion_sp_qkv_op.py -q -> 15 passed. New head: bdd5c6816.

Understood on #7728 -- whichever of the two lands second will hit the same divergence, and the same scanner regeneration applies. Thanks also for the CONTRACT.md observation; if it works out here, I may propose it as the recommended shape in a follow-up.

@zufayu

zufayu commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

@aiter-bot review

@zufayu zufayu closed this Nov 12, 2026
@zufayu zufayu reopened this Nov 12, 2026
@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 6689 --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.

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 2 review(s); expect to start in about 57 min. The box reviews one PR at a time.

@aiter-bot

Copy link
Copy Markdown

⚠️ aiter-bot — this review could not complete: a problem with the GLM model service, not with this PR.

GLM backend unavailable at http://localhost:30000 (deep inference probe returned '000')

@yhl-amd — please take a look.

Triage: if GLM serves but its output is malformed it may be the ATOM framework (@valarLip); if the box, GPU, disk or network is unhealthy it may be the machine (@gyohuangxin).

Re-comment @aiter-bot review once it is resolved.

@zufayu
zufayu merged commit d6bda77 into main Nov 12, 2026
@zufayu
zufayu deleted the blyu/gemm-fusion-sp-qkv branch November 12, 2026 05:10
zufayu added a commit that referenced this pull request Nov 12, 2026
#6689 added the sp_qkv_fused contract. Clean merge; verified rather than
assumed -- 16 contracts with none added or lost by this branch, both the
eager snapshot and _as_custom_op intact, and the registered op still an
OpOverloadPacket.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
zufayu added a commit that referenced this pull request Nov 12, 2026
#6689 added sp_qkv_fused to the baseline. Clean merge -- the two entries
are far enough apart in a sorted file not to collide this time. Verified:
17 contracts, main's 16 plus mla_sparse_prefill, none lost.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
… an out-of-tree provider (#6689)

AITER keeps the op contract and the aiter.plugin routing surface; the gemm_fusion
framework, kernels, configs, runtime and evidence move to the plugin_poc provider.
The plugin interface is staged byte-identically from PR #7484 so this branch is
testable before #7484 lands.

- aiter/plugin/: staged #7484 interface.
- aiter/ops/gemm_fusion/sp_qkv: route-only neutral op (route(op=..., version=1))
  on the existing flat 15-arg signature; native body raises NoKernelProviderError;
  CONTRACT.md rewritten for the contract/provider model.
- aiter/__init__.py: lazy sp_qkv_fused export; sp_qkv_covers removed.
- op_tests/test_gemm_fusion_sp_qkv_op.py: CPU-only registration/no-provider/fake-
  provider/kill-switch/contract-mismatch/decline tests.
- Removed from aiter (now in plugin_poc feat/sp-qkv-aiter-provider): aiter/gemm_fusion,
  aiter/ops/gemm_fusion/sp_qkv implementation, csrc/gemm_fusion, configs and the
  implementation docs/tools/tests.

CPU gate: pytest op_tests/test_gemm_fusion_sp_qkv_op.py -q -> 7 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants