AI Hero Club

Efficient LLM Inference · Lesson 7

Marked Complete by You0 / 8

Saved in this browser only. Marking a lesson complete does not mean the project has passed verification.

Lesson Outline 7 subsections
Course Contents 8 lessons
Full course plan.
Efficient LLM Inference / Learning Plan ↗

LESSON 07 / 8Suggested study 120 minutes

Measurement: Fixed Traces, Paired Repeats and Performance Limits

Is one faster timing enough? How do we check numerical equivalence and repeated run times on the same inputs?

3 Questions for This Lesson
  • CPU benchmarks that can be recovered and time-bound
  • Recapitulate median from the original and check noise
  • Distinguishing physical, sub-theory, simulations and not yet operational items
Course Project ZIP ↓

Read the Protocol Before Interpreting the Numbers

This chapter connects the previous mechanisms to the same frozen object. The items are two layers, 32 widths, 4 headers, 128 prior, 31 word sheets, 64 random decoding devices; 17 seeds, double accuracy, CPU single-twice, eval mode and no dropout. Time input is generated by a separate fixed random generator with a total length of 28 length, reminder 12, for a specified follow-on input of 16 batch 1. Cache and reference every time you see exactly the same numeric track, do not sample, do not encounter EOS, do not contain network requests. The numbers answer only the question of a specific small matrix forward to work.

Time is counted using a high resolution single-size perf_counter, unit second. Each starting point is placed before the model is called, and the endpoint is placed after the bottom position of the logits and clone; input generation, weight initialization, file reading, JSON writing, error calculation are all external. When prefilling the independent count, each step is recorded separately, then 16 steps are taken together. Cache updates occur in front of the internals, so the consolidation costs are within range. The clone output from the last position is also within range, so that the candidate path is not finished with the output and is stopped in advance.

Warm-up, Ordering, and Shared Inputs

Runs two sets of reference and cache tracks before the official measurements, with the aim of triggering lazy initialization of the operating library and stabilizing the basic execution path. Preheating does not delete all slow results; it is fixed before the experiment; the formal nine compositions are saved in full duplicates. The odd group refers to the cache first, the even group to the cache first, so as to reduce confusion between the fixed order and temperature, backstage load or frequency drifting. Interlacing does not remove the noise of all systems, so preserving each original set of time and minimum maximum value without taking a quickest sample as a guarantee.

The maximum error should not exceed the agreement in chapter II if the same logarithm is compared to all logits outside of the time range after completion. If one error is first counted but achieved very quickly, and another version of the correct evidence is endorsed, the condition is not jointly satisfied on the same object. Project cpu-timing.json records duplicate numbers, caches, prefilled seconds, step-by-seconds, total decoding seconds with that pair. These original values enable a summary, rather than just trusting an unretroactive cut.

Worked Example 1: Reporting Local Measurements Accurately

The current frozen machine operates from Python at 3:12:14, PyTorch at 2:06.00, macos arm64, and a torch thread. Nine sets of 16 steps decoding total median length to minimum maximum values are shown in the table below, with the median ratio being about 1.5506. The prefilling median is 0.6462 and 0.7125 milliseconds respectively. This is the description that has been saved for one run and the run value is subject to system noise.

PathDecoding median msMinimum msMax. ms
false14.68559.335222.6540
true9.47085.494823.2611
The same freezing model, fixed 16 follow-on input steps; false is a reference for the whole prefix and true is a cache.

Sixteen fixed follow-up input steps cannot be renamed in the report as 16 new outputs received by the user because the experiment did not sample and export transmissions. The model can be reported as a fixed step to vomit: 16 divided by total decoding seconds; but the median number of time is taken first and then taken backwards, which is not equal to the average after calculating each group rate. Nor can the reference be separated from the minimum value of each cache and called typical acceleration. The project summary explicitly uses the median number of total decoding times, with the original match remaining in the document, allowing readers to calculate contrast distributions and check sequence effects.

ρ=median⁡rTuncached(r)median⁡rTcached(r)\rho=\frac{\operatorname{median}_r T^{(r)}_{uncached}}{\operatorname{median}_r T^{(r)}_{cached}}
The margin definition reported under this item is not the mean value of the comparative value, nor is it the ratio of the fastest achievement.
Run in the Project DirectoryProject directory running: read only the original receipt, independent recovery summary, non-recounting.
import json,statistics,pathlib
root=pathlib.Path('evidence')
d=json.loads((root/'cpu-timing.json').read_text())
t={flag:[r['decode_total_seconds'] for r in d['raw'] if r['cached']==flag]
   for flag in [False,True]}
ratio=statistics.median(t[False])/statistics.median(t[True])
assert abs(ratio-d['median_decode_ratio_uncached_over_cached'])<1e-12
assert len(t[False])==len(t[True])==9
print(ratio,{str(k):[min(v),max(v)] for k,v in t.items()})

Worked Example 2: Two Statistical Summaries Can Give Opposite Verdicts

Construct three sets of reference times eight, eight, eight, and twenty milliseconds. The median is down from eight to four, looking twice the typical sample; the mean is down from eight to nine thirty-three milliseconds. If the service target requires all requests to be below ten milliseconds, the candidate fails one time and does not refer to it. The three sets are insufficient to estimate the probability of a reliable tail, which only proves that the median improvement does not contain the tail requirement.

Standalone ProgramThe independent standard bank reverses the example: median and mean, service thresholds cannot be replaced.
import statistics
base=[8.,8.,8.];candidate=[4.,4.,20.]
assert statistics.median(base)/statistics.median(candidate)==2
assert statistics.mean(candidate)>statistics.mean(base)
assert sum(x>10 for x in candidate)==1
print(statistics.mean(candidate))

Small Samples, Tail Behavior, and Causal Interpretation

The nine components detect significant temporal fluctuations in the repeat, but are not sufficient to stabilize the estimate of 99%. If the latest method is used, the nine samples will fall directly to the maximum, with only one observation support; it will not be a reliable estimate of the end of the request for amounts on the line. Repeats come from the same machine for the same short period of time and may not necessarily be distributed independently, and the back-office task and thermal state can be relevant.

If the result is different from that of chapter I, check whether the calibre is the same: the reference is to execute the head of the entire vocabulary for the position, the cache is to perform only a new position, contains a volume allocation and a combination, and the window is to be rebuilt. Again, the workload explanation is distinguished from evidence of hardware bottlenecks. Without actual bandwidth or kernel analysis, no single claim of a band width can be based on “It's not that fast.” alone. The cost of the fixed call for the current CPU small model may be significant, but this is just a reasonable candidate explanation, which will have to be determined by specific changes in shape and diagnostics. The course will mark the explanatory assumptions separately from the measured values.

Why GPU Performance and Serving Latency Need Separate Experiments

The end of CPU forward call usually means that the calculations have been calculated accordingly and that the current range can be compared directly with clock differences; GPU operates in a routine asterisk queues, which, if submitted only by the host, will miss the device. The migration should use an event of the equipment or synchronize with the protocol to indicate whether the host equipment is transmitted and synchronized. The PyTorch official baseline tool handles preheating, linear setting is synchronized with the necessary asynchronous process, which can serve as a reference for new experimental design. This project did not run GPU, the receipt clearly states NOT RUN and cannot copy the approximately 1.506 value of CPU to the FlashAttention or other hardware promotion.

The online service also needs to get to the process, the true input length distribution, co-match, coding, queuing, cancellation, network output and failure logs. The fixed trajectory benchmark does not have these content, so user_latency_slo is marked NOT MEASURED. The Tick schedule in chapter IV also does not fill the vacancy, because it assumes that each round takes a fixed time. To study the first word and output interval, a real end-to-end stamp and request identity, and load must cross the stable and condensed area; these are follow-up independent experiments, not the functions that have been completed for this small project.

The first type of check is the original data recovery: median, unit conversion, range, double count and margin should be obtained by the original array to be saved. The second category is matching consistency: with the Hashi model, input, window and logits; the necessary job specific to a candidate is not missing outside the time frame for re-checking. Quality is built simultaneously with speed improvement on a frozen version. If an anomaly occurs only at the start of a cache or a group error fails, the entry should be retained and marked for invalid comparisons.

