Skip to content

cuda: give the token-tile ldmatrix its shared state space - #748

Open
pmasala wants to merge 1 commit into
antirez:mainfrom
pmasala:fix/cuda-tokentile-ldmatrix-state-space
Open

cuda: give the token-tile ldmatrix its shared state space#748
pmasala wants to merge 1 commit into
antirez:mainfrom
pmasala:fix/cuda-tokentile-ldmatrix-state-space

Conversation

@pmasala

@pmasala pmasala commented Aug 8, 2026

Copy link
Copy Markdown

Fixes #734.

The three ldmatrix wrappers carried no state space qualifier, so the PTX asks
for generic addressing, while the operand comes from tt_smem_addr(), that is
__cvta_generic_to_shared(). ptxas then subtracts the shared window base from an
address that is already relative. SASS on sm_89, the same kernel twice:

no .shared::cta:  IADD3 R0, R0, -c[0x0][0x18], RZ
                  LDSM.16.M88.2 R6, [R0]
.shared::cta:     LDSM.16.M88.2 R6, [R0]

That killed every batch prefill of 128 tokens or more under --ssd-streaming,
which is where the token-tile gate engages. Whether ptxas emits the conversion
is a toolchain decision, so the same source can be fine on CUDA 12 and fatal on
CUDA 13.

Verified with DS4_CUDA_MMQ=0 and no other workaround: 128 / 512 / 2048 / 8192
tokens in one chunk, plus 2048 with --prefill-chunk 256 and 512, all clean and
coherent. The 8192-token prefill used to die even with
DS4_CUDA_NO_WINDOW_ATTENTION=1, so that was the same defect. At 2048 tokens the
token-tile path now gives 9.60 t/s against 7.91 for the generic fallback.

RTX 3500 Ada 12 GB (sm_89), CUDA 13.0, WSL2, DeepSeek-V4-Flash IQ2_XXS 80.8 GB.

The PTX carried no state space qualifier, so ptxas assumed generic addressing and
emitted a shared-window base subtraction ahead of every LDSM, corrupting an address
tt_smem_addr had already converted; any prefill of 128 tokens or more died on it.

Closes antirez#734
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.

CUDA --ssd-streaming: prefill dies with illegal memory access at exactly 128 prompt tokens

2 participants