Repository navigation
[Perf] Fuse SWA page lookup and mapping clear - #38948
Merged
Merged
Conversation
Collaborator
Author
|
/tag-and-rerun-ci |
Jialin
marked this pull request as ready for review
September 10, 2026 22:23
Jialin
requested review from
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
HydraQYH,
Kangyan-Zhou,
alphabetc1,
bingxche,
celve,
hnyls2002,
ispobock,
merrymercy and
yuan-luo
as code owners
September 10, 2026 22:23
Collaborator
Author
|
/tag-and-rerun-ci |
Collaborator
Author
|
/rerun-failed-ci 09/10 10:24PM PT: after fixed trunk in #39019 |
Jialin
force-pushed
the
jialin/fuse-swa-page-free
branch
2 times, most recently
from
September 13, 2026 05:15
d588b0c to
1b4faf8
Compare
hnyls2002
requested review from
huangtingwei9988,
hzh0425 and
xiezhq-hermann
as code owners
September 14, 2026 09:46
Collaborator
Author
|
/rerun-failed-ci 09/14 11:39AM PT: Add run-ci and run-ci-extra labels |
Jialin
force-pushed
the
jialin/fuse-swa-page-free
branch
from
September 15, 2026 07:16
1b4faf8 to
c53dbf1
Compare
Collaborator
Author
|
/rerun-failed-ci |
Resolve SWA page representatives and clear their FULL-page mappings in one Triton launch. Preserve CPU/NPU fallback, debug validation and request-ring ownership. Co-authored-by: Jialin Ouyang <jialino@meta.com>
Co-authored-by: Jialin Ouyang <jialino@meta.com>
Jialin
force-pushed
the
jialin/fuse-swa-page-free
branch
from
September 18, 2026 17:20
c53dbf1 to
785e4fe
Compare
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
SWA segment frees currently launch separate Torch operations to look up peer pages and clear FULL-to-SWA mappings. Fuse that metadata work into one Triton kernel to reduce per-free scheduler dispatch overhead.
Modifications
test/registered/kernel/taxonomy in the kernel CI path filter.Accuracy Tests
SGLANG_IS_IN_CI=trueandSGLANG_ENABLE_ASYNC_ASSERT=true: 139 tests and 244 subtests passed at750ba1d20.Validation commands
These command payloads ran through
uv run --project <existing CUDA environment> --no-sync, with this checkout'spython/first onPYTHONPATH.Speed Tests and Profiling
For a paged segment (
page_size > 1, debug checks off), the metadata path changes from eight GPU launches to one:aten::index)aten::gt)aten::floor_divide)aten::mul)aten::arange)aten::add)aten::index_fill_)get_and_clear_swa_pages_kernelThe kernel reads one representative per distinct FULL page, returns its SWA page ID and peer-mapped flag, then clears that FULL page's mapping entries. A partial segment tail still clears the whole allocated page. The block barrier orders representative loads before mapping clears. The expanded index tensor is eliminated; its former
unsqueeze/reshapeviews did not launch GPU kernels.Eight back-to-back one-page frees therefore use 64 → 8 metadata launches, saving 56 launches without deferring ownership resolution. At page size 1, the same path changes from 3 → 1 launches per free.
This breakdown covers lookup and mapping clear, not the entire eviction or scheduler. Invariant-check kernels, FULL-page release arithmetic, and free-list updates remain outside it. Debug checks may synchronize, and first-use JIT compilation remains possible. No model-level serving-throughput result is claimed.
Model-free measurements
Measured on NVIDIA GB300 with PyTorch 2.11.0+cu130 and Triton 3.6.0 at
7e2774215(runtime code is unchanged by the test-only follow-up). All 16 shapes (page_size = 1/16/64/128, pages per free =1/8/64/1024) matched the Torch reference. The table shows one-page frees, with int64 inputs and debug checks off:Medians of 100 samples after 10 warmups, measured without the profiler. CPU time covers eager enqueue work, excluding explicit completion waits. GPU timing uses CUDA events around graph replay and includes graph-launch overhead; a 256 MiB cache flush occurs outside the timed interval. Mapping resets, invariant checks, and allocator free-list updates are excluded.
Benchmark script · All samples and results
Profiler screenshots and traces
Actual Perfetto screenshots of one paged free (
page_size = 128): eight baseline GPU kernels versus one fused kernel. Each view is zoomed independently. These profiled spans illustrate dispatch structure; the unprofiled timings are in the table above. No Python stacks were captured. Trace metadata is reduced to generic CPU/GPU labels and relative timestamps.Baseline:
Fused:
Click an image to open the full-size image. Download the complete eight-free traces and open them in Perfetto: baseline, 64 kernels · fused, 8 kernels.
Checklist
Review and Merge Process
Ready for maintainer feedback. CI was requested on
750ba1d20with/tag-and-rerun-ci; results are pending. Merge remains gated on review and passing CI.CI States
Latest PR Test (Base): 🚫 Run #35373755609
Latest PR Test (Extra): 🚫 Run #35373755078
Latest PR Test (AMD ROCm 10): ❌ Run #35373755553
Original commits
3fb8e3407ab0245048926a61d025c6e3fa2d7ef5