← Inference From First Principles

From Training to Execution

What training leaves behind, what must be true before it is executed, and what the first request pays that later ones do not.

The GPT-2 checkpoint on this machine is 548,105,171 bytes. The loaded model has 124,439,808 parameters, recorded here as 32-bit floats, which account for 497,759,232 bytes. The remaining 50,345,939 bytes are not learned parameters. Most of that difference is twelve saved attention-mask tensors; a much smaller part is the safetensors container header. This is a measurement of one pinned artefact, not a rule for estimating model size from parameter count.

That difference is the subject of this chapter in miniature. We say “the model” as though it were one object, a block of learned numbers. What an inference runtime actually consumes is a bundle: learned parameters, any saved non-parameter state, an architecture definition, a tokeniser, generation defaults and executable loading code. Those components can be produced, packaged or changed at different stages of the training-to-deployment process. Loading the weights is therefore necessary but not sufficient. A model can load successfully and still execute under different numerical, gradient or decoding conditions from those intended.

Chapter 1 timed one request and found that forward computation dominated its measured stages. It treated the model as given and reported loading separately. This chapter opens that box. By the end you should be able to identify the files and tensors behind a model name, distinguish the independent PyTorch settings that govern evaluation and autograd, and separate process startup, model loading and first-forward costs. The important question is not whether the first request is always slower, but which one-off costs the measured workload incurred and which subsequent requests can avoid.

Where this sits

Chapter 1’s real-model path recorded load_model as a stage for the one-shot command, whereas its repeated-request path reported loading separately; both used free-form metadata that recorded the model name without automatically pinning a revision. These are different measurement boundaries, and they should not be combined without explanation. This chapter adds an artefact manifest and separates framework import, model load and first-forward work, so later measurements can make those boundaries explicit.

The Inference Lab piece added here is the artefact manifest: file hashes and an inventory of the loaded parameter tensors, plus a readiness check that reports execution-mode state. These observations improve the claim “this result came from this artefact” over a model name alone, but neither is a complete attestation. The present tensor digest excludes buffers, and the readiness check cannot prove that weights will remain unchanged. We will use the stronger terminology of recorded identity and observed execution state, reserving reproducibility and integrity guarantees for comparisons that validate the whole relevant execution environment.

For the wider Pi series, the connection is practical. Retrieval, memory and agent volumes call models by name through providers, and a name does not identify an artefact. The manifest is the local, checkable version of “which model was that, exactly?”, and the same question returns, in a weaker form, when we reach provider APIs in Part VI.

What training leaves behind

Training learns parameter values, but a deployable model requires more than those values. Export and packaging also determine which buffers, configuration files, tokeniser assets and generation defaults accompany the parameters. Some of those artefacts are created during model development or training; others may be added or revised when the model is published. For the pinned GPT-2 snapshot used in the local experiment, the manifest recorded these files:

File Bytes SHA-256 (first 12 hex) What it is
model.safetensors 548,105,171 248dfc391186 Tensors
tokenizer.json 1,355,256 8414cab924d8 Tokeniser, serialised
vocab.json 1,042,301 196139668be6 Token strings to ids
merges.txt 456,318 1ce1664773c5 Byte-pair merge rules
config.json 665 0daed7749b4f Architecture hyperparameters
generation_config.json 124 ed0b32ac72c0 Default decoding settings
tokenizer_config.json 26 5e04eb606e3a Tokeniser options

Model artefact bundle

Only model.safetensors contains the stored weight tensors and the other tensors discussed below. The remaining files configure how those tensors are loaded and used. Changing config.json to specify an incompatible layer count can make loading fail. Changing merges.txt can alter tokenisation for some inputs, but it does not follow that every token id changes. Changing generation_config.json can change decoding when the calling library consumes those defaults and the request does not override them. These are three different outcomes—load failure, changed inputs and changed generation settings—and none requires modifying a learned parameter. Record the complete file set before attributing a change in output to the weights.

The file sizes and hashes below were recorded by python examples/ch02/execution_modes.py manifest for cached snapshot 607a30d783dfa663caf39e06633721c8d4cfcd7e. They are local book results for that snapshot, not proof that every later GPT-2 experiment necessarily loaded identical bytes. The current manifest command resolves a cached snapshot when invoked; it does not pin that revision as a command-line invariant. Reproduction should therefore save the reported snapshot, file hashes, library versions and invocation alongside each result.

The 50 megabytes

The saved safetensors file contains 160 named tensors, while the loaded module’s parameter inventory contains 148 parameter tensors. Inspection of this particular file’s header identified twelve additional h.N.attn.bias tensors, one per transformer layer, each shaped 1 × 1 × 1024 × 1024 and stored as 32-bit floats. They account for 12 × 4,194,304 = 50,331,648 bytes. Adding 497,759,232 parameter bytes gives 548,090,880 bytes of tensor data; the remaining 14,291 bytes comprise the file’s eight-byte header-length prefix and JSON header. The sum, 548,090,880 + 14,291 = 548,105,171 bytes, matches the observed file size. These counts come from reading the serialized header and the loaded parameter inventory; they do not, by themselves, demonstrate that all twelve stored buffers remain resident in the same representation after loading.

Three consequences matter later. First, checkpoint file size is not just the learned-parameter byte count: serialized buffers and container overhead also occupy space. Second, file contents and live runtime memory are different measurements; a loader may transform or omit serialized state, and the framework allocates additional memory. Third, the chapter’s parameter_manifest and parameter_digest inspect named_parameters() only. They do not include named_buffers(). The file hash detects a changed saved mask, but a parameter-only digest cannot. Any later claim about complete loaded-state identity must account for both parameters and buffers, as well as relevant configuration.

Frozen is a policy, not a property

Inference normally intends to leave learned parameters unchanged, but that is a runtime policy rather than an intrinsic property of a PyTorch module. In the GPT-2 measurement, all 148 parameter tensors still had requires_grad=True after loading and entering evaluation mode. That flag means they can participate in gradient computation when grad mode permits it; it does not mean an optimizer is running or that the weights have changed. Conversely, disabling gradients does not prohibit in-place parameter updates. The runtime must distinguish gradient tracking, parameter trainability and actual mutation.

The experiment makes the autograd distinction visible. With the model in evaluation mode and ordinary grad mode enabled, the forward output retained a computation graph, and calling backward() on a scalar derived from the logits populated parameter gradients. With torch.no_grad() or torch.inference_mode(), this forward output had no backward graph; the attempted backward() raised an error. That establishes the state of these forward computations, not a proof that the underlying parameter bytes were immutable. The same model can be run under all three modes without changing its stored weights.

So “the weights are frozen” needs an operational definition. eval() governs training-sensitive layer behaviour, no_grad() or inference_mode() suppress graph recording for the enclosed computation, and requires_grad_(False) controls whether parameters participate in autograd during later grad-enabled operations. None alone prevents arbitrary code from mutating tensor storage. A genuinely checked non-mutation claim would compare parameter digests before and after the execution path, subject to the digest’s limitations. This chapter measures execution mode and gradients; it has not performed that before-and-after immutability test. The readiness check below is therefore a useful preflight, not an immutability certificate.

Three switches that look like one

There are three separate things that people loosely call “inference mode”.

  1. Module mode (model.eval() or model.train()) controls module behaviours such as dropout and batch normalisation; it does not disable gradients.
  2. Autograd context (torch.no_grad() or torch.inference_mode()) controls whether the operations in that context are recorded for reverse-mode differentiation. These contexts are thread-local; inference_mode() also affects tensors created inside it.
  3. Parameter trainability (requires_grad or model.requires_grad_(False)) determines which parameter tensors can accumulate autograd gradients when graph recording is enabled. It does not make their storage read-only.

These controls serve different purposes, and none substitutes for all the others. The experiments below inspect a few carefully chosen states, not an exhaustive matrix of every combination. In particular, the readiness flag does not imply that every parameter has requires_grad=False, and it says nothing about future in-place updates.

Three switches that look like one

Module mode: dropout

During training, dropout zeroes each activation with probability \(p\) and rescales the survivors so the expected value is unchanged. For an activation \(x\):

\[ y = \frac{m \odot x}{1-p}, \qquad m_i \sim \text{Bernoulli}(1-p) \]
In evaluation mode the mask is not applied and \(y = x\). GPT-2 has dropout with \(p = 0.1\) on the embeddings, on the attention weights and on the residual connections.

The probe ran the same 10-token input twice with dropout active and compared the complete logit tensors. In that recorded run, the maximum absolute difference was 41.68. With dropout disabled in evaluation mode, the two outputs matched exactly on this machine and input. The last-position argmax agreed in both train-mode runs, even though many logits differed. That is a distinction between changed scores and changed selected tokens; it does not establish whether a complete greedy continuation, another prompt or another environment would agree. The seed, model version and measurement code determine how this observation can be reproduced.

The practical failure mode is quiet: leaving dropout enabled can produce numerically different scores without raising an error. Depending on the prompt and decoding rule, that may or may not change selected tokens or final text. When an evaluation run unexpectedly varies, checking model.training is an inexpensive first diagnostic; it does not replace checking the sampler’s random state, numerical kernels and other sources of nondeterminism discussed in Chapter 39.

In the recorded Transformers 5.17.0 environment, from_pretrained() returned this GPT-2 module with training = False; calling model.eval() again did not change the observed flag. That is a version-qualified finding from this run, not a contract to assume for every model class or future release. An inference entry point should state and inspect its desired module mode explicitly.

Global autograd mode: memory

When gradient recording is enabled and the output depends on tensors requiring gradients, PyTorch can retain intermediate state needed for a later backward pass. A pure inference request has no use for that graph, so the overhead is avoidable. This chapter measures process-level memory under three modes; it does not directly count the individual tensors autograd saved.

For each mode, the harness started a separate process, loaded GPT-2, warmed it with an eight-token forward pass and then processed 512 tokens. It recorded the process’s peak working set, a Windows process-wide high-water mark, before and after the measured forward pass. This is not a snapshot of live activations or an exact measure of memory allocated by autograd; the baseline already includes imports, model loading and allocator history.

Mode Peak working set after forward Backward possible Output type
Autograd enabled 1,768.7 MB yes ordinary tensor with grad_fn
torch.no_grad() 1,272.0 MB no ordinary tensor
torch.inference_mode() 1,272.5 MB no inference tensor

In these runs, the recorded high-water mark rose by about 528 MB above the pre-forward peak with autograd enabled, versus roughly 32 MB with either graph-disabled mode. That is strong evidence of a large observed peak-memory difference for this workload. It is not an exact attribution of 496 MB to saved activations: process-wide peaks can include temporary allocations and allocator effects, and they conceal allocations that never exceed a prior high-water mark. The conclusion supported by the comparison is narrower and more useful: on this CPU setup, enabling graph recording substantially increased the measured process peak.

A dimensional estimate helps explain why a long input can increase memory pressure. One dense attention-score array at 512 positions with 12 heads and four-byte elements occupies 12 × 512 × 512 × 4 = 12,582,912 bytes, about 12.6 MB. Autograd may retain attention-related tensors and feed-forward activations across twelve layers. The full logits array, 512 × 50,257 × 4, is about 103 MB and is required regardless of gradient mode in this unoptimised implementation. The attention-score term grows as sequence length squared, but the total difference in process peak memory is not thereby proved to be quadratic: feed-forward activations, temporary buffers, implementation-specific kernels and high-water-mark accounting also matter. Exercise 4 should test that dependence over several lengths before the book assigns a scaling law to the measured overhead.

Disabling unnecessary graph recording is more than a cosmetic setting. In the uncached loop from Chapter 1, every next-token step recomputes the prefix; leaving grad mode enabled can create unwanted autograd state on each step. The amount that persists between steps depends on whether references to earlier outputs or graphs are retained, so it would be misleading to multiply this chapter’s one-pass peak difference by the number of generated tokens.

no_grad versus inference_mode

The observed peaks of 1,272.0 MB (no_grad) and 1,272.5 MB (inference_mode) are too close for this single-run setup to distinguish. The important documented difference is semantic. Both contexts suppress backward-graph recording, but inference_mode() also skips additional autograd bookkeeping, including version-counter and view tracking for inference tensors. In this experiment, the output created in inference_mode() reported is_inference() == True. Such tensors have restrictions on later use in autograd-recorded operations; they are not universally unusable in every subsequent computation. Where a normal tensor is required, cloning outside inference mode is one possible conversion, with a cost that must be measured.

Those restrictions are useful when an entire execution path is inference-only, but they matter for pipelines that later need differentiable computations. no_grad() outputs are generally easier to reuse in later grad-enabled work; inference_mode() outputs may need conversion or a different execution boundary. The timings in results.json include a warm-up and a backward attempt, so they do not isolate a speed difference between the two modes. The appropriate rule is to use inference_mode() when its restrictions match the consumer, and benchmark a representative pipeline rather than inferring performance from the API name.

Parameter trainability

Neither eval() nor inference_mode() clears requires_grad on the model’s parameters; all 148 GPT-2 parameter tensors retained that flag in this experiment. For an inference-only module, model.requires_grad_(False) can prevent autograd from tracking gradients through those parameters in an accidentally grad-enabled forward call. It does not prevent a forward graph through other trainable inputs, does not prevent direct parameter mutation and may be inappropriate if the same module is reused for training or gradient-based analysis. This chapter did not measure the cost or benefit of changing those flags, so the suggested guard is a design choice to test, not a measured zero-cost improvement.

The readiness check

The three settings can be inspected together. inference_readiness(module) in examples/ch02/execution_modes.py reports the module’s training flag, the number of parameters with requires_grad=True, and the current thread’s autograd state. Its ready field is intentionally only (not module.training) and (not torch.is_grad_enabled()). It does not check all submodule modes, the model’s device, revision, tokeniser compatibility, parameter hashes, absence of mutation or the subsequent generation call. The code is a useful teaching preflight whose name must not be mistaken for full production readiness:

def inference_readiness(module) -> dict:
    parameters = list(module.parameters())
    trainable = sum(1 for p in parameters if p.requires_grad)
    return {
        "training_mode": bool(module.training),
        "trainable_tensors": trainable,
        "total_tensors": len(parameters),
        "autograd_enabled": bool(torch.is_grad_enabled()),
        "ready": (not module.training) and (not torch.is_grad_enabled()),
    }

On the recorded GPT-2 run, this function returned ready: false after loading and again after model.eval(), because the thread’s ordinary grad mode remained enabled. Inside torch.inference_mode() it returned ready: true despite all 148 parameter tensors still having requires_grad=True. That is expected under this narrow predicate, and it makes the predicate’s limits especially clear. A future request record should capture the check at the generation boundary and, separately, the version and artefact identifiers actually used.

This distinction also exposes a mismatch between toy and real evidence. The Chapter 2 toy generator writes gradients_enabled_during_generation = False and model_training_mode = False as fixed values, although it has neither PyTorch autograd nor dropout. Its simulated_stages list includes training_mode to disclose that limitation. The real-model code queries the execution state at runtime. Identical-looking fields therefore have different evidential meaning; a downstream comparison must distinguish observed, declared and not applicable, rather than treating both records as equivalent measurements.

Identifying the artefact

A useful identity record needs more than a model name. This experiment builds two complementary but incomplete views: a file-level manifest of selected files in the cached snapshot, and a digest of loaded parameter tensors. The first can detect changes to serialized buffers; the second is useful for comparing parameter values across files. Neither view, alone, specifies the whole execution environment or proves trusted origin.

File layer. The table gives file sizes and SHA-256 digests for seven explicitly selected names under the cached GPT-2 snapshot. Comparing those digests can detect changes to the corresponding file bytes, including saved non-parameter tensors. It does not enumerate arbitrary additional files or establish the origin of the snapshot. In the observed cache layout, the blob name for model.safetensors agreed with an independently calculated SHA-256; that is a useful local consistency check, not a guaranteed property of every cache or distribution.

Loaded-parameter layer. parameter_manifest enumerates 148 named parameter tensors, totalling 124,439,808 elements and 497,759,232 bytes, all recorded as float32. parameter_digest hashes sorted parameter names, shapes and raw values. For this model it produces 95cb2531cd09fbf7…. Unlike a file hash, it can match across different containers when loading yields the same named parameter shapes and byte representations. But the implementation does not explicitly hash dtype metadata, non-parameter buffers, module code or tokenizer assets, and it assumes parameter names and representation match. Calling it a digest of the entire loaded model would overstate what it does. A stricter future manifest should specify dtype, buffer state, serialization conventions and runtime revisions, and tests should deliberately change each one.

What a hash proves depends on what was hashed and what the comparison trusts. Matching a saved digest shows byte agreement with that digest, not authorship or authenticity; an attacker able to replace a file and its adjacent digest can replace both. The safetensors format avoids executable pickle deserialization and specifies a length-prefixed JSON header and tensor data, but it is not a signature, malware scan or supply-chain attestation. For closed API models the client cannot inspect weights at all; it can record the requested and returned model identifiers, provider, API revision where available, timestamps and observed behaviour. Such a record is weaker than a local file-and-tensor manifest, and the book must not imply otherwise.

Manifest layers

The toy analogue

The toy path in examples/ch02/reproducible_generation.py gives a smaller integrity example. A Checkpoint contains a transition table, bias, vocabulary and seed. The recorded save produced a 93,259-byte JSON file carrying a digest of the checkpoint’s canonical data, f51790a1c6eb34f8…. Changing one transition-table value by \(10^{-9}\) caused load_checkpoint() to reject the mismatch. There is an important current implementation limit: if the sha256 field is missing, the loader accepts the file without verifying it. The program therefore detects an altered payload when a valid digest field remains present; it does not yet enforce mandatory integrity verification or authenticated provenance.

This analogue demonstrates canonical-data hashing, not complete checkpoint validation. Reformatting whitespace in the outer saved JSON can leave the canonical checkpoint values and their digest unchanged, so loading still succeeds. Altering values while keeping the old embedded digest causes a mismatch. Altering both the values and the digest, or removing the digest entirely, can bypass the current check. A production-facing exercise is to reject missing digests and compare against a trusted digest supplied separately from the file.

What the first request pays

Chapter 1 recorded load times between 1.58 and 3.20 seconds across separate runs, but did not measure Python import time. Here five fresh Python processes each imported libraries, loaded GPT-2 and ran four forward passes over a seven-token prompt. The harness reports three distinct observed costs: import, loading and the first forward pass. These are process-level measurements rather than a complete API time-to-first-token trace; no request queueing, transport or streaming was involved.

Cost Median over 5 processes Range Paid
Library import (torch, transformers) 15.9 s 15.2 – 17.7 s once per process
Model load 1.48 s 1.38 – 1.61 s once per process
First forward pass 154 ms 126 – 157 ms first call only
Later forward passes 103 ms 88 – 129 ms every later call

The library-import phase dominated these measured startup components on this Windows machine, with a median of 15.9 seconds. It is a cost of starting this process and importing the software stack, not of the model’s tensor arithmetic. The experiment did not independently measure whether the operating-system file cache was warm, the effect of antivirus scanning or how imports would behave under another installation. This is one practical reason for a long-lived service to amortise interpreter and framework initialisation, but it does not establish the cold-start performance of a production inference server.

The five processes showed a median model load of about 1.5 seconds. Resident memory rose from roughly 577 MB after import to 1,089 MB after load, a process-level increase of about 512 MB, consistent in scale with—but not exclusively attributable to—the loaded parameter bytes. Within each process the first seven-token forward pass was slower than the next three. Across the five runs its median was 154 ms, versus a pooled median of 103 ms for later passes. This supports a first-forward penalty on this setup, around 51 ms at those medians. It does not isolate its cause: allocator effects, runtime initialisation, operating-system scheduling and other one-off work remain possibilities, not findings.

This resolves a question raised, not settled, in Chapter 1. A first-forward difference of roughly 50 ms can be noticeable for a very short workload yet hard to see in the total duration of sixteen much larger uncached decoding steps. The chapter-level observations are compatible in that limited sense; they are not paired experiments with identical prompts and timing boundaries. When the book later reports time to first token (Chapter 36), it must distinguish process cold start, post-load warm-up, request queueing, prefill and transport rather than attaching all of them to one ambiguous “first request” number.

Benchmarks must therefore declare warm-up policy. Include startup when the question is cold-start latency; exclude it when the question is warmed steady-state execution. Neither choice is intrinsically wrong, but mixing them without labels is. A robust report keeps both distributions, the number of processes and requests, and the exact boundaries of each timer.

What the numbers do not show

  • One machine, one session, one CPU thread. Absolute latencies are not portable. Disk state, imported packages, background processes and allocator state were not varied systematically.
  • A Windows high-water mark is not an activation profiler. Peak working set includes allocations outside autograd, and sub-peak allocations may be invisible.
  • Dropout was probed on one input. The 41.68 maximum logit difference and the agreeing argmax are local observations, not error rates.
  • Evaluation mode is not a determinism guarantee. The two evaluated outputs matched in this specific test. Across runs, libraries, hardware or numerical algorithms, bitwise agreement is not guaranteed; Chapter 39 treats reproducibility separately.
  • GPU execution was not measured. CUDA was available, but the model parameters remained on CPU. An earlier result mislabelled availability as execution device; the code now reports the parameter device, and the original result retains an explicit correction note.
  • Manifest completeness is limited. Seven files were enumerated, the loaded tensor digest covered parameters rather than buffers, and the toy loader accepted a missing embedded digest.
  • No production validation. The probes do not establish checkpoint authenticity, safe input handling, provider-side provenance or cold-start behaviour under concurrent load.

Inference Lab increment

The Lab now has two additions to the request record from Chapter 1:

  • file_manifest, parameter_manifest and parameter_digest, which together describe an artefact as hashes and tensor inventory.
  • inference_readiness, which reports module mode, trainable tensors and autograd state.

A future unified request record should carry the selected file hashes, parameter digest, relevant non-parameter state, library and code revisions, and a readiness observation taken during generation. This chapter has implemented the separate manifest and readiness helpers; it has not yet demonstrated that the Chapter 1 request record automatically contains all of those fields. An engineer should not confuse the proposed integrated contract with current measured behaviour. Chapter 3 extends the identity problem to tokenisation, which can change the actual token sequence without changing model weights.

What you should now be able to do

  • List the components of a model artefact beyond its parameters, and say which of them can change behaviour without touching a weight.
  • Explain why file size and parameter count differ, with an example from a real file.
  • Distinguish module mode, global autograd mode and parameter trainability, and say which of them each of eval(), no_grad() and inference_mode() changes.
  • Compute a manifest and a parameter digest for a model and say what each does and does not prove.
  • Split “model load time” into import, load and first-call warm-up, and state which of them a long-lived server amortises.

Key terms

  • Artefact: the files, configuration and code needed to instantiate and execute a particular model, not merely its learned weights.
  • Parameter: a tensor registered as a trainable model parameter; whether it currently receives gradients depends on flags and execution mode.
  • Buffer: registered non-parameter module state, such as a stored causal mask, that can still affect execution.
  • Frozen weights: an operational requirement that parameter values not change during a specified execution path; not synonymous with eval() or no_grad().
  • Computation graph: recorded operations and intermediate relationships used for automatic differentiation.
  • Evaluation mode: a module setting selected with eval() that changes training-sensitive layer behaviour, not a gradient-control mechanism.
  • Inference tensor: a tensor created under torch.inference_mode() with restrictions on some later autograd and mutation operations.
  • Manifest: an explicit, versioned description of selected artefact files or loaded tensor state; completeness must be declared.
  • Cold start: execution that includes one-off process or runtime initialisation costs, with a stated measurement boundary.

Reader exercises

  1. Corrupt one value in the saved toy checkpoint and confirm that loading rejects the unchanged embedded digest. Now remove the sha256 key entirely. Does the current loader accept it? Propose a test and an implementation change that refuse missing digests.
  2. Reformat only the whitespace of the saved toy JSON. Does loading still succeed? Explain why the embedded hash is over canonical checkpoint data rather than the saved file’s exact bytes.
  3. Run execution_modes.py dropout on a module without dropout. Why is agreement there not evidence that training and evaluation modes are interchangeable in general?
  4. Add model.requires_grad_(False) to a copy of the loading path, then test a grad-enabled forward and a deliberate in-place weight update separately. Which kind of work does the flag prevent, and which does it not?
  5. Repeat execution_modes.py modes at 128, 256 and 512 tokens, with multiple fresh processes per mode and length. Graph the increment in process peak, not “bytes saved by autograd”; test linear and quadratic fits without assuming either in advance.
  6. Change one registered model buffer while leaving parameters unchanged. Compare the parameter digest with a digest that explicitly includes named_buffers(). What does each claim actually identify?
  7. Rerun execution_modes.py startup --repeat 5 and document import, load and forward timings separately. Then write a time-to-first-token definition for a long-lived service, naming which costs that metric excludes.

References

Evidence in this chapter

Claim Category / evidential limit
eval() changes training-sensitive layers; grad contexts control graph recording Established background; PyTorch documentation
inference_mode() creates restricted inference tensors Established background; PyTorch documentation
Serialized GPT-2 snapshot has 160 named tensors; 12 additional saved masks occupy 50,331,648 bytes Local file-header inspection, pinned snapshot
Loaded module has 148 named parameter tensors, 124,439,808 elements Local parameter inventory
Parameter digest 95cb2531cd09fbf7… identifies parameters only, not buffers or dtype metadata explicitly Local implementation property; limited identity claim
Train-mode pair differed by up to 41.68 in logits; eval-mode pair agreed Book result, one input and environment
Recorded 512-token process peak rose about 528 MB with autograd, versus 32 MB without Book result, one process per mode; not direct activation memory
First forward median about 154 ms versus later pooled median about 103 ms Book result, five processes; causal mechanism unisolated
Autograd-related total process-peak overhead scales quadratically with length Hypothesis; not established by the 512-token test
Toy checkpoint rejects altered data when the old sha256 remains, but accepts absent hash Code-supported limitation; no authenticated provenance
Model bytes remain unchanged throughout generation Not tested by before/after parameter comparison
GPU behaviour, distributed loading, cross-hardware determinism, production service cold starts Not measured