research24 min studyLesson 740 in Engineering

Validate the target law and the serving benefit separately

Combine finite-distribution branch checks, statistical limits, cache-state tests, and matched-load latency evidence without treating samples as a proof of exactness.

On this page

What you’ll understand

  • Use analytic finite cases to test acceptance and residual branches.
  • Interpret empirical frequency differences under explicit sampling assumptions.
  • Report latency and throughput under matching target laws and workload conditions.

A speculative implementation produces plausible text and a favorable token-per-second number. Neither observation proves that it samples the intended target distribution or improves the latency users experience. Validation needs two evidence paths: correctness of the probability and state machinery, and performance of the supported configuration under a declared workload. Analytic small cases can reveal branch errors directly. Finite samples and benchmarks then test practical behavior within their statistical, numerical, and workload limits rather than supply a universal theorem.

Start with distributions whose answer is known

Enumerate a tiny vocabulary and calculate accepted overlap, rejection probability, and conditional residual exactly. Include p=q, disjoint supports, target-only tokens, proposal-only tokens, near equality, and rejection at every position of a short block. Confirm that the accepted-plus-corrected mixture equals the target token by token and that the zero-rejection branch never normalizes 0/0. Add greedy path and tie cases separately. For a block or tree, compare target conditionals after each committed prefix against independent ordinary model evaluation so a correct sampler is not fed corrupted logits or stale KV.

Pin target and draft weights, tokenizer, processors, stopping rules, dtype, kernels, cache layout, and generation mode. Batch shape and numerical precision can change probabilities even when the conceptual model is the same. Pinned vLLM 0.10.2 explicitly separates algorithmic tests from log-probability stability limits, while the original papers state their numerical setting. Define which mathematical law is being approximated and which tolerances the implementation supports. Quality similarity, a matching greedy corpus, or a collection of equal seeded strings can support particular observations but does not replace the stochastic branch argument.

TV⁡^=12∑x∈V∣p^(x)−p(x)∣\widehat{\operatorname{TV}}=\frac12\sum_{x\in V}|\widehat{p}(x)-p(x)|
For a declared finite vocabulary and empirical frequency vector p_hat, this dimensionless distance summarizes the observed sample discrepancy from known p. Finite-sample variation means it is not automatically the true distance of the implementation’s unknown output law from p.↔ Scroll wide equations horizontally.

Interpret finite samples without declaring equivalence from silence

Repeated independent draws from a fixed known prefix can test one conditional distribution. Whole generated sequences contain dependent token positions and many different histories, so pooling them as identical Bernoulli trials is generally inappropriate. Predefine outcomes, sample size, and testing or interval procedures, and account for multiple tested histories or categories. A failure to reject a difference does not prove equality; a test can lack power for small but important errors. Conversely, a rare discrepancy can occur under a correct sampler. Investigate branch and numerical evidence alongside the statistical result.

Use exact or appropriate proportion methods for small counts and boundaries, and preserve the actual experimental grouping when comparing prompts or hardware runs. An empirical acceptance average is also not a distributional correctness test: a biased heuristic can accept many tokens. Track correction and stop branches and validate them directly. If using a tolerance-based approximation, report that target and estimate its effect rather than call the procedure mathematically exact. Distinguish the algebraic proof under exact normalized probabilities from the finite-precision and pseudorandom implementation that the tests exercise.

SD⁡(p^A)=pA(1−pA)N,N>0\operatorname{SD}(\widehat{p}_A)=\sqrt{\frac{p_A(1-p_A)}{N}},\qquad N>0
For N independent identical draws from one fixed history and known event probability p_A∈[0, 1], this is the exact standard deviation of its sample fraction. It is not a confidence interval for arbitrary dependent tokens or a guarantee of test power.↔ Scroll wide equations horizontally.

Measure user-visible and loaded-service outcomes

Compare the same target decoding contract and a declared prompt, context-length, output-length, and arrival mix. Separate prefill, first-token latency, inter-token gaps, completion latency, throughput, peak memory, and acceptance-prefix statistics. Speculative output can arrive in bursts, so a mean cost per committed token does not describe every gap. Include warmup and compilation policy, request cancellation, errors, and dropped work. Avoid reporting only the easiest prompt slice or comparing a different sampling temperature or approximate verifier against an exact baseline without identifying the changed workload.

The sampling lab isolates one known-prefix event model. For each separate view, Reset, set both p=0.6 and n to 25 or 100, predict the sample-mean variance, then inspect. The exact variances are 0.0096 and 0.0024. Playback highlights probability outcomes and the normal comparison is approximate; no decoder is run and no random samples are collected. The display helps reason about finite evidence but cannot certify equality of a large vocabulary law, cache rollback, or serving latency. Those conclusions require the analytic, implementation, and matched-load checks above.

A sample discrepancy is evidence to investigate, not a proof by itself

A fictional fixed-prefix target has p(A, B)=(0.6, 0.4). A test collects 10000 independent output draws under one frozen configuration and observes 6200 A and 3800 B outcomes. Use the stated ideal target as the null model.

  1. Observed frequencies are(0.62, 0.38), giving empirical TV distance 0.5×(0.02+0.02)=0.02.

  2. Under the stated independent target model, the standard deviation of the A fraction is sqrt(0.6×0.4/10000)≈0.004899. The observed 0.02 gap is about 4.08 such standard deviations.

  3. This is a notable diagnostic under the stated assumptions, warranting the predefined statistical analysis and branch investigation. It does not alone identify a particular bug, establish distributional equality or inequality with certainty, or cover untested histories and numerical settings.

The result

The observed discrepancy is two percentage points, about 4.08 null standard deviations for this fixed-prefix test. Interpret it within the declared statistical design and inspect the implementation evidence.

Explore the model

Interactive lab

Interactive lab · sampling

Quantify the scope of a known-prefix sampling check

For each view: Reset, set both p=0.6 and n, predict, then inspect. Compare n=25 and n=100: sample-mean variances are 0.0096 and 0.0024. Exact binomial bars and an approximate normal comparison are displayed; playback is not random sampling or decoder execution.

Quantify the scope of a known-prefix sampling checkExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). 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 forFinite evidence has sampling variation even in a simple independent model. Passing an empirical check is not a proof of equality across every history or a latency result.

Check your understanding

A finite stochastic test finds no significant difference from the target. What follows?

Try it yourself

A matched-load benchmark lowers mean time per committed token from 20 ms to 14 ms, but its 99th-percentile inter-token gap rises from 35 ms to 50 ms. Compute the mean-time speed ratio and describe the supported conclusion.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compare the same statistic for the ratio, then retain the different tail statistic separately.

Compare with the solution

The mean-time ratio is 20/14≈1.42857 times. That aggregate improvement coexists with a worse measured 99th-percentile gap, so the configuration is not uniformly lower-latency under these observations. Correctness and other loads still require their own evidence and the release decision must use its declared objectives.

Take it with you

  • Use exact finite branch calculations and actual-state comparisons for correctness.
  • Finite samples test stated events with limited power and explicit dependence assumptions.
  • Measure performance separately under the same target law and representative serving load.

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.