[Kernel] Migrate scattered quantization kernels to sglang.kernels (RFC #29630, Phase 2.5, 1/7) - #30784
Merged
Conversation
…sgl-project#29630, Phase 2.5, 1/7) First of the seven Phase 2.5 sweeps: move the Triton / CuTe DSL quantization kernels still living under srt/layers/quantization into sglang.kernels.ops.quantization, byte-identical except import rewrites. - fp8_kernel.py (12 Triton kernels), int8_kernel.py, awq/awq_triton.py, mxfp8_amd_gfx95.py, and the CuTe DSL nvfp4_gemm_swiglu_nvfp4_quant.py move wholesale; the w8a8 tuned-config JSON directory (used only by fp8_kernel/int8_kernel) moves with them. - mxfp4_flashinfer_trtllm_moe.py is a quant-method module with one embedded kernel: extract PackTopkIds + its Triton kernel into sglang.kernels.ops.moe.pack_topk_ids (it is MoE-routing functionality, also consumed by moe_runner/flashinfer_trtllm); the quant-method glue stays in srt. - Register the migrated public entry points as KernelSpec inventory (TRITON / CUTE_DSL backends) and extend the namespace test's expected set. - Rewrite all in-tree importers (82 files across python/, test/, benchmark/). Only content change inside moved files is fp8_kernel's lazy sibling import of int8_kernel following the move. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
BBuf
requested review from
1am9trash,
AniZpZ,
Edwardf0t1,
FlamingoPg,
Fridge003,
HaiShaw,
Qiaolin-Yu,
YAMY1234,
Ying1123,
alphabetc1,
b8zhong,
ch-wan,
fzyzcjy,
hanming-lu,
hebiao064,
hnyls2002,
hubertlu-tw,
hzh0425,
ispobock,
jybsuper,
kkHuang-amd,
lifuhuang,
merrymercy,
mickqian,
rainj-me,
xiezhq-hermann,
yichiche,
yizhang2077 and
yushengsu-thu
as code owners
July 10, 2026 14:10
awq/__init__ and fp8_utils still imported awq_triton / fp8_kernel / mxfp8_amd_gfx95 from their pre-migration paths; repoint to sglang.kernels.ops.quantization.*. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
/rerun-failed-ci |
1 similar comment
Collaborator
Author
|
/rerun-failed-ci |
Collaborator
Author
tuning_block_wise_kernel.py still defaulted --save-path to the pre-migration
python/sglang/srt/layers/quantization/configs (now empty; the 159 tuned JSONs
and the get_w8a8_block_{fp8,int8}_configs loader moved to
python/sglang/kernels/ops/quantization/configs). Repoint the default so tuned
configs land where the runtime loader reads them.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
BBuf
added a commit
to BBuf/sglang
that referenced
this pull request
Jul 13, 2026
…t#30784 (moe) Each side relocated a different kernel into sglang.kernels.ops; resolution takes the union of both new-namespace imports and drops now-relocated old paths. Adopts main's removal of the DSA fused-metadata flag (attention). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BBuf
added a commit
to BBuf/sglang
that referenced
this pull request
Jul 13, 2026
…t#30784 (attention) Each side relocated a different kernel into sglang.kernels.ops; resolution takes the union of both new-namespace imports and drops now-relocated old paths. Adopts main's removal of the DSA fused-metadata flag (attention). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BBuf
added a commit
to BBuf/sglang
that referenced
this pull request
Jul 13, 2026
…t#30784 (dsa-dsv4) Each side relocated a different kernel into sglang.kernels.ops; resolution takes the union of both new-namespace imports and drops now-relocated old paths. Adopts main's removal of the DSA fused-metadata flag (attention). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
BBuf
added a commit
to BBuf/sglang
that referenced
this pull request
Jul 13, 2026
…nflict (vendored) Union of vendored fla relocation + main's quantization relocation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
DarkSharpness
pushed a commit
to DarkSharpness/sglang
that referenced
this pull request
Jul 13, 2026
Rename per_token_group_quant_v3 -> per_token_group_quant everywhere (files, symbols, custom-op and KernelSpec ids, tests); it is the default kernel, not a versioned variant. Mark the v2 JIT kernel deprecated: a module docstring plus benchmark comments state it is kept only as the perf baseline (benchmark impl keys are now jit_v2/current), and no sglang runtime code may call it. Also adapts to the post-rebase tree: sgl-project#30784 (RFC sgl-project#29630 Phase 2.5) moved fp8_kernel/int8_kernel to sglang.kernels.ops.quantization, so the branch-added tests/benchmarks/wrapper now import from the new paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merged
8 tasks
This was referenced Jul 14, 2026
Draft
5 tasks
DarkSharpness
pushed a commit
to DarkSharpness/sglang
that referenced
this pull request
Jul 21, 2026
Rename per_token_group_quant_v3 -> per_token_group_quant everywhere (files, symbols, custom-op and KernelSpec ids, tests); it is the default kernel, not a versioned variant. Mark the v2 JIT kernel deprecated: a module docstring plus benchmark comments state it is kept only as the perf baseline (benchmark impl keys are now jit_v2/current), and no sglang runtime code may call it. Also adapts to the post-rebase tree: sgl-project#30784 (RFC sgl-project#29630 Phase 2.5) moved fp8_kernel/int8_kernel to sglang.kernels.ops.quantization, so the branch-added tests/benchmarks/wrapper now import from the new paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
…sgl-project#29630, Phase 2.5, 1/7) (sgl-project#30784) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
sgl-project#29630 sgl-project#30784) (sgl-project#31089) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 2026
…sgl-project#29630, Phase 2.5, 1/7) (sgl-project#30784) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 2026
sgl-project#29630 sgl-project#30784) (sgl-project#31089) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Phase 2.5 of RFC #29630 (see the updated migration plan in the issue): a full-tree audit after #30044 found ~280 Triton kernels plus CuTe DSL / TileLang kernels still scattered outside the three canonical locations. This is sweep 1 of 7: the quantization group.
Modifications
Byte-identical file moves + import rewrites only (
git diff -Mshows 100% renames):fp8_kernel.pysglang/kernels/ops/quantization/fp8_kernel.pyint8_kernel.pysglang/kernels/ops/quantization/int8_kernel.pyawq/awq_triton.pysglang/kernels/ops/quantization/awq_triton.pymxfp8_amd_gfx95.pysglang/kernels/ops/quantization/mxfp8_amd_gfx95.pynvfp4_gemm_swiglu_nvfp4_quant.pysglang/kernels/ops/quantization/nvfp4_gemm_swiglu_nvfp4_quant.pyconfigs/(159 w8a8 tuned JSONs)sglang/kernels/ops/quantization/configs/mxfp4_flashinfer_trtllm_moe.pyis a quant-method module with one embedded kernel:PackTopkIds+ its Triton kernel are extracted verbatim intosglang/kernels/ops/moe/pack_topk_ids.py(MoE-routing functionality, also consumed bymoe_runner/flashinfer_trtllm.py); the quant-method glue stays in srt.Also:
KernelSpecinventory (TRITON / CUTE_DSL backends).python/,test/,benchmark/).fp8_kernel's lazy sibling import ofint8_kernel.test_kernels_namespace.pyexpected-ops set.Verification
import sglang.kernelsstays metadata-only (import-purity test passes: nosgl_kernel/sglang.jit_kernelimport).test_kernels_namespace.py+test_fused_op.py: 33 passed.test/registered/quant/*) now import through the new path and run unchanged in their CI lanes.Checklist
Part of the RFC #29630 Phase 2.5 series (1/7). Next: moe, top-level layers strays, generic attention, dsa+dsv4, linear-attention family, vendored fla/mamba.
🤖 Generated with Claude Code
Kernel-migration verification (no perf / config regression)
All moved modules are byte-identical relocations (git rename similarity R100, except
fp8_kernel.pyat R099 whose only delta is anint8_kernelimport-path rewrite — no kernel logic changed), so per-kernel latency is unchanged by construction.Import fixes in this PR:
awq/__init__andfp8_utilsstill importedawq_triton/fp8_kernel/mxfp8_amd_gfx95from pre-migration paths → repointed tosglang.kernels.ops.quantization.*.Tuning configs: 158 fp8/int8 block-shape config JSONs moved together with
get_w8a8_block_fp8_configs; the loader resolves them viaos.path.dirname(__file__)/configs, so co-locating loader + configs preserves the lookup.Empirical A/B (H200,
w8a8_block_fp8_matmul, N=1536 K=7168, block=[128,128], fp16 out): both main and PR load the tuned config (CONFIG_HIT=True, 18 entries) and latency matches within noise:→ tuning config still hit at the new location, no latency regression.
CI States
Latest PR Test (Base): ⏳ Run #29226631377
Latest PR Test (Extra): ❌ Run #29226631233