Skip to content

engine/sglang: upstream patches for FA4 hd256 (SM90) and the sgl-kernel sm_90a build - #226

Merged
SamMausberg merged 4 commits into
mainfrom
upstream/session4-patches
Oct 2, 2026
Merged

SamMausberg merged 4 commits into
mainfrom
upstream/session4-patches

Conversation

@SamMausberg

@SamMausberg SamMausberg commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Adds the session's two upstream SGLang patches as format-patches under engine/sglang/patches/upstream/, with a section in engine/sglang/README.md. Both are single commits on upstream SGLang main at f6fcda8827, and both also apply to the paper's pin (git apply --check on bd66ce343e).

The README section describes the patches and links their upstream status. It cites no local evidence: the measurements are in the upstream threads. The patch files are byte-identical to git format-patch of local commits 4eba651f81 and 8e08130136, both on upstream f6fcda8827. The commit on sgl-project/sglang#42263 is 6027833579 on upstream main 0098b9d29d: the same patch (git range-diff gives "="). Repository pre-commit passes on the changed files.

…sgl-kernel sm_90a build

Two format-patches on upstream SGLang f6fcda8827 (both also apply to the pin), with a README
section linking their upstream status: 0001 (FA4 paged-KV ceil-divide + SM90 test) is the fix in
sgl-project/sglang#35757, where the test is offered in a comment; 0002 (sm_90a gencode for
common_ops without FA3) is sgl-project/sglang#42263.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T23:17:06.008585Z 60d6d6b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8ea4f03edf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES at 8ea4f03

The patches are right: both are exactly what was posted or offered upstream, and both apply as stated. One sentence in the README says more than the posted #42263 body does. That sentence is the only blocking item.

Blocking

  1. engine/sglang/README.md:333 (row 0002): "FA3 is off by default on aarch64, so the aarch64 wheels carried no sm_90a code." The posted #42263 body makes a narrower claim. It inspected one release (sglang-kernel 0.4.8) and found no sm_90a in that wheel's common_ops, and it says that flashmla_ops in the same wheel does carry sm_90a. As written, the README sentence contradicts the posted text and turns one inspected wheel into a statement about all aarch64 wheels. Suggested wording: "FA3 is off by default on aarch64, so common_ops in the aarch64 wheel (inspected: sglang-kernel 0.4.8) has no sm_90a code. On GH200 its SM90 CUTLASS GEMMs (fp8_scaled_mm, int8_scaled_mm, the FP8 and W4A8 MoE GEMMs) print CUTLASS's "Arch conditional MMA" error and return without computing."

Optional

  1. README:332 (row 0001): state what was tested, for example "Checked at head_dim 256 (tile_n 80 and 64) and 192 (tile_n 112), the configurations in the comment; other head dims on SM90's cp.async paged path are not covered." Without this, a reader can take the row as a general fix for SM90 paged KV, and the upstream run logs show it is not one. Those logs are not committed, so state the scope here, not their results.
  2. README:332: "Qwen3.5's full-attention layers" could say Qwen3.5-4B, the only model that was run. The same holds for any head_dim 256 model on SM90 by code reading.
  3. README:332: "the same fix is in the open fix: FA4 paged-KV zero-size page-table registers on SM90 sgl-project/sglang#35757". #35757 writes the fix as cute.ceil_div(n_block_size, num_threads). Consider "the same ceil-divide (written there as cute.ceil_div)", which matches what the comment checked.
  4. PR body: "the upstream commits (4eba651f81 and 8e08130136)" are local commits on f6fcda8827. The commit on #42263 is 6027833579, on upstream main 0098b9d29d. It is the same patch: git range-diff gives "=", and the format-patch output differs only in the From <sha> line.

What I checked

  • Byte identity: git format-patch -1 --stdout of 4eba651f81 and 8e08130136 (git 2.34.1) matches the two committed files exactly (cmp). Both commits have one parent, f6fcda8827, and author Sam Mausberg.
  • 0002 against #42263: the hunk from gh pr diff 42263 -R sgl-project/sglang matches the patch's hunk. git range-diff f6fcda8827..8e08130136 0098b9d29d..6027833579 gives "=".
  • 0001 against the #35757 comment (issuecomment-5961366446): the test function in the patch is byte for byte the code block posted there (2,136 characters), including the is_sm90_supported import the comment asks for. The paged_kv.py hunk, comment line and expression, matches [CuTe] Fix forward dynamic-shape correctness Dao-AILab/flash-attention#2745's hunk. #35757 is open, and its diff touches only that line.
  • git am: in a sparse shared clone, each patch and the two-patch series apply with git am to f6fcda8827, and the resulting trees equal the source commits' trees (e8fc7fea, 86c7bc06). They also apply to the pin bd66ce343e. The three touched files have the same blobs at the pin, at f6fcda8827 and at 0098b9d29d.
  • README claims against code at f6fcda8827:
    • The SM90 head_dim 256 tile is 128 x 80 (64 with a window) (interface.py:212-213).
    • The cp.async loader gets num_threads_per_warp_group = 128 (flash_fwd_sm90.py:324, 983-996), so floor division gives 0 entries per thread.
    • FA3 defaults off on aarch64 (CMakeLists.txt:109-114).
    • The sm_90a block (:243) feeds SGL_KERNEL_CUDA_FLAGS, which both common_ops builds and spatial_ops use (:318, :332, :541).
  • Run log: the Qwen3.5-4B fa4 server on f6fcda8827 fails during prefill CUDA graph capture with the paged_kv.py ValueError at page_size 1, as the README and the comment say.
  • No committed line cites local evidence. No hostname or IP appears in the diff, the commit or the PR body. No AI attribution. The files are 4.9 KB and 1.5 KB. .patch files are excluded from the auto-fixing hooks, so they stay byte-identical, and the README has no trailing whitespace.
  • Codex: "Didn't find any major issues" on 8ea4f03, with no inline threads.
  • Not yet checked: pre-commit. A timed hold is running, so I queued it in the CPU window and will report the result on the next head.

On the next head I will check the delta for item 1, any optional items taken, Codex on that head and the pre-commit result.

Row 0002 now says that common_ops in the inspected aarch64 wheel
(sglang-kernel 0.4.8) lacks sm_90a, as the posted
sgl-project/sglang#42263 body does, instead of saying all aarch64 wheels
carry none. Row 0001 names Qwen3.5-4B, lists the head dims checked, and
says sgl-project/sglang#35757 writes the ceil-divide as cute.ceil_div.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 026ecddeaf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: REQUEST CHANGES at 026ecdd

I re-checked only the delta from 8ea4f03: one commit that changes two README rows. My blocker and all four optional items are done as suggested. One new problem: since this head was written, our #35757 comment has been edited (updated 2026-10-02 22:02 UTC), and the new 0001 sentence no longer matches it.

Blocking

  1. engine/sglang/README.md:332 (row 0001) says the patch was "Checked at head_dim 256 (tile_n 80 and 64) and 192 (tile_n 112), the configurations in the comment; other head dims on SM90's cp.async paged path are not covered." The live comment now also reports head_dim 160 (tile_n 112) and 224 (tile_n 80). With the ceil-divide they get past the compile error but give wrong output, so they need a separate fix. The README phrase "the configurations in the comment" now leaves those two out, and "not covered" is weaker than what is now posted. Suggested sentence: "Checked at head_dim 256 (tile_n 80 and 64) and 192 (tile_n 112). At head_dim 160 and 224 it gets past the compile error but not to correct output, so those need a separate fix (see the comment); other head dims on SM90's cp.async paged path are not covered." This cites the posted comment, not local evidence.

Re-checked

  • Previous blocker, row 0002: now reads "common_ops in the aarch64 wheel (inspected: sglang-kernel 0.4.8) has no sm_90a code. On GH200 its SM90 CUTLASS GEMMs ...", which matches the #42263 body.
  • Optional items:
    • Qwen3.5-4B is now named.
    • "the same ceil-divide (written there as cute.ceil_div)" is in. #35757 is still open.
    • The tested-scope sentence is added (see item 1).
  • PR body: it now names 4eba651f81 and 8e08130136 as local commits on f6fcda8827, and 6027833579 on 0098b9d29d as the #42263 commit, with range-diff "=".
  • The delta touches only engine/sglang/README.md, so the patch files are unchanged and stay byte-identical to the posted patches.
  • The test code block in the edited #35757 comment is unchanged, so it still equals the patch's test.
  • Codex: "Didn't find any major issues" on 026ecdd.
  • Pre-commit:
    • The author's log for 026ecdd gives rc=0.
    • My CPU-window run on 8ea4f03 also passed (rc=0).
  • No hostname or IP appears in the delta.

On the next head I will check the 0001 sentence against the live comment and run Codex.

Row 0001 now says, as the edited sgl-project/sglang#35757 comment does,
that at head_dim 160 and 224 the ceil-divide gets past the compile error
but not to correct output.
@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 0931f9700f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 60d6d6bdb8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SamMausberg

Copy link
Copy Markdown
Owner Author

Verdict: APPROVE at 60d6d6b

This is a delta review from 026ecdd, my predecessor's last verdict (REQUEST CHANGES on one README sentence).

What I re-checked

  • 0931f97 changes one table row: README row 0001 in engine/sglang/README.md. It now reads "Checked at head_dim 256 (tile_n 80 and 64) and 192 (tile_n 112). At head_dim 160 and 224 it gets past the compile error but not to correct output, so those need a separate fix (see the comment); other head dims on SM90's cp.async paged path are not covered." That resolves the blocker.
    • I read the live #35757 comment (issuecomment-5961366446, updated 22:02 UTC; same text as the reviewed edit). It says head_dim 160 (tile_n 112) and 224 (tile_n 80) fail on main with the ValueError, and the ceil-divide "gets them past it, but not to correct output, so they need a separate fix".
    • The row matches the comment, and the comment's tested configurations (256 at tile_n 80 and 64, 192 at tile_n 112) match the row's.
  • 60d6d6b merges main 5a125d9 into 0931f97. Merge base c63c296.
    • Of the 34 files changed against the base, the two upstream patches equal 0931f97's blobs. The 31 files only main changed (speed-lowc patches, evidence, experiments) equal 5a125d9's blobs. git diff 5a125d9 60d6d6b touches only the README and the two upstream patches.
    • engine/sglang/README.md at 60d6d6b is the base (lines 1-319, byte-identical), a blank line, the upstream section (lines 321-333, byte-identical to 0931f97's), a blank line, then main's speed-lowc section (lines 335-352, byte-identical to 5a125d9's lines 321-338). diff of the merged README against each parent shows additions only.
  • Nothing in the merged tree contradicts the live #35757 comment or #42263. I read #42263's body live: open, head 6027833579, updated 21:37 UTC. README row 0002 matches it on every claim:
    • in the aarch64 0.4.8 wheel only common_ops lacks sm_90a;
    • the CUTLASS "Arch conditional MMA" error, with no product computed;
    • the FP8/INT8 and W4A8 MoE GEMMs are affected;
    • builds with FA3 on get identical flags.
      The speed-lowc section and evidence/speed_lowc/README.md speak only of head_dim 256 and "tiles with n below 128 now compile", which is consistent with the comment: compiling is not correctness.
  • Codex is clean on 0931f97 (22:31 UTC) and on 60d6d6b (23:17 UTC), with no inline threads on either.
  • Merging into current main (7a394a6, after bf16_paths: neither BF16 miss at the served gross positions is shown to be specific to SGLang #222) is clean. git merge-tree shows no conflict markers in engine/sglang/README.md, and the upstream section lands before speed-lowc.
  • Pre-commit was not rerun. The delta is one README sentence plus main's already-checked section, and a timed hold is running. The predecessor's runs at 8ea4f03 and the author's at 026ecdd passed.

Optional

  1. A later pass over main's speed-lowc row 0001 could add, next to "tiles with n below 128 now compile", that compiling is not correctness at head_dim 160 and 224 (the #35757 comment). This was my predecessor's optional note on speed-lowc probes: split-KV killed, GDN fusion not built, FA4 sm_90 hd256 backport, FA4 target and drafter attention probes #220. It is not for this PR, which must keep main's section byte-identical.

@SamMausberg
SamMausberg merged commit f6f86ac into main Oct 2, 2026
SamMausberg added a commit that referenced this pull request Oct 3, 2026
…es and the upstream patches

BF16 (#222, evidence/bf16_paths): the served benchmark read both gross
positions as ill-conditioned in BF16. #222 supports that for a4db11ff/333
only. At 579ae7ce/439, the paper's 8.9-nat position, transformers in BF16
keeps FP32's top token in all 16 readings, FP32 under one-rounding noise
moves 1756 by at most 0.52 nats, and no single SGLang kernel swap removes
the miss: an SGLang outlier at a selected position, whose frequency the
unselected positions cannot compare with transformers'. The abstract and
§4.5 add "unlike transformers'"; App E.5, the served README (two places)
and a new notes subsection give the reading; register entry bf16-paths in
both registers.

Low-concurrency probes (#220, evidence/speed_lowc): one notes paragraph
(split-KV verify dropped by its rule; FA4's head-dim-256 compile failure
and backport; one-session served FA4 probes, exactness not classified;
fused GDN chain passed its rule but not built), H6, "What did not work",
register entry speed-lowc, and the missing index rows.

Upstream (#226): one notes paragraph and register entry upstream-patches
(the FA4 test as a comment on sgl-project/sglang#35757; the sgl-kernel
sm_90a build fix open as sgl-project/sglang#42263). The two FP8 lines say
the CUTLASS GEMM "fails" rather than "aborts", consistent with the engine
README.

Reviewer's optional item from #227: "calls of up to 30-64 positions" in
the abstract and §4.5 (largest certified calls at each point).

Paid for in §4.5's paragraph with no claim dropped; the main text still
ends at the foot of p10.
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.

1 participant