본문으로 건너뛰기
cccskills
무료GitHub에 공개

kernel-organization

Organize SGLang GPU operations when adding or moving code. It guides API placement, operation registration, test organization, and migration checks to preserve existing behavior, references, and continuous integration coverage.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Apply the SGLang kernels RFC when adding, moving, splitting, or reviewing kernel APIs, registry metadata, kernel tests, benchmarks, and model-specific implementations. Use with add-jit-kernel, add-sgl-kernel, and write-sglang-test for placement and migration checks.

설치 방법 보기

이럴 때 유용합니다

  • Choose where to place a new GPU operation
  • Split or move existing operation files
  • Review API registration and test placement
  • Check references and CI coverage after a migration

포함된 파일(1)

  • SKILL.md4.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Kernel organization

Read python/sglang/kernels/README.md and test/README.md before choosing a location. RFC #29630 establishes the namespace; subsequent migrations #32148 and #40922 clarify logical grouping and remove the old _jit_ filename prefix.

Choose the owner

  • Put callable SGLang kernel APIs under sglang.kernels.ops.<group>. Runtime and integration tests import from that namespace, including its submodules. The sgl_kernel wheel retains its own public API and packaging tests.
  • Group by computation, not model or GPU: GEMM and GEMV in gemm, expert routing in moe, attention index selection in attention, sampling in sampling, normalization in layernorm. A quantized GEMM is still a GEMM; quantization alone belongs in quantization.
  • Model-specific files/subpackages and tuning data are allowed inside a logical group. Do not add a model bundle or an implementation file directly under ops/. Propose a new logical group only for a distinct responsibility, and update ops._GROUPS, documentation, and tests together.
  • Classify a fused operator by its complete contract. Do not split a fused kernel into separate launches just to separate norm, RoPE, or quantization. Split unrelated public entry points that happen to share a source file.
  • Keep shared CUDA build/runtime infrastructure in kernels/jit; operator wrappers call it from their logical group. Keep process groups, communicator state, model dispatch, and buffer ownership in srt. K3-specific adapters in srt/layers/communication/ need not pretend to be generic interfaces.

Register the public entry point

Add lazy KernelSpec metadata in the owning group's __init__.py, or use the existing BaseFusedOp registration when the operation has interchangeable backends. Group imports must not import GPU implementations or compile kernels.

Use <group>.<name> for the op id and module:callable for the target. Preserve existing backend dispatch and describe actual device/architecture restrictions with CapabilityRequirement; JIT/AOT are not device types. Input shape/dtype checks remain part of the entry point's contract. Registering a torch custom op does not register it in the SGLang kernel inventory. Predicates, private JIT factories, reference helpers, and runtime classes are not separate kernel APIs.

Place and preserve tests

  • Kernel numerical tests: test/registered/kernels/ops/<group>/.
  • CI microbenchmarks: test/registered/kernels/benchmark/<group>/.
  • Inventory/selector tests: test/registered/unit/kernels/.
  • Runtime unit tests: test/registered/unit/<subsystem>/, following the tested runtime module. A CUDA allocation does not make a runtime test a kernel test.
  • Non-CI smoke scripts and benchmarks: test/manual/kernels/; do not leave standalone test/benchmark entry points in production operator modules.
  • Shared test helpers: sglang.test.kernels. Preserve vendored upstream trees and AOT wheel packaging boundaries instead of reorganizing them incidentally.

For a move/split, preserve assertions, parametrization, fixtures, platform skips, execution entry points, and CI stages/runners. Apportion existing time estimates across split files; do not duplicate the original budget for every output file or silently drop a registration. Follow write-sglang-test for CI registration.

Verify a migration

  1. Search all runtime, test, benchmark, documentation, patch-string, and lazy registry references before deleting the old path. Check relative imports and package re-exports as well as direct imports. Do not leave forwarding shims.
  2. Keep tuning files with the GEMM that loads them and preserve relative lookup behavior. Check wheel/package inclusion as well as source-tree execution.
  3. Preserve module singleton state: every runtime caller must import the same new communication adapter, not a second copy of its buffer registry.
  4. Separate relocation commits from semantic changes. Use mechanical-refactor-verify to reproduce moves, and compare test inventories and CI registration coverage before/after. Only delete an experimental path after checking its call sites, flags, source, and dedicated tests together.
  5. Run the namespace/dispatch CPU tests, the registered-test validation hook, pre-commit, and relevant GPU tests when available. State exactly which GPU checks ran; import/AST checks do not prove numerical or performance parity.

Do not infer violations solely from a model name inside a group, a missing _jit_ prefix, use of a runtime utility, or absence of BaseFusedOp inheritance.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Develop lightweight CUDA operations for SGLang using JIT, which compiles code on first use. A tensor-scaling example explains implementation conventions, input validation, memory access helpers, and when to choose this approach.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Add a lightweight CUDA operation to SGLang
  • Choose between JIT and ahead-of-time compilation
  • Validate tensor inputs in a kernel launcher
sgl-project/sglang3.7만2026년 10월 19일 업데이트

Add a CUDA/C++ GPU operation to sgl-kernel using AOT, meaning compilation before use. Follow the implementation through PyTorch registration, Python API exposure, SGLang integration, correctness tests, and benchmarks that account for cache reuse.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding a CUDA/C++ operation to sgl-kernel
  • Registering an operation with PyTorch and exposing a Python API
  • Testing numerical results and invalid inputs
sgl-project/sglang3.7만2026년 10월 19일 업데이트

Monitor selected GitHub Actions checks on an SGLang pull request until they pass on its latest commit. Diagnose failures, push small validated fixes, and retry only failed jobs within defined limits.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Monitor selected PR checks until they pass
  • Separate code failures from infrastructure problems
  • Apply small fixes and track the resulting checks
sgl-project/sglang3.7만2026년 10월 19일 업데이트

Review existing tests and CI, the automated checks run during development, for redundant coverage, misplaced tests, and opportunities to reduce runtime or cost. Receive file-specific recommendations based on documented improvement patterns, with uncertain findings separated.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Investigating a slow test suite
  • Finding redundant or misplaced tests
  • Reviewing CI runtime and cost
sgl-project/sglang3.7만2026년 10월 19일 업데이트

Understand and modify SGLang's CI pipelines, including test stage order, start conditions, early stopping after failures, and workload splitting. Use the guide to add jobs and investigate failed, skipped, or cancelled checks.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Add a test job to an SGLang CI stage
  • Investigate failed or skipped CI checks
  • Update test partitions and waiting job counts
sgl-project/sglang3.7만2026년 10월 19일 업데이트

Collect and review SGLang startup logs to identify unnecessary output and trace its source. Get saved logs and specific cleanup proposals while preserving useful diagnostics, with runtime changes left for user approval.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Investigating repeated messages in startup logs
  • Checking which startup warnings need attention
  • Comparing startup logs across models and GPU counts
sgl-project/sglang3.7만2026년 10월 19일 업데이트

sgl-project의 스킬 모두 보기

이 스킬의 문제 신고