Skip to main content
kb-nano uses a three-tier benchmarking system. Each tier adds scope: isolated kernels → full-model inference → multi-model evaluation sweeps.

Tier 1: Kernel Benchmark

Tests a single operator replacement by instantiating baseline and candidate nn.Modules side-by-side, copying weights, and comparing forward() outputs and timing across a registry of input shapes.
Key flags: A scenario passes if max-abs-error < 0.01 (bfloat16 tolerance). Speedup > 1.0 means faster than baseline.

Tier 2: E2E Benchmark

Full-model inference benchmarks. The CLI mirrors vLLM’s interface, so the same flags work in both.

Tier 3: Eval Sweep

Runs a standardized evaluation across all candidate kernels using fixed workloads. Each job pair (baseline vs candidate) runs in an isolated subprocess to prevent contamination.
Key flags:

Standardized workloads

Eval uses fixed, non-configurable workloads for reproducibility: Throughput (per model/TP pair):
  • prefill-heavy — 1024 input, 512 output tokens
  • balanced — 512 input, 512 output tokens
  • decode-heavy — 512 input, 1024 output tokens
Latency (per model/TP pair):
  • single-request — batch 1, 128 in/out tokens
  • fixed-batch-32 — batch 32, 128 in/out tokens

Input Registry

Kernel benchmarks (Tier 1) draw input shapes from a YAML manifest at bench/utils/inputs/llm.yaml. Each entry specifies tensor shapes, dtypes, and init args for a given operator × model × TP × sequence-length combination.

Experiment Tracking

All three benchmark tiers automatically log their results to MLflow. After any kb_nano kernels, kb_nano e2e, or kb_nano eval run, you can query the results with kb_nano history or browse them in the MLflow web UI via kb_nano mlflow-ui. See Experiment Tracking for details.

Conflict Resolution

When multiple candidate kernels overlap (e.g. an L2 attention kernel internally replaces an L1 rms_norm), the kernel swapper detects subsumption automatically and warns. Candidates are always applied bottom-up (L1 → L4).