Repository navigation
[Perf] kda: Reuse int64 prefill offsets across layers - #50102
Merged
kpham-sgl merged 2 commits intoNov 13, 2026
Merged
Conversation
alphabetc1
requested review from
hanming-lu,
hebiao064,
yizhang2077 and
yuan-luo
as code owners
November 12, 2026 11:45
41 of 42 tasks
Co-authored-by: Khoa Pham <[email protected]>
alphabetc1
force-pushed
the
port-k31-kda-metadata-review
branch
from
November 12, 2026 11:52
1f4d448 to
02ab384
Compare
kpham-sgl
approved these changes
Nov 13, 2026
hnyls2002
added a commit
that referenced
this pull request
Nov 15, 2026
kevin-mii
added a commit
that referenced
this pull request
Nov 15, 2026
Brings in the c13 catch-up (main up to a56dbcf, #50102) and the k3_ar_fusion workspace-provider follow-up. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 of 5 tasks
5 tasks
MatsueYu
added a commit
to MatsueYu/sglang
that referenced
this pull request
Nov 16, 2026
… kernel KDAAttnBackend.init_forward_metadata reads extend_kernel.wants_int64_query_start_loc unconditionally since sgl-project#50102. The Ascend _AscendKDAExtendKernel is a duck-typed kernel that does not inherit LinearAttnKernelBase, so Kimi-K3 prefill failed with AttributeError. The kernel casts query_start_loc to int64 inside extend(), so the shared int64 offset copy is unnecessary; declare the flag as False.
lihenga
added a commit
to lihenga/sglang-sugon
that referenced
this pull request
Nov 18, 2026
Build the optional int64 query offsets once per eager non-speculative extend forward and keep that tensor alive for all KDA layers. FlashInfer's host contents memoization can then reuse its tensor identity instead of repeating the int32-to-int64 conversion and host read in every layer. Keep other kernels opted out and preserve the original-offset fallback. Adapt the offsets reuse change from upstream SGLang PR sgl-project#50102. Validation: the combined worktree was exercised on TP8 B300 Kimi-K3 with Mooncake L4, including 100-document mixed-replica replay, deterministic answers, external-cache restore, and the trace-disabled path. A separate profile confirmed the 16/32/48-byte copies each fell from 69 calls to one; profile wall times are not a controlled speed comparison. Static checks pass. No unit tests were run, following the workspace instruction.
3 of 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.
Original author: @kpham-sgl (Khoa Pham); credited with a
Co-authored-bytrailer in the port commit.Port of #48414
Takes only the per-forward int64
cu_seqlensreuse fromf87a6998703. The pinned FlashInfer 0.7.4 casts int32 sequence offsets to a new int64 tensor on each KDA prefill call, while its host-metadata cache keys on the live tensor identity. Passing a new tensor at every layer defeats that cache and repeatscpu().tolist()on the CUDA offsets.References: FlashInfer's conversion and host-metadata memo.
Modifications
The selected source hunks are unchanged. Left in #48414: pinned checkpoint-metadata H2D, verify block-limit changes, state-free decode radix, FlashMLA token-packing runtime integration, and megakernel changes.
Validation
pre-commiton all four changed files andgit diff --check: passed._cu_seqlens_contentshelper: int64 values/dtype, fresh metadata on the next forward, backend opt-out, decode, target verify, and memo reuse. The metadata builder and initializer execute their source code; GPU imports and unrelated pool setup are isolated.registered/kernels/ops/attention/test_kda_prefill.pyandregistered/kernels/ops/attention/test_kda_prefill_graph.py.Performance
This removes repeated metadata conversion and host-content reads in the eager FlashInfer KDA path. No GPU speedup or model-accuracy result is claimed. GPU validation and engine-step benchmarking on current main remain outstanding.
CI States
Latest PR Test (Base): 🚫 Run #43214595030
Latest PR Test (Extra): ❌ Run #43214594802
Latest PR Test (AMD ROCm 10): ❌ Run #43214594904
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: