flashinfer-bench
CLAUDE.md288 starsChanged 7 months agoApache-2.0View on GitHub
This document gives agents repo-level context for working in flashinfer-bench. Use it for repository structure, trace dataset conventions, and source-of-truth guidance. Task-specific procedures live in .claude/skills/. FlashInfer-Bench is a GPU kernel optimization benchmarking framework for: - Standardizing FlashInfer Trace format - Real-time workload tracing and collection - Automated kernel optimization and replacement - Performance leaderboards and tracking The canonical (and only) trace dataset lives at flashinfer-ai/flashinfer-trace on HuggingFace. It contains definitions, reference tests, baseline solutions, workloads, blobs, and evaluation traces.
In this repository10 other files it gives its agents.
- add-reference-testsSkill
- clone-reposSkill
- collect-workloads-benchSkill
- collect-workloadsSkill
- discover-modelsSkill
- extract-kernel-definitionsSkill
- onboard-modelSkill
- submit-onboarding-prsSkill
- track-modelsSkill
- validate-datasetSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
16 rules. About 0 are common, 4 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 4
Use it for repository structure, trace dataset conventions, and source-of-truth guidance.
- Very specific: line 77
Run /clone-repos to ensure tmp/flashinfer-trace/ is checked out and up to date.
- Very specific: line 134
Start with flashinfer_bench/data/.
- Very specific: line 139
Start with flashinfer_bench/bench/ for the benchmarking engine, and flashinfer_bench/compile/ for the build system that compiles solutions.
- Very specific: line 144
Start with flashinfer_bench/apply/.
- Very specific: line 149
Start with web/apps/web/data/ for the web UI data layer, and docs/ for model coverage documentation.
- Very specific: line 154
Start with flashinfer_bench/serve/.
- Very specific: line 159
When the question is about published trace contents, workload coverage, or synced definitions, reason against the external dataset …
- Very specific: line 165
Start with .claude/skills/.
- Distinctive: line 175
add-reference-tests: Add pytest tests to validate reference implementations against FlashInfer or SGLang ground truth
- Very specific: line 203
Create operation documentation in docs/op-types/
- Very specific: line 204
Create Definition JSON files under tmp/flashinfer-trace/definitions/{new_op_type}/ (the HuggingFace dataset clone — submit via a PR to …
- Distinctive: line 207
Create Solution implementations (Triton/CUDA optimized)
- Distinctive: line 214
Update CLAUDE.md when any of the following change:
- Very specific: line 221
Update the relevant .claude/skills/*.md files when task procedures change.
- Distinctive: line 222
Keep this file focused on repo-level context.
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
FlashInfer-Bench Repo Guide
This document gives agents repo-level context for working in flashinfer-bench.
Use it for repository structure, trace dataset conventions, and source-of-truth guidance.
Task-specific procedures live in .claude/skills/.
Project Overview
FlashInfer-Bench is a GPU kernel optimization benchmarking framework for:
- Standardizing FlashInfer Trace format
- Real-time workload tracing and collection
- Automated kernel optimization and replacement
- Performance leaderboards and tracking
Core Concepts
- Definition: Specifies an operation's interface (inputs/outputs, axes, reference implementation)
- Solution: Concrete implementation of a Definition (Python/Triton/CUDA)
- Workload: Specific input configuration and test case
- Trace: Execution record containing correctness and performance data
- Model: Hierarchical module structure mapping model components to Definitions
Repository Structure
flashinfer-bench/
├── flashinfer_bench/ # Main Python package
│ ├── data/ # Definition, Solution, Workload, Trace data classes
│ ├── bench/ # Benchmarking engine + evaluators
│ ├── compile/ # Build system (Python/Triton/CUDA)
│ ├── apply/ # Kernel auto-replacement API
│ ├── serve/ # Benchmark orchestration service (NOT inference)
│ ├── integration/ # FlashInfer integration
│ ├── tracing/ # Workload tracing utilities
│ └── agents/ # Agent orchestration tools
├── tests/ # Pytest test suite
├── scripts/ # Standalone scripts (workload collection, sanitization)
├── tools/ # Developer tools (GPU locking, etc.)
├── docs/ # Documentation (model coverage, op_type schemas)
├── web/ # Web UI for visualization
├── examples/ # Example code and benchmarks
├── .claude/skills/ # Agent skill definitions (see below)
└── tmp/ # Cloned external repos, including the
# flashinfer-trace HF dataset clone
# (SGLang, FlashInfer, sgl-cookbook, flashinfer-trace)Trace Dataset
Single source of truth: HuggingFace
The canonical (and only) trace dataset lives at
flashinfer-ai/flashinfer-trace
on HuggingFace. It contains definitions, reference tests, baseline solutions, workloads,
blobs, and evaluation traces.
There is no in-repo flashinfer_trace/ directory in flashinfer-bench. The earlier
"internal trace layer" was removed in the trace-dataset refactor (PR #418); definitions,
reference tests, and workloads no longer live here. Skills that need to read or edit trace
content do so through a local clone of the HF dataset at tmp/flashinfer-trace/:
tmp/flashinfer-trace/ # local clone of the HuggingFace dataset
├── definitions/{op_type}/{definition_name}.json
├── tests/references/test_{definition_name}.py
├── solutions/baseline/{op_type}/{definition_name}/...
├── workloads/{op_type}/{definition_name}.jsonl
├── blob/workloads/{op_type}/{definition_name}/*.safetensors
└── traces/{op_type}/{definition_name}.jsonlBrowse tmp/flashinfer-trace/definitions/ to see the current set of supported op_types
once /clone-repos has been run.
Lifecycle
- Run
/clone-reposto ensuretmp/flashinfer-trace/is checked out and up to date. - Generate or update content under
tmp/flashinfer-trace/and commit on a feature branch. - Open a PR against the HuggingFace dataset repo (PR 2 in the onboard-model flow).
- Open a companion PR against
flashinfer-benchthat updates onlydocs/model_coverage.mdxto reflect the new coverage (PR 1 in the onboard-model flow).
The HuggingFace dataset is the primary edit surface — flashinfer-bench owns code, docs, and the coverage doc, not the trace data itself.
Definition JSON Structure
Each definition JSON follows a common structure:
{
"name": "...",
"description": "...",
"op_type": "...",
"tags": ["stage:decode", "status:verified", "model:...", "fi_api:...", "tp:N"],
"axes": { "batch_size": {"type": "var"}, "num_heads": {"type": "const", "value": 16} },
"constraints": ["len_indptr == batch_size + 1"],
"inputs": { "tensor_name": {"shape": ["axis1", "axis2"], "dtype": "bfloat16"} },
"outputs": { "output": {"shape": ["axis1", "axis2"], "dtype": "bfloat16"} },
"reference": "import torch\n\ndef run(...):\n ..."
}Key conventions:
- Axes:
type: "var"for runtime dimensions (batch_size, seq_len);type: "const"withvaluefor model-specific constants (num_heads, hidden_size) - Tags:
stage:,status:,model:,fi_api:,tp:,ep:,quantization:prefixes - Reference: Plain PyTorch
run()function serving as ground truth - TP/EP: Some kernel types (attention, MoE) produce separate definitions per tensor/expert
parallelism setting because parallelism changes constant axis values (e.g., head counts,
local expert counts). Other kernel types (normalization, GEMM, RoPE, sampling) are
parallelism-agnostic. See the
extract-kernel-definitionsskill for the full rules.
Refer to docs/flashinfer-trace/definition.mdx for the complete schema documentation.
Documentation Structure (docs/)
docs/
├── Getting Started # index, installation, quickstart
├── Tutorials # run-benchmark, cli, server-api, bring-your-own-kernel
├── FlashInfer Trace # definition, workload, solution, trace schemas
├── Dataset # model_coverage
└── Op Type Reference # per-op-type specs (gemm, gqa, mla, moe, sampling, ...)Navigation is defined in docs/docs.json. Page files live under docs/start/,
docs/tutorials/, docs/flashinfer-trace/, and docs/op-types/.
Where To Look By Task
Understanding data structures
Start with flashinfer_bench/data/. This package defines Definition, Solution,
Workload, Trace, and TraceSet — the core data classes used throughout the codebase.
Running or writing benchmarks
Start with flashinfer_bench/bench/ for the benchmarking engine, and
flashinfer_bench/compile/ for the build system that compiles solutions.
Kernel auto-replacement at runtime
Start with flashinfer_bench/apply/. The apply(...) function is the shared entry point
for both optimized kernel dispatch and workload tracing.
Model coverage or web metadata
Start with web/apps/web/data/ for the web UI data layer, and docs/ for
model coverage documentation.
Benchmark service behavior
Start with flashinfer_bench/serve/. This subsystem exposes benchmark orchestration as
a service — it is not an inference server.
Dataset-facing questions
When the question is about published trace contents, workload coverage, or synced definitions,
reason against the external dataset
flashinfer-ai/flashinfer-trace.
Agent and skill workflows
Start with .claude/skills/. Each subdirectory contains a SKILL.md with full instructions.
- onboard-model: End-to-end pipeline for discovering new LLMs and onboarding them (repo updates, model discovery, definition generation, workload collection, PR submission)
- extract-kernel-definitions: Extract kernel schemas from SGLang model implementations with deduplication, generate Definition JSON files
- collect-workloads: Collect real workloads from SGLang inference runs using FlashInfer logging API, sanitize and submit to flashinfer-trace
- collect-workloads-bench: Collect workloads using
bench_serving.pywith model-specific server configs frommodel_configs.json - add-reference-tests: Add pytest tests to validate reference implementations against FlashInfer or SGLang ground truth
- track-models: Track open-source LLMs and update
docs/model_coverage.mdxwith kernel support status - clone-repos: Clone SGLang, FlashInfer, sgl-cookbook, and flashinfer-trace to
tmp/
Common Misunderstandings
Tracing and apply are unrelated entry points
They are different runtimes, but the apply(...) call path is a shared entry point for both
optimized dispatch and workload collection (tracing). This matters when reading runtime
interception logic in flashinfer_bench/apply/.
Benchmark only measures speed
Benchmark also validates correctness against the reference implementation and stores evaluation results as traces.
serve/ is for generic inference traffic
It is not. The serve subsystem is a benchmark orchestration service over dataset-backed workloads.
Contributing New Operation Types
To add a new op_type beyond what currently exists:
- Create operation documentation in
docs/op-types/ - Create Definition JSON files under
tmp/flashinfer-trace/definitions/{new_op_type}/(the HuggingFace dataset clone — submit via a PR toflashinfer-ai/flashinfer-trace) - Provide a Python reference implementation in the definition's
referencefield - Create Solution implementations (Triton/CUDA optimized)
- Optionally create a FlashInfer adapter in
flashinfer_bench/integration/
The existing op_type directories under tmp/flashinfer-trace/definitions/ serve as templates.
Maintenance Notes
Update CLAUDE.md when any of the following change:
- The internal vs external trace boundary or sync lifecycle
- Repository directory structure
- Core concept definitions
- The definition JSON schema conventions
Update the relevant .claude/skills/*.md files when task procedures change.
Keep this file focused on repo-level context. Skill-specific procedures and
op_type-specific details belong in their respective skill files.
References
- FlashInfer Documentation
- SGLang GitHub
- HuggingFace Hub
- Definition Schema Documentation
- Operation Type Schema
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

