What problem does it solve?
Prefill and decode paths in sglang run different kernels over different shapes, so a corrupted radix-cache prefix, stale conv/mamba checkpoint, or batch-dependent kernel can silently diverge while accuracy benchmarks like gsm8k still pass. This Skill explains how to write, calibrate, and debug the KL divergence tests that catch these state and numerics bugs.
Core Features & Use Cases
- Two-condition diagnosis: Separates batch-invariance failures (condition 1) from same-function state bugs (condition 2) using the three KLDivergenceMixin helpers, so a helper-specific divergence immediately names the faulty path.
- Threshold calibration: Guides choosing per-(model, tp) KL thresholds, explains why MoE models amplify numerical differences versus dense models, and why deterministic-inference servers should assert near-zero.
- Divergence localization: Covers the forward-hook dumper workflow (DUMPER_* environment variables, CUDA graph pitfalls, alignment verification) to pinpoint the first operator whose inputs match but outputs differ.
- Use Case: A new model shows avg_kl_div of 0.05 only in the prefill_cache_hit helper. Use this Skill to recognize a prefix-restore logic bug rather than float noise, then localize it to the exact layer with the dumper.
Quick Start
Ask the AI to help debug a high KL divergence number in an sglang model test and identify whether it is a batch-invariance or cache-restore problem.