Repository navigation
docs: unbreak the -W build and correct the EP fp4 target list - #688
Merged
Merged
Conversation
- docs/MORI-GEMM-AR-BENCHMARK.md links the gemm_ar README with a relative path that leaves the Sphinx source dir, so MyST resolves it as a source document and cannot find one. Harmless until #680 turned on -W, at which point it failed the docs job on main. Neither PR's CI saw the combination: #662 merged while warnings were still advisory, and #680 was branched before that page existed. Use the absolute GitHub URL, which is already how ep_backends.rst references a package README. It is the only link in docs/ that escapes the source dir. - fp4 is not gfx950-only. intranode_kernels.py:_accum_funcs has a gfx1250 branch (one cvt_scale_pk8_f32_fp4 per i32) alongside the gfx950 pair-at-a- time family, and hip_tuning_configs carries measured gfx1250 fp4 geometry. gfx942 is the target that lacks the intrinsics. Corrected in ep_backends.rst before it reached the published site, and in the v2 README it was copied from. - ep_backends.rst attributed the internode quant_type restriction to the HIP backend. The check is on is_internode in EpDispatchCombineConfig and applies to any backend; HIP is just the only one with an internode path today. - Add the link-checker fixtures #680 described but did not ship, and run them in the docs job ahead of the build. Publication is gated on that checker, so one that passed everything would keep the job green while the site rotted. Also document that it follows <a href> only, and match the job's sphinx invocation to the -E form the configuration was validated with. Verified: the strict build reproduces the main failure before the fix and succeeds after; check_docs_links reports 0 errors over 8958 links across 25 pages; the 8 fixtures pass; black 25.1.0, ruff 0.12.0 and git diff --check are clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The strict Sphinx build plus the checker's own run over the real site are the gate; hand-written fixtures only guarded the case where the checker silently stops checking anything, which is not worth a test file and a pytest install on the docs runner. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
yangyuhuiling
pushed a commit
that referenced
this pull request
Sep 20, 2026
…lished Rebasing onto main brought in #688, which converted this file's one link into `python/` to an absolute GitHub URL: Sphinx builds `docs/` alone, so a relative path to a file outside that tree is a broken reference and `-W` fails the build. The rewrite in this branch added three more of them. Same rule applied to all four. Links the other way -- from the operator README into `docs/` -- stay relative, because that file is not in the toctree and GitHub resolves them. Verified with the gate itself rather than by eye: `sphinx -E -n -W --keep-going` builds clean, and `tools/check_docs_links.py` reports 8872 local links across 25 pages with 0 errors. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
yangyuhuiling
added a commit
that referenced
this pull request
Sep 21, 2026
…ctive (#690) * gemm_ar: MXFP8 (32-wide ue8m0), the quantisation V4.1-Flash actually ships `GemmAllReduceOp` served 1x128 / 128x128 fp8 block scales. DeepSeek-V4.1-Flash quantises 32-wide ue8m0 on both operands (`weight_block_size [32, 32]`, `scale_fmt "ue8m0"`), which is a different operand contract and a different kernel, not a parameter of the old one. CDNA4's `v_mfma_scale_f32_16x16x128_f8f6f4` takes the ue8m0 scales as *instruction operands*, so this form needs no dequantisation arithmetic at all -- no second accumulator, no running rescale. `_BlockScaleK`'s promote/rescale chain exists precisely because a 128-wide block cannot be expressed that way. Two layout results came out of making it fast, both about addresses rather than bytes, and both carry the counters that settle them: * **Scales must be K-block major.** A block group's sixteen lanes want sixteen consecutive rows of one K block. K-block major coalesces them; the quantiser's own row-major `[M, K/32]` spreads them K/32 bytes apart -- same instruction count, 3.2x the cache accesses, +50-67% on the GEMM. * **Four M tiles pack into one scale dword.** `opsel_b` on the scaled MFMA is an atom-time attribute naming which byte of a 32-bit scale operand to read, so one load serves four tiles and the select is free. -29.1% `SQ_INSTS_VMEM` with VALU flat, worth -5 to -7.5%. A quantiser can emit the layout directly, at no extra traffic. `_PinnedLaunch` resolves each compiled kernel's dispatch once. `JitFunction` re-derived its cache key per call -- an inspect bind, a 35-global snapshot, a drift check -- which measured 181.6us of Python per fused call against 5.9us of actual `hipModuleLaunchKernel`, enough to make the layer host-bound. It verifies the argument tuple element by element before pinning and falls back to the normal path on any surprise, so a FlyDSL change costs performance, not correctness. The fp8 all-gather leg gets its two knobs settled by measurement: pull it over LSA rather than pushing over SDMA (2.0-4.0%), and do not fuse the quantise into the reduce (1.2-1.9%). Both hold at every M and in all three modes. `_gemm_a8w8_8wave.py` is vendored from aiter and now diverges in two places rather than one: `Mfma16x16x128` grew the scaled form of the atom. Both new arguments default to off and the unscaled path is byte-for-byte what it was, so a re-vendor stays a merge. The file's header says so. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * gemm_ar: the GEMM without a collective, for prefill M and for decode's Most of what this integration is worth turns out to be the multiply, not the overlap. At V4.1-Flash's shapes the GEMM is ~180us against 1130-1410us of communication, so hiding it entirely would be worth 11-18% and fusing collects about half of that -- while the GEMM alone is worth ~30% against the route SGLang would otherwise take. And a `ColumnParallelLinear` has no all-reduce to fuse with at all, so `wq_b` was unreachable. `Mxfp8GemmOp` (`gemm.py`) is the same kernel with the epilogue tail compiled out: no communicator, no window, an ordinary tensor out. Two things about it are not obvious. M only has to be a multiple of 64, not of BLOCK_M, because the grid is ceildiv and the tail block masks -- 64 is the packed scale's group. And there is exactly one compile per (N, K) per tile width, because `c_m` is a runtime argument; a per-M cache looks harmless until a server drives it, where every prefill batch pays a fresh multi-second FlyDSL compile. Which N tile to use is decided by the resulting **grid**, not by M. The tile exists to double the grid when the wide one is launch-starved, and the grid is `ceildiv(M,256) * (N/256)`, so a threshold on M alone is only ever right for the N it was fitted to. Across 110 measured points the separation is total: below 128 workgroups the 128-wide tile wins every single time by 9-17%, from 129 the 256-wide one wins every single time by 26-29%. `_WIDE_TILE_MIN_GRID = 140` sits in the gap at zero regret. `Mxfp8GemvOp` (`gemv.py`, `kernels_gemv.py`) is a different kernel for decode's token counts, where a 256-row tile has nothing to fill it. It inverts the same scaled MFMA -- the weight is the A operand and the tokens are B, because the weight is what there is a lot of -- streams the weight from global with no LDS staging, and splits K across a workgroup's waves, reducing through LDS in a fixed order so a row stays batch-invariant. Against SGLang's `mxfp8_gemv` on the same fp8 bytes it is 3-8% faster on the two tuned shapes and **bit-identical** at every M, which is the check that matters: same instruction, same operands, so a layout disagreement shows up as a mismatch rather than a tolerance. Its margin is tuning, and that is recorded next to the table: shapes falling back to the heuristic land inside +-2%, except `wo_a`, which loses 12-16%. The operands are deliberately not uniform. Both ops take `preshuffle_b`'s weight, so a server shuffles once, but the GEMM wants the A scale through `preshuffle_a_scale` while the GEMV takes both scales exactly as the checkpoint stores them. That is not an inconsistency: the GEMM's sixteen lanes read sixteen rows of one K block and have to coalesce, where the GEMV's are sixteen tokens, M is at most 32, and the whole A scale is under a kilobyte. Tests cover both ops at both real shapes, the ragged and unpadded M contracts, and the GEMV across its configuration space -- each configuration in its own process, because a FlyDSL compile failure takes the interpreter with it. Every masked address in the GEMV is pushed out of its buffer's records or clamped: 0xFF is NaN in both ue8m0 and e4m3, and NaN times a zeroed weight is still NaN. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * benchmark, docs: one timer, three entry points, and the traps that cost most The measurements, and the harness that has to be right for them to mean anything. Most of the work here was finding out that it was not. **Three measurement traps, each of which produced a confident wrong number.** A single-call CUDA-graph replay has a ~13.4us floor on this box, which is most of any small-M measurement -- `timing.py` amortises the capture. A repeated call reads the weight out of the 256MB LLC at 1.7x the bandwidth a forward pass gets, so cold is the number that predicts a server -- it rotates copies past the cache. And getting *that* right took two more corrections: the ring advances at capture time, so a graph of `reps` calls only ever touches `reps` copies; and the ring has to be sized so each tensor clears the cache on its own, not so their sum does, because a caller may hand over several weights of which the kernel reads one. Each is documented where it bit, because the symptom is always a plausible number rather than a failure. The worst of them was in the comparison itself: the baseline's *bf16* weight was never rotated, while `native_route_plan` picks `hipblaslt_bf16` -- which reads exactly that tensor -- on most large-M points. Those rows measured a hot baseline against a cold mori, which ran against mori, not for it. Corrected, SGLang is 3.6-18.6% slower there and mori's margin moves up to 28 points in its favour. The rows whose route never reads that tensor are unchanged within a point, which is how the fix was confirmed to touch only what it should. **Failure has to reach the caller.** A correctness sweep that printed `fail=N` and exited 0 -- verified with a probe rigged to fail all 112 cases -- is now a pytest grid. Every benchmark returns non-zero, `sweep.py` exits with the count of failed points, and "mori declines this shape by construction" is recorded as a result rather than a crash, so ten expected declines cannot bury one real break. **Six entry points, not seventeen.** `bench_gemm.py` covers the two scopes that are genuinely different questions -- `--scope kernel` for pre-quantised operands and `--scope linear` for a whole layer -- where three scripts had encoded the distinction implicitly. Six shell sweeps and a tuning script become `sweep.py` presets; two reporters become `report.py`, which keys on every axis a sweep declares varying and so cannot silently overwrite one configuration with another. The SGLang baseline is optional throughout: mori's own numbers need nothing but mori. One historical experiment is kept and renamed: `fused-blockscale-control` ran V4.1-Flash's shapes under a quantisation the checkpoint does not use, while presenting itself as a V4.1 benchmark. `--mode split-lsa --gather-dtype fp8` is refused where it is asked for. The LSA all-reduce has no fp8 leg, and the combination used to run a bf16 collective and report it under the fp8 label; the validation gate's two-sided band caught it, but only after paying for the run. `docs/` keeps how-to-run and a summary; every full table lives in the operator README, next to the code it is about. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs: re-measure the end-to-end numbers on AMD's own V4.1 branch The SGLang-side numbers were taken against a synthetic snapshot of the container image, because the V4.1 code existed on no branch at the time. It does now -- sgl-project/sglang#39857, `kevin-mii:dsv41-amd-main` -- so all three servers were re-run on top of it. The fused wo_b reproduces and is slightly better: fp8 wire +5.6% to +6.0% at bs 4-16 against +5.1% to +5.7% before, bf16 +1.9% to +2.8% against +2.3% to +2.6%. GSM8K 0.917 / 0.912 / 0.918. Added, because it had never been in this section: the standalone GEMM on its own, +2.2% to +2.5% with nothing fused, GSM8K 0.920 / 0.928. And a note that the two results do not add -- `fused_wo_b` runs first and the linear only sees what it declines, so they split `wo_b` rather than stacking on it. Both together is a fourth configuration nobody has measured. **One claim here was wrong and is corrected.** It called bs=1 a built-in control on the grounds that M=4096 is below both floors. The floors are 8192 for bf16 and 2048 for fp8, and the shape log confirms the consequence: the bf16 wire's smallest served M is 7734, the fp8 wire's is 1792. bs=1 is a control for the bf16 column only, and the fp8 column's +3.4% there is a real win that was being dismissed as drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs: the fourth configuration, and one fault that has not reproduced Both SGLang-side paths enabled together, which this section had been calling unmeasured: +7.4% to +7.7% prefill throughput at bs 4-16, against +6.0% for the fp8 wire alone and +2.3% for the standalone GEMM alone. They stack without adding, and the structure says why -- `fused_wo_b` runs first and the linear only sees what it declines, so at `wo_b` they divide the layer by M, and the ~1.7% on top is the column-parallel layers fusing cannot reach. Also recorded: one server out of nine hit `hipErrorIllegalAddress` under sustained load, and re-running the same variant completed cleanly. Written as what it is -- one sample, cause not established, the combination merely the only configuration that has shown it -- rather than as a known defect or as nothing. The five hypotheses already eliminated are listed so the next person does not re-walk them, and so is the reason `AMD_SERIALIZE_KERNEL=3` is being held back: it is worth spending on a repro that reproduces, and serialising perturbs the timing a race would depend on. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs: absolute URLs for the links out of the docs tree, as #688 established Rebasing onto main brought in #688, which converted this file's one link into `python/` to an absolute GitHub URL: Sphinx builds `docs/` alone, so a relative path to a file outside that tree is a broken reference and `-W` fails the build. The rewrite in this branch added three more of them. Same rule applied to all four. Links the other way -- from the operator README into `docs/` -- stay relative, because that file is not in the toctree and GitHub resolves them. Verified with the gate itself rather than by eye: `sphinx -E -n -W --keep-going` builds clean, and `tools/check_docs_links.py` reports 8872 local links across 25 pages with 0 errors. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * gemm_ar: fix the CI break, and satisfy the pre-commit hooks Two unrelated CI failures on this branch. They are in one commit because `black` reflowed lines adjacent to the real fix, so splitting them would mean hunk surgery on the same few lines rather than a cleaner history. **The CCO unit test.** All ten `test_standalone_mxfp8_gemv` cases failed with AttributeError: 'Int32' object has no attribute 'type'. Did you mean: 'dtype'? _arith_ops_gen.py:3163, in ShRUIOp.__init__ while the same tests passed here. The generated MLIR builders infer their result type as `operands[0].type`, so they need an operand that is already an `ArithValue`; `fx.Int32` is a wrapper and carries `dtype`. FlyDSL's operators go through `_make_binop` -> `_extract_arith`, which unwraps first, so `(v >> shift) & 0xFF` is right on any FlyDSL that has the operators at all. Whether the wrapper exposes `.type` differs between the FlyDSL here and the one in CI's container, which is why this was invisible locally. The rule that holds on both: hand wrappers to FlyDSL operators, never to raw builders. `kernels_fused._load_byte` carried the identical expression and the identical latent break; CI never reached it because the GEMV tests failed first. The one `arith.andi` over two predicates became nested `arith.select` -- same result, and `select` is what the rest of mori builds with, so it is the op proven against whatever FlyDSL CI ships. Every `arith.*` call left in this branch is now one `origin/main` also uses. 146 tests pass locally, including the fp32-reference numerics that would catch any change in what the shift and mask compute. **pre-commit.** Formatting from the hooks themselves, plus two they flagged and could not fix: - `needs_sglang` in bench_gemm.py was dead (F841). It computed a condition nothing read; `build_mxfp8(want_sglang=...)` already gates the only thing that needs it, and `--scope linear` imports SGLang's quantiser inside `mori_linear_call`, where a missing build is a reported per-impl failure and a non-zero exit. Deleted rather than wired up: there was no guard to restore. - `l` as a comprehension variable in sweep.py (E741) -> `line`. The license hook appended the full MIT header to timing.py above its SPDX short form, leaving two notices; dropped the short one. The second notice in `_gemm_a8w8_8wave.py` is the deliberate vendored-from-aiter attribution and is left alone. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * gemm_ar: close the four gaps from review on the new public surface All four reproduce as reported; none are in the MXFP8 numerics. **`supports_gemm` said yes to a tile the store cannot write.** The permlane guard was `BLOCK_N >= 256`, but `_PermlaneStoreC._emit` pairs *exactly* two N-tiles and asserts `n_tiles_b == 2`. So `block_n=512` passed every predicate and died several frames deeper -- and because the wide tile is only chosen once the grid is large enough, such an instance serves small batches correctly and fails when one grows. That is the worst shape a failure can take. `GemmAllReduceOp` already rejected it at its constructor; `Mxfp8GemmOp` and `supports_gemm` are new here and did not. Rather than restate the rule a third time, it is now `permlane_tile_constraint()` next to `_tile_constraints` in op.py, used by all three, with the kernel's own assert tightened to an equality as the backstop for callers that compile directly. Review suggested the assert alone would cover the predicate; it does not -- `supports_gemm` has to answer without compiling, which is why the rule has to exist as a predicate too. **The benchmarks reported `validated=true` for runs that validated nothing.** `bench_gemm.py` seeded `ref` from the first implementation's output, so that impl was its own reference: `rel_l2` identically 0 and a pass regardless of what it computed. A single-impl run -- which the docs recommend -- checked nothing, and a bug shared by every impl was invisible. `bench_gemv.py` had the same hole via `--baseline none`. Both now score against `reference_partial()`, the fp32 reference `bench_gemm_ar.py` next door already uses, built from the raw operands. The first impl's relL2 is now 1.66e-03 rather than 0, which is the fp8 floor and matches what review measured independently. Where no independent reference exists -- anything quantising inside the timed region -- `validated` is `None` and prints as `n/a`, never `True`. **`--scope kernel --impl sglang` compared two different inputs.** mori's kernel path builds its own pre-quantised A from seed 99 while SGLang's entry point is a linear and quantises the outer bf16 `x`. The baseline was scored against an unrelated result and read as failing validation -- a false accusation -- and the timings were not comparable either, only one side carrying the quantisation. Now refused at argument parsing, which is what this file's own docstring already said: linear is the scope where that comparison means anything. **`sweep.py fused-fp8` shipped 3 points that cannot run.** The preset listed `split-lsa` while appending `--gather-dtype fp8`, and the bench refuses that pair at entry -- a rejection this branch added and did not propagate here. 15 points, 3 of them unrunnable on a healthy box. Dropped from this preset only; the bf16 preset keeps `split-lsa`, where it is legal. Not addressed: the `wo_a` tuning entries review found worth 13.9-17.5%. That is a new performance claim and wants its own reproduction rather than being taken on the review's numbers inside an already-large PR. 66 tests pass; both kernel-scope paths verified against the new reference. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: xiangch <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The docs job has been failing on
mainsince #680 landed. This unbreaks it and folds in the three follow-ups from that review.The break
Not a bug in either PR — a merge race.
docs/MORI-GEMM-AR-BENCHMARK.mdcame from #662 and links the package README with a relative path that leaves the Sphinx source dir, so MyST resolves it as a source document and finds none. That was an advisory warning until #680 turned on-W. #662 merged while warnings were still advisory; #680 was branched before that page existed, so neither job saw the combination.Fixed by using the absolute GitHub URL, which is already how
ep_backends.rstreferences a package README. I scanneddocs/— this is the only link that escapes the source dir, in.mdor.rst.Follow-ups from the #680 review
fp4 is not gfx950-only.
intranode_kernels.py:_accum_funcshas a gfx1250 branch — onecvt_scale_pk8_f32_fp4per i32 — alongside the gfx950 pair-at-a-timecvt_scalef32_pk_*_fp4family, andhip_tuning_configs.pycarries measured gfx1250 fp4 geometry. gfx942 is the target that lacks the intrinsics. Corrected inep_backends.rstbefore it reached the published site, and in the v2 README it was copied from.The internode
quant_typerestriction is not a HIP restriction. The check is onis_internodeinEpDispatchCombineConfigand applies to any backend. HIP is simply the only backend with an internode path today. Reworded.Scope note on the checker. Documented that it follows
<a href>only --<link rel="next|prev">,<img src>,<script src>and stylesheet links are not followed -- so a clean run is not read as "every asset resolves". Also matched the job's sphinx invocation to the-Eform the configuration was validated with.Verification
sphinx -E -n -W --keep-going -b html docsreproduces the failure onmain(rc=1, the one warning above) and succeeds on this branch (rc=0)check_docs_links.py→Checked 8958 local links in 25 HTML pages; 0 errorsgit diff --checkcleanKnown gap, deliberately not changed here
test_dispatch_combine_v2_intranode.pystill gates itsfp4-gathercase on_skip_fp4 = skipif(not _IS_GFX950), so fp4 stays untested on gfx1250 even though the kernel supports it. Widening that changes what CI executes, and I cannot run it on gfx1250 to confirm — better as its own change by someone who can.🤖 Generated with Claude Code