Calibrate on the deployment distribution without leaking evaluation
Treat observed ranges and reconstruction objectives as estimates with explicit coverage limits.
On this page
The question for today
What you’ll understand
- Separate calibration, development selection and final held-out evaluation.
- Quantify how rare regimes can disappear from a small calibration sample.
- Version the data and processing that produced quantization parameters.
Calibration estimates the behavior of a particular model on a particular set of inputs. It may collect activation extrema, histograms or inputs for a layer reconstruction objective. None of these observations guarantees that future prompts have the same range. A useful calibration plan describes the intended deployment workload, the sampling unit and the regimes whose omission would make a low-error calibration result misleading.
Ranges depend on the full input pipeline
Use the deployed tokenizer, chat template, preprocessing and model revision while collecting statistics. An activation maximum measured before a template change need not remain representative afterward. Context length matters because longer requests create more opportunities to encounter unusual values, and decoding can differ from prompt processing. A collection of short English questions provides weak evidence for multilingual long-context code generation, even if the token count is large. Record the domain mixture and length distribution instead of reporting only a convenient number of examples.
A maximum observer retains extremes encountered during calibration; a histogram-based approach can trade clipping against resolution under an estimated distribution. Their parameters answer different optimization questions. Rare values can be genuine and important, while a single corrupted example can also stretch a range needlessly. Diagnose the examples creating extremes and check data integrity before choosing a rule. A quantization method that uses reconstruction inputs is still dependent on their coverage, even when no gradient-based model finetuning occurs.
Split before choosing quantization settings
Keep calibration data separate from the final task evaluation set. A development set can select clipping thresholds, group sizes or smoothing settings, but repeated selection turns its results into development evidence rather than an untouched estimate. Group related documents, prompt variants and source conversations before splitting to reduce overlap. Even unlabeled text can leak evaluation structure into a quantizer when its statistics or reconstruction errors guide the chosen representation. Labels are not required for this kind of selection dependence.
If a critical regime is rare, intentionally allocate calibration examples to it rather than hoping a small random sample includes it. Stratification changes the sampling distribution, so record that choice and evaluate using the actual deployment mixture or separately declared slices. Do not claim a universal minimum sample count: some ranges stabilize quickly while rare channels and long sequences need more coverage. Compare parameter stability across independent calibration subsets, and investigate large changes rather than silently averaging them away.
Make calibration reproducible and inspectable
Store dataset identifiers or approved fingerprints, sampling seeds, preprocessing versions, tensor observer configuration and the resulting scales with the artifact. Ensure the evaluation report identifies which settings were selected using which data. Repeat measurements for deployment-relevant shapes and phase boundaries; some serving paths use separate kernels or precision policies. When deployment shifts, rerun representative calibration and held-out comparisons together. A newly observed clipping spike is evidence to investigate, not permission to retune using the final evaluation answers.
For a coverage calculation, Reset the probability lab and set both p=0.1 and n=20. Predict mean two rare examples and probability of zero approximately 0.1216. In a separate run Reset and set both p=0.1 and n=30; predict mean three and zero probability approximately 0.0424. Play highlights exact binomial outcomes rather than sampling calibration records. This iid model explains a coverage risk; it cannot certify that actual prompts are independent or that any observed range is sufficient.
Work it through
A rare regime needs explicit coverage
Assume independent calibration requests have a 1% probability of entering a critical regime. A team samples 100 requests. Compute the probability that none enters it, then find the smallest sample count making that probability at most 5%.
Under the stated iid assumption, missing the regime in all 100 examples has probability 0.99 to the power 100, approximately 0.3660. A hundred examples therefore still leaves roughly a 36.6% chance of no coverage of that regime.
Require 0.99 to the power n to be at most 0.05. Taking logarithms and dividing by the negative log of 0.99 reverses the inequality, giving n at least log(0.05)/log(0.99), approximately 298.07.
Round upward to 299 examples. At 298 the miss probability is about 0.05004, above the requirement; at 299 it is about 0.04954. This arithmetic addresses encountering the regime at least once, not estimating its activation tail reliably.
Use at least 299 iid requests for this particular coverage threshold, or deliberately sample the critical regime. Neither strategy replaces separate evaluation of its quantized task behavior.
The living notebook
Explore the model
Interactive lab · probability
How a regime can be absent
Fresh Reset → set p=0.1 and n=20 → predict mean 2 and P(K=0)≈0.1216. Separately Reset → set p=0.1 and n=30 → predict mean 3 and P(K=0)≈0.0424.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forThe exact binomial instrument assumes independent common-probability trials. Playback highlights outcomes, not collected calibration examples.
Pause & reason
Check your understanding
Your turn
Try it yourself
For an iid regime probability p=0.02 and n=50 requests, estimate the miss probability. What sample count makes it at most 10%, and what changes if the 50 requests are duplicates of one source request?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Use 0.98^50 and then the ceiling of log(0.1)/log(0.98). Duplication changes the effective independent sampling unit.
Compare with the solution
The miss probability is approximately 0.3642. The threshold is ceil(113.97)=114 independent examples. If every record duplicates one independently chosen source, the probability of missing the regime is instead 0.98, because there is only one independent opportunity. Counting repeated windows as fresh iid examples would overstate coverage.
Keep the idea
Take it with you
- Representative calibration includes preprocessing, length and deployment phase.
- Selection using evaluation inputs can leak information without labels.
- Coverage probabilities require a defensible independent sampling unit.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.