Expand description
GPT-2 model assembly and generation.
Structs§
- Attn
Step - One block’s attention probabilities for one decode step, read back from the device.
- Gpt2
- Gpt2
Config - KvCache
- Preallocated per-layer K/V tensors (
[n_head, n_ctx, head_dim]) for incremental decode.lenpositions are filled; new tokens append. - Layer
Detail - One block’s Q/K/V, MLP and output tensors for one step, read back from the
device. Captured only for the first
detail_layersblocks — the expensive kinds — whileAttnStepis captured for every block. - Sampler
- Draws tokens from a row of logits, carrying the sampling stream with it.
- Step
Trace - Everything one decode step computed, read back in a single batched round
trip. A strict superset of
AttnStep:attnis exactly whatGpt2::logits_step_attn_asyncreports for the same step. - Surprisal
- Per-position surprisal from
Gpt2::surprisal_async. All three vectors are the length of the input, and index 0 is a placeholder in each — nothing precedes the first token.
Enums§
Functions§
- top_
probs - The
nmost likely next tokens and their probabilities, most likely first.