[Fix] Cast Ascend kernel indices to int64 before stride multiply - #1216
Open
sunyi0505 wants to merge 1 commit into
Open
[Fix] Cast Ascend kernel indices to int64 before stride multiply#1216sunyi0505 wants to merge 1 commit into
sunyi0505 wants to merge 1 commit into
Conversation
sunyi0505
force-pushed
the
fix_overflow
branch
from
September 3, 2026 03:27
b875959 to
de47b89
Compare
sunyi0505
force-pushed
the
fix_overflow
branch
from
September 3, 2026 06:23
de47b89 to
49a6d69
Compare
sunyi0505
marked this pull request as ready for review
September 3, 2026 07:20
Contributor
Author
|
@zhiyuan1i This pr is ready for review. Could you please review this PR? Thanks! |
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.
Summary
Triton-Ascend kernels were overflowing int32 when building GM addresses on long sequences.
Program IDs and grid-derived indices (
i_b,i_t,i_n,NT,bos) are int32. Products likei_b * T,i_tg * HV * K * V, orbos * HVwrap past 2³¹ before a trailing.to(tl.int64). That pattern also fails to compile when the index is specialized (constexprhas no.to()).Typical wrap points:
HV * K * Vwith K=V=128, HV=64, BT=64 → overflow at NT > 2048 (T > 131K)offset * Dwith D=4096 → overflow at T > 524Kcu_seqlensloaded as int32, then(bos * HV + i_h) * V(HV=32, V=4096 → safebos≈ 16K)This PR casts the index to int64 first, then multiplies:
tl.cast(i_b, tl.int64) * Tinstead of(i_b * T).to(tl.int64)cu_seqlensastl.int64; keepT_cur = (eos - bos).to(tl.int32)make_block_ptroffsets/block_shape as int32 (i_t * BT)Touched 20
triton_ascendfiles: modules (fused CE, layernorm, l2norm, rotary, fused_norm_gate) and ops (chunk_h / chunk_o / chunk_delta_h, GDN wy_fast/gate, GLA chunk, KDA, cumsum, solve_tril).Test plan
hardware: Atlas 800T A3(X86)

FLA_NPU_XDIST=1 ASCEND_RT_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 pytest --exitfirst -n 8 --dist load tests/modules tests/ops/utils tests/ops/test_gdn_kernels.py tests/ops/test_gdn.py tests/ops/test_kda.py tests/ops/test_attnres.py tests/ops/test_solve_tril.py tests/ops/test_gla.py
Benchmark / NCU (kernel changes only)
Not involved
Breaking changes
None
Checklist
If you ticked the "minor" box above
Standalone minor PRs are normally not accepted (see No busywork PRs).
Justify here why yours is worth a maintainer's review time — minor PRs without a justification may be closed without review: