Estimate remaining generation without discarding the long requests
Distinguish output caps, realized lengths, censored observations, conditional remaining work, and predictor calibration across request cohorts.
On this page
The question for today
What you’ll understand
- Separate a requested cap from natural completion length and observed output.
- Calculate what right-censored length records do and do not establish.
- Update a remaining-length expectation using survival information rather than blind subtraction.
Prompt length is known after serialization, but natural output length is usually not. A scheduler may predict it to improve admission or priority, yet prediction errors can systematically disadvantage particular tenants, languages, or tasks. Completion logs can also omit exactly the longest requests when they time out or hit a cap. Treat length estimation as a measured model with a defined target and observation process, not as a hidden oracle that makes every scheduling promise deterministic.
Define the prediction target and keep stop reasons
Distinguish the requested output cap, tokens actually generated, tokens delivered, and the length at which the model would naturally stop under a specified decoding policy. A cap is enforceable if the engine applies it, but it is not an unbiased prediction of natural completion. Cancellation can stop delivery before generation is acknowledged, and a server error can terminate the observation for another reason. Save stop reasons and progress so these cases are not all relabeled as short successful responses.
For natural-length estimation, a request that has produced forty tokens without its stopping event before a forty-token observation cutoff provides a lower-bound observation, not a completed length of forty. Dropping it and averaging only EOS completions can bias the estimate downward when long requests are more likely to be cut off. Statistical censoring methods require their own assumptions; cancellation based on user dissatisfaction or resource pressure may be informative rather than independent. Recording a censor flag is necessary but does not automatically solve that dependence.
Condition remaining work on having survived this far
A request still running after k generated tokens supplies new information about its total length. The expected remaining work is conditional on L>k and relevant request features. Subtracting k from an unconditional mean can be badly wrong: surviving beyond the short-response mode can leave only the long-response mode. A predictor should state whether it estimates total length at arrival or remaining length during execution, and when updates use observed progress.
Calibrate predictions on eligible cohorts with the same tokenizer and decoding settings as serving. Inspect underestimation rates, tail coverage, and error by prompt length, tenant, domain, and stop reason. A model can have a small overall mean error while systematically underpredicting one expensive class. Use an enforced maximum for a true resource cap; a chosen prediction quantile supports a probabilistic budget only with a justified calibration claim and an explicit policy when the prediction is exceeded.
Avoid an estimator-scheduler feedback trap
If the scheduler prioritizes predicted-short requests, its completed-request log can overrepresent easy or short work. Training the next predictor only on that log can reinforce the original bias. Preserve offered requests, admission outcomes, incomplete observations, and enough controlled follow-up to assess the observation process. A model tested only on traffic it already chose to complete has not demonstrated performance on all offered requests. Changes in temperature, stopping rules, or model weights can also shift the length distribution and invalidate old calibration.
The probability lab isolates a fictional count of long-class requests under independent identical assignments. Reset, set both p=0.5 and n=10, predict five expected long-class assignments, then Play or Step. Reset and set both p=0.8,n=10 for eight. The exact binomial bars are not sampled request traces and contain no lengths, censoring, predictor, or conditional remaining-time update. They help separate class prevalence from a single observed batch, while the actual estimator must be evaluated on the recorded cohort and stop-policy evidence.
Work it through
Keep censored lengths in the evidence
Five fictional requests share one fixed decoding policy. Three complete naturally at lengths 10,20,30. Two are observed through forty tokens without natural completion, so their integer natural lengths exceed forty. No further distributional assumption is supplied.
The completed-only mean is (10+20+30)/3=20 tokens. It describes only the three completed records, not an unbiased estimate of all five natural lengths.
Each censored integer length is at least forty-one, so the five-record natural-length mean is at least (10+20+30+41+41)/5=28.4 tokens.
The two unknown lengths can be much larger. Report the lower-bound information and censoring process rather than inventing a point estimate or treating forty as an observed completion.
The data establish a five-record mean lower bound of 28.4 tokens, while the completed-only mean is twenty. They do not identify the full mean or tail distribution.
The living notebook
Explore the model
Interactive lab · probability
Inspect a hypothetical mixture count without estimating lengths
Fresh Reset → set both p=0.5,n=10 predicts mean count 5; Reset → set both p=0.8,n=10 predicts 8. Play or Step highlights exact binomial outcomes, not generated requests. There is no output-length distribution, censoring, predictor calibration, or survival update.
- 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 forA completed subset and a declared offered population can have different compositions.
Pause & reason
Check your understanding
Your turn
Try it yourself
Natural length L is ten tokens with probability one half and one hundred with probability one half. A request is still running after twenty tokens. What is its expected remaining length, and how does this compare with subtracting twenty from the arrival-time mean?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Condition on L>20 before calculating the remaining work. The short component is no longer possible.
Compare with the solution
The arrival-time mean is 0.5×10+0.5×100=55 tokens, so blind subtraction gives thirty-five. Conditional on still running after twenty, L must be one hundred in this toy distribution, leaving eighty tokens. The eighty-token result uses the explicit two-point model and known survival event; it is not a universal rule for real requests. It shows why remaining-work estimates should incorporate observed progress.
Keep the idea
Take it with you
- Caps, natural completions, generated tokens, and delivered tokens are distinct records.
- Censored requests provide lower-bound evidence and can bias completed-only estimates.
- Remaining-work prediction should condition on progress and be calibrated across the offered workload.
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.