[examples] Read only the causal columns in chunk_fwd_A_diag_anchored - #3290
Open
tarinduj wants to merge 1 commit into
Open
[examples] Read only the causal columns in chunk_fwd_A_diag_anchored#3290tarinduj wants to merge 1 commit into
tarinduj wants to merge 1 commit into
Conversation
The intra-chunk score matrix is causal, so everything above its diagonal is structurally zero, and `chunk_fwd_A_diag_anchored_helion` was computing it anyway: each `BC_DIAG`-row sub-block read all `C` columns and then masked most of the result away. It now reads only the columns that can be nonzero, `0 : (i + 1) * BC_DIAG` for sub-block `i`, so the two matmuls span `BC_DIAG * (1 + 2 + ... + NC) = C * (NC + 1) / 2` columns instead of `NC * C`. `A` and `Akk` arrive zeroed, so the skipped columns already hold zeros. The diff reads as a manual unroll because a narrowing width has to be a literal: `hl.arange` rejects arithmetic on a specialized size, so each tier is written out and guarded on `C`. FLA's KDA does the same in `chunk_intra.py`. The tiers cover `C` of 32 and 64, the two chunk sizes FLA's KDA accepts, and the kernel asserts that. `kda` and `full_gla` share the kernel across four call sites, two of them backward. ## Benchmarks `%FLA = 100 * fla_ms / helion_ms` on H100, autotuned with `HELION_AUTOTUNE_EFFORT=full`. **Higher is faster than FLA.** The baseline row is the same variant's table in #3200. Forward: | variant | B1_T8192_H96_D128 | B2_T16384_H16_D128 | B4_T2048_H16_D128 | B4_T4096_H64_D128 | B8_T2048_H32_D256 | B8_T1024_H8_D64 | |---|---|---|---|---|---|---| | kda (#3200) | 118% | 117% | 109% | 116% | 109% | 104% | | kda | 129% | 126% | 98% | 128% | 111% | 95% | | full_gla (#3200) | 143% | 161% | 128% | 145% | 134% | 115% | | full_gla | 154% | 169% | 130% | 155% | 137% | 108% | Forward + backward: | variant | B1_T8192_H96_D128 | B2_T16384_H16_D128 | B4_T2048_H16_D128 | B4_T4096_H64_D128 | B8_T2048_H32_D256 | B8_T1024_H8_D64 | |---|---|---|---|---|---|---| | kda (#3200) | 117% | 113% | 114% | 116% | 109% | 141% | | kda | 119% | 115% | 115% | 119% | 110% | 130% | | full_gla (#3200) | 235% | 248% | 211% | 243% | 215% | 139% | | full_gla | 240% | 252% | 200% | 247% | 216% | 128% | stack-info: PR: #3290, branch: tarinduj/stack/4
tarinduj
force-pushed
the
tarinduj/stack/3
branch
from
August 5, 2026 22:34
a804a31 to
7e39307
Compare
tarinduj
force-pushed
the
tarinduj/stack/4
branch
from
August 5, 2026 22:34
2b0cbf7 to
9f52f0c
Compare
This was referenced Aug 5, 2026
tarinduj
force-pushed
the
tarinduj/stack/4
branch
from
August 5, 2026 22:37
9f52f0c to
043d1f9
Compare
tarinduj
marked this pull request as ready for review
August 6, 2026 15:56
AmesingFlank
approved these changes
Aug 6, 2026
tarinduj
marked this pull request as draft
August 6, 2026 23:31
tarinduj
force-pushed
the
tarinduj/stack/4
branch
from
August 6, 2026 23:32
043d1f9 to
0d2fb92
Compare
tarinduj
marked this pull request as ready for review
August 6, 2026 23:32
tarinduj
force-pushed
the
tarinduj/stack/4
branch
from
August 7, 2026 00:06
0d2fb92 to
1545b1e
Compare
tarinduj
marked this pull request as draft
August 7, 2026 00:23
tarinduj
marked this pull request as ready for review
August 7, 2026 00:23
tarinduj
marked this pull request as draft
August 7, 2026 00:31
tarinduj
marked this pull request as ready for review
August 7, 2026 00:32
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.
Stacked PRs:
[examples] Read only the causal columns in chunk_fwd_A_diag_anchored
The intra-chunk score matrix is causal, so everything above its diagonal is structurally zero, and
chunk_fwd_A_diag_anchored_helionwas computing it anyway: eachBC_DIAG-row sub-block read allCcolumns and then masked most of the result away. It now reads only the columns that can be nonzero,0 : (i + 1) * BC_DIAGfor sub-blocki, so the two matmuls spanBC_DIAG * (1 + 2 + ... + NC) = C * (NC + 1) / 2columns instead ofNC * C.AandAkkarrive zeroed, so the skipped columns already hold zeros.The diff reads as a manual unroll because a narrowing width has to be a literal:
hl.arangerejects arithmetic on a specialized size, so each tier is written out and guarded onC. FLA's KDA does the same inchunk_intra.py. The tiers coverCof 32 and 64, the two chunk sizes FLA's KDA accepts, and the kernel asserts that.kdaandfull_glashare the kernel across four call sites, two of them backward.Benchmarks
%FLA = 100 * fla_ms / helion_mson H100, autotuned withHELION_AUTOTUNE_EFFORT=full. Higher is faster than FLA. The baseline row is the same variant's table in #3200.Forward:
Forward + backward: