Audit an Architecture-Family Specification

Audit clean sequences, actual inputs, visibility, Q/K/V sources, target alignment, padding, and forbidden dependencies. Diagnose leakage and source mistakes that preserve valid tensor shapes.

A plausible family name can conceal target leakage, wrong cross-attention sources, unmasked padding, or an undefined readout. Audit the computation from inputs to targets before inspecting model quality.

Write an Evidence Table

ContractEncoder-onlyDecoder-onlyEncoder-decoder
self-attention sourceinputtarget/token streamsource in encoder; target in decoder
causal target maskusually noyesdecoder self-attention only
cross-attention Qabsentabsentdecoder records
cross-attention K,Vabsentabsentencoder records
common outputcontextual recordsnext-token logitsconditional target logits

“Usually” leaves room for declared variants. Any departure needs an explicit mask and objective, not silent reuse of a family label.

Audit in Dependency Order

  1. List clean source and target sequences.
  2. Write the exact tensors presented to each stack.
  3. Draw each attention visibility matrix.
  4. Assign Q, K, and V sources for every attention operation.
  5. Align every logits row with its target.
  6. Mark padding and excluded loss positions.
  7. Verify intermediate and output shapes.
  8. Change one forbidden input and test that an earlier output is unchanged.

Common Failure Signatures

ObservationFirst place to inspect
decoder training loss is nearly zero immediatelytarget shift or leakage
earlier target output changes when a later target changescausal mask or preprocessing
cross-attention score shape is (Tt,Tt)(T_t,T_t)K/V may come from decoder instead of encoder
real-token output changes with extra paddingsource padding mask or pooling
classifier uses an undocumented positionreadout contract
generated output ignores the sourcecross-attention source, mask, or training evidence

Interventions Are Stronger Than Names

For a decoder, alter a later token and compare earlier logits. For an encoder, alter one real token and observe which contextual records may change. For encoder-decoder cross-attention, alter a source record while holding the target prefix fixed. These tests establish computational dependence in a particular implementation; they do not explain everything a trained model represents.

Q1. Diagnose a cross-attention source bug

A cross-attention layer has score shape (B,Tt,Tt)(B,T_t,T_t) even though TsTtT_s\ne T_t. Which source assignment should you inspect first?

Choose the first source assignment to inspect

Select one choice, then check.

Hint
Cross-attention columns correspond to encoder positions.
Solution
Inspect whether KK and VV were projected from decoder records. They should come from encoder records and produce TsT_s columns.
Not attempted
Review

Not marked done.

Carry the Family Contract Forward

Chapter 6 fixes the decoder-only contract, including its token shift, final normalization, vocabulary projection, and loss. The family audit developed here becomes the first layer of that end-to-end model audit.

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerAudit an Architecture-Family Specificationhttps://llmprimer.com/transformers/transformer-architecture-families/audit-an-architecture-family-specification© 2026 LLM Primer