Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

extract-kernel-definitions

БесплатноБез исполняемых скриптовНе проверен

Generate Definition JSON files for the flashinfer-trace HuggingFace dataset by harvesting them from a short SGLang inference pass (FlashInfer's…

flashinfer-aiот flashinfer-ai★ 314 звёзд на GitHub18 установок в других каталогах

Об этом скилле

Extract Kernel Definitions

Produce per-(op, shape) Definition JSONs and stage them in the HuggingFace dataset clone at tmp/flashinfer-trace/definitions/{op_type}/. PR submission is out of scope here — see submit-onboarding-prs (Phase 4 of /onboard-model).

Two paths

Path When to use What you do
A. Trace-dump (primary) Kernel is fi_supported per /discover-models — i.e. the FlashInfer API used by SGLang carries a @flashinfer_api(trace=...) template (see coverage list). Run a short SGLang inference pass with FLASHINFER_TRACE_DUMP=1. The dumper writes one JSON per unique (op, shape) before the kernel runs (crash-safe, deduplicated).
B. Manual extraction (fallback) Kernel is fi_missing, or the relevant FlashInfer API is not yet trace-instrumented. Read the SGLang model source + sgl-cookbook serving config + HF model config; write the Definition JSON by hand using the schema reference.

The trace-dump path is the default — it eliminates manual axis derivation and produces JSONs that already carry axes, inputs, outputs, tags (fi_api:*, status:verified), and a reference implementation.

Background: the trace dumper was added in flashinfer-ai/flashinfer#2931. Schema and full env-var docs live at docs/fi_trace.rst in the FlashInfer repo. SGLang harness reference: tests/trace/example_sglang.py.

Usage

# Path A — auto-dump every fi_supported definition for a model in one inference pass
/extract-kernel-definitions --model-name llama-3.2-3b --hf-repo-id meta-llama/Llama-3.2-3B-Instruct

# Path A — multi-config: one short run per (TP, EP) listed in sgl-cookbook
/extract-kernel-definitions --model-name qwen3-next --tp-list 2,4

# Path B — manual fallback for fi_missing kernels (or names that didn't appear in the dump)
/extract-kernel-definitions --model-name kimi-k2 --manual --op-types new_op_type

Parameters

  • --model-name (required): Model slug (e.g. llama, deepseek-v3, qwen3-next). Used to look up the SGLang model file and the sgl-cookbook YAML.
  • --hf-repo-id (optional): HuggingFace repo override; inferred from --model-name if omitted.
  • --tp-list (optional): Comma-separated TP values to run for; default reads sgl-cookbook YAML.
  • --ep-list (optional): Comma-separated EP values for MoE models.
  • --manual (optional): Force Path B (manual extraction) even for fi_supported ops.
  • --op-types (optional): Comma-separated op_type filter when using --manual or for --dry-run reporting.
  • --dry-run (optional): Report what would be dumped/written without running anything.
  • --skip-existing (optional, default true): Skip any definition whose name already exists under tmp/flashinfer-trace/definitions/.

Prerequisites

  • /clone-repos has been run, so tmp/sglang/, tmp/flashinfer/, tmp/sgl-cookbook/, and tmp/flashinfer-trace/ are present and current. The HF dataset clone at tmp/flashinfer-trace/ is the only home for definitions — the in-repo flashinfer_trace/ directory was removed in the trace-dataset refactor.
  • For Path A: a working CUDA-enabled environment, GPU memory sufficient for the chosen model + TP, and attention_backend="flashinfer" available in the installed SGLang.
  • For Path B: HuggingFace config.json access for the target model.

Path A: trace-dump from a short SGLang pass

The dumper fires inside FlashInfer when both env vars are set before the FlashInfer import. SGLang routes through @flashinfer_api(trace=...)-decorated APIs whenever attention_backend="flashinfer" is selected, so a single short prefill+decode pass exercises most ops at once.

A1. Pick the serving config(s)

Open the sgl-cookbook YAML for the target model and list the unique TP/EP values — one trace-dump pass per unique combination is enough to cover every shape variant.

ls tmp/sgl-cookbook/data/models/generated/v0.5.6/ | grep -i {model_name}
cat tmp/sgl-cookbook/data/models/generated/v0.5.6/{model_yaml}

If the model has no cookbook entry, default to TP=1 (single-GPU baseline) and skip EP.

A2. Run the trace-dump pass

Use tools/gpu-lock so CUDA_VISIBLE_DEVICES is set correctly. The script below mirrors tests/trace/example_sglang.py in the FlashInfer repo — adapt the model_path, tp_size, and attention_backend:

DUMP_DIR=tmp/dumps/fi_trace_{model_slug}_tp{TP}_ep{EP}

tools/gpu-lock --gpus {TP} --exec-timeout 1800 -- python - <<EOF
import os, shutil
from pathlib import Path

# Must be set BEFORE
Полный SKILL.md на GitHub

Установить extract-kernel-definitions в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл extract-kernel-definitions?

Generate Definition JSON files for the flashinfer-trace HuggingFace dataset by harvesting them from a short SGLang inference pass (FlashInfer's @flashinfer_api(trace=...) dumper) — or, as a fallback, by manually transcribing the schema from SGLang sources when FlashInfer doesn't yet have a trace template. Use when adding a new model, extracting GPU kernels (MLA, MoE, GQA, RMSNorm, GEMM, GDN, RoPE, sampling), or filling gaps in the dataset.

Как установить скилл extract-kernel-definitions?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл extract-kernel-definitions запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить extract-kernel-definitions с