[LoRA][I] Add MOE LoRA JIT alignment kernel and tests #19710
Merged
Fridge003 merged 11 commits intosgl-project:mainfrom Mar 12, 2026
Merged
[LoRA][I] Add MOE LoRA JIT alignment kernel and tests #19710Fridge003 merged 11 commits intosgl-project:mainfrom
Fridge003 merged 11 commits intosgl-project:mainfrom
Conversation
Add JIT-compiled CUDA kernels for MOE LoRA block size alignment: - moe_lora_align.py: JIT wrapper for moe_lora_align_block_size - moe_lora_align_kernel.cu: CUDA kernels for token alignment, sorting, and expert counting - test_moe_lora_align_block_size.py: Unit tests for the alignment kernel Made-with: Cursor
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Collaborator
Author
|
Co-authored-by: Jonah Bernard jb2528@cornell.edu |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a JIT-compiled CUDA implementation for MoE+LoRA token alignment (block-size padding + per-expert sorting), along with a Python wrapper and a CUDA CI unit test, as part of the larger MoE LoRA enablement work split out from #14105.
Changes:
- Introduce
moe_lora_align_block_sizePython wrapper that JIT-loads a new CUDA kernel. - Add CUDA kernels to build a per-LoRA token mask, align counts to
block_size, and sort tokens by expert. - Add a CUDA-registered pytest validating expert assignment and LoRA ownership of sorted blocks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| python/sglang/jit_kernel/moe_lora_align.py | JIT loader + Python entrypoint for the new MOE LoRA alignment kernel. |
| python/sglang/jit_kernel/csrc/lora/moe_lora_align_kernel.cu | CUDA implementation for token masking, expert counting/padding, and sorting for MoE LoRA alignment. |
| python/sglang/jit_kernel/tests/test_moe_lora_align_block_size.py | CUDA CI test validating the alignment/sorting results. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
|
/tag-and-rerun-ci |
25 tasks
Collaborator
Author
|
/tag-and-rerun-ci |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fridge003
approved these changes
Mar 12, 2026
6 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.
Split this PR #14105 into 3 parts - Part I
Add JIT-compiled CUDA kernels for MOE LoRA block size alignment:
Made-with: Cursor
Motivation
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci