Standard reverse-mode stores S×S attention probabilities in high-bandwidth memory between forward and backward passes, dominating activation footprint as context scales.
Recomputes local tiles in SRAM via log-sum-exp statistics
Retains only per-row log-sum-exp accumulators, recomputing P_ij on-chip during backward GQA passes while verifying exact numerical match against full PyTorch autograd.
code/ch11/ch11_kernels_verify.py · Verified vs torch.autograd
Every analytical VJP equation is cross-checked against PyTorch autograd and central finite differences.
FIG. F — Architecture, operating pathStages in record order
01VJP Bridge
Frobenius adjoints · Ch. 01–04
02Attention
Multi-head masked VJP · Ch. 06
03Tiling
Online softmax · SRAM/HBM · Ch. 11
04GQA & RoPE
Group-sum backward · 2D rotation
05Adapters
Quantization · LoRA · MoE top-k
06Synthesis
91M GQA+RoPE+SwiGLU · Ch. 17
FIG. F — The operating path as recorded. Nodes are stages of the system, not claims about deployment.
Engineering decisions — ledger of 3, as recorded. The signal edge marks the rejected alternative in each row.
Ref
Decision — and why
Trade-off accepted
Rejected alternative
A
Test every analytical backward formula against dual controls Checking manual VJPs against both PyTorch autograd and central finite differences catches subtle broadcasting and mixed-precision scaling bugs.
Verification harnesses run slower in FP64 finite-difference mode than standard FP16 training.
Rely on analytical derivations in text without executable numerical checks.
B
Isolate architectural variants inside code/tgd/ Comparing MHA, GQA, LoRA, and quantized linear layers against one shared canonical decoder makes byte and gradient deltas concrete.
Refrains from external framework abstractions in favor of transparent explicit tensor code.
Build chapter demos as disconnected one-off scripts with duplicated blocks.
C
Check vector diagrams cleanly via regenerate_figures.py Computational flow diagrams and Graphviz graphs should regenerate from the verified codebase rather than drifting manually.
Requires Graphviz tool availability when regenerating SVGs.
Maintain static unlinked illustrations separately from verification code.
Revision table — evidence provenance, verbatim from the record
Rev
Evidence
Result
Semantics
A
Chapters 01–17 verification scripts
Numerical & memory-contract reference verification; focused on exact backward derivations rather than custom CUDA kernel occupancy.
17 chapter harnesses cross-checked against PyTorch autograd & central finite diffs
REPRODUCIBLEVerified
B
Chapter 11 tiled attention & GQA kernels
Models algorithmic HBM byte contracts in Python/PyTorch; not a substitute for Nsight Compute silicon profiling.
Explicit SRAM vs HBM traffic modeling and online-softmax backward rescaling check
REPRODUCIBLEVerified
C
Chapter 17 full decoder integration
Reproducible via ch17_model_verify.py at the pinned commit; synthetic training step verification.
REF. — The pinned public artifact. Verification command as recorded; the boundary rows above still apply.
Measurement contract — what would make the preferred answer fail?
EVALUATION METHOD
Reverse-mode autograd derivations are verified only when manual VJPs, cancellation bounds, and tiled memory contracts match dual numerical controls.
Standalone PyTorch verification harnesses (Ch. 01–17) comparing analytical formulas against PyTorch autograd and central finite differences.
01
Autograd parity
manual VJP vs torch.autograd across Ch. 01–1702
Finite-diff margin
central difference numerical check03
Tiled softmax HBM
SRAM rescaling without O(S^2) writeout04
GQA broadcast backward
group-sum gradient identity verified05
Quant & adapter path
FP8/INT8/INT4 · LoRA · MoE routing gradients06
Full 91M synthesis
end-to-end GQA + RoPE + SwiGLU decoder
NOTE 1 — OWNERSHIP.
Personal authored technical monograph & PyTorch verification suite
Published under MIT at github.com/TensorScholar/transformer-backward-pass. Executable verification harnesses for Chapters 1–17.
NOTE 2 — READING. Numbers on this page carry their boundary lines. Quoting a result without its boundary omits its scope.
Exclusions — Not a Triton or CUDA kernel compiler · Not a pre-trained foundational checkpoint release · Hardware occupancy requires silicon profiling outside Python
Prints on paper ink regardless of the active film; recorded output prints expanded.