Test sequence effects are also allowed for data. The first group running the cache is listed separately from the subsequent group running the cache, observing whether the margin is uniform; if the bias is significant, the interval should be expanded or a more systematic random order of preference should be adopted, rather than merely retained. The current nine groups, using sex replacements to facilitate recovery and auditing, do not claim to have completed a significant test. Prefills and curves should also be retained, as the sum of the same ones may mask a single step; conversely, an occasional peak cannot alone prove that the algorithm has deteriorated with length. This kind of causal judgement can only be supported by multiple repetitions and explicit changes between the same length zones.

In particular, two minimum levels of each noise are not to be divided into a stable ceiling. The minimum is occasionally used to estimate less disruptive performances, but its meaning must be stated separately and cannot be described as typical experience for the user. The minimum and maximum values are retained for the purpose of displaying the scope, and the subject of the conclusion is still supported by pre-selected median numbers and complete original duplications.

Exercises and Project Contributions

TRY IT YOURSELF

Base: unit to value

The median number of 16 steps is 0.012 seconds, and the candidate is 0.008 seconds.

Hint 1
Speeds should be reduced by reference time and the fixed speed by step by candidate.
Hint 2
Check whether the molecules are 16 fixed input forward steps or user output, and whether they are included in queues, sampling and transmissions.
Compare with the Solution
The value 0.012/0.008 = 1.5. Candidate 16/0.008 = 2000 fixed input step per second. This does not make it possible to claim that the user receives 2,000 output per second, as sampling, queue and transmission are not included.

TRY IT YOURSELF

Step: Identification of the unfair range

The reference time contains a model loaded, the candidate is loaded first and then counted. Can you report the cache acceleration directly, even if the output is identical?

Hint 1
The same boundary is drawn for both ends.
Hint 2
The steady state excludes loading on both sides, and the cold start contains on both sides; the output equivalent is not restored to an unfair time range.
Compare with the Solution
No. Loading boundaries are different, and the margin mixes two mechanisms. Both ends should exclude loading to study a steady state forward, or both should include research for cold start-up and naming separately. The same output only fixes the correctness and does not fix the timescales unfairly.

TRY IT YOURSELF

Challenge: Why can't you promise your tail nine times?

Nine times, all less than 20 milliseconds, the line is written at p.99 below 20 milliseconds. Two gaps in statistics and work loads are noted.

Hint 1
Could the nine observations not exceeding the threshold limit a total of one per cent of the end and whether the samples are independent?
Hint 2
Whether the additional load covers arrival, length and dispatch; separates the findings of the current fixed CPU sample from the evaluation of future end-of-service delays.
Compare with the Solution
The sample is too few and may be relevant, the failure to see a threshold does not amount to a super-threshold probability of less than one per cent; the fixed input trajectory does not cover real arrival, length and distribution. The conclusion should be limited to nine specific CPUs for the calculation of samples, plus sufficient real service requests and pre-registration load protocols for the evaluation of the tail.

The delivery of this chapter is a summary of cpu-timing.json’s original repetition and scope. Running lab.py generates new measurements, so that the raw frozen data should be kept or written into a new directory, and old numbers cannot be described as newly produced after running again. The final chapter provides a way to bind the source code, models and evidence, and indicates that a qualified report can include both pass, non-realization, non-operational and non-measurement.

CHECK YOUR UNDERSTANDING

Check Your Understanding

Answer first, then open the explanation to check your reasoning. These questions help reveal gaps in understanding; independent implementation and transfer require separate evaluation.

1. What is the baseline primarily?

Show ExplanationIt has no network, sample or queue.
2. What is the main reduction in the order of succession at both ends?

Show ExplanationThe rotational reduction of the order deviation cannot eliminate environmental noise.
3. All nine times, do you have proof of p99 on line?

Show ExplanationNeither small samples nor work loads cover the end of the line.
Direct host call possible for 4. GPU astrostep execution?

Show ExplanationSynchronization or equipment events should be used and the scope clearly defined.

Manual completion records your progress; it does not certify your project.