GPT-OSS-Lite

OpenAI GPT-OSS-Lite

From-scratch PyTorch reproduction of OpenAI’s GPT-OSS at ~502M params total / ~247M active — 6 sliding-window (W=128) + 6 full-attention layers in alternation, learned per-head attention-sink bias, YaRN RoPE 128K, and top-2-of-8 MoE with one sanctioned Triton grouped-GEMM. Read it like a field notebook: a name, a wiring sketch, then the measurements.

KV CACHE REDUCTION
≥ 1.8× CUT
6 SWA (W=128 ring buffer) + 6 global layers → O(1) decode per step at 128K
ACTIVE COMPUTE
49.2% FLOPs
Top-2 of 8 routed (2×1536 SwiGLU) + 1 shared ≈ 247M / 502M total params
ATTENTION SINKS
β ∈ [−10, +15] CLAMP
Learned per-head sink bias (virtual sink column, β ∈ [−10, +15]) stabilizes softmax across SWA layers
CONTEXT LENGTH
128K YaRN RoPE
NTK-by-parts ramp θ=100K, scale=32, pruned RoPE on 25% global-layer dims
FIG. A0 ATTENTION-SINK GRAVITY WELL & YaRN 128K RESONANCE SINK · W=128 SLIDING WINDOW · 36 YaRN PHASORS
01 · params
~502M total
02 · layers
12 alt 6+6
03 · d_model
768
04 · attn
8Q/4KV GQA
05 · ffn
1536 SwiGLU
06 · vocab
128K
07 · ctx
128K YaRN
08 · MoE
top-2/8 +1 shared
GPT-OSS-Lite core mechanisms · interactive benchmark labs
01 · SWA KV CACHE Mixed KV Footprint Analyzer

Compare KV cache memory between full-attention (all 12 layers, full context) and the GPT-OSS-Lite mixed scheme (6 global + 6 SWA W=128 ring buffer) with GQA 4 KV heads × 96 head_dim × bf16.

Context Length: 32,768 tokens
Full Attention (12 layers): 0.56 GB
Mixed (6 Global + 6 SWA W=128): 0.28 GB
KV Cache Saved: 0.28 GB (2.00× cut)
02 · ATTENTION SINKS Per-Head Sink Bias Monitor

Visualize learned per-head additive sink bias βh across 8 GQA heads. Clamped to [−10, +15] at forward time to prevent BF16 SDPA mask-add overflow.

Mean Sink Bias: +0.00
Sink Status: INITIALIZED
03 · MoE DISPATCH Top-2 of 8 Router + Shared

Simulate the GPT-OSS MoE router: top-2 of 8 routed experts (SwiGLU, ffn=1536) + 1 always-active shared expert. Standard aux load-balancing loss (α=0.01).

Active Experts: #02, #05 + shared
Dispatch Backend: torch (default)
FIG. A1 FULL TRAINING STEP PIPELINE FORWARD · AUTOGRAD BACKWARD · ADAMW
8 chapters

Part I: Foundations

1 chapter

Part II: The data

6 chapters

Part III: The training run