Skip to content

perf(kda): parallelize diagonal solves in Prefill - #1703

Merged
shihaobai merged 2 commits into
mainfrom
bsh/glm-kda-split-triangular
Nov 12, 2026
Merged

shihaobai merged 2 commits into
mainfrom
bsh/glm-kda-split-triangular

Conversation

@shihaobai

@shihaobai shihaobai commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Compute the four independent 16x16 diagonal inverses in parallel before merging each 64x64 inverse. KDA Prefill opts into the shared solver's 64-token branch, which supports both packed and dense batch layouts. Select splitting by the FP32 workspace budget and minimum input length; the workspace may use at most the FP32 input size.

H200, 8192 tokens (16 requests of 512 tokens), 64 heads: the solver takes 0.968 → 0.476 ms with 32 MiB additional workspace. A 64-token, 64-head solve takes 0.0347 → 0.0254 ms.

Validation:

  • 34 tests pass on H200, covering packed/dense solver equivalence, KDA recurrence and GDN regression.
  • Compute Sanitizer memcheck: 9 solver cases, 0 memory errors (--report-api-errors no, CUDA memory caching disabled).
  • Non-TMA dense output matches the unsplit solver bit for bit; SM80/89/90/100/120 compilation passes.
  • Black and Flake8 pass.

@shihaobai
shihaobai marked this pull request as ready for review November 11, 2026 14:04
@shihaobai
shihaobai force-pushed the bsh/glm-kda-split-triangular branch from dae6c2d to 8c815ee Compare November 11, 2026 14:09
@shihaobai shihaobai changed the title perf(kda): parallelize diagonal solves in Hopper Prefill perf(kda): parallelize diagonal solves in Prefill Nov 11, 2026
Solve the four diagonal blocks independently and retain FP32 inverse tiles through merging. Select by chunk occupancy to bound scratch, with CUDA regression coverage for packed layouts, dtypes, precision modes and fallback behavior.
@shihaobai
shihaobai force-pushed the bsh/glm-kda-split-triangular branch from 4d70ee5 to 87deeb0 Compare November 11, 2026 15:24
@shihaobai
shihaobai merged commit 9640f76 into main Nov 12, 2026
1 check passed
@shihaobai
shihaobai deleted the bsh/glm-kda-split-triangular branch November 12, 2026 11:43
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.

1 participant