Conversation
page_idx and sub come from tl.program_id(0), so both byte offsets in _page_split_kernel are int32 products. Past 2**31 they wrap and Triton sign-extends the result onto the 64-bit pointer, putting the access about 2 GiB below the buffer. The two offsets wrap at different pool sizes, so each gets its own test: the destination at dst page 57,359 (14,340 source pages), the source at page_idx 14,340. Each test packs the axis it is not exercising, so only one buffer spans 2**31 at a time and peak stays at 4.13 GiB. Both sit above a canary region, so a regression trips an assertion instead of an illegal access that would take down the CUDA context for the process. Also carries the one-line int64 promotion from sgl-project#34027 so the test is green standalone.
edenfunf
requested review from
BBuf,
DarkSharpness,
HaiShaw,
HydraQYH,
celve and
yuan-luo
as code owners
August 21, 2026 08:34
5 tasks
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.
Motivation
_page_split_kerneltakespage_idxandsubfromtl.program_id(0)(int32) and builds two byte offsets from them:Both products are int32. Past 2**31 they wrap, and Triton sign-extends the result onto the 64-bit pointer, so the access lands about 2 GiB below the buffer: a silent write into a neighbouring allocation, or an illegal access if that page is unmapped.
#34025 reported this and #34027 carries the fix. This adds the regression coverage to go with it, so the offset cannot quietly return to int32 in a later refactor.
Modifications
Adds
test/registered/kernels/ops/attention/test_page_split_int32_offset.pyonbase-b-kernel-unit/1-gpu-large.The two offsets wrap at different pool sizes, so each gets its own test:
page_idx14,340, at the shipped 149,760 B page strideBoth strides are kernel parameters, so each test packs the axis it is not exercising. Only one buffer has to span 231 at a time, which holds peak at 4.13 GiB instead of ~8. The source test sets
src_stride0to 227 so the wrap arrives at page 16 and its destination stays a few MB.Each large buffer sits above a canary region in the same allocation. A regression then writes into memory the test owns and trips an assertion, rather than raising an illegal access that would take the CUDA context down for everything else in the process.
Masked page skipping, the alignment tail and the persistent-buffer contract are already covered by
TestTouchedPageSplitintest_flash_mla_backends.py, through the production entry point. This file only covers the arithmetic past 2**31.Includes the one-line fix from #34027 so the test passes standalone. I will drop it and rebase if that lands first.
Accuracy Tests
RTX 5070 (SM120), torch 2.9.1+cu128 / triton 3.5.1. Peak 4.13 GiB, nothing retained between tests.
data_src_off = 0fails 53 assertions. Source pages carry a per-(page, sub) signature so that class of regression cannot hide behind a uniform fill.Speed Tests and Profiling
At 8,192 pages, where neither variant wraps: int32 4.818 ms, int64 4.797 ms (-0.43%, noise). One widened scalar op against ~37 KB of copy per program.
Checklist