Skip to content

[Kernel] Classification cleanup: unify _jit_ naming, drop empty/model groups, add elementwise (RFC #29630) - #32148

Merged
BBuf merged 2 commits into
sgl-project:mainfrom
BBuf:bbuf/kernels-classification-cleanup
Jul 23, 2026
Merged

BBuf merged 2 commits into
sgl-project:mainfrom
BBuf:bbuf/kernels-classification-cleanup

Conversation

@BBuf

@BBuf BBuf commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Post-migration review follow-up on python/sglang/kernels/ — tightens classification and naming consistency. Almost entirely git mv renames + import rewrites.

Changes

  • Unify JIT-op naming — drop the leftover _jit_ prefix (a batch-1 shim-era artifact) from 8 modules so JIT-backed ops read consistently with the rest (flash_attention.py, rope.py, …): activation/activation, layernorm/norm, gemm/dsv3_{fused_a,router}_gemm, kvcache/set_mla_kv_buffer, quantization/per_{tensor_quant_fp8,token_group_quant,token_group_quant_8bit_v2}.
  • Delete the empty spatial group — it was declared in _GROUPS with zero operators.
  • Remove the model group — redistribute the inkling kernels by function: communication (all_reduce, ar_fused, ar_scattered_sconv), attention (attn_prologue, rel_proj, row_scale), moe (gate_topk_renorm).
  • Add an elementwise group for cross-cutting pointwise kernels — move attention/add_constant.py (the generic JIT reference kernel the dev guide walks through; no production caller) and the mixed fused-pointwise collection layernorm/elementwise.py (softcap / sigmoid-mul / gated-activation / fused-rmsnorm shared across grok/qwen) into it. The two fused-rmsnorm variants stay layernorm.* ops (registration target repointed to the new module; op ids unchanged).
  • Move hadamard attention → quantization (the Hadamard transform is a quantization-rotation primitive).

ops groups: 19 → 18 (−spatial, −model, +elementwise).

Validation

  • import sglang.kernels.ops stays metadata-only (CLEAN — no sgl_kernel / sglang.kernels.jit); all 18 groups load.
  • All 18 renamed/moved module targets resolve via find_spec.
  • Zero dangling refs (dotted + package-relative forms + stale path comments all rewritten).
  • py_compile + pre-commit (isort/ruff/black + registry-validation + no-registered-tests-in-package) clean.

Follow-up to #32072 / #32128.


CI States

Latest PR Test (Base): ⏳ Run #29981512360
Latest PR Test (Extra): ⏳ Run #29981512306

… groups, add elementwise (RFC sgl-project#29630)

Post-migration review follow-up:

- **Unify JIT-op naming**: drop the leftover `_jit_` prefix (a batch-1 shim-era
  artifact) from 8 modules so JIT-backed ops are named consistently with the
  rest (flash_attention.py, rope.py, ...): activation, layernorm/norm,
  gemm/dsv3_{fused_a,router}_gemm, kvcache/set_mla_kv_buffer,
  quantization/per_{tensor_quant_fp8,token_group_quant,token_group_quant_8bit_v2}.
- **Delete the empty `spatial` group** (declared in _GROUPS with zero ops).
- **Remove the `model` group**: redistribute inkling kernels by function —
  communication (all_reduce, ar_fused, ar_scattered_sconv), attention
  (attn_prologue, rel_proj, row_scale), moe (gate_topk_renorm).
- **Add an `elementwise` group** for cross-cutting pointwise kernels: move
  attention/add_constant.py (generic JIT reference kernel, no prod use) and the
  mixed fused-pointwise collection layernorm/elementwise.py (softcap /
  sigmoid-mul / gated-act / fused-rmsnorm shared across models) into it.
  The two fused-rmsnorm variants stay `layernorm.*` ops (target repointed).
- **Move hadamard** attention -> quantization (Hadamard transform is a
  quantization-rotation primitive).

All refs rewritten (dotted + package-relative + stale comments). Validated:
`import sglang.kernels.ops` stays metadata-only (CLEAN), 18 groups load, all
18 renamed/moved targets resolve via find_spec, py_compile + pre-commit clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@BBuf
BBuf requested a review from HydraQYH as a code owner July 23, 2026 05:00
@github-actions github-actions Bot added documentation Improvements or additions to documentation quant LLM Quantization Multi-modal multi-modal language model deepseek sgl-kernel diffusion SGLang Diffusion jit-kernel labels Jul 23, 2026
…removal

The hardcoded GROUPS canary in test_kernels_namespace.py still listed the
now-deleted `spatial` group (and lacked the new `elementwise` group), so
test_group_importable[spatial] failed with ModuleNotFoundError. Update the
expected list: drop `spatial`, add `elementwise`. Verified locally: 16 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BBuf
BBuf merged commit 11b0e5c into sgl-project:main Jul 23, 2026
70 of 186 checks passed
xinguozhu-2026 pushed a commit to xinguozhu-2026/sglang that referenced this pull request Jul 23, 2026
… groups, add elementwise (RFC sgl-project#29630) (sgl-project#32148)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Zhylkaaa pushed a commit to Zhylkaaa/sglang that referenced this pull request Jul 29, 2026
… groups, add elementwise (RFC sgl-project#29630) (sgl-project#32148)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jinzhenfan pushed a commit to jinzhenfan/sglang that referenced this pull request Jul 29, 2026
… groups, add elementwise (RFC sgl-project#29630) (sgl-project#32148)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
jakki-amd pushed a commit to jakki-amd/sglang that referenced this pull request Sep 9, 2026
… groups, add elementwise (RFC sgl-project#29630) (sgl-project#32148)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
… groups, add elementwise (RFC sgl-project#29630) (sgl-project#32148)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail bypass-maintenance deepseek diffusion SGLang Diffusion documentation Improvements or additions to documentation enable-retry Enable retry logic for CI tests jit-kernel Multi-modal multi-modal language model quant LLM Quantization run-ci run-ci-extra sgl-kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant