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

speculative-naming

Apply consistent names to SGLang speculative decoding code, which verifies draft tokens to generate text. Distinguish tokens with or without the bonus token, counts, counters, and arrays when adding identifiers, renaming code, or reviewing changes.

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

원문원문 설명 보기

Naming conventions for SGLang speculative decoding identifiers. Use when adding, renaming, or reviewing identifiers in speculative decoding code — anything under `python/sglang/srt/speculative/`, related attention backends, scheduler accumulators, IPC fields, observability metrics, or CLI flags.

설치 방법 보기

이럴 때 유용합니다

  • Naming variables in speculative decoding code
  • Renaming identifiers to match their meaning
  • Reviewing metric and counter names
  • Checking which existing names should remain unchanged

포함된 파일(1)

  • SKILL.md6.2 KB

SKILL.md(원문)

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

Speculative Decoding — Naming Conventions

Apply this skill when adding, renaming, or reviewing identifiers in speculative decoding code (anything under python/sglang/srt/speculative/, related attention backends, scheduler accumulators, IPC fields, observability metrics, or CLI flags).

Rule 1 — Verb form, drop -ed

Use the verb form accept everywhere. Don't use the past-participle form accepted.

Don'tDo
num_accepted_tokensnum_accept_tokens
accepted_indicesaccept_indices
accepted_token_idsaccept_tokens (also see Rule 3)

Rule 2 — The extra/bonus token is bonus_token / bonus_tokens

The "+1" token that the target model always emits in addition to verifying drafts is the bonus token. Use bonus_token / bonus_tokens per Rule 7.

Don'tDo
verified_id / verified_idsbonus_token / bonus_tokens
output_id / output_ids (when referring to the bonus)bonus_token / bonus_tokens

req.output_ids (the full output history of a request) is unrelated and stays as is.

Rule 3 — accept includes bonus; correct excludes bonus

The semantic distinction lives in the verb, not the noun. Don't enumerate noun pairs.

VerbMeaning
accept_*Includes the bonus token
correct_*Drafts only, no bonus

Pair with whatever noun fits the data (tokens, drafts, indices, …). No required pairing, but preferred default nouns: accept_tokens and correct_drafts — correct semantically describes drafts (what got verified), accept describes the resulting token sequence (incl. bonus).

FormMeaning
accept_tokens / accept_indicesInclude bonus
correct_draftsDrafts only, no bonus
num_accept_tokensCount incl. bonus
num_correct_draftsCount excl. bonus

Exception: accept_rate / accept_length follow paper convention

These two metric names are entrenched in the spec-decoding literature and in external-facing fields (meta_info, Prometheus). Their semantics are paper-defined, not Rule-3-defined:

NamePaper termBonus?Definition
accept_rate$\alpha$ (Leviathan 2023)Noper-draft-token acceptance probability = correct_drafts / proposed_drafts
accept_length$\tau$ (EAGLE)Yesavg tokens per verify step = completion_tokens / verify_ct

Internal counters still follow Rule 3 strict semantics: num_correct_drafts (no bonus), num_accept_tokens (with bonus).

Rule 4 — num_ for counts; _ct for counters; _rate for rates; no prefix for IDs

Each form has its own marker. Never mix (no num_X_ct, no num_accept_rate).

FormPatternMeaningExamples
Countnum_XSnapshot quantity at one point in time (often a tensor or scalar)num_accept_tokens, num_correct_drafts, num_proposed_drafts
CounterX_ctMonotonically incrementing accumulator over timespec_verify_ct, forward_ct
Rate / ratioX_rateFractional value in [0, 1]accept_rate
Tokens / content arrayno prefixThe actual token data, not a countaccept_tokens, correct_drafts, bonus_token

Rule 5 — Drop redundant _token_id / _token_ids suffix in spec scope

_id / _ids and _token / _tokens are both fine. But don't combine — _token_id / _token_ids is redundant inside spec decoding, because spec code only ever deals with vocab integers.

The semantic differs by scope:

ScopeExampleWhat _token_id means
Framework / multimodal / tokenizerimage_token_id, pad_token_id, eos_token_id, mask_token_id, bos_token_idA specific named/role token's vocab ID. The prefix names the role; _token_id says it's the integer ID for that role. Both halves carry information.
Spec decodingaccepted_token_ids, curr_token_id, out_token_idsRedundant. Spec only deals with vocab integers; _id adds nothing beyond _token.

Renames

Don'tDo
accepted_token_idsaccept_tokens (Rule 1 + 3)
curr_token_idcurrent_token
out_token_idsout_tokens
_resolve_spec_overlap_token_ids_resolve_spec_overlap_tokens

Rule 6 — Singular vs plural

Plural for any non-scalar tensor ([bs]-shaped, flat, or multi-dim); singular only for scalars (kernel tl.load results, single-int locals). Applies to all spec-decoding tensors (tokens, indices, etc.).

accept_tokens: torch.Tensor     # [total_accepted] flat - plural
accept_indices: torch.Tensor    # [bs, num_draft_tokens] - plural
draft_tokens: torch.Tensor      # [bs * num_draft_tokens] flat - plural
bonus_tokens: torch.Tensor      # [bs] - plural
accept_token = tl.load(...)     # int32 scalar in a kernel iteration - singular
bonus_token = tl.load(...)      # int32 scalar inside a kernel - singular

Out of scope (these names stay as is)

These rules apply to spec-decoding-specific identifiers. Pre-existing or framework-level names are kept.

  • PyTorch / ecosystem: seq_lens, extend_seq_lens, cu_seqlens_q
  • Framework / multimodal vocab: image_token_id, pad_token_id, eos_token_id, mask_token_id, hot_token_id, bos_token_id, topk_id
  • Request-level state: req.input_ids, req.output_ids, req.origin_input_ids, next_token_ids (model_runner.sample output)
  • Frozen C++ kwargs: accept_token_num (sgl-kernel)
  • Non-token IDs: req_id, gpu_id, layer_id, program_id
  • _len / _lens names: num_X is preferred for counts (Rule 4), but _len / _lens names are acceptable. Triton kernel params in particular often use _lens / _len to align with the PyTorch ecosystem (seq_lens, cu_seqlens_q). Rule 1 still requires the -ed-less form (accept_length OK, accepted_length not).

리뷰

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

댓글

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

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

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. 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의 스킬 모두 보기

이 스킬의 문제 신고