Command Palette

Search for a command to run...

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

add-reference-tests

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

Add pytest tests to validate reference implementations in the flashinfer-trace HuggingFace dataset against FlashInfer or SGLang ground truth. Use when…

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

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

Add Reference Tests

Add tests to validate reference implementations in the HuggingFace dataset clone at tmp/flashinfer-trace/. Ground truth is sourced from FlashInfer repository or SGLang when FlashInfer doesn't have the implementation.

Description

This skill creates test cases under tmp/flashinfer-trace/tests/references/ (the HF dataset clone — the in-repo flashinfer_trace/ directory was removed in the trace-dataset refactor) to validate that reference implementations in Definition JSON files produce correct outputs. The ground truth comes from:

  1. FlashInfer repository (preferred): Official optimized GPU kernels in tmp/flashinfer/
  2. SGLang repository (fallback): When FlashInfer doesn't have the kernel, use tmp/sglang/

Usage

# Test all definitions of a specific op_type
/add-reference-tests --op-type mla_paged
/add-reference-tests --op-type moe
/add-reference-tests --op-type gqa_paged
/add-reference-tests --op-type rmsnorm

# Test a specific definition
/add-reference-tests --definition-name mla_paged_decode_h16_ckv512_kpe64_ps1

# Test all definitions in the definitions directory
/add-reference-tests --all

# Test with custom tolerance
/add-reference-tests --definition-name rmsnorm_h4096 --tolerance 1e-4

Parameters

  • definition_name (optional): Specific definition to test (e.g., "mla_paged_decode_h16_ckv512_kpe64_ps1")
  • op_type (optional): Test all definitions of a specific op_type (e.g., "mla_paged", "moe", "rmsnorm")
  • all (optional): Test all definitions in the definitions directory
  • test_sizes (optional): List of test sizes ["small", "medium", "large"] (default: ["small", "medium"])
  • tolerance (optional): Numerical tolerance for comparison (default: 1e-3 for fp16, 1e-5 for fp32)

Prerequisites

Run /clone-repos first to set up the tmp/ directory with SGLang, FlashInfer, and the HuggingFace trace dataset clone at tmp/flashinfer-trace/ — that clone is the only home for definitions and reference tests.

What This Skill Does

Phase 1: Definition Discovery

  1. Load Target Definitions:

    • If definition_name specified: load single definition
    • If op_type specified: load all definitions matching op_type from tmp/flashinfer-trace/definitions/{op_type}/
    • If all: scan all definitions
  2. Check Existing Tests:

    • Scan tmp/flashinfer-trace/tests/references/ for existing test files
    • Skip definitions that already have tests (unless force=true)
  3. Parse Definition Schema:

    • Extract axes (const/var), inputs, outputs
    • Identify required shapes and dtypes
    • Parse reference implementation code

Phase 2: Ground Truth Discovery

For each definition, locate ground truth implementation using this priority order:

For Model Constants: HuggingFace + SGLang (Required)

Note: See extract-kernel-definitions for detailed guidance on sourcing model constants from HuggingFace and SGLang.

For Ground Truth Execution: FlashInfer API (Primary)

  • When: FlashInfer has the kernel implementation (MOST kernels)
  • Location: tmp/flashinfer/python/flashinfer/
  • Use for: Running optimized GPU kernel as ground truth
  • Examples:
    import flashinfer
    # GQA decode
    flashinfer.BatchDecodeWithPagedKVCacheWrapper(...)
    # GQA prefill
    flashinfer.BatchPrefillWithPagedKVCacheWrapper(...)
    # MLA
    flashinfer.mla.BatchMLAPagedAttentionWrapper(...)
    # RMSNorm
    flashinfer.norm.rmsnorm(...)
    
  • Important: FlashInfer is the PRIMARY ground truth for correctness validation

For Ground Truth Execution: SGLang (Fallback ONLY)

  • When: FlashInfer does NOT have the kernel (e.g., some MoE variants)
  • Location: tmp/sglang/python/sglang/srt/layers/
  • Use for: Ground truth when FlashInfer unavailable
  • Examples:
    layers/moe/fused_moe.py         # MoE when FlashInfer MoE unavailable
    
  • Important: ONLY use SGLang as ground truth when FlashInfer doesn't support the kernel

Ground Truth Source Mapping

Op Type Ground Truth Source FlashInfer API Fallback (if FlashInfer unavailable)
rmsnorm FlashInfer flashinfer.norm.rmsnorm N/A (FlashInfer has it)
fused_add_rmsnorm FlashInfer flashinfer.norm.fused_add_rmsnorm N/A (FlashInfer has it)
gqa_paged FlashInfer flashinfer.BatchDecodeWithPagedKVCacheWrapper, flashinfer.BatchPrefillWithPagedKVCacheWrapper N/A
gqa_ragged FlashInfer flashinfer.BatchPrefillWithRaggedKVCacheWrapper N/A
mla_paged FlashInfer flashinfer.mla.BatchMLAPagedAttentionWrapper N/A (FlashInfer has it)
moe SGLang (fallback) N/A (FlashInfer MoE may not cover all variants) sglang/layers/moe/fused_moe.py
gemm PyTorch N/A torch.nn.functional.linear
`sampling
Полный SKILL.md на GitHub

Установить add-reference-tests в Claude Code и Claude Desktop

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

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

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

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

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

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

FAQ

Что делает скилл add-reference-tests?

Add pytest tests to validate reference implementations in the flashinfer-trace HuggingFace dataset against FlashInfer or SGLang ground truth. Use when validating kernel definitions, adding tests for new op_types, or verifying reference implementations are correct.

Как установить скилл add-reference-tests?

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

Скилл add-reference-tests запускает скрипты?

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

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

Сравнить add-reference-tests с