Skip to content

[benchmarks] Correct the MLA causal reference and document raw negative views - #4760

Merged
choijon5 merged 2 commits into
mainfrom
choijon5/helion-b200/mla/1
Nov 28, 2026
Merged

choijon5 merged 2 commits into
mainfrom
choijon5/helion-b200/mla/1

Conversation

@choijon5

@choijon5 choijon5 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PRs:


[benchmarks] Correct the MLA causal reference and document raw negative views

The decode reference broadcast the single-token benchmark mask to every
query, allowing earlier queries to read future tokens. Compute each
query's last visible position from its input length, on its own device.

Two CPU cases cover the benchmark token and three distinct causal windows
across a noncontiguous sequence of physical KV pages. The shipped kernel,
Triton backend selection and saved config are unchanged.

The accompanying known gap records the existing distinction between raw
storage and a PyTorch lazy-negative view in the deployed Triton preset.
Changing the original function or its AOT key convention belongs to a
separate compatibility change.

Testing: test_flash_mla_reference_masks_each_query passed both one-query
and three-query 16-head CPU cases. The original reference returned
[2,2,2] where the correct causal values were [0,1,2]. A pristine
B200 2 check on torch 2.14.1 also reproduced the independent raw view
problem: maximum error 1.390625 for the lazy-negative query versus
0.00390625 when resolving it. Strict lint and Pyrefly passed. No launch
configuration, kernel or public dispatch behavior changes.

Review notes:

  • The suggested local normalization can cover the MLA read, and is
    recorded as such. It is not a remedy for the now-scoped raw pointer
    read/write boundary; the unchanged preset is its numerical reproducer.

autoreview passed: claude, codex

This five-PR DeepSeek-V3 MLA series starts on the shared B200 compiler #4759 and ends at the opt-in preset #4764.

…oots

An ordered persistent phase can borrow its siblings' thread block for
ordinary row selection and free-iota warp reductions. Prove the root's
coordinates and disjoint stores before lowering it; this applies to an
inferred local pipeline and to an explicit local barrier with one or more
producers. Keep full-block sorts, wider thread counts, TF32 fragment
dots and other complete-root modes on a launch the root owns. A flat
ordered-phase program gives each phase its own launch. The autotuner
retains bounded resource tiles when choosing that witness and keeps a
warp alternative on a persistent carrier when all its roots support it.
When a phase needs the new rank-one selection-coordinate proof, check
its live storage at registration and the corresponding immutable fact
at code generation, for both flat and shared persistent launches.
Standalone and intrinsically owned fragments keep their existing
in-place contract. A flat stage takes the new proof independently of
whether its selection uses serial or warp workers. Check both candidate
owners with the same native reduction and physical axis facts. A stage
may own its own reduction helper graphs; the shared persistent CTA
still requires one eligible ordinary root. Discovery makes the same
distinction: the warp top-k is available on the flat carrier when a
nested consumer loop belongs to its projected stage, and remains
ineligible on the shared persistent launch.

Narrow a persistent PID dispatch only for the compiler's unchanged
scalar selectors with the same reaching definitions. In a leading
dispatch, the compiler's unshadowed one-argument Int32/Int64 casts
preserve that proof; neither an arbitrary call nor a read through an
aliased tensor becomes an invariant through a cast. An assigned
coordinate or a read from storage that can change across a barrier
retains the full branch. Original absolute PID offsets and unrelated
backends' control flow are preserved.

Testing: 265 CuTe CPU cases passed (persistent dispatch, selection,
fragment coverage, FP32 dot and phase source). They render a rank-one
shared selection without a reduction and the three-root shared warp owner,
the flat CTA sorter, flat 256-thread launch, and flat TF32 MMA, including
their persistent negative controls. B200 4 passed the changed-input
phase replays and grouped rank-3 and selected worklist suites (115
passed, one skipped after moving both CPU-only rank-3 cases): the second call changes winning values, and the
negative-gather tests distinguish bounded reads from explicit wrap.
The dynamic routed program's two loop bodies use exactly their own
operands under these casts; focused tests include aliases of the cast
namespace and payload. All 237 cases in the 12-module CPU selection passed on the cast
correction, followed by 13/13 B200 4 phase replays on the current source. Both the
untiled and 32-wide reduction plus top-k gather were refused on the
former stack, then matched PyTorch exactly on both signed frames. A
second genuine consumer with a nested grid loop has a flat-only
autotuner witness and matched the changed-input PyTorch results.
The new flat rank-one case checks changed signed rows and their gathered
payload; aliased input/output views get neither a shared nor a flat warp witness. All seven projected scan cases preserve their original reducer graphs. The scan
capacity negative explicitly uses the admitted flat launch so it reaches
its device operation check. Earlier selector checks passed 62 Triton CPU cases (five skipped) and
272 Pallas interpreter cases (44 skipped). Strict lint and Pyrefly passed.

autoreview passed: claude, codex

stack-info: PR: #4759, branch: choijon5/helion-b200/shared/11
…ve views

The decode reference broadcast the single-token benchmark mask to every
query, allowing earlier queries to read future tokens. Compute each
query's last visible position from its input length, on its own device.

Two CPU cases cover the benchmark token and three distinct causal windows
across a noncontiguous sequence of physical KV pages. The shipped kernel,
Triton backend selection and saved config are unchanged.

The accompanying known gap records the existing distinction between raw
storage and a PyTorch lazy-negative view in the deployed Triton preset.
Changing the original function or its AOT key convention belongs to a
separate compatibility change.

Testing: test_flash_mla_reference_masks_each_query passed both one-query
and three-query 16-head CPU cases. The original reference returned
[2,2,2] where the correct causal values were [0,1,2]. A pristine
B200 2 check on torch 2.14.1 also reproduced the independent raw view
problem: maximum error 1.390625 for the lazy-negative query versus
0.00390625 when resolving it. Strict lint and Pyrefly passed. No launch
configuration, kernel or public dispatch behavior changes.

Review notes:
- The suggested local normalization can cover the MLA read, and is
  recorded as such. It is not a remedy for the now-scoped raw pointer
  read/write boundary; the unchanged preset is its numerical reproducer.

autoreview passed: claude, codex

stack-info: PR: #4760, branch: choijon5/helion-b200/mla/1
@choijon5
choijon5 marked this pull request as draft November 28, 2026 05:33
@choijon5
choijon5 changed the base branch from choijon5/helion-b200/shared/11 to main November 28, 2026 05:33
@choijon5
choijon5 force-pushed the choijon5/helion-b200/mla/1 branch from e6249b5 to 3c31ecd Compare November 28, 2026 05:33
@choijon5
choijon5 changed the base branch from main to choijon5/helion-b200/shared/11 November 28, 2026 05:33
@choijon5
choijon5 marked this pull request as ready for review November 28, 2026 05:33
@choijon5
choijon5 changed the base branch from choijon5/helion-b200/shared/11 to main November 28, 2026 06:34
@choijon5
choijon5 merged commit 3db2106 into main Nov 28, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants