Run the stack
# grade this stage (from your course directory)
npx theinference test --stage run-the-stack --watchThread the embeddings through all 12 blocks. This is the body of GPT-2 — the hidden states [T, 768] just before the final norm and head. Same shape in, same shape out, twelve times over.
ids[T] ─embed─▶ [T,768] ─block 0─▶ [T,768] ─block 1─▶ … ─block 11─▶ [T,768]
x x x x (return this)
└── each block's output becomes the next block's input ──┘
What to build
Implement runHidden
Implement runHidden(inputIds): embed the input (reuse runEmbeddings), then run all 12 blocks in order (reuse runBlock for layers 0–11), and return the [T, 768] hidden states. No final norm yet.
export function runHidden(inputIds: number[]): number[][] {
// embed -> 12 blocks -> [T, 768]
}
Chain it: let x = embed(ids); for (let l = 0; l < 12; l++) x = runBlock(x, l); return x;. Feeding the original embedding into every block (instead of the running x) still produces a [T, 768] of the right shape but wrong values — and atol 1e-4 will catch it.
Your [T, 768] output is compared with allclose, atol 1e-4. (Errors accumulate across 12 blocks, so the tolerance is looser than the single-block steps.)