Metrics glossary
Definitions of every tracked metric, from loss and MFU to MaxVio, the GSPO sequence ratio, KL estimators, pass@k and avg@k, each with its alarm threshold and, where it fired, the number I saw.
This page defines every metric I tracked, in the order of the pipeline. The list of metrics is
pretraining/Metrics-and-Monitoring-Reference.md; every formula below was checked against the code that computes it.
Each entry says what an alarm looks like, and seen gives the value this project hit, where one was recorded.
A monitor checked every alarm threshold every 2 minutes during the GPU runs. Before the end of the main run, every one of the reference’s 281 rows had a producer.
Pretraining
Loss and perplexity
The training and validation loss is the mean next-token cross-entropy:
Here \(N\) is the number of predicted tokens, \(x_t\) the token at position \(t\), \(x_{<t}\) the tokens before it, and \(p_\theta\) the model’s next-token probability.
In words: the average surprise, in nats, of the model at each true next token.
Here \(L_{\text{val}}\) is equation (1) on the validation set.
In words: perplexity is the number of equally likely tokens the model is, on average, choosing between.
- Alarm: the loss is flat from step 1, or the validation loss stops tracking the training loss. A loss at least 10× the maximum of the first 100 steps is flagged by Megatron and that step is re-run.
- Yardstick: a uniform guess over the 128,256-token vocabulary scores \(\ln 128{,}256 = 11.76\).
- Seen: an evaluation on random weights read a loss of 11.85 and still exited 0. The main run ended at validation loss 3.046, perplexity 21.0.
Other training signals
| Metric | Definition | Alarm |
|---|---|---|
| Gradient norm | The L2 norm of the full gradient, before clipping | Unstable after warm-up, or a spike above 10× normal |
| Gradient zeros | The count of exactly-zero gradient entries (--log-num-zeros-in-grad) |
A sudden increase: underflow |
| Learning rate | The current rate | Off the WSD schedule |
| Tokens processed | Training tokens so far | Short of the 2.60B target |
| Parameter norm | The weights’ norm (--log-params-norm) |
Drift: instability |
| Max attention logit | The largest attention logit (--log-max-attention-logit) |
Growth: attention instability |
Seen: the dense baseline’s gradient norm spiked to 116 at iteration 3, during warm-up, then settled at 0.5–2.5. The main run’s schedule matched WSD to a maximum error of 5.0e-8 × the rate.
Throughput and efficiency
Here \(B\) is the global batch in sequences (512), \(S\) the sequence length (4,096) and \(t_{\text{step}}\) the step time.
In words: the tokens in one optimizer step divided by the time that step took.
Here \(P_{\text{active}} = 1.22 \times 10^9\) is the parameter count a token passes through, \(n_{\text{GPU}} = 8\), and \(F_{\text{peak}}\) is the H100 SXM’s dense BF16 peak, 989.4 TFLOP/s per GPU in the code. Megatron’s own count takes 3 × the forward FLOPs, attention and logits included, without recomputation; the \(6P\) count leaves attention out.
In words: the share of the GPUs’ peak arithmetic that went into the model’s own matrix multiplies.
| Metric | Definition | Target or alarm |
|---|---|---|
| TFLOP/s per GPU | Megatron’s model FLOPs per second per GPU (--log-throughput) |
Compare with the forced-even ceiling |
| Step time | Seconds per optimizer step | Compare dense and MoE |
| Throughput ratio | MoE tokens/s over dense tokens/s | The MoE’s overhead |
| Communication fraction | Profiler time with any NCCL kernel running, over step time | Under 10% on one NVLink node |
| All-to-all time | Per MoE layer, per direction, per micro-batch | About 2–3 ms (the reference’s NVLink estimate) |
| All-gather time | Per optimizer step (distributed optimizer) | Should overlap with compute |
| GEMM share | Profiler: matrix multiplies’ share of step time | Should dominate the step |
| Memory-bound share | Profiler: RMSNorm, SwiGLU and other memory-bound kernels | If dominant, try torch.compile |
| Idle gaps | nsys: time with no kernel running | Communication not overlapping compute |
Seen: the main pretraining run reached 194.7 TFLOP/s per GPU, MFU 19.7% by Megatron’s count and 17.7% by \(6P\). The forced-even arm, perfectly balanced, spent 30.8% of its step in communication, with 3.96 ms per all-to-all: both targets missed. The main run’s own profile, at steps 50–52, put GEMMs at 21.8% of the step, memory-bound kernels at 24.6% and communication at 45.3%. The performance page has the full numbers.
Expert balance (mixture of experts)
Here \(c_e\) is the number of tokens routed to expert \(e\) in one layer and step, and \(E = 64\) is the number of experts. With top-8 routing, one expert can receive at most every token once, so MaxVio can reach \(E/k - 1 = 64/8 - 1 = 7\).
In words: how far the busiest expert is above an even share, as a fraction of that share.
- Alarm (pretraining): 0 is even; above 2 is concerning. The value 7.0 means every token goes to the same 8 experts.
- Alarm (SFT and RL): MaxVio above 2× its value at the start of that stage.
- Seen: 7.000 in all 16 layers by step 10, for both the V4 and the aux-loss routers. Quantile balancing brought the layer mean to 0.737 at step 100 and 0.437 at step 200.
- Seen in GSPO: a flat 6.29–6.41, which is an artifact. About 90% of the routed tokens were padding, sent to the same 8 experts.
| Metric | Definition | Target or alarm |
|---|---|---|
| Tokens per expert | \(c_e\), from --save-tokens-per-expert-interval |
Roughly even across the 64 experts |
| Dead experts | Experts with 0 tokens | Must be 0 |
| Starved experts | Experts under 1% of an even share | Used here to read a collapse; 51–55 of 64 in the collapsed arms |
| Rogue experts | An expert whose mean per-token output norm exceeds 10× its layer’s median | None (rule fixed before reading); seen: largest 3.47× |
| Aux loss per layer | The balancing loss (--moe-per-layer-logging) |
Should decrease |
| Expert bias spread | \(\max_e b_e - \min_e b_e\) per layer, from the checkpoint | Should stabilize within about 500 steps; seen: after about step 600 |
| Load-balance throughput | TFLOP/s against the forced-even arm | The gap is the slowdown from imbalance |
The router z-loss, computed from the routing trace’s saved logits:
Here \(T\) is the number of traced tokens and \(\ell_{t,e}\) the router logit of token \(t\) for expert \(e\). This is ST-MoE’s router z-loss before its coefficient; I trained without it, so the trace gives the value it would have had.
In words: the average squared log-sum-exp of the router logits, which grows when the logits grow.
- Alarm: it should stay bounded.
- Seen: the 16-layer mean went from 25.3 to 25.9 (+2.4%) through RL.
The entropy of a token’s routing mix, over its 8 chosen experts:
Here \(\mathcal{T}_t\) is the set of 8 experts chosen for token \(t\) and \(g_{t,j}\) the gate weight of expert \(j\).
In words: how evenly a token spreads its weight over the 8 experts it uses; the maximum is \(\ln 8 = 2.079\) nats.
- Alarm: low entropy means one expert dominates each token’s mix. A collapse across experts shows in MaxVio and dead experts, not here.
- Seen: 1.996 → 1.989 nats through RL.
- Max1/Max2, the largest gate weight over the second largest: near 1 is a flat gate; the reference calls above 1.5 healthy. Seen: 1.349 → 1.377 through RL.
GPUs and memory
| Metric | Tool | Target or alarm | Seen (8×H100 run) |
|---|---|---|---|
| GPU utilization | nvidia-smi | Above 90%, but meaningless alone; 0% during training points at the host | 5 of 8 GPUs at 0% during the storage stall |
| Temperature | nvidia-smi | Below 83 °C (throttling starts above) | Maximum 60–67 °C |
| Power draw | nvidia-smi | Below 700 W | One-second peaks of 700.6–714.9 W at the cap |
| ECC errors | nvidia-smi -q | Must be 0 | 0 |
| HBM memory used | torch.cuda.max_memory_* |
70–90% of 80 GB | — |
| Peak allocated memory | max_memory_allocated() |
Below 70 GB | 58.8 GiB in the MoE study arms |
| Peak reserved memory | max_memory_reserved() |
Includes fragmentation | Logged every 10 iterations |
The reference’s memory model estimated about 18 GB of model state per GPU and about 110 GB for a full checkpoint. The main run’s full checkpoint measured 89.46 GiB.
Supervised fine-tuning
The training signals are those of pretraining. The gradient norm should stay under 1.0, with clipping at 1.0, and the step time should be similar to pretraining’s.
| Metric | Definition | Target or alarm |
|---|---|---|
| Format compliance | Share of answers that are exactly <think>…</think> then one <answer>…</answer> |
Above 80% after SFT; above 50% at the RL gate; above 90% during RL |
| Instruction following | A manual spot check of 10 prompts | Coherent and on topic |
| Response length | Mean generated tokens | Near the SFT data: median 100, p90 152 |
| Expert MaxVio and dead experts | Equation (5), counts every 26 SFT steps | Stable; 0 dead |
| Router bias drift | Mean absolute change of each expert’s bias from the pretrained checkpoint | Large means adapting, which is normal |
| Per-expert token distribution | Counts against pretraining | Do some experts attract math tokens? |
| Validation perplexity | Equation (2) on the SFT validation lines | Should decrease |
Seen: format compliance 69%, 91% and 90% at SFT epochs 1–3. Balance stayed even (MaxVio 0.062 at step 26, 0.039 at step 104), and the bias moved by a mean of 1.10, 1.02 and 0.99 at steps 35, 70 and 104.
Evaluation
| Metric | Definition | Notes |
|---|---|---|
| Greedy accuracy (pass@1) | Share of problems whose greedy answer is right | Greedy is not deterministic across evaluations in a dynamic-batching engine |
| Free-score floor | The score of giving each set’s most common answer every time | SVAMP 8.33%, MultiArith 7.78%, ASDiv 4.91%, GSM8K 3.03%, MATH 2.96%, MAWPS 0.96% |
| Hold-out perplexity | Equation (2) on the pretraining hold-out | The forgetting check after SFT and after GSPO |
| Reach | Share of problems solved by any of the 8 samples or the greedy answer | Separates new reach from sharpening |
pass@k uses the unbiased estimator over \(n\) samples:
Here \(P\) is the number of problems, \(n = 8\) the samples per problem at temperature 1, and \(c_p\) the number of correct samples for problem \(p\). With \(k = n = 8\), a problem counts 1 if any sample is right.
In words: for each problem, the chance that at least one of \(k\) answers drawn from the \(n\) samples is right, averaged over problems.
avg@k is PocketRL’s metric:
Here \(c_p\) is the number of correct samples out of \(k = 8\) for problem \(p\). avg@8 uses all 8 samples, while pass@8 keeps one bit per problem, so avg@8 detects smaller changes. GSPO-A against SFT gave p = 0.002 by avg@8 and 0.038 by pass@8.
In words: the share of correct answers among the \(k\) samples, averaged over problems.
- Alarm: a gain inside the noise floor. Seen: the same weights evaluated twice moved MATH-500 avg@8 by −0.33 points (SE 0.86), and only 198 of 500 greedy texts were identical.
The SFT → RL gate
| Check | Pass condition | Seen |
|---|---|---|
| GSM8K accuracy (greedy, 200 test) | Recorded; if exactly 0%, RL has no signal | 2.0% after SFT |
| Format compliance (200 dev answers) | Above 50% | 74.5% (PASS) |
| Group signal: G = 8, 64 problems | At least 30% of groups mixed | 6.3% after 3 epochs, 1.6% at the kept step 175, epoch 5 of 6 (FAIL); 43.8% on the medium tier with G = 32 (PASS) |
| First RL step | Loss and gradients finite | PASS |
| Sequence ratio on the first mini-batch | \(s_i = 1\) exactly | Exactly 1 on one GPU; not at expert parallelism 8 |
| KL at step 1 | Near 0 | 0.0027 at expert parallelism 8 |
| Batch invariance | Rows scored inside two different batches give identical log-probs | Holds by construction: one row per forward pass |
| Expert combine precision | The expert-output weighted sum in fp32 | Not met. The router runs in fp32 (--moe-router-dtype fp32), but at d6316eb45 the router weights are applied inside the experts and their outputs are summed in bf16. The gate’s “pass” rested on the router flag alone |
GSPO, every step
Advantage, ratio and clipping
Here \(r_i\) is answer \(i\)’s reward, and \(\bar{r}\) and \(\sigma_r\) are the mean and standard deviation of the rewards in its group of \(G\) answers to the same prompt. The zero rule judges by correctness, not by reward, so a format bonus alone never trains the model.
In words: an answer’s advantage is how much better its reward is than its group’s average, in units of the group’s spread.
Here \(y_i\) is answer \(i\), \(|y_i|\) its length in tokens, \(\pi_\theta\) the policy being trained and \(\pi_{\text{old}}\) the policy that generated the batch.
In words: GSPO’s importance ratio is the geometric mean, over an answer’s tokens, of how much more likely the current policy makes each token than the policy that sampled it.
- Alarm: \(s_i \ne 1\) on the first mini-batch, which can only be numerical mismatch.
- Seen: exactly 1 on one GPU; at expert parallelism 8, a median \(|\log s_i|\) of 0.0049 (p99 0.034) before any weight change.
Here \(\varepsilon_{\text{lo}}\) and \(\varepsilon_{\text{hi}}\) are the clip bounds, and \(\mathbf{1}[\cdot]\) is 1 when its condition holds. The trainer also logs the same share counted per answer.
In words: the share of tokens that belong to answers whose ratio has passed the clip in the direction their advantage pushes.
- Alarm: above 0.30 on mini-batches 2–4, about 2× the GSPO paper’s average of 0.15. A value of 0 means clipping is inactive.
- Seen: 0–1.6% per update in GSPO-A, at the raised clip of 2e-2 / 2.7e-2.
The ratio by staleness \(k\) logs \(\max_i |s_i - 1|\) and the clipped share separately for each mini-batch, where \(k\) is the number of updates since the rollout (0–3). At \(k = 0\) the ratio should be exactly 1: it was on one GPU, but not at expert parallelism 8 (above).
KL to the reference model
Here \(\pi_{\text{ref}}\) is the frozen SFT model and \(y_t\) a token sampled from \(\pi_\theta\). An answer’s KL is the mean over its tokens, and a step’s value is the mean over answers.
In words: the K3 estimate of the KL divergence from the reference, per sampled token; it is never negative and is 0 only when the two policies agree on that token.
- Alarm: above 0.1 per token. The contingency is to raise \(\beta\) from 0.01 to 0.05, then halve the rate. Report the median and the p99 as well as the mean.
- Seen: GSPO-A rose from 0.0024, its noise floor at step 1, to 0.028 by step 39.
- A caution: K3 is a tail statistic. On the laptop, the top 1% of the trained tokens held 77% of the fp32 mean.
Answers and diversity
Here the sum runs over all \(N\) sampled answer tokens of a step, with the sampler’s own log-probs. In the Megatron runs the logged value averages each answer’s mean instead, so every answer counts equally.
In words: the mean surprise of the policy at its own sampled tokens, a free stand-in for the entropy.
- Alarm: falling toward 0 means the policy is collapsing onto single answers. Read it with accuracy, since a confident right answer is also low.
- Seen: 1.21 → 1.10 nats over GSPO-A.
| Metric | Definition | Alarm |
|---|---|---|
| Mean reward | The mean of the per-answer reward (configs) | Recorded, not the signal: read the solve rate |
| Reward standard deviation | Over a step’s answers | 0 means no learning signal |
| Mean advantage | Mean of equation (10) | Should be about 0 |
| Policy loss | The value of the GSPO objective | NaN or spikes; it is not expected to fall steadily |
| Response length (mean, p50, p99, max) | Tokens per answer | p50 should settle near the SFT median of 100; watch the p99 tail; the hard stop is 1,536 tokens with the prompt |
| Length, correct vs wrong | Median length of each, and the wrong-minus-correct gap inside mixed groups | Wrong much longer than right: GSPO is pushing every answer shorter |
| Answers per group | Distinct answer texts and distinct final answers among a prompt’s \(G\) answers | Falling to 1: no group signal |
| Gradient norm | As in pretraining | Above 10× normal: kernel mismatch |
| Generation, update and suspend times | Seconds per rollout batch, per update, and engine suspend | Generation dominates; suspend should be small |
Seen: in the control run, sampling was silently greedy: 1.44 distinct texts per group of 8, where 8.0 was expected.
GSPO, every 50 steps
| Metric | Definition | Target or alarm |
|---|---|---|
| Held-out accuracy | Greedy, 200 per test set (all 180 of MultiArith) | Should rise over training |
| pass@1 to pass@8 | Equation (8) on GSM8K’s first 50 problems | Measured at each evaluation |
| Format compliance | As in SFT | Above 90% during RL |
| Solve rate | Correct answers over all answers in a step | Below 0.1: too hard, move easier; above 0.8: too easy, move harder |
| Groups with any correct | Share of groups with at least one right answer | Above 30% |
| All-correct rate | Share of groups where all answers are right | Below 80% |
| Groups skipped | One minus the mixed share | Below 70% |
| Curriculum tier | The tier the controller is on | Track the transitions |
The share of mixed groups is the learning signal itself:
Here \(Q\) is the number of prompts in a step, \(c_q\) the number of correct answers to prompt \(q\), and \(G\) the group size. Only mixed groups carry a GSPO gradient.
In words: the share of prompts whose answers include at least one right and at least one wrong answer.
If each answer to a prompt is right independently with probability \(p\), the chance that the group is mixed is:
Here \(p\) is the per-answer success rate and \(G\) the group size. At \(p = 0.01\) this gives 7.73% for \(G = 8\) and 47.44% for \(G = 64\).
In words: one minus the chance that all \(G\) answers are wrong and minus the chance that all are right.
- Alarm: below 30% at the start of RL.
- Seen: 1.6% on the easy tier with \(G = 8\), which moved GSPO-A to the medium tier with \(G = 32\) (43.8%). The control run’s base model gave 94% with \(G = 8\).
MoE metrics during RL
| Metric | Definition | Alarm |
|---|---|---|
| MaxVio per layer | Equation (5), every GSPO step | Above 2× its step-1 value |
| Router bias change | Bias difference between checkpoints | 0 by design: the balancing is frozen; any change means the freeze failed |
| Routing entropy | Equation (7), start of RL against the end | Stable or slightly falling |
| Dead experts | Experts with 0 tokens | Must be 0 |
| Expert token distribution | Per-expert counts at the start and the end of RL | Look for math specialization |
| Step time breakdown | Rollout time against gradient time | Rollout dominates in synchronous RL |
| Rollout throughput | Generated tokens from rollouts.jsonl over the rollout timer |
Megatron’s own tokens/s is nominal: batch × 1,536, padding included |
| Rollout record | Definition |
|---|---|
| KV-cache usage | The engine’s block occupancy, printed every 200 engine steps |
| Every rollout saved | Question, response, reward, advantage and step in rollouts.jsonl; per-token log-probs in rollout_logprobs.jsonl |
Sampler–learner mismatch
Generation (decode with a KV cache) and the training forward are different computations, even inside one codebase.
Here \(p_{\text{gen}}\) is the inference engine’s probability, \(p_{\text{train}}\) the training forward’s, and \(N\) the number of sampled tokens.
In words: the mean absolute difference between the inference engine’s and the trainer’s log-probability of the same sampled token, at the same weights.
- Alarm: above 2× its early-run level.
- Seen: 0.0133 nats/token in the one-GPU rehearsal, about 0.035 in the 8×H100 run, and 0.0072 at the control run’s first update.
With \(d_t = \log \pi_{\text{target}}(y_t) - \log \pi_{\text{behaviour}}(y_t)\) for tokens drawn from the behaviour policy, two KL estimators are logged:
Here the behaviour policy is the one that drew the \(N\) tokens, and the target is the one being compared with it. K3 is unbiased only when the target puts all its probability inside the behaviour’s support. With top-k or top-p sampling it is biased low (0.008 against a true 0.127 at top-p 0.85), so K1 is the one to read for truncated sampling.
In words: both estimate the KL from the behaviour policy to the target policy; K1 is unbiased, and K3 has lower variance.
The importance weight \(w_t = p_{\text{train}}(y_t)/p_{\text{gen}}(y_t)\) gives two more diagnostics:
Here \(D_2\) is the Rényi divergence of order 2, and the averages run over the sampled tokens. A high second moment means unstable gradients. Seen: \(D_3\) = 0.00024 and \(\mathbb{E}[w^2]\) = 1.0005 at the control run’s first update.
In words: the second moment of the weight grows exponentially with the order-2 Rényi divergence, and \(D_3\) is 0 only when every weight is 1.
The routing flip rate, the share of tokens whose top-8 expert set differs between generation and training, was not measured.
RL checkpoints
| Item | Why |
|---|---|
| Weights in fp32 | An fp16 save can round most of an RL update away |
| Optimizer state | Without Adam’s moments, a restart behaves like a fresh start |
| Curriculum state | The tier, the mix and the solve-rate history |
| RNG states and step | So a restart resumes exactly |
| Restart test, once | Save at step N, resume, compare step N + 1 with the uninterrupted run |
Seen: the rehearsal’s RL restart resumed at iteration 8 once --finetune was removed.
4-bit and distillation
| Metric | Definition | What to watch |
|---|---|---|
| Held-out perplexity, 4-bit | Equation (2) for the quantized model | Against full precision |
| Perplexity gap | QAT against plain post-training quantization | QAT should be closer to full precision |
| Expert weight distribution | Histogram of the quantized weights | Roughly symmetric |
| Quantization error | Mean per-layer error between original and quantized weights | Recorded |
| Fake-quant vs real kernel | Log-prob gap between the QAT forward and the real 4-bit kernel | About 0 |
| Students with and without a teacher | Held-out perplexity of each, same data and tokens | The teacher’s student should be better |
Seen (rehearsal, shrunk model): codes symmetric, quantization error 11.7%; the KD student’s KL to the teacher 0.215 against the CE student’s 0.293. Both stages were cut from the main run.
Serving
Here \(t_{\text{latency}}\) is a request’s total time, \(t_{\text{TTFT}}\) its time to the first token, and \(n_{\text{tokens}}\) the tokens it generated.
In words: the time per output token after the first one.
Here \(n_{\text{layers}} = 16\), the 2 counts K and V, \(n_{\text{kv}} = 4\) key-value heads, \(d_{\text{head}} = 64\), and \(b = 2\) bytes in bf16.
In words: every token stores one key and one value vector per key-value head per layer.
| Metric | Definition |
|---|---|
| TTFT | Time to the first token: the prefill |
| Tokens/s and tokens/s per GPU | Generated tokens over wall time, for the system and per GPU |
| Batch capacity | The most concurrent sequences, limited by KV-cache memory |
Infrastructure and data checks
| Check | Pass condition |
|---|---|
| GPU health | Every GPU passes; ECC on with no errors |
| NCCL all-to-all bandwidth | Bus bandwidth recorded, #wrong = 0; again with NVLink off |
| GPU count | 8 |
| Data integrity | Every data, SFT and tokenizer file matches its SHA-256 manifest |
| Decontamination | No 10-gram overlap between training text and any of the six test sets |
| SFT decontamination | Numbers-masked and embedding checks as well |
| Hold-out | The 1% hold-out is separate from training |
| SFT against RL | No overlap between the SFT data and the RL curriculum |
| PII | Regex masking applied to the pretraining data |
Seen: the first health check failed on one one-second power reading of 706.3 W; the re-run passed.
Failure modes and their symptoms
| Failure | Symptom | First response |
|---|---|---|
| Expert collapse | MaxVio spikes; one expert gets all the tokens | Raise the bias rate \(\gamma\); check for dead experts |
| Catastrophic forgetting (SFT) | Follows instructions but loses general knowledge | Lower the SFT rate, fewer epochs |
| Format not learned | No <think>/<answer> after SFT |
Check the template and the data |
| Loss does not decrease | Flat from step 1 | Check the rate, the data loading and the gradient flow |
| Reward hacking (RL) | Reward up but quality down | Check how the format bonus is normalized |
| Length collapse (RL) | Answers shrink to 1–2 tokens | The length penalty is too aggressive |
| Length explosion (RL) | Answers grow without bound | Add a length penalty, check the KL |
| Router destabilizing (RL) | MaxVio above 2× its baseline | Raise β to 0.05, then halve the rate |
| All-wrong or all-right groups (RL) | Reward standard deviation 0, no gradient | Move to an easier or a harder tier |
| Numerical mismatch (RL) | Importance ratio not 1.0 at step 1 | Align the kernels |
| Mismatch drift (RL) | The same-weights gap rises over training | Check kernels and precision |
| RL update lost on save | A reloaded RL checkpoint scores like the pre-RL model | Save in fp32 |