The neural notebook
← All chapters

IV-59 / Part XV · Modern LLM Architectures

Decoder-Only Transformer Anatomy

Follow two real feature-processing blocks from repeated token IDs to causal attention, three-coordinate feed-forward layers and stable next-token probabilities.

Review the ideas this chapter uses

Suppose the observed input is a, a. Both items have the same name, but they occupy different places. How can the second block receive different information at those places without changing either token’s identity? We will follow two feature rows from lookup to a next-token recommendation, keeping every stage small enough to inspect by hand.

Learning objective: Locate embeddings, repeated blocks, output head and causal decoding.

The parameters below are hand-set and untrained. This is one disclosed decoder-only toy, with two forward blocks and a three-token vocabulary. It calculates a recommendation; it does not append a token or run a generation loop. Two blocks are two stages within one forward calculation, not two decoded tokens.

Compute it yourself

Decoder-Only Transformer Anatomy

Follow two observed token IDs through an embedding lookup, absolute position addition, two distinct causal blocks and a three-class readout. Edit a token or position value first; expand each gain or bias group to change the hand-set toy parameters. The same actual saved calculation supplies the graph, tables, selected operation and five graded questions.

The two token menus admit only a / 97, b / 98 and observed EOS / 512. positionScale accepts finite numbers in [0,1], all ten gains in [-1,1], and all three biases in [-2,2]. All fourteen numeric operands admit -0 and preserve its saved sign. An invalid, out-of-range or unfinished draft keeps the last valid input state internally while withholding all computed results, trace, evidence and questions. Fix it or use Reset example. Reset restores the declared default; editing, reset and trace selection clear answers.

nextTokenId97
nextTokenProbability0.804004634821441
blockCount2
observedPositions2
Block 1 gains
Block 2 gains
Three-class readout biases
Exact starting inputs for this saved calculation

nextTokenId 97. nextTokenProbability 0.804004634821441. blockCount 2. observedPositions 2. Capture the complete two-block decoder toy. Sixteen actual finite inputs are captured before domains. Both observed positions traverse both pre-norm blocks, every width-three FFN coordinate and the same three-class readout. These owner-authored parameters are hand-set; no training or generation step is hidden.

Capture the complete two-block decoder toy

X0=E[observedIds]+P; Y1=block1(X0); Y2=block2(Y1); logits=Y2*U+bias; probabilities=stableClassSoftmax(logits)

Sixteen actual finite inputs are captured before domains. Both observed positions traverse both pre-norm blocks, every width-three FFN coordinate and the same three-class readout. These owner-authored parameters are hand-set; no training or generation step is hidden.

Saved inputs

token0
97
token1
97
positionScale
0.5
q1
1
k1
1
v1
1
o1
0.5
f1
0.5
q2
1
k2
0.5
v2
1
o2
0.25
f2
0.25
biasA
0
biasB
0
biasEOS
0

Saved outputs

token0
97
token1
97
positionScale
0.5
q1
1
k1
1
v1
1
o1
0.5
f1
0.5
q2
1
k2
0.5
v2
1
o2
0.25
f2
0.25
biasA
0
biasB
0
biasEOS
0
B
1
T
2
D
2
H
1
Dk
2
Dv
2
M
3
Vocab
3
blockCount
2
rawInputCount
16

Selected saved step setup. Capture the complete two-block decoder toy. Equation: X0=E[observedIds]+P; Y1=block1(X0); Y2=block2(Y1); logits=Y2*U+bias; probabilities=stableClassSoftmax(logits). Sixteen actual finite inputs are captured before domains. Both observed positions traverse both pre-norm blocks, every width-three FFN coordinate and the same three-class readout. These owner-authored parameters are hand-set; no training or generation step is hidden. Saved inputs: token0=97; token1=97; positionScale=0.5; q1=1; k1=1; v1=1; o1=0.5; f1=0.5; q2=1; k2=0.5; v2=1; o2=0.25; f2=0.25; biasA=0; biasB=0; biasEOS=0. Saved outputs: token0=97; token1=97; positionScale=0.5; q1=1; k1=1; v1=1; o1=0.5; f1=0.5; q2=1; k2=0.5; v2=1; o2=0.25; f2=0.25; biasA=0; biasB=0; biasEOS=0; B=1; T=2; D=2; H=1; Dk=2; Dv=2; M=3; Vocab=3; blockCount=2; rawInputCount=16.

Eight stages from the same saved root

B=1 is the batch count; T=2 counts observed positions; D=2 counts features; H=1 is the attention head count. Each head uses Dk=Dv=2 query/key and value coordinates. The class axis has three entries in ascending public-ID order. This diagram follows the actual toy tensors; two blocks are two levels of feature computation.

  1. Observed token IDs
    decoder_TokenIds · [1,2]
    97, 97
  2. Embedding lookup
    decoder_Embeddings · [1,2,2]
    1, 0, 1, 0
  3. Absolute position addition
    decoder_Features · [1,2,2]
    1, 0, 1, 0.5
  4. Pre-norm causal block 1
    decoder_block1_Output · [1,2,2]
    1.7849814953237821, -0.35355339059327373, 1.6620067484160792, 0.2060920369795486
  5. Pre-norm causal block 2
    decoder_block2_Output · [1,2,2]
    2.2446825997084527, -0.5800172539239893, 2.0994655028551374, -0.01041853568410156
  6. Three-class readout
    decoder_Logits · [1,2,3]
    2.2446825997084527, -0.5800172539239893, 0, 2.0994655028551374, -0.01041853568410156, 0
  7. Stable class probabilities
    decoder_Probabilities · [1,2,3]
    0.8581572274855295, 0.050911431098732265, 0.09093134141573832, 0.804004634821441, 0.09748719103040979, 0.09850817414814908
  8. Last-row greedy recommendation
    decoder_ArgmaxIds · [1,2]
    97, 97
Lookup once, then add the actual absolute position row
Observed positionPublic IDEmbedding rowPosition rowX0 = embedding + position
097[1, 0][0, 0][1, 0]
197[1, 0][0, 0.5][1, 0.5]

Token IDs select E rows: a=97, b=98 and EOS=512. An observed EOS uses its explicit [0,0] embedding; it does not trigger generation stopping. This toy adds absolute positions, unlike IV-43’s RoPE. Repeated IDs share an embedding lookup, while their positioned and contextual features can differ.

Block 1: X0 → Y1

Both pre-norm blocks compute the same sequence with separate gains. A residual adds a branch to its unchanged input row. Each LayerNorm uses that position’s two features, population variance, epsilon 1/4, gamma=[1,1] and beta=[0,0]. FFN means feed-forward network; its hidden width is three, and ReLU keeps positive values and maps nonpositive values to zero.

decoder_block1: both per-position feature paths
Saved boundaryPosition 0Position 1
Input features · Features[1, 0][1, 0.5]
First LayerNorm output · n1_Output[0.7071067811865475, -0.7071067811865475][0.4472135954999579, -0.4472135954999579]
Attention branch after WO · attn_Y[0.35355339059327373, -0.35355339059327373][0.2939079630204514, -0.2939079630204514]
First residual R1 · R1[1.3535533905932737, -0.35355339059327373][1.2939079630204513, 0.2060920369795486]
Second LayerNorm output · n2_Output[0.8628562094610168, -0.8628562094610168][0.7361975707912559, -0.7361975707912561]
Hidden affine values · ffn_Z[0.8628562094610168, -0.8628562094610168, 0][0.7361975707912559, -0.7361975707912561, 0]
Hidden ReLU activations · ffn_Hidden[0.8628562094610168, 0, 0][0.7361975707912559, 0, 0]
FFN output branch · ffn_F[0.4314281047305084, 0][0.36809878539562796, 0]
Second residual / block output · Output[1.7849814953237821, -0.35355339059327373][1.6620067484160792, 0.2060920369795486]
decoder_block1: every causal score, mask and attention probability
Query positionKey positionQK dot productScaled scoreAllowedSaved attention logitAttention probability
000.99999999999999980.7071067811865474true0.70710678118654741
010.63245553203367580.4472135954999578false0.44721359549995780
100.63245553203367580.4472135954999578true0.44721359549995780.5410004505100806
110.399999999999999970.28284271247461895true0.282842712474618950.4589995494899193

Q, K and V are the query, key and value projections. Query i can use key j only when j≤i. The forbidden future score is still calculated; its mask is false, its exponential is omitted and its probability is exact +0. The tables below retain all expanded WQ/WK/WV/WO, Q/K/V copies, weighted values and both norm statistic rows. W1=[2,3] and W2=[3,2] retain the third hidden coordinate even when it is zero. Zero gains never bypass these operations.

All 47 saved tensors for this block: complete matrices, norms, width-three FFN and native copies

decoder_block1_Features

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual captured per-position block features; repeated token IDs do not merge positions.

decoder_block1_Features: complete saved storage
Outer row (zero-based)D 0D 1
010
110.5

decoder_block1_Gains

Gain=5 · shape [5] · float64 · declared display precision 8 · 5 stored cells

Actual q,k,v,o,f gain words; diagonal slots copy these words and off-diagonal slots are literal +0.

decoder_block1_Gains: complete saved storage
Outer row (zero-based)qkvof
01110.50.5

decoder_block1_n1_Gamma

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature scales [1,1].

decoder_block1_n1_Gamma: complete saved storage
Outer row (zero-based)D 0D 1
011

decoder_block1_n1_Beta

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature offsets [+0,+0].

decoder_block1_n1_Beta: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block1_n1_Statistics

B=1 × T=2 × NormStatistic=10 · shape [1,2,10] · float64 · declared display precision 8 · 20 stored cells

Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

decoder_block1_n1_Statistics: complete saved storage
Outer row (zero-based)summeancentered0centered1square0square1squareSumvariancevariancePlusEpsilondenominator
010.50.5-0.50.250.250.50.250.50.7071067811865476
11.50.750.25-0.250.06250.06250.1250.06250.31250.5590169943749475

decoder_block1_n1_Centered

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual saved input feature minus feature mean, before division.

decoder_block1_n1_Centered: complete saved storage
Outer row (zero-based)D 0D 1
00.5-0.5
10.25-0.25

decoder_block1_n1_Normalized

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual centered/denominator words before gamma multiplication and beta addition.

decoder_block1_n1_Normalized: complete saved storage
Outer row (zero-based)D 0D 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_n1_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

decoder_block1_n1_Output: complete saved storage
Outer row (zero-based)D 0D 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_X

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Active token rows; D=2 input features always retained.

decoder_block1_attn_X: complete saved storage
Outer row (zero-based)D 0D 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_WQ

D=2 × QueryFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Query columns packed by h*Dk+f from wq{d}{h}{f}.

decoder_block1_attn_WQ: complete saved storage
Outer row (zero-based)QueryFeature 0QueryFeature 1
010
101

decoder_block1_attn_WK

D=2 × KeyFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Key columns packed by h*Dk+f from wk{d}{h}{f}.

decoder_block1_attn_WK: complete saved storage
Outer row (zero-based)KeyFeature 0KeyFeature 1
010
101

decoder_block1_attn_WV

D=2 × ValueFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Value columns packed by h*Dv+f from wv{d}{h}{f}.

decoder_block1_attn_WV: complete saved storage
Outer row (zero-based)ValueFeature 0ValueFeature 1
010
101

decoder_block1_attn_QConcat

B=1 × T=2 × QueryFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWQ; each packed coordinate has two products and one sum.

decoder_block1_attn_QConcat: complete saved storage
Outer row (zero-based)QueryFeature 0QueryFeature 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_KConcat

B=1 × T=2 × KeyFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWK; each packed coordinate has two products and one sum.

decoder_block1_attn_KConcat: complete saved storage
Outer row (zero-based)KeyFeature 0KeyFeature 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_VConcat

B=1 × T=2 × ValueFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWV; values are projected separately from queries and keys.

decoder_block1_attn_VConcat: complete saved storage
Outer row (zero-based)ValueFeature 0ValueFeature 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_QSplit

B=1 × T=2 × H=1 × Dk=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

QConcat reshaped without changing flat order; feature=h*F+f.

decoder_block1_attn_QSplit: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_QHeads

B=1 × H=1 × T=2 × Dk=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

QSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block1_attn_QHeads: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_KSplit

B=1 × T=2 × H=1 × Dk=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

KConcat reshaped without changing flat order; feature=h*F+f.

decoder_block1_attn_KSplit: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_KHeads

B=1 × H=1 × T=2 × Dk=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

KSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block1_attn_KHeads: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_VSplit

B=1 × T=2 × H=1 × Dv=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

VConcat reshaped without changing flat order; feature=h*F+f.

decoder_block1_attn_VSplit: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_VHeads

B=1 × H=1 × T=2 × Dv=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

VSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block1_attn_VHeads: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.7071067811865475-0.7071067811865475
10.4472135954999579-0.4472135954999579

decoder_block1_attn_raw

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Separate QHeads KHeads transpose products within every batch and head.

decoder_block1_attn_raw: complete saved storage
Outer row (zero-based)Key 0Key 1
00.99999999999999980.6324555320336758
10.63245553203367580.39999999999999997

decoder_block1_attn_scores

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

raw/sqrt(Dk); the two-product order matches IV25 for H1,Dk2.

decoder_block1_attn_scores: complete saved storage
Outer row (zero-based)Key 0Key 1
00.70710678118654740.4472135954999578
10.44721359549995780.28284271247461895

decoder_block1_attn_allowed

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · bool · declared display precision 8 · 4 stored cells

Causal and/or valid-key mask; shared validity across B and H; every query retained.

decoder_block1_attn_allowed: complete saved storage
Outer row (zero-based)Key 0Key 1
0truefalse
1truetrue

decoder_block1_attn_logits

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Finite score+shift, including forbidden cells; mask applied separately.

decoder_block1_attn_logits: complete saved storage
Outer row (zero-based)Key 0Key 1
00.70710678118654740.4472135954999578
10.44721359549995780.28284271247461895

decoder_block1_attn_probabilities

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Stable allowed-key softmax for each B/H/query independently; forbidden probabilities exactly zero.

decoder_block1_attn_probabilities: complete saved storage
Outer row (zero-based)Key 0Key 1
010
10.54100045051008060.4589995494899193

decoder_block1_attn_OHeads

B=1 × H=1 × Query=2 × Dv=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-head P times VHeads; every product and running sum is traced.

decoder_block1_attn_OHeads: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.7071067811865475-0.7071067811865475
10.5878159260409028-0.5878159260409028

decoder_block1_attn_C

B=1 × T=2 × JoinedValue=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

OHeads permuted to token-major order then joined by c=h*Dv+f; values unchanged.

decoder_block1_attn_C: complete saved storage
Outer row (zero-based)JoinedValue 0JoinedValue 1
00.7071067811865475-0.7071067811865475
10.5878159260409028-0.5878159260409028

decoder_block1_attn_WO

JoinedValue=2 × D=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

wo{h}{f}{d} packed in h,f,d order, preserving parameter identity.

decoder_block1_attn_WO: complete saved storage
Outer row (zero-based)D 0D 1
00.50
100.5

decoder_block1_attn_Y

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Y=C WO, summing products in ascending joined-feature order from zero; no normalization.

decoder_block1_attn_Y: complete saved storage
Outer row (zero-based)D 0D 1
00.35355339059327373-0.35355339059327373
10.2939079630204514-0.2939079630204514

decoder_block1_R1

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Exact named-shape addition of decoder_block1_Features and decoder_block1_attn_Y; no broadcasting.

decoder_block1_R1: complete saved storage
Outer row (zero-based)D 0D 1
01.3535533905932737-0.35355339059327373
11.29390796302045130.2060920369795486

decoder_block1_n2_Gamma

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature scales [1,1].

decoder_block1_n2_Gamma: complete saved storage
Outer row (zero-based)D 0D 1
011

decoder_block1_n2_Beta

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature offsets [+0,+0].

decoder_block1_n2_Beta: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block1_n2_Statistics

B=1 × T=2 × NormStatistic=10 · shape [1,2,10] · float64 · declared display precision 8 · 20 stored cells

Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

decoder_block1_n2_Statistics: complete saved storage
Outer row (zero-based)summeancentered0centered1square0square1squareSumvariancevariancePlusEpsilondenominator
010.50.8535533905932737-0.85355339059327370.72855339059327370.72855339059327371.45710678118654750.72855339059327370.97855339059327370.9892185757421227
11.50.750.5439079630204513-0.54390796302045140.29583587223705660.295835872237056760.59167174447411330.295835872237056650.54583587223705670.738807060224154

decoder_block1_n2_Centered

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual saved input feature minus feature mean, before division.

decoder_block1_n2_Centered: complete saved storage
Outer row (zero-based)D 0D 1
00.8535533905932737-0.8535533905932737
10.5439079630204513-0.5439079630204514

decoder_block1_n2_Normalized

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual centered/denominator words before gamma multiplication and beta addition.

decoder_block1_n2_Normalized: complete saved storage
Outer row (zero-based)D 0D 1
00.8628562094610168-0.8628562094610168
10.7361975707912559-0.7361975707912561

decoder_block1_n2_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

decoder_block1_n2_Output: complete saved storage
Outer row (zero-based)D 0D 1
00.8628562094610168-0.8628562094610168
10.7361975707912559-0.7361975707912561

decoder_block1_ffn_W1

D=2 × HiddenFeature=3 · shape [2,3] · float64 · declared display precision 8 · 6 stored cells

Shared input-to-hidden weights, f1{d}{m}; M=3 hidden features.

decoder_block1_ffn_W1: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
0100
1010

decoder_block1_ffn_b1

HiddenFeature=3 · shape [3] · float64 · declared display precision 8 · 3 stored cells

Shared hidden bias, added after the two products.

decoder_block1_ffn_b1: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
0000

decoder_block1_ffn_Z

B=1 × T=2 × HiddenFeature=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Hidden preactivations X W1+b1; no batch or token mixing.

decoder_block1_ffn_Z: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
00.8628562094610168-0.86285620946101680
10.7361975707912559-0.73619757079125610

decoder_block1_ffn_Hidden

B=1 × T=2 × HiddenFeature=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

ReLU(Z)=max(0,Z), before the second affine layer.

decoder_block1_ffn_Hidden: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
00.862856209461016800
10.736197570791255900

decoder_block1_ffn_W2

HiddenFeature=3 × D=2 · shape [3,2] · float64 · declared display precision 8 · 6 stored cells

Shared hidden-to-output weights, f2{m}{d}.

decoder_block1_ffn_W2: complete saved storage
Outer row (zero-based)D 0D 1
00.50
100.5
200

decoder_block1_ffn_b2

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared output bias, added after all three running sums.

decoder_block1_ffn_b2: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block1_ffn_F

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

ReLU(X W1+b1) W2+b2, independently per token with shared parameters.

decoder_block1_ffn_F: complete saved storage
Outer row (zero-based)D 0D 1
00.43142810473050840
10.368098785395627960

decoder_block1_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Exact named-shape addition of decoder_block1_R1 and decoder_block1_ffn_F; no broadcasting.

decoder_block1_Output: complete saved storage
Outer row (zero-based)D 0D 1
01.7849814953237821-0.35355339059327373
11.66200674841607920.2060920369795486

decoder_block1_NativeArguments

Native=8 × NativeField=2 · shape [8,2] · float64 · declared display precision 8 · 16 stored cells

Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

decoder_block1_NativeArguments: complete saved storage
Outer row (zero-based)inputoutput
00.50.7071067811865476
10.31250.5590169943749475
221.4142135623730951
301
401
5-0.164370883025338870.8484272962382063
60.97855339059327370.9892185757421227
70.54583587223705670.738807060224154

decoder_block1_NativeKinds

Native=8 · shape [8] · int32 · declared display precision 0 · 8 stored cells

Native kind codes in native occurrence order: sqrt=0, exp=1.

decoder_block1_NativeKinds: complete saved storage
Outer row (zero-based)Native 0Native 1Native 2Native 3Native 4Native 5Native 6Native 7
000011100
Actual Y1 handoff: block 1 output and block 2 input
PositionY1 = block 1 outputActual block 2 captured features
0[1.7849814953237821, -0.35355339059327373][1.7849814953237821, -0.35355339059327373]
1[1.6620067484160792, 0.2060920369795486][1.6620067484160792, 0.2060920369795486]

Block 2 receives these actual Y1 words at each position. It does not look up the IDs again or consume predicted IDs or logits.

Block 2: actual Y1 → Y2

Both pre-norm blocks compute the same sequence with separate gains. A residual adds a branch to its unchanged input row. Each LayerNorm uses that position’s two features, population variance, epsilon 1/4, gamma=[1,1] and beta=[0,0]. FFN means feed-forward network; its hidden width is three, and ReLU keeps positive values and maps nonpositive values to zero.

decoder_block2: both per-position feature paths
Saved boundaryPosition 0Position 1
Input features · Features[1.7849814953237821, -0.35355339059327373][1.6620067484160792, 0.2060920369795486]
First LayerNorm output · n1_Output[0.9058554533228621, -0.9058554533228621][0.8242906579156054, -0.8242906579156055]
Attention branch after WO · attn_Y[0.22646386333071553, -0.22646386333071553][0.21651057266365012, -0.21651057266365015]
First residual R1 · R1[2.011445358654498, -0.5800172539239893][1.8785173210797292, -0.01041853568410156]
Second LayerNorm output · n2_Output[0.9329489642158189, -0.9329489642158191][0.8837927271016323, -0.8837927271016323]
Hidden affine values · ffn_Z[0.9329489642158189, -0.9329489642158191, 0][0.8837927271016323, -0.8837927271016323, 0]
Hidden ReLU activations · ffn_Hidden[0.9329489642158189, 0, 0][0.8837927271016323, 0, 0]
FFN output branch · ffn_F[0.2332372410539547, 0][0.22094818177540806, 0]
Second residual / block output · Output[2.2446825997084527, -0.5800172539239893][2.0994655028551374, -0.01041853568410156]
decoder_block2: every causal score, mask and attention probability
Query positionKey positionQK dot productScaled scoreAllowedSaved attention logitAttention probability
000.8205741023147680.5802335122128363true0.58023351221283631
010.7466881875959410.5279882808809828false0.52798828088098280
100.7466881875959410.5279882808809828true0.52798828088098280.511883007007217
110.67945508872694170.4804473007505278true0.48044730075052780.4881169929927831

Q, K and V are the query, key and value projections. Query i can use key j only when j≤i. The forbidden future score is still calculated; its mask is false, its exponential is omitted and its probability is exact +0. The tables below retain all expanded WQ/WK/WV/WO, Q/K/V copies, weighted values and both norm statistic rows. W1=[2,3] and W2=[3,2] retain the third hidden coordinate even when it is zero. Zero gains never bypass these operations.

All 47 saved tensors for this block: complete matrices, norms, width-three FFN and native copies

decoder_block2_Features

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual captured per-position block features; repeated token IDs do not merge positions.

decoder_block2_Features: complete saved storage
Outer row (zero-based)D 0D 1
01.7849814953237821-0.35355339059327373
11.66200674841607920.2060920369795486

decoder_block2_Gains

Gain=5 · shape [5] · float64 · declared display precision 8 · 5 stored cells

Actual q,k,v,o,f gain words; diagonal slots copy these words and off-diagonal slots are literal +0.

decoder_block2_Gains: complete saved storage
Outer row (zero-based)qkvof
010.510.250.25

decoder_block2_n1_Gamma

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature scales [1,1].

decoder_block2_n1_Gamma: complete saved storage
Outer row (zero-based)D 0D 1
011

decoder_block2_n1_Beta

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature offsets [+0,+0].

decoder_block2_n1_Beta: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block2_n1_Statistics

B=1 × T=2 × NormStatistic=10 · shape [1,2,10] · float64 · declared display precision 8 · 20 stored cells

Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

decoder_block2_n1_Statistics: complete saved storage
Outer row (zero-based)summeancentered0centered1square0square1squareSumvariancevariancePlusEpsilondenominator
01.43142810473050840.71571405236525421.069267442958528-1.0692674429585281.1433328645710691.1433328645710692.2866657291421381.1433328645710691.3933328645710691.180395215413494
11.8680987853956280.9340493926978140.7279573557182653-0.72795735571826540.5299219117443290.52992191174432911.0598438234886580.5299219117443290.7799219117443290.8831318767569932

decoder_block2_n1_Centered

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual saved input feature minus feature mean, before division.

decoder_block2_n1_Centered: complete saved storage
Outer row (zero-based)D 0D 1
01.069267442958528-1.069267442958528
10.7279573557182653-0.7279573557182654

decoder_block2_n1_Normalized

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual centered/denominator words before gamma multiplication and beta addition.

decoder_block2_n1_Normalized: complete saved storage
Outer row (zero-based)D 0D 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_n1_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

decoder_block2_n1_Output: complete saved storage
Outer row (zero-based)D 0D 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_X

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Active token rows; D=2 input features always retained.

decoder_block2_attn_X: complete saved storage
Outer row (zero-based)D 0D 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_WQ

D=2 × QueryFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Query columns packed by h*Dk+f from wq{d}{h}{f}.

decoder_block2_attn_WQ: complete saved storage
Outer row (zero-based)QueryFeature 0QueryFeature 1
010
101

decoder_block2_attn_WK

D=2 × KeyFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Key columns packed by h*Dk+f from wk{d}{h}{f}.

decoder_block2_attn_WK: complete saved storage
Outer row (zero-based)KeyFeature 0KeyFeature 1
00.50
100.5

decoder_block2_attn_WV

D=2 × ValueFeature=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

Value columns packed by h*Dv+f from wv{d}{h}{f}.

decoder_block2_attn_WV: complete saved storage
Outer row (zero-based)ValueFeature 0ValueFeature 1
010
101

decoder_block2_attn_QConcat

B=1 × T=2 × QueryFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWQ; each packed coordinate has two products and one sum.

decoder_block2_attn_QConcat: complete saved storage
Outer row (zero-based)QueryFeature 0QueryFeature 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_KConcat

B=1 × T=2 × KeyFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWK; each packed coordinate has two products and one sum.

decoder_block2_attn_KConcat: complete saved storage
Outer row (zero-based)KeyFeature 0KeyFeature 1
00.45292772666143105-0.45292772666143105
10.4121453289578027-0.41214532895780276

decoder_block2_attn_VConcat

B=1 × T=2 × ValueFeature=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

XWV; values are projected separately from queries and keys.

decoder_block2_attn_VConcat: complete saved storage
Outer row (zero-based)ValueFeature 0ValueFeature 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_QSplit

B=1 × T=2 × H=1 × Dk=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

QConcat reshaped without changing flat order; feature=h*F+f.

decoder_block2_attn_QSplit: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_QHeads

B=1 × H=1 × T=2 × Dk=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

QSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block2_attn_QHeads: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_KSplit

B=1 × T=2 × H=1 × Dk=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

KConcat reshaped without changing flat order; feature=h*F+f.

decoder_block2_attn_KSplit: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.45292772666143105-0.45292772666143105
10.4121453289578027-0.41214532895780276

decoder_block2_attn_KHeads

B=1 × H=1 × T=2 × Dk=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

KSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block2_attn_KHeads: complete saved storage
Outer row (zero-based)Dk 0Dk 1
00.45292772666143105-0.45292772666143105
10.4121453289578027-0.41214532895780276

decoder_block2_attn_VSplit

B=1 × T=2 × H=1 × Dv=2 · shape [1,2,1,2] · float64 · declared display precision 8 · 4 stored cells

VConcat reshaped without changing flat order; feature=h*F+f.

decoder_block2_attn_VSplit: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_VHeads

B=1 × H=1 × T=2 × Dv=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

VSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

decoder_block2_attn_VHeads: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.9058554533228621-0.9058554533228621
10.8242906579156054-0.8242906579156055

decoder_block2_attn_raw

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Separate QHeads KHeads transpose products within every batch and head.

decoder_block2_attn_raw: complete saved storage
Outer row (zero-based)Key 0Key 1
00.8205741023147680.746688187595941
10.7466881875959410.6794550887269417

decoder_block2_attn_scores

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

raw/sqrt(Dk); the two-product order matches IV25 for H1,Dk2.

decoder_block2_attn_scores: complete saved storage
Outer row (zero-based)Key 0Key 1
00.58023351221283630.5279882808809828
10.52798828088098280.4804473007505278

decoder_block2_attn_allowed

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · bool · declared display precision 8 · 4 stored cells

Causal and/or valid-key mask; shared validity across B and H; every query retained.

decoder_block2_attn_allowed: complete saved storage
Outer row (zero-based)Key 0Key 1
0truefalse
1truetrue

decoder_block2_attn_logits

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Finite score+shift, including forbidden cells; mask applied separately.

decoder_block2_attn_logits: complete saved storage
Outer row (zero-based)Key 0Key 1
00.58023351221283630.5279882808809828
10.52798828088098280.4804473007505278

decoder_block2_attn_probabilities

B=1 × H=1 × Query=2 × Key=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Stable allowed-key softmax for each B/H/query independently; forbidden probabilities exactly zero.

decoder_block2_attn_probabilities: complete saved storage
Outer row (zero-based)Key 0Key 1
010
10.5118830070072170.4881169929927831

decoder_block2_attn_OHeads

B=1 × H=1 × Query=2 × Dv=2 · shape [1,1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-head P times VHeads; every product and running sum is traced.

decoder_block2_attn_OHeads: complete saved storage
Outer row (zero-based)Dv 0Dv 1
00.9058554533228621-0.9058554533228621
10.8660422906546005-0.8660422906546006

decoder_block2_attn_C

B=1 × T=2 × JoinedValue=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

OHeads permuted to token-major order then joined by c=h*Dv+f; values unchanged.

decoder_block2_attn_C: complete saved storage
Outer row (zero-based)JoinedValue 0JoinedValue 1
00.9058554533228621-0.9058554533228621
10.8660422906546005-0.8660422906546006

decoder_block2_attn_WO

JoinedValue=2 × D=2 · shape [2,2] · float64 · declared display precision 8 · 4 stored cells

wo{h}{f}{d} packed in h,f,d order, preserving parameter identity.

decoder_block2_attn_WO: complete saved storage
Outer row (zero-based)D 0D 1
00.250
100.25

decoder_block2_attn_Y

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Y=C WO, summing products in ascending joined-feature order from zero; no normalization.

decoder_block2_attn_Y: complete saved storage
Outer row (zero-based)D 0D 1
00.22646386333071553-0.22646386333071553
10.21651057266365012-0.21651057266365015

decoder_block2_R1

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Exact named-shape addition of decoder_block2_Features and decoder_block2_attn_Y; no broadcasting.

decoder_block2_R1: complete saved storage
Outer row (zero-based)D 0D 1
02.011445358654498-0.5800172539239893
11.8785173210797292-0.01041853568410156

decoder_block2_n2_Gamma

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature scales [1,1].

decoder_block2_n2_Gamma: complete saved storage
Outer row (zero-based)D 0D 1
011

decoder_block2_n2_Beta

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared literal feature offsets [+0,+0].

decoder_block2_n2_Beta: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block2_n2_Statistics

B=1 × T=2 × NormStatistic=10 · shape [1,2,10] · float64 · declared display precision 8 · 20 stored cells

Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

decoder_block2_n2_Statistics: complete saved storage
Outer row (zero-based)summeancentered0centered1square0square1squareSumvariancevariancePlusEpsilondenominator
01.43142810473050860.71571405236525431.2957313062892435-1.29573130628924371.67891961809802931.678919618098033.35783923619605941.67891961809802971.92891961809802971.3888555065585584
11.86809878539562770.93404939269781380.9444679283819154-0.94446792838191540.89201966774202690.89201966774202691.78403933548405380.89201966774202691.1420196677420271.0686532027472837

decoder_block2_n2_Centered

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual saved input feature minus feature mean, before division.

decoder_block2_n2_Centered: complete saved storage
Outer row (zero-based)D 0D 1
01.2957313062892435-1.2957313062892437
10.9444679283819154-0.9444679283819154

decoder_block2_n2_Normalized

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual centered/denominator words before gamma multiplication and beta addition.

decoder_block2_n2_Normalized: complete saved storage
Outer row (zero-based)D 0D 1
00.9329489642158189-0.9329489642158191
10.8837927271016323-0.8837927271016323

decoder_block2_n2_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

decoder_block2_n2_Output: complete saved storage
Outer row (zero-based)D 0D 1
00.9329489642158189-0.9329489642158191
10.8837927271016323-0.8837927271016323

decoder_block2_ffn_W1

D=2 × HiddenFeature=3 · shape [2,3] · float64 · declared display precision 8 · 6 stored cells

Shared input-to-hidden weights, f1{d}{m}; M=3 hidden features.

decoder_block2_ffn_W1: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
0100
1010

decoder_block2_ffn_b1

HiddenFeature=3 · shape [3] · float64 · declared display precision 8 · 3 stored cells

Shared hidden bias, added after the two products.

decoder_block2_ffn_b1: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
0000

decoder_block2_ffn_Z

B=1 × T=2 × HiddenFeature=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Hidden preactivations X W1+b1; no batch or token mixing.

decoder_block2_ffn_Z: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
00.9329489642158189-0.93294896421581910
10.8837927271016323-0.88379272710163230

decoder_block2_ffn_Hidden

B=1 × T=2 × HiddenFeature=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

ReLU(Z)=max(0,Z), before the second affine layer.

decoder_block2_ffn_Hidden: complete saved storage
Outer row (zero-based)HiddenFeature 0HiddenFeature 1HiddenFeature 2
00.932948964215818900
10.883792727101632300

decoder_block2_ffn_W2

HiddenFeature=3 × D=2 · shape [3,2] · float64 · declared display precision 8 · 6 stored cells

Shared hidden-to-output weights, f2{m}{d}.

decoder_block2_ffn_W2: complete saved storage
Outer row (zero-based)D 0D 1
00.250
100.25
200

decoder_block2_ffn_b2

D=2 · shape [2] · float64 · declared display precision 8 · 2 stored cells

Shared output bias, added after all three running sums.

decoder_block2_ffn_b2: complete saved storage
Outer row (zero-based)D 0D 1
000

decoder_block2_ffn_F

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

ReLU(X W1+b1) W2+b2, independently per token with shared parameters.

decoder_block2_ffn_F: complete saved storage
Outer row (zero-based)D 0D 1
00.23323724105395470
10.220948181775408060

decoder_block2_Output

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Exact named-shape addition of decoder_block2_R1 and decoder_block2_ffn_F; no broadcasting.

decoder_block2_Output: complete saved storage
Outer row (zero-based)D 0D 1
02.2446825997084527-0.5800172539239893
12.0994655028551374-0.01041853568410156

decoder_block2_NativeArguments

Native=8 × NativeField=2 · shape [8,2] · float64 · declared display precision 8 · 16 stored cells

Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

decoder_block2_NativeArguments: complete saved storage
Outer row (zero-based)inputoutput
01.3933328645710691.180395215413494
10.7799219117443290.8831318767569932
221.4142135623730951
301
401
5-0.0475409801304550460.953571394851756
61.92891961809802971.3888555065585584
71.1420196677420271.0686532027472837

decoder_block2_NativeKinds

Native=8 · shape [8] · int32 · declared display precision 0 · 8 stored cells

Native kind codes in native occurrence order: sqrt=0, exp=1.

decoder_block2_NativeKinds: complete saved storage
Outer row (zero-based)Native 0Native 1Native 2Native 3Native 4Native 5Native 6Native 7
000011100

All three classes at both positions

The hand-set readout U has shape [D,Vocab]=[2,3]. Each class uses two feature products, their sum and its bias last. Stable softmax shifts by that row’s saved maximum, exponentiates, adds three terms in order starting from +0, then divides by the saved denominator. The winner comes from the actual logits; equal logits retain the smallest public ID.

Every saved readout coordinate and class probability
PositionPublic classProduct 0Product 1Saved sumBiasLogitShifted logitExp termFinal denominatorProbability
0a / 972.2446825997084527-02.244682599708452702.2446825997084527011.16528762792114620.8581572274855295
0b / 980-0.5800172539239893-0.58001725392398930-0.5800172539239893-2.8246998536324420.059326460779112591.16528762792114620.050911431098732265
0EOS / 5120-0000-2.24468259970845270.105961167142033571.16528762792114620.09093134141573832
1a / 972.0994655028551374-02.099465502855137402.0994655028551374011.24377392453973480.804004634821441
1b / 980-0.01041853568410156-0.010418535684101560-0.01041853568410156-2.1098840385392390.121252026180247611.24377392453973480.09748719103040979
1EOS / 5120-0000-2.09946550285513740.122521898359487031.24377392453973480.09850817414814908
Both saved selections; only the last row supplies the recommendation
Observed positionClass indexSelected public IDSelected probabilityRole
00970.8581572274855295Inspectable earlier-row prediction
10970.804004634821441Last observed row: next-token recommendation

Current whole-root nextTokenId=97; nextTokenProbability=0.804004634821441. No token is appended. The trace cursor selects an explanation; it does not change this complete-root result or the fifth question’s answer.

All 21 remaining root tensors: raw16, E, positions, U, biases, both class rows and native copies

Every storage table groups the last named axis into columns; outer rows flatten the preceding axes in row-major order. A cell’s zero-based flat storage index is retained in its selector. Values use round-trip decimal text, with -0 explicit and booleans true/false. Declared precision is metadata; these tables do not round to it.

decoder_Raw

RawField=16 · shape [16] · float64 · declared display precision 8 · 16 stored cells

Captured raw16 in declared field order; token0/token1 cells are integer VALUE, all other cells binary64 WORD.

decoder_Raw: complete saved storage
Outer row (zero-based)token0token1positionScaleq1k1v1o1f1q2k2v2o2f2biasAbiasBbiasEOS
097970.51110.50.510.510.250.25000

decoder_TokenIds

B=1 × T=2 · shape [1,2] · int32 · declared display precision 0 · 2 stored cells

Both observed input token IDs; EOS is an ordinary explicit lookup row here.

decoder_TokenIds: complete saved storage
Outer row (zero-based)T 0T 1
09797

decoder_VocabularyIds

Vocab=3 · shape [3] · int32 · declared display precision 0 · 3 stored cells

Class order and strict-tie ID order: a=97,b=98,EOS=512.

decoder_VocabularyIds: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
09798512

decoder_E

Vocab=3 × D=2 · shape [3,2] · float64 · declared display precision 8 · 6 stored cells

Authored embedding rows [1,0],[0,1],[0,0] for a,b,EOS.

decoder_E: complete saved storage
Outer row (zero-based)D 0D 1
010
101
200

decoder_Positions

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Literal P0=[+0,+0], P1=[+0,positionScale]; disclosed absolute position addition.

decoder_Positions: complete saved storage
Outer row (zero-based)D 0D 1
000
100.5

decoder_Embeddings

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual E lookup copies before position addition.

decoder_Embeddings: complete saved storage
Outer row (zero-based)D 0D 1
010
110

decoder_Features

B=1 × T=2 × D=2 · shape [1,2,2] · float64 · declared display precision 8 · 4 stored cells

Actual lookup plus position sums; first block input, retained on its residual skip.

decoder_Features: complete saved storage
Outer row (zero-based)D 0D 1
010
110.5

decoder_U

D=2 × Vocab=3 · shape [2,3] · float64 · declared display precision 8 · 6 stored cells

Authored feature-last readout rows [1,0,0],[0,1,0].

decoder_U: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
0100
1010

decoder_Bias

Vocab=3 · shape [3] · float64 · declared display precision 8 · 3 stored cells

Actual biasA,biasB,biasEOS words, added after both feature products.

decoder_Bias: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
0000

decoder_Readout

B=1 × T=2 × Vocab=3 × ReadoutField=4 · shape [1,2,3,4] · float64 · declared display precision 8 · 24 stored cells

Actual product0,product1,sum,logit per position and class.

decoder_Readout: complete saved storage
Outer row (zero-based)ReadoutField 0ReadoutField 1ReadoutField 2ReadoutField 3
02.2446825997084527-02.24468259970845272.2446825997084527
10-0.5800172539239893-0.5800172539239893-0.5800172539239893
20-000
32.0994655028551374-02.09946550285513742.0994655028551374
40-0.01041853568410156-0.01041853568410156-0.01041853568410156
50-000

decoder_Logits

B=1 × T=2 × Vocab=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Actual final readout logits before stable class softmax.

decoder_Logits: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
02.2446825997084527-0.58001725392398930
12.0994655028551374-0.010418535684101560

decoder_ClassMaxima

B=1 × T=2 · shape [1,2] · float64 · declared display precision 8 · 2 stored cells

Actual selected maximum logit per observed position.

decoder_ClassMaxima: complete saved storage
Outer row (zero-based)T 0T 1
02.24468259970845272.0994655028551374

decoder_ClassShifted

B=1 × T=2 × Vocab=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Actual direct exp arguments, each saved once as logit minus row maximum.

decoder_ClassShifted: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
00-2.824699853632442-2.2446825997084527
10-2.109884038539239-2.0994655028551374

decoder_ClassTerms

B=1 × T=2 × Vocab=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Actual native exp outputs; no log native exists in this family.

decoder_ClassTerms: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
010.059326460779112590.10596116714203357
110.121252026180247610.12252189835948703

decoder_ClassDenominators

B=1 × T=2 · shape [1,2] · float64 · declared display precision 8 · 2 stored cells

Final ordered +0 then term0,term1,term2 running sums.

decoder_ClassDenominators: complete saved storage
Outer row (zero-based)T 0T 1
01.16528762792114621.2437739245397348

decoder_Probabilities

B=1 × T=2 × Vocab=3 · shape [1,2,3] · float64 · declared display precision 8 · 6 stored cells

Actual term/final denominator probabilities at every observed position.

decoder_Probabilities: complete saved storage
Outer row (zero-based)Vocab 0Vocab 1Vocab 2
00.85815722748552950.0509114310987322650.09093134141573832
10.8040046348214410.097487191030409790.09850817414814908

decoder_ArgmaxIndices

B=1 × T=2 · shape [1,2] · int32 · declared display precision 0 · 2 stored cells

Smallest class index on exact actual-logit ties.

decoder_ArgmaxIndices: complete saved storage
Outer row (zero-based)T 0T 1
000

decoder_ArgmaxIds

B=1 × T=2 · shape [1,2] · int32 · declared display precision 0 · 2 stored cells

Actual selected token IDs in observed-position order.

decoder_ArgmaxIds: complete saved storage
Outer row (zero-based)T 0T 1
09797

decoder_SelectedProbabilities

B=1 × T=2 · shape [1,2] · float64 · declared display precision 8 · 2 stored cells

Unchanged copies of the actual selected class probabilities.

decoder_SelectedProbabilities: complete saved storage
Outer row (zero-based)T 0T 1
00.85815722748552950.804004634821441

decoder_NativeArguments

Native=22 × NativeField=2 · shape [22,2] · float64 · declared display precision 8 · 44 stored cells

Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

decoder_NativeArguments: complete saved storage
Outer row (zero-based)inputoutput
00.50.7071067811865476
10.31250.5590169943749475
221.4142135623730951
301
401
5-0.164370883025338870.8484272962382063
60.97855339059327370.9892185757421227
70.54583587223705670.738807060224154
81.3933328645710691.180395215413494
90.7799219117443290.8831318767569932
1021.4142135623730951
1101
1201
13-0.0475409801304550460.953571394851756
141.92891961809802971.3888555065585584
151.1420196677420271.0686532027472837
1601
17-2.8246998536324420.05932646077911259
18-2.24468259970845270.10596116714203357
1901
20-2.1098840385392390.12125202618024761
21-2.09946550285513740.12252189835948703

decoder_NativeKinds

Native=22 · shape [22] · int32 · declared display precision 0 · 22 stored cells

Native kind codes in native occurrence order: sqrt=0, exp=1.

decoder_NativeKinds: complete saved storage
Outer row (zero-based)Native 0Native 1Native 2Native 3Native 4Native 5Native 6Native 7Native 8Native 9Native 10Native 11Native 12Native 13Native 14Native 15Native 16Native 17Native 18Native 19Native 20Native 21
00001110000011100111111

Ordered native-leaf ledger

All saved native occurrences: identity, kind, argument and actual output
OccurrenceExact IDKindSaved argumentSaved output
0decoder_block1_n1_0_0_sqrtsqrt0.50.7071067811865476
1decoder_block1_n1_0_1_sqrtsqrt0.31250.5590169943749475
2decoder_block1_attn_sqrtsqrt21.4142135623730951
3decoder_block1_attn_exp_0_0_0_0exp01
4decoder_block1_attn_exp_0_0_1_0exp01
5decoder_block1_attn_exp_0_0_1_1exp-0.164370883025338870.8484272962382063
6decoder_block1_n2_0_0_sqrtsqrt0.97855339059327370.9892185757421227
7decoder_block1_n2_0_1_sqrtsqrt0.54583587223705670.738807060224154
8decoder_block2_n1_0_0_sqrtsqrt1.3933328645710691.180395215413494
9decoder_block2_n1_0_1_sqrtsqrt0.7799219117443290.8831318767569932
10decoder_block2_attn_sqrtsqrt21.4142135623730951
11decoder_block2_attn_exp_0_0_0_0exp01
12decoder_block2_attn_exp_0_0_1_0exp01
13decoder_block2_attn_exp_0_0_1_1exp-0.0475409801304550460.953571394851756
14decoder_block2_n2_0_0_sqrtsqrt1.92891961809802971.3888555065585584
15decoder_block2_n2_0_1_sqrtsqrt1.1420196677420271.0686532027472837
16decoder_readout_exp_0_0exp01
17decoder_readout_exp_0_1exp-2.8246998536324420.05932646077911259
18decoder_readout_exp_0_2exp-2.24468259970845270.10596116714203357
19decoder_readout_exp_1_0exp01
20decoder_readout_exp_1_1exp-2.1098840385392390.12125202618024761
21decoder_readout_exp_1_2exp-2.09946550285513740.12252189835948703

Both complete block-native ledgers precede output-head exp occurrences in token/class order. LN sqrt and attention sqrt(Dk) save actual outputs. Old attention shifted arguments repeat the identical immutable-operand subtraction used internally by stableSoftmax: functional word reconstruction, not a physical instruction trace. Output-head exp arguments are captured directly. No log, sin, cos or native call during serialization.

Declared future independent policy: positive finite sqrt outputs with argument [1/4,4096] and exp outputs with argument [-256,0], at most four ordered binary64 word steps from an independently isolated RN-even reference. Admit each complete TS/canonical record separately, then require exact scalar/copy words inside it. This is neither bit-exact libm parity nor validation evidence.

Complete saved operation text fallback: all 198 frames in trace order

setup: Capture the complete two-block decoder toy

X0=E[observedIds]+P; Y1=block1(X0); Y2=block2(Y1); logits=Y2*U+bias; probabilities=stableClassSoftmax(logits)

Sixteen actual finite inputs are captured before domains. Both observed positions traverse both pre-norm blocks, every width-three FFN coordinate and the same three-class readout. These owner-authored parameters are hand-set; no training or generation step is hidden.

Saved inputs
token0
97
token1
97
positionScale
0.5
q1
1
k1
1
v1
1
o1
0.5
f1
0.5
q2
1
k2
0.5
v2
1
o2
0.25
f2
0.25
biasA
0
biasB
0
biasEOS
0
Saved outputs
token0
97
token1
97
positionScale
0.5
q1
1
k1
1
v1
1
o1
0.5
f1
0.5
q2
1
k2
0.5
v2
1
o2
0.25
f2
0.25
biasA
0
biasB
0
biasEOS
0
B
1
T
2
D
2
H
1
Dk
2
Dv
2
M
3
Vocab
3
blockCount
2
rawInputCount
16

decoder_embedding_0_0: Observed position 0, feature 0: lookup then add position

feature=embedding+position

Look up this observed token ID in the authored E table and add the displayed absolute-position coordinate. An observed EOS has its explicit zero row; no token is generated or silently stopped.

Saved inputs
t
0
d
0
tokenId
97
row
0
embedding
1
position
0
Saved outputs
feature
1

decoder_embedding_0_1: Observed position 0, feature 1: lookup then add position

feature=embedding+position

Look up this observed token ID in the authored E table and add the displayed absolute-position coordinate. An observed EOS has its explicit zero row; no token is generated or silently stopped.

Saved inputs
t
0
d
1
tokenId
97
row
0
embedding
0
position
0
Saved outputs
feature
0

decoder_embedding_1_0: Observed position 1, feature 0: lookup then add position

feature=embedding+position

Look up this observed token ID in the authored E table and add the displayed absolute-position coordinate. An observed EOS has its explicit zero row; no token is generated or silently stopped.

Saved inputs
t
1
d
0
tokenId
97
row
0
embedding
1
position
0
Saved outputs
feature
1

decoder_embedding_1_1: Observed position 1, feature 1: lookup then add position

feature=embedding+position

Look up this observed token ID in the authored E table and add the displayed absolute-position coordinate. An observed EOS has its explicit zero row; no token is generated or silently stopped.

Saved inputs
t
1
d
1
tokenId
97
row
0
embedding
0
position
0.5
Saved outputs
feature
0.5

decoder_block1_n1_0_0_statistics: 0_0: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1
x1
0
epsilon
0.25
Saved outputs
sum
1
mean
0.5
centered0
0.5
centered1
-0.5
square0
0.25
square1
0.25
squareSum
0.5
variance
0.25
variancePlusEpsilon
0.5
denominator
0.7071067811865476

decoder_block1_n1_0_0_feature_0: 0_0: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.5
denominator
0.7071067811865476
gamma
1
beta
0
Saved outputs
normalized
0.7071067811865475
scaled
0.7071067811865475
value
0.7071067811865475

decoder_block1_n1_0_0_feature_1: 0_0: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.5
denominator
0.7071067811865476
gamma
1
beta
0
Saved outputs
normalized
-0.7071067811865475
scaled
-0.7071067811865475
value
-0.7071067811865475

decoder_block1_n1_0_1_statistics: 0_1: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1
x1
0.5
epsilon
0.25
Saved outputs
sum
1.5
mean
0.75
centered0
0.25
centered1
-0.25
square0
0.0625
square1
0.0625
squareSum
0.125
variance
0.0625
variancePlusEpsilon
0.3125
denominator
0.5590169943749475

decoder_block1_n1_0_1_feature_0: 0_1: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.25
denominator
0.5590169943749475
gamma
1
beta
0
Saved outputs
normalized
0.4472135954999579
scaled
0.4472135954999579
value
0.4472135954999579

decoder_block1_n1_0_1_feature_1: 0_1: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.25
denominator
0.5590169943749475
gamma
1
beta
0
Saved outputs
normalized
-0.4472135954999579
scaled
-0.4472135954999579
value
-0.4472135954999579

decoder_block1_attn_setup: Validate every scalar slot, then select active dimensions

D=2; X[B,T,2]; WQ,WK[2,H*Dk]; WV[2,H*Dv]

All inactive fields remain finite and bounded. Parameter names identify input d, head h and feature f, so changing width never relabels a head’s weights.

Saved inputs
B
1
T
2
H
1
Dk
2
Dv
2
x000
0.7071067811865475
x001
-0.7071067811865475
x010
0.4472135954999579
x011
-0.4472135954999579
x020
0
x021
0
x100
0
x101
0
x110
0
x111
0
x120
0
x121
0
wq000
1
wq001
0
wq010
0
wq011
0
wq100
0
wq101
1
wq110
0
wq111
0
wk000
1
wk001
0
wk010
0
wk011
0
wk100
0
wk101
1
wk110
0
wk111
0
wv000
1
wv001
0
wv010
0
wv011
0
wv100
0
wv101
1
wv110
0
wv111
0
mode
1
valid0
1
valid1
1
valid2
1
shift
0
wo000
0.5
wo001
0
wo010
0
wo011
0.5
wo100
0
wo101
0
wo110
0
wo111
0
Saved outputs
B
1
T
2
D
2
H
1
Dk
2
Dv
2

decoder_block1_attn_project_Q_0_0_0_0: Q[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.7071067811865475
x1
-0.7071067811865475
w0
1
w1
0
Saved outputs
product0
0.7071067811865475
product1
-0
value
0.7071067811865475

decoder_block1_attn_project_Q_0_0_0_1: Q[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.7071067811865475
x1
-0.7071067811865475
w0
0
w1
1
Saved outputs
product0
0
product1
-0.7071067811865475
value
-0.7071067811865475

decoder_block1_attn_project_Q_0_1_0_0: Q[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.4472135954999579
x1
-0.4472135954999579
w0
1
w1
0
Saved outputs
product0
0.4472135954999579
product1
-0
value
0.4472135954999579

decoder_block1_attn_project_Q_0_1_0_1: Q[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.4472135954999579
x1
-0.4472135954999579
w0
0
w1
1
Saved outputs
product0
0
product1
-0.4472135954999579
value
-0.4472135954999579

decoder_block1_attn_project_K_0_0_0_0: K[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.7071067811865475
x1
-0.7071067811865475
w0
1
w1
0
Saved outputs
product0
0.7071067811865475
product1
-0
value
0.7071067811865475

decoder_block1_attn_project_K_0_0_0_1: K[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.7071067811865475
x1
-0.7071067811865475
w0
0
w1
1
Saved outputs
product0
0
product1
-0.7071067811865475
value
-0.7071067811865475

decoder_block1_attn_project_K_0_1_0_0: K[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.4472135954999579
x1
-0.4472135954999579
w0
1
w1
0
Saved outputs
product0
0.4472135954999579
product1
-0
value
0.4472135954999579

decoder_block1_attn_project_K_0_1_0_1: K[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.4472135954999579
x1
-0.4472135954999579
w0
0
w1
1
Saved outputs
product0
0
product1
-0.4472135954999579
value
-0.4472135954999579

decoder_block1_attn_project_V_0_0_0_0: V[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.7071067811865475
x1
-0.7071067811865475
w0
1
w1
0
Saved outputs
product0
0.7071067811865475
product1
-0
value
0.7071067811865475

decoder_block1_attn_project_V_0_0_0_1: V[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.7071067811865475
x1
-0.7071067811865475
w0
0
w1
1
Saved outputs
product0
0
product1
-0.7071067811865475
value
-0.7071067811865475

decoder_block1_attn_project_V_0_1_0_0: V[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.4472135954999579
x1
-0.4472135954999579
w0
1
w1
0
Saved outputs
product0
0.4472135954999579
product1
-0
value
0.4472135954999579

decoder_block1_attn_project_V_0_1_0_1: V[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.4472135954999579
x1
-0.4472135954999579
w0
0
w1
1
Saved outputs
product0
0
product1
-0.4472135954999579
value
-0.4472135954999579

decoder_block1_attn_reshape_Q: Q: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block1_attn_permute_Q_0_0_0_0: Q: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.7071067811865475
Saved outputs
value
0.7071067811865475

decoder_block1_attn_permute_Q_0_0_0_1: Q: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.7071067811865475
Saved outputs
value
-0.7071067811865475

decoder_block1_attn_permute_Q_0_0_1_0: Q: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.4472135954999579
Saved outputs
value
0.4472135954999579

decoder_block1_attn_permute_Q_0_0_1_1: Q: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.4472135954999579
Saved outputs
value
-0.4472135954999579

decoder_block1_attn_reshape_K: K: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block1_attn_permute_K_0_0_0_0: K: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.7071067811865475
Saved outputs
value
0.7071067811865475

decoder_block1_attn_permute_K_0_0_0_1: K: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.7071067811865475
Saved outputs
value
-0.7071067811865475

decoder_block1_attn_permute_K_0_0_1_0: K: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.4472135954999579
Saved outputs
value
0.4472135954999579

decoder_block1_attn_permute_K_0_0_1_1: K: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.4472135954999579
Saved outputs
value
-0.4472135954999579

decoder_block1_attn_reshape_V: V: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block1_attn_permute_V_0_0_0_0: V: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.7071067811865475
Saved outputs
value
0.7071067811865475

decoder_block1_attn_permute_V_0_0_0_1: V: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.7071067811865475
Saved outputs
value
-0.7071067811865475

decoder_block1_attn_permute_V_0_0_1_0: V: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.4472135954999579
Saved outputs
value
0.4472135954999579

decoder_block1_attn_permute_V_0_0_1_1: V: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.4472135954999579
Saved outputs
value
-0.4472135954999579

decoder_block1_attn_score_0_0_0_0: Batch 0, head 0: query 0 against key 0

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
0
j
0
Dk
2
divisor
1.4142135623730951
q0
0.7071067811865475
k0
0.7071067811865475
q1
-0.7071067811865475
k1
-0.7071067811865475
Saved outputs
product0
0.4999999999999999
product1
0.4999999999999999
raw
0.9999999999999998
score
0.7071067811865474

decoder_block1_attn_score_0_0_0_1: Batch 0, head 0: query 0 against key 1

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
0
j
1
Dk
2
divisor
1.4142135623730951
q0
0.7071067811865475
k0
0.4472135954999579
q1
-0.7071067811865475
k1
-0.4472135954999579
Saved outputs
product0
0.3162277660168379
product1
0.3162277660168379
raw
0.6324555320336758
score
0.4472135954999578

decoder_block1_attn_score_0_0_1_0: Batch 0, head 0: query 1 against key 0

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
1
j
0
Dk
2
divisor
1.4142135623730951
q0
0.4472135954999579
k0
0.7071067811865475
q1
-0.4472135954999579
k1
-0.7071067811865475
Saved outputs
product0
0.3162277660168379
product1
0.3162277660168379
raw
0.6324555320336758
score
0.4472135954999578

decoder_block1_attn_score_0_0_1_1: Batch 0, head 0: query 1 against key 1

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
1
j
1
Dk
2
divisor
1.4142135623730951
q0
0.4472135954999579
k0
0.4472135954999579
q1
-0.4472135954999579
k1
-0.4472135954999579
Saved outputs
product0
0.19999999999999998
product1
0.19999999999999998
raw
0.39999999999999997
score
0.28284271247461895

decoder_block1_attn_row_0_0_0: Batch 0, head 0, query 0: key-axis stable softmax

logit_j=score_j+shift; max=max(allowed logits); term_j=allowed_j?exp(logit_j-max):0; denominator=sum_j term_j; p_j=term_j/denominator

Each head has its own probabilities. Key validity is shared across batches and heads; queries remain. Forbidden terms are exactly zero, without an infinity sentinel or invented shifted value. Allowed terms can underflow; a large common shift can change low bits.

Saved inputs
b
0
h
0
i
0
mode
1
shift
0
score0
0.7071067811865474
score1
0.4472135954999578
allowed0
1
allowed1
0
Saved outputs
max
0.7071067811865474
denominator
1
shifted0
0
term0
1
term1
0
p0
1
p1
0

decoder_block1_attn_row_0_0_1: Batch 0, head 0, query 1: key-axis stable softmax

logit_j=score_j+shift; max=max(allowed logits); term_j=allowed_j?exp(logit_j-max):0; denominator=sum_j term_j; p_j=term_j/denominator

Each head has its own probabilities. Key validity is shared across batches and heads; queries remain. Forbidden terms are exactly zero, without an infinity sentinel or invented shifted value. Allowed terms can underflow; a large common shift can change low bits.

Saved inputs
b
0
h
0
i
1
mode
1
shift
0
score0
0.4472135954999578
score1
0.28284271247461895
allowed0
1
allowed1
1
Saved outputs
max
0.4472135954999578
denominator
1.8484272962382065
shifted0
0
shifted1
-0.16437088302533887
term0
1
term1
0.8484272962382063
p0
0.5410004505100806
p1
0.4589995494899193

decoder_block1_attn_head_mix_0_0_0_0: OHeads[0,0,0,0]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
0
f
0
p0
1
v0
0.7071067811865475
p1
0
v1
0.4472135954999579
Saved outputs
product0
0.7071067811865475
product1
0
running0
0.7071067811865475
running1
0.7071067811865475
value
0.7071067811865475

decoder_block1_attn_head_mix_0_0_0_1: OHeads[0,0,0,1]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
0
f
1
p0
1
v0
-0.7071067811865475
p1
0
v1
-0.4472135954999579
Saved outputs
product0
-0.7071067811865475
product1
-0
running0
-0.7071067811865475
running1
-0.7071067811865475
value
-0.7071067811865475

decoder_block1_attn_head_mix_0_0_1_0: OHeads[0,0,1,0]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
1
f
0
p0
0.5410004505100806
v0
0.7071067811865475
p1
0.4589995494899193
v1
0.4472135954999579
Saved outputs
product0
0.38254508718065516
product1
0.2052708388602477
running0
0.38254508718065516
running1
0.5878159260409028
value
0.5878159260409028

decoder_block1_attn_head_mix_0_0_1_1: OHeads[0,0,1,1]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
1
f
1
p0
0.5410004505100806
v0
-0.7071067811865475
p1
0.4589995494899193
v1
-0.4472135954999579
Saved outputs
product0
-0.38254508718065516
product1
-0.2052708388602477
running0
-0.38254508718065516
running1
-0.5878159260409028
value
-0.5878159260409028

decoder_block1_attn_concat_0_0_0_0: Join head 0, feature 0 into C[0,0,0]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
0
h
0
f
0
concatFeature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.7071067811865475
Saved outputs
value
0.7071067811865475

decoder_block1_attn_concat_0_0_0_1: Join head 0, feature 1 into C[0,0,1]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
0
h
0
f
1
concatFeature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.7071067811865475
Saved outputs
value
-0.7071067811865475

decoder_block1_attn_concat_0_1_0_0: Join head 0, feature 0 into C[0,1,0]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
1
h
0
f
0
concatFeature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.5878159260409028
Saved outputs
value
0.5878159260409028

decoder_block1_attn_concat_0_1_0_1: Join head 0, feature 1 into C[0,1,1]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
1
h
0
f
1
concatFeature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.5878159260409028
Saved outputs
value
-0.5878159260409028

decoder_block1_attn_output_0_0_0: Y[0,0,0]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
0
d
0
c0
0.7071067811865475
w0
0.5
c1
-0.7071067811865475
w1
0
Saved outputs
product0
0.35355339059327373
product1
-0
running0
0.35355339059327373
running1
0.35355339059327373
value
0.35355339059327373

decoder_block1_attn_output_0_0_1: Y[0,0,1]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
0
d
1
c0
0.7071067811865475
w0
0
c1
-0.7071067811865475
w1
0.5
Saved outputs
product0
0
product1
-0.35355339059327373
running0
0
running1
-0.35355339059327373
value
-0.35355339059327373

decoder_block1_attn_output_0_1_0: Y[0,1,0]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
1
d
0
c0
0.5878159260409028
w0
0.5
c1
-0.5878159260409028
w1
0
Saved outputs
product0
0.2939079630204514
product1
-0
running0
0.2939079630204514
running1
0.2939079630204514
value
0.2939079630204514

decoder_block1_attn_output_0_1_1: Y[0,1,1]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
1
d
1
c0
0.5878159260409028
w0
0
c1
-0.5878159260409028
w1
0.5
Saved outputs
product0
0
product1
-0.2939079630204514
running0
0
running1
-0.2939079630204514
value
-0.2939079630204514

decoder_block1_r1_0_0_0: decoder_block1_R1[0,0,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
0
skip
1
branch
0.35355339059327373
Saved outputs
value
1.3535533905932737

decoder_block1_r1_0_0_1: decoder_block1_R1[0,0,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
1
skip
0
branch
-0.35355339059327373
Saved outputs
value
-0.35355339059327373

decoder_block1_r1_0_1_0: decoder_block1_R1[0,1,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
0
skip
1
branch
0.2939079630204514
Saved outputs
value
1.2939079630204513

decoder_block1_r1_0_1_1: decoder_block1_R1[0,1,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
1
skip
0.5
branch
-0.2939079630204514
Saved outputs
value
0.2060920369795486

decoder_block1_n2_0_0_statistics: 0_0: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1.3535533905932737
x1
-0.35355339059327373
epsilon
0.25
Saved outputs
sum
1
mean
0.5
centered0
0.8535533905932737
centered1
-0.8535533905932737
square0
0.7285533905932737
square1
0.7285533905932737
squareSum
1.4571067811865475
variance
0.7285533905932737
variancePlusEpsilon
0.9785533905932737
denominator
0.9892185757421227

decoder_block1_n2_0_0_feature_0: 0_0: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.8535533905932737
denominator
0.9892185757421227
gamma
1
beta
0
Saved outputs
normalized
0.8628562094610168
scaled
0.8628562094610168
value
0.8628562094610168

decoder_block1_n2_0_0_feature_1: 0_0: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.8535533905932737
denominator
0.9892185757421227
gamma
1
beta
0
Saved outputs
normalized
-0.8628562094610168
scaled
-0.8628562094610168
value
-0.8628562094610168

decoder_block1_n2_0_1_statistics: 0_1: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1.2939079630204513
x1
0.2060920369795486
epsilon
0.25
Saved outputs
sum
1.5
mean
0.75
centered0
0.5439079630204513
centered1
-0.5439079630204514
square0
0.2958358722370566
square1
0.29583587223705676
squareSum
0.5916717444741133
variance
0.29583587223705665
variancePlusEpsilon
0.5458358722370567
denominator
0.738807060224154

decoder_block1_n2_0_1_feature_0: 0_1: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.5439079630204513
denominator
0.738807060224154
gamma
1
beta
0
Saved outputs
normalized
0.7361975707912559
scaled
0.7361975707912559
value
0.7361975707912559

decoder_block1_n2_0_1_feature_1: 0_1: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.5439079630204514
denominator
0.738807060224154
gamma
1
beta
0
Saved outputs
normalized
-0.7361975707912561
scaled
-0.7361975707912561
value
-0.7361975707912561

decoder_block1_ffn_hidden_0_0_0: Hidden affine [0,0,0]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
0
x0
0.8628562094610168
x1
-0.8628562094610168
w0
1
w1
0
bias
0
Saved outputs
product0
0.8628562094610168
product1
-0
sum
0.8628562094610168
preactivation
0.8628562094610168

decoder_block1_ffn_hidden_0_0_1: Hidden affine [0,0,1]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
1
x0
0.8628562094610168
x1
-0.8628562094610168
w0
0
w1
1
bias
0
Saved outputs
product0
0
product1
-0.8628562094610168
sum
-0.8628562094610168
preactivation
-0.8628562094610168

decoder_block1_ffn_hidden_0_0_2: Hidden affine [0,0,2]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
2
x0
0.8628562094610168
x1
-0.8628562094610168
w0
0
w1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
preactivation
0

decoder_block1_ffn_hidden_0_1_0: Hidden affine [0,1,0]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
0
x0
0.7361975707912559
x1
-0.7361975707912561
w0
1
w1
0
bias
0
Saved outputs
product0
0.7361975707912559
product1
-0
sum
0.7361975707912559
preactivation
0.7361975707912559

decoder_block1_ffn_hidden_0_1_1: Hidden affine [0,1,1]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
1
x0
0.7361975707912559
x1
-0.7361975707912561
w0
0
w1
1
bias
0
Saved outputs
product0
0
product1
-0.7361975707912561
sum
-0.7361975707912561
preactivation
-0.7361975707912561

decoder_block1_ffn_hidden_0_1_2: Hidden affine [0,1,2]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
2
x0
0.7361975707912559
x1
-0.7361975707912561
w0
0
w1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
preactivation
0

decoder_block1_ffn_relu_0_0_0: ReLU [0,0,0]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
0
preactivation
0.8628562094610168
Saved outputs
activation
0.8628562094610168

decoder_block1_ffn_relu_0_0_1: ReLU [0,0,1]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
1
preactivation
-0.8628562094610168
Saved outputs
activation
0

decoder_block1_ffn_relu_0_0_2: ReLU [0,0,2]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
2
preactivation
0
Saved outputs
activation
0

decoder_block1_ffn_relu_0_1_0: ReLU [0,1,0]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
0
preactivation
0.7361975707912559
Saved outputs
activation
0.7361975707912559

decoder_block1_ffn_relu_0_1_1: ReLU [0,1,1]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
1
preactivation
-0.7361975707912561
Saved outputs
activation
0

decoder_block1_ffn_relu_0_1_2: ReLU [0,1,2]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
2
preactivation
0
Saved outputs
activation
0

decoder_block1_ffn_output_0_0_0: FFN output [0,0,0]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
0
d
0
h0
0.8628562094610168
w0
0.5
h1
0
w1
0
h2
0
w2
0
bias
0
Saved outputs
product0
0.4314281047305084
product1
0
product2
0
running0
0.4314281047305084
running1
0.4314281047305084
running2
0.4314281047305084
sum
0.4314281047305084
value
0.4314281047305084

decoder_block1_ffn_output_0_0_1: FFN output [0,0,1]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
0
d
1
h0
0.8628562094610168
w0
0
h1
0
w1
0.5
h2
0
w2
0
bias
0
Saved outputs
product0
0
product1
0
product2
0
running0
0
running1
0
running2
0
sum
0
value
0

decoder_block1_ffn_output_0_1_0: FFN output [0,1,0]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
1
d
0
h0
0.7361975707912559
w0
0.5
h1
0
w1
0
h2
0
w2
0
bias
0
Saved outputs
product0
0.36809878539562796
product1
0
product2
0
running0
0.36809878539562796
running1
0.36809878539562796
running2
0.36809878539562796
sum
0.36809878539562796
value
0.36809878539562796

decoder_block1_ffn_output_0_1_1: FFN output [0,1,1]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
1
d
1
h0
0.7361975707912559
w0
0
h1
0
w1
0.5
h2
0
w2
0
bias
0
Saved outputs
product0
0
product1
0
product2
0
running0
0
running1
0
running2
0
sum
0
value
0

decoder_block1_r2_0_0_0: decoder_block1_Output[0,0,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
0
skip
1.3535533905932737
branch
0.4314281047305084
Saved outputs
value
1.7849814953237821

decoder_block1_r2_0_0_1: decoder_block1_Output[0,0,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
1
skip
-0.35355339059327373
branch
0
Saved outputs
value
-0.35355339059327373

decoder_block1_r2_0_1_0: decoder_block1_Output[0,1,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
0
skip
1.2939079630204513
branch
0.36809878539562796
Saved outputs
value
1.6620067484160792

decoder_block1_r2_0_1_1: decoder_block1_Output[0,1,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
1
skip
0.2060920369795486
branch
0
Saved outputs
value
0.2060920369795486

decoder_block2_n1_0_0_statistics: 0_0: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1.7849814953237821
x1
-0.35355339059327373
epsilon
0.25
Saved outputs
sum
1.4314281047305084
mean
0.7157140523652542
centered0
1.069267442958528
centered1
-1.069267442958528
square0
1.143332864571069
square1
1.143332864571069
squareSum
2.286665729142138
variance
1.143332864571069
variancePlusEpsilon
1.393332864571069
denominator
1.180395215413494

decoder_block2_n1_0_0_feature_0: 0_0: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
1.069267442958528
denominator
1.180395215413494
gamma
1
beta
0
Saved outputs
normalized
0.9058554533228621
scaled
0.9058554533228621
value
0.9058554533228621

decoder_block2_n1_0_0_feature_1: 0_0: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-1.069267442958528
denominator
1.180395215413494
gamma
1
beta
0
Saved outputs
normalized
-0.9058554533228621
scaled
-0.9058554533228621
value
-0.9058554533228621

decoder_block2_n1_0_1_statistics: 0_1: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1.6620067484160792
x1
0.2060920369795486
epsilon
0.25
Saved outputs
sum
1.868098785395628
mean
0.934049392697814
centered0
0.7279573557182653
centered1
-0.7279573557182654
square0
0.529921911744329
square1
0.5299219117443291
squareSum
1.059843823488658
variance
0.529921911744329
variancePlusEpsilon
0.779921911744329
denominator
0.8831318767569932

decoder_block2_n1_0_1_feature_0: 0_1: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.7279573557182653
denominator
0.8831318767569932
gamma
1
beta
0
Saved outputs
normalized
0.8242906579156054
scaled
0.8242906579156054
value
0.8242906579156054

decoder_block2_n1_0_1_feature_1: 0_1: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.7279573557182654
denominator
0.8831318767569932
gamma
1
beta
0
Saved outputs
normalized
-0.8242906579156055
scaled
-0.8242906579156055
value
-0.8242906579156055

decoder_block2_attn_setup: Validate every scalar slot, then select active dimensions

D=2; X[B,T,2]; WQ,WK[2,H*Dk]; WV[2,H*Dv]

All inactive fields remain finite and bounded. Parameter names identify input d, head h and feature f, so changing width never relabels a head’s weights.

Saved inputs
B
1
T
2
H
1
Dk
2
Dv
2
x000
0.9058554533228621
x001
-0.9058554533228621
x010
0.8242906579156054
x011
-0.8242906579156055
x020
0
x021
0
x100
0
x101
0
x110
0
x111
0
x120
0
x121
0
wq000
1
wq001
0
wq010
0
wq011
0
wq100
0
wq101
1
wq110
0
wq111
0
wk000
0.5
wk001
0
wk010
0
wk011
0
wk100
0
wk101
0.5
wk110
0
wk111
0
wv000
1
wv001
0
wv010
0
wv011
0
wv100
0
wv101
1
wv110
0
wv111
0
mode
1
valid0
1
valid1
1
valid2
1
shift
0
wo000
0.25
wo001
0
wo010
0
wo011
0.25
wo100
0
wo101
0
wo110
0
wo111
0
Saved outputs
B
1
T
2
D
2
H
1
Dk
2
Dv
2

decoder_block2_attn_project_Q_0_0_0_0: Q[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.9058554533228621
x1
-0.9058554533228621
w0
1
w1
0
Saved outputs
product0
0.9058554533228621
product1
-0
value
0.9058554533228621

decoder_block2_attn_project_Q_0_0_0_1: Q[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.9058554533228621
x1
-0.9058554533228621
w0
0
w1
1
Saved outputs
product0
0
product1
-0.9058554533228621
value
-0.9058554533228621

decoder_block2_attn_project_Q_0_1_0_0: Q[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.8242906579156054
x1
-0.8242906579156055
w0
1
w1
0
Saved outputs
product0
0.8242906579156054
product1
-0
value
0.8242906579156054

decoder_block2_attn_project_Q_0_1_0_1: Q[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.8242906579156054
x1
-0.8242906579156055
w0
0
w1
1
Saved outputs
product0
0
product1
-0.8242906579156055
value
-0.8242906579156055

decoder_block2_attn_project_K_0_0_0_0: K[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.9058554533228621
x1
-0.9058554533228621
w0
0.5
w1
0
Saved outputs
product0
0.45292772666143105
product1
-0
value
0.45292772666143105

decoder_block2_attn_project_K_0_0_0_1: K[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.9058554533228621
x1
-0.9058554533228621
w0
0
w1
0.5
Saved outputs
product0
0
product1
-0.45292772666143105
value
-0.45292772666143105

decoder_block2_attn_project_K_0_1_0_0: K[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.8242906579156054
x1
-0.8242906579156055
w0
0.5
w1
0
Saved outputs
product0
0.4121453289578027
product1
-0
value
0.4121453289578027

decoder_block2_attn_project_K_0_1_0_1: K[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.8242906579156054
x1
-0.8242906579156055
w0
0
w1
0.5
Saved outputs
product0
0
product1
-0.41214532895780276
value
-0.41214532895780276

decoder_block2_attn_project_V_0_0_0_0: V[0,0,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
0
x0
0.9058554533228621
x1
-0.9058554533228621
w0
1
w1
0
Saved outputs
product0
0.9058554533228621
product1
-0
value
0.9058554533228621

decoder_block2_attn_project_V_0_0_0_1: V[0,0,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
0
h
0
f
1
x0
0.9058554533228621
x1
-0.9058554533228621
w0
0
w1
1
Saved outputs
product0
0
product1
-0.9058554533228621
value
-0.9058554533228621

decoder_block2_attn_project_V_0_1_0_0: V[0,1,head 0,feature 0]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
0
x0
0.8242906579156054
x1
-0.8242906579156055
w0
1
w1
0
Saved outputs
product0
0.8242906579156054
product1
-0
value
0.8242906579156054

decoder_block2_attn_project_V_0_1_0_1: V[0,1,head 0,feature 1]: both input contributions

product0=x0*w0; product1=x1*w1; value=product0+product1

One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.

Saved inputs
b
0
t
1
h
0
f
1
x0
0.8242906579156054
x1
-0.8242906579156055
w0
0
w1
1
Saved outputs
product0
0
product1
-0.8242906579156055
value
-0.8242906579156055

decoder_block2_attn_reshape_Q: Q: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block2_attn_permute_Q_0_0_0_0: Q: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.9058554533228621
Saved outputs
value
0.9058554533228621

decoder_block2_attn_permute_Q_0_0_0_1: Q: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.9058554533228621
Saved outputs
value
-0.9058554533228621

decoder_block2_attn_permute_Q_0_0_1_0: Q: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.8242906579156054
Saved outputs
value
0.8242906579156054

decoder_block2_attn_permute_Q_0_0_1_1: Q: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.8242906579156055
Saved outputs
value
-0.8242906579156055

decoder_block2_attn_reshape_K: K: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block2_attn_permute_K_0_0_0_0: K: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.45292772666143105
Saved outputs
value
0.45292772666143105

decoder_block2_attn_permute_K_0_0_0_1: K: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.45292772666143105
Saved outputs
value
-0.45292772666143105

decoder_block2_attn_permute_K_0_0_1_0: K: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.4121453289578027
Saved outputs
value
0.4121453289578027

decoder_block2_attn_permute_K_0_0_1_1: K: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.41214532895780276
Saved outputs
value
-0.41214532895780276

decoder_block2_attn_reshape_V: V: reshape the packed feature axis

[B,T,H*F] → [B,T,H,F]; feature=h*F+f

Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.

Saved inputs
B
1
T
2
H
1
F
2
features
2
elements
4
Saved outputs
elements
4

decoder_block2_attn_permute_V_0_0_0_0: V: copy [0,0,0,0] to [0,0,0,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
0
feature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.9058554533228621
Saved outputs
value
0.9058554533228621

decoder_block2_attn_permute_V_0_0_0_1: V: copy [0,0,0,1] to [0,0,0,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
0
f
1
feature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.9058554533228621
Saved outputs
value
-0.9058554533228621

decoder_block2_attn_permute_V_0_0_1_0: V: copy [0,1,0,0] to [0,0,1,0]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
0
feature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.8242906579156054
Saved outputs
value
0.8242906579156054

decoder_block2_attn_permute_V_0_0_1_1: V: copy [0,1,0,1] to [0,0,1,1]

axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]

Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.

Saved inputs
b
0
h
0
t
1
f
1
feature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.8242906579156055
Saved outputs
value
-0.8242906579156055

decoder_block2_attn_score_0_0_0_0: Batch 0, head 0: query 0 against key 0

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
0
j
0
Dk
2
divisor
1.4142135623730951
q0
0.9058554533228621
k0
0.45292772666143105
q1
-0.9058554533228621
k1
-0.45292772666143105
Saved outputs
product0
0.410287051157384
product1
0.410287051157384
raw
0.820574102314768
score
0.5802335122128363

decoder_block2_attn_score_0_0_0_1: Batch 0, head 0: query 0 against key 1

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
0
j
1
Dk
2
divisor
1.4142135623730951
q0
0.9058554533228621
k0
0.4121453289578027
q1
-0.9058554533228621
k1
-0.41214532895780276
Saved outputs
product0
0.3733440937979705
product1
0.37334409379797057
raw
0.746688187595941
score
0.5279882808809828

decoder_block2_attn_score_0_0_1_0: Batch 0, head 0: query 1 against key 0

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
1
j
0
Dk
2
divisor
1.4142135623730951
q0
0.8242906579156054
k0
0.45292772666143105
q1
-0.8242906579156055
k1
-0.45292772666143105
Saved outputs
product0
0.3733440937979705
product1
0.37334409379797057
raw
0.746688187595941
score
0.5279882808809828

decoder_block2_attn_score_0_0_1_1: Batch 0, head 0: query 1 against key 1

product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)

Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.

Saved inputs
b
0
h
0
i
1
j
1
Dk
2
divisor
1.4142135623730951
q0
0.8242906579156054
k0
0.4121453289578027
q1
-0.8242906579156055
k1
-0.41214532895780276
Saved outputs
product0
0.3397275443634708
product1
0.3397275443634709
raw
0.6794550887269417
score
0.4804473007505278

decoder_block2_attn_row_0_0_0: Batch 0, head 0, query 0: key-axis stable softmax

logit_j=score_j+shift; max=max(allowed logits); term_j=allowed_j?exp(logit_j-max):0; denominator=sum_j term_j; p_j=term_j/denominator

Each head has its own probabilities. Key validity is shared across batches and heads; queries remain. Forbidden terms are exactly zero, without an infinity sentinel or invented shifted value. Allowed terms can underflow; a large common shift can change low bits.

Saved inputs
b
0
h
0
i
0
mode
1
shift
0
score0
0.5802335122128363
score1
0.5279882808809828
allowed0
1
allowed1
0
Saved outputs
max
0.5802335122128363
denominator
1
shifted0
0
term0
1
term1
0
p0
1
p1
0

decoder_block2_attn_row_0_0_1: Batch 0, head 0, query 1: key-axis stable softmax

logit_j=score_j+shift; max=max(allowed logits); term_j=allowed_j?exp(logit_j-max):0; denominator=sum_j term_j; p_j=term_j/denominator

Each head has its own probabilities. Key validity is shared across batches and heads; queries remain. Forbidden terms are exactly zero, without an infinity sentinel or invented shifted value. Allowed terms can underflow; a large common shift can change low bits.

Saved inputs
b
0
h
0
i
1
mode
1
shift
0
score0
0.5279882808809828
score1
0.4804473007505278
allowed0
1
allowed1
1
Saved outputs
max
0.5279882808809828
denominator
1.953571394851756
shifted0
0
shifted1
-0.047540980130455046
term0
1
term1
0.953571394851756
p0
0.511883007007217
p1
0.4881169929927831

decoder_block2_attn_head_mix_0_0_0_0: OHeads[0,0,0,0]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
0
f
0
p0
1
v0
0.9058554533228621
p1
0
v1
0.8242906579156054
Saved outputs
product0
0.9058554533228621
product1
0
running0
0.9058554533228621
running1
0.9058554533228621
value
0.9058554533228621

decoder_block2_attn_head_mix_0_0_0_1: OHeads[0,0,0,1]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
0
f
1
p0
1
v0
-0.9058554533228621
p1
0
v1
-0.8242906579156055
Saved outputs
product0
-0.9058554533228621
product1
-0
running0
-0.9058554533228621
running1
-0.9058554533228621
value
-0.9058554533228621

decoder_block2_attn_head_mix_0_0_1_0: OHeads[0,0,1,0]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
1
f
0
p0
0.511883007007217
v0
0.9058554533228621
p1
0.4881169929927831
v1
0.8242906579156054
Saved outputs
product0
0.46369201336079235
product1
0.4023502772938081
running0
0.46369201336079235
running1
0.8660422906546005
value
0.8660422906546005

decoder_block2_attn_head_mix_0_0_1_1: OHeads[0,0,1,1]: this head’s weighted values

product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum

Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.

Saved inputs
b
0
h
0
i
1
f
1
p0
0.511883007007217
v0
-0.9058554533228621
p1
0.4881169929927831
v1
-0.8242906579156055
Saved outputs
product0
-0.46369201336079235
product1
-0.4023502772938082
running0
-0.46369201336079235
running1
-0.8660422906546006
value
-0.8660422906546006

decoder_block2_attn_concat_0_0_0_0: Join head 0, feature 0 into C[0,0,0]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
0
h
0
f
0
concatFeature
0
sourceOffset
0
destinationOffset
0
sourceValue
0.9058554533228621
Saved outputs
value
0.9058554533228621

decoder_block2_attn_concat_0_0_0_1: Join head 0, feature 1 into C[0,0,1]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
0
h
0
f
1
concatFeature
1
sourceOffset
1
destinationOffset
1
sourceValue
-0.9058554533228621
Saved outputs
value
-0.9058554533228621

decoder_block2_attn_concat_0_1_0_0: Join head 0, feature 0 into C[0,1,0]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
1
h
0
f
0
concatFeature
0
sourceOffset
2
destinationOffset
2
sourceValue
0.8660422906546005
Saved outputs
value
0.8660422906546005

decoder_block2_attn_concat_0_1_0_1: Join head 0, feature 1 into C[0,1,1]

C[b,t,h*Dv+f]=OHeads[b,h,t,f]

Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.

Saved inputs
b
0
t
1
h
0
f
1
concatFeature
1
sourceOffset
3
destinationOffset
3
sourceValue
-0.8660422906546006
Saved outputs
value
-0.8660422906546006

decoder_block2_attn_output_0_0_0: Y[0,0,0]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
0
d
0
c0
0.9058554533228621
w0
0.25
c1
-0.9058554533228621
w1
0
Saved outputs
product0
0.22646386333071553
product1
-0
running0
0.22646386333071553
running1
0.22646386333071553
value
0.22646386333071553

decoder_block2_attn_output_0_0_1: Y[0,0,1]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
0
d
1
c0
0.9058554533228621
w0
0
c1
-0.9058554533228621
w1
0.25
Saved outputs
product0
0
product1
-0.22646386333071553
running0
0
running1
-0.22646386333071553
value
-0.22646386333071553

decoder_block2_attn_output_0_1_0: Y[0,1,0]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
1
d
0
c0
0.8660422906546005
w0
0.25
c1
-0.8660422906546006
w1
0
Saved outputs
product0
0.21651057266365012
product1
-0
running0
0.21651057266365012
running1
0.21651057266365012
value
0.21651057266365012

decoder_block2_attn_output_0_1_1: Y[0,1,1]: explicit output projection

product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum

WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.

Saved inputs
b
0
t
1
d
1
c0
0.8660422906546005
w0
0
c1
-0.8660422906546006
w1
0.25
Saved outputs
product0
0
product1
-0.21651057266365015
running0
0
running1
-0.21651057266365015
value
-0.21651057266365015

decoder_block2_r1_0_0_0: decoder_block2_R1[0,0,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
0
skip
1.7849814953237821
branch
0.22646386333071553
Saved outputs
value
2.011445358654498

decoder_block2_r1_0_0_1: decoder_block2_R1[0,0,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
1
skip
-0.35355339059327373
branch
-0.22646386333071553
Saved outputs
value
-0.5800172539239893

decoder_block2_r1_0_1_0: decoder_block2_R1[0,1,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
0
skip
1.6620067484160792
branch
0.21651057266365012
Saved outputs
value
1.8785173210797292

decoder_block2_r1_0_1_1: decoder_block2_R1[0,1,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
1
skip
0.2060920369795486
branch
-0.21651057266365015
Saved outputs
value
-0.01041853568410156

decoder_block2_n2_0_0_statistics: 0_0: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
2.011445358654498
x1
-0.5800172539239893
epsilon
0.25
Saved outputs
sum
1.4314281047305086
mean
0.7157140523652543
centered0
1.2957313062892435
centered1
-1.2957313062892437
square0
1.6789196180980293
square1
1.67891961809803
squareSum
3.3578392361960594
variance
1.6789196180980297
variancePlusEpsilon
1.9289196180980297
denominator
1.3888555065585584

decoder_block2_n2_0_0_feature_0: 0_0: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
1.2957313062892435
denominator
1.3888555065585584
gamma
1
beta
0
Saved outputs
normalized
0.9329489642158189
scaled
0.9329489642158189
value
0.9329489642158189

decoder_block2_n2_0_0_feature_1: 0_0: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-1.2957313062892437
denominator
1.3888555065585584
gamma
1
beta
0
Saved outputs
normalized
-0.9329489642158191
scaled
-0.9329489642158191
value
-0.9329489642158191

decoder_block2_n2_0_1_statistics: 0_1: feature-only mean and population variance

sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)

Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.

Saved inputs
x0
1.8785173210797292
x1
-0.01041853568410156
epsilon
0.25
Saved outputs
sum
1.8680987853956277
mean
0.9340493926978138
centered0
0.9444679283819154
centered1
-0.9444679283819154
square0
0.8920196677420269
square1
0.8920196677420269
squareSum
1.7840393354840538
variance
0.8920196677420269
variancePlusEpsilon
1.142019667742027
denominator
1.0686532027472837

decoder_block2_n2_0_1_feature_0: 0_1: affine feature 0

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
0
source
0.9444679283819154
denominator
1.0686532027472837
gamma
1
beta
0
Saved outputs
normalized
0.8837927271016323
scaled
0.8837927271016323
value
0.8837927271016323

decoder_block2_n2_0_1_feature_1: 0_1: affine feature 1

normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta

The source is the saved centered feature. Gamma and beta may change output mean and variance.

Saved inputs
d
1
source
-0.9444679283819154
denominator
1.0686532027472837
gamma
1
beta
0
Saved outputs
normalized
-0.8837927271016323
scaled
-0.8837927271016323
value
-0.8837927271016323

decoder_block2_ffn_hidden_0_0_0: Hidden affine [0,0,0]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
0
x0
0.9329489642158189
x1
-0.9329489642158191
w0
1
w1
0
bias
0
Saved outputs
product0
0.9329489642158189
product1
-0
sum
0.9329489642158189
preactivation
0.9329489642158189

decoder_block2_ffn_hidden_0_0_1: Hidden affine [0,0,1]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
1
x0
0.9329489642158189
x1
-0.9329489642158191
w0
0
w1
1
bias
0
Saved outputs
product0
0
product1
-0.9329489642158191
sum
-0.9329489642158191
preactivation
-0.9329489642158191

decoder_block2_ffn_hidden_0_0_2: Hidden affine [0,0,2]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
0
m
2
x0
0.9329489642158189
x1
-0.9329489642158191
w0
0
w1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
preactivation
0

decoder_block2_ffn_hidden_0_1_0: Hidden affine [0,1,0]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
0
x0
0.8837927271016323
x1
-0.8837927271016323
w0
1
w1
0
bias
0
Saved outputs
product0
0.8837927271016323
product1
-0
sum
0.8837927271016323
preactivation
0.8837927271016323

decoder_block2_ffn_hidden_0_1_1: Hidden affine [0,1,1]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
1
x0
0.8837927271016323
x1
-0.8837927271016323
w0
0
w1
1
bias
0
Saved outputs
product0
0
product1
-0.8837927271016323
sum
-0.8837927271016323
preactivation
-0.8837927271016323

decoder_block2_ffn_hidden_0_1_2: Hidden affine [0,1,2]

product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias

The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.

Saved inputs
b
0
t
1
m
2
x0
0.8837927271016323
x1
-0.8837927271016323
w0
0
w1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
preactivation
0

decoder_block2_ffn_relu_0_0_0: ReLU [0,0,0]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
0
preactivation
0.9329489642158189
Saved outputs
activation
0.9329489642158189

decoder_block2_ffn_relu_0_0_1: ReLU [0,0,1]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
1
preactivation
-0.9329489642158191
Saved outputs
activation
0

decoder_block2_ffn_relu_0_0_2: ReLU [0,0,2]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
0
m
2
preactivation
0
Saved outputs
activation
0

decoder_block2_ffn_relu_0_1_0: ReLU [0,1,0]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
0
preactivation
0.8837927271016323
Saved outputs
activation
0.8837927271016323

decoder_block2_ffn_relu_0_1_1: ReLU [0,1,1]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
1
preactivation
-0.8837927271016323
Saved outputs
activation
0

decoder_block2_ffn_relu_0_1_2: ReLU [0,1,2]

activation=max(0,preactivation)

ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.

Saved inputs
b
0
t
1
m
2
preactivation
0
Saved outputs
activation
0

decoder_block2_ffn_output_0_0_0: FFN output [0,0,0]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
0
d
0
h0
0.9329489642158189
w0
0.25
h1
0
w1
0
h2
0
w2
0
bias
0
Saved outputs
product0
0.2332372410539547
product1
0
product2
0
running0
0.2332372410539547
running1
0.2332372410539547
running2
0.2332372410539547
sum
0.2332372410539547
value
0.2332372410539547

decoder_block2_ffn_output_0_0_1: FFN output [0,0,1]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
0
d
1
h0
0.9329489642158189
w0
0
h1
0
w1
0.25
h2
0
w2
0
bias
0
Saved outputs
product0
0
product1
0
product2
0
running0
0
running1
0
running2
0
sum
0
value
0

decoder_block2_ffn_output_0_1_0: FFN output [0,1,0]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
1
d
0
h0
0.8837927271016323
w0
0.25
h1
0
w1
0
h2
0
w2
0
bias
0
Saved outputs
product0
0.22094818177540806
product1
0
product2
0
running0
0.22094818177540806
running1
0.22094818177540806
running2
0.22094818177540806
sum
0.22094818177540806
value
0.22094818177540806

decoder_block2_ffn_output_0_1_1: FFN output [0,1,1]

product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias

Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.

Saved inputs
b
0
t
1
d
1
h0
0.8837927271016323
w0
0
h1
0
w1
0.25
h2
0
w2
0
bias
0
Saved outputs
product0
0
product1
0
product2
0
running0
0
running1
0
running2
0
sum
0
value
0

decoder_block2_r2_0_0_0: decoder_block2_Output[0,0,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
0
skip
2.011445358654498
branch
0.2332372410539547
Saved outputs
value
2.2446825997084527

decoder_block2_r2_0_0_1: decoder_block2_Output[0,0,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
0
d
1
skip
-0.5800172539239893
branch
0
Saved outputs
value
-0.5800172539239893

decoder_block2_r2_0_1_0: decoder_block2_Output[0,1,0]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
0
skip
1.8785173210797292
branch
0.22094818177540806
Saved outputs
value
2.0994655028551374

decoder_block2_r2_0_1_1: decoder_block2_Output[0,1,1]: skip plus branch

value=skip+branch

The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.

Saved inputs
b
0
t
1
d
1
skip
-0.01041853568410156
branch
0
Saved outputs
value
-0.01041853568410156

decoder_readout_0_0: Readout at position 0, class 0

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
0
c
0
x0
2.2446825997084527
x1
-0.5800172539239893
u0
1
u1
0
bias
0
Saved outputs
product0
2.2446825997084527
product1
-0
sum
2.2446825997084527
logit
2.2446825997084527

decoder_readout_0_1: Readout at position 0, class 1

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
0
c
1
x0
2.2446825997084527
x1
-0.5800172539239893
u0
0
u1
1
bias
0
Saved outputs
product0
0
product1
-0.5800172539239893
sum
-0.5800172539239893
logit
-0.5800172539239893

decoder_readout_0_2: Readout at position 0, class 2

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
0
c
2
x0
2.2446825997084527
x1
-0.5800172539239893
u0
0
u1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
logit
0

decoder_readout_1_0: Readout at position 1, class 0

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
1
c
0
x0
2.0994655028551374
x1
-0.01041853568410156
u0
1
u1
0
bias
0
Saved outputs
product0
2.0994655028551374
product1
-0
sum
2.0994655028551374
logit
2.0994655028551374

decoder_readout_1_1: Readout at position 1, class 1

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
1
c
1
x0
2.0994655028551374
x1
-0.01041853568410156
u0
0
u1
1
bias
0
Saved outputs
product0
0
product1
-0.01041853568410156
sum
-0.01041853568410156
logit
-0.01041853568410156

decoder_readout_1_2: Readout at position 1, class 2

product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias

Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.

Saved inputs
t
1
c
2
x0
2.0994655028551374
x1
-0.01041853568410156
u0
0
u1
0
bias
0
Saved outputs
product0
0
product1
-0
sum
0
logit
0

decoder_classMax_0: Stable class maximum at position 0

max=logit0; scan class1,class2; replace only on strict greater

The maximum is selected from the actual saved logits. Class order is a,b,EOS with ascending IDs 97,98,512.

Saved inputs
logit0
2.2446825997084527
logit1
-0.5800172539239893
logit2
0
Saved outputs
max
2.2446825997084527

decoder_classExp_0_0: Stable class exponential at position 0, class 0

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
2.2446825997084527
max
2.2446825997084527
Saved outputs
shifted
0
term
1

decoder_classExp_0_1: Stable class exponential at position 0, class 1

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
-0.5800172539239893
max
2.2446825997084527
Saved outputs
shifted
-2.824699853632442
term
0.05932646077911259

decoder_classExp_0_2: Stable class exponential at position 0, class 2

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
0
max
2.2446825997084527
Saved outputs
shifted
-2.2446825997084527
term
0.10596116714203357

decoder_classSum_0_0: Ordered class denominator at position 0, class 0

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
0
term
1
Saved outputs
sum
1

decoder_classSum_0_1: Ordered class denominator at position 0, class 1

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
1
term
0.05932646077911259
Saved outputs
sum
1.0593264607791126

decoder_classSum_0_2: Ordered class denominator at position 0, class 2

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
1.0593264607791126
term
0.10596116714203357
Saved outputs
sum
1.1652876279211462

decoder_classProbability_0_0: Class probability at position 0, class 0

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
1
denominator
1.1652876279211462
Saved outputs
probability
0.8581572274855295

decoder_classProbability_0_1: Class probability at position 0, class 1

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
0.05932646077911259
denominator
1.1652876279211462
Saved outputs
probability
0.050911431098732265

decoder_classProbability_0_2: Class probability at position 0, class 2

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
0.10596116714203357
denominator
1.1652876279211462
Saved outputs
probability
0.09093134141573832

decoder_argmax_0: Greedy recommendation from position 0

index=first maximum logit; tokenId=IDS[index]; probability=probabilities[index]

Strict-greater scanning retains the smallest actual token ID on an exact logit tie. This row recommends the next token after this observed prefix; it does not append it.

Saved inputs
logit0
2.2446825997084527
logit1
-0.5800172539239893
logit2
0
probability0
0.8581572274855295
probability1
0.050911431098732265
probability2
0.09093134141573832
Saved outputs
index
0
tokenId
97
probability
0.8581572274855295

decoder_classMax_1: Stable class maximum at position 1

max=logit0; scan class1,class2; replace only on strict greater

The maximum is selected from the actual saved logits. Class order is a,b,EOS with ascending IDs 97,98,512.

Saved inputs
logit0
2.0994655028551374
logit1
-0.01041853568410156
logit2
0
Saved outputs
max
2.0994655028551374

decoder_classExp_1_0: Stable class exponential at position 1, class 0

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
2.0994655028551374
max
2.0994655028551374
Saved outputs
shifted
0
term
1

decoder_classExp_1_1: Stable class exponential at position 1, class 1

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
-0.01041853568410156
max
2.0994655028551374
Saved outputs
shifted
-2.109884038539239
term
0.12125202618024761

decoder_classExp_1_2: Stable class exponential at position 1, class 2

shifted=logit-max; term=exp(shifted)

Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.

Saved inputs
logit
0
max
2.0994655028551374
Saved outputs
shifted
-2.0994655028551374
term
0.12252189835948703

decoder_classSum_1_0: Ordered class denominator at position 1, class 0

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
0
term
1
Saved outputs
sum
1

decoder_classSum_1_1: Ordered class denominator at position 1, class 1

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
1
term
0.12125202618024761
Saved outputs
sum
1.1212520261802477

decoder_classSum_1_2: Ordered class denominator at position 1, class 2

sum=previous+term

Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.

Saved inputs
previous
1.1212520261802477
term
0.12252189835948703
Saved outputs
sum
1.2437739245397348

decoder_classProbability_1_0: Class probability at position 1, class 0

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
1
denominator
1.2437739245397348
Saved outputs
probability
0.804004634821441

decoder_classProbability_1_1: Class probability at position 1, class 1

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
0.12125202618024761
denominator
1.2437739245397348
Saved outputs
probability
0.09748719103040979

decoder_classProbability_1_2: Class probability at position 1, class 2

probability=term/denominator

Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.

Saved inputs
term
0.12252189835948703
denominator
1.2437739245397348
Saved outputs
probability
0.09850817414814908

decoder_argmax_1: Greedy recommendation from position 1

index=first maximum logit; tokenId=IDS[index]; probability=probabilities[index]

Strict-greater scanning retains the smallest actual token ID on an exact logit tie. This row recommends the next token after this observed prefix; it does not append it.

Saved inputs
logit0
2.0994655028551374
logit1
-0.01041853568410156
logit2
0
probability0
0.804004634821441
probability1
0.09748719103040979
probability2
0.09850817414814908
Saved outputs
index
0
tokenId
97
probability
0.804004634821441

finish: Recommend from the last observed position

nextTokenId=argmaxIds[1]; nextTokenProbability=selectedProbabilities[1]

Copy the selected ID and probability from position one, after both actual blocks. Position zero remains inspectable. Counts describe the declared source graph; they measure neither hardware work nor training, and no token is appended.

Saved inputs
lastPosition
1
index
0
tokenId
97
probability
0.804004634821441
Saved outputs
nextTokenId
97
nextTokenProbability
0.804004634821441
blockCount
2
observedPositions
2
featureWidth
2
hiddenWidth
3
vocabularySize
3
sqrtCalls
10
expCalls
12
nativeElementaryCalls
22
frames
198
tensorCount
115
Saved source counts, input policy and numerical limits
Twelve saved primary root outputs
Output keySaved value
nextTokenId97
nextTokenProbability0.804004634821441
blockCount2
observedPositions2
featureWidth2
hiddenWidth3
vocabularySize3
sqrtCalls10
expCalls12
nativeElementaryCalls22
frames198
tensorCount115

Exact own-data raw16 on a plain/null-prototype object: all descriptors, then all actual finite numbers, then domains in raw order, then ASCII prefix. Tokens are integer members {97,98,512}; positionScale [0,1]; ten gains [-1,1]; three biases [-2,2]. No coercion, clamping, partial defaults or skipped inactive computation.

Separate finite binary64 scalar operations retain primitive order without contraction or reassociation. Every numeric operand/result/copy uses WORD including admitted -0, except explicit token IDs, indices, dimensions, mask decisions, kind codes and counts use VALUE. Display precision8 is presentation only. Root Raw token cells are VALUE and its other fourteen cells are WORD.

Every actual primitive frame is retained with prefixed block IDs and unchanged kernel label, equation, explanation and operand-key order. The local factory captures finite inputs/outputs once, checks nonempty unique IDs before operands and the 512 cap after operands, then freezes detached frames. Every frame output appears as frameId_key in root outputs; no alias recomputes arithmetic.

nextTokenId is the last observed row selected token ID (VALUE); nextTokenProbability is its unchanged actual probability word. All other primary summaries are integer VALUE source counts. Root nativeIds/nativeKinds bind decoder_NativeArguments input/output rows and decoder_NativeKinds codes; block native tensors/texts bind the identical occurrences again.

Authored forward-only toy with hand-set embeddings, gains, norms, FFN and readout. Two blocks are neither two generated tokens nor two optimizer steps. An observed EOS is an input embedding; generated-EOS stopping is not implemented. No loss, gradient, training, sampling, cache, latency, production intelligence or physical-trace claim. Runtime validation remains deferred under the FluxGeo hold.

Owner-chosen IV59 toy within the human full-book source authorization; these concrete model choices are not attributed to the human or the dossier. No external model or dataset.

SOURCE IMPLEMENTATION ONLY. All tests, independent executable authority, canonical parity, typecheck, build, browser, accessibility and offline checks are UNRUN under the human FluxGeo hold. Source adoption and validation belong to the owner; this record is not runtime acceptance.

The two block storage sections and remaining root section expose all 115 saved tensors. The house inspector below also exposes every scalar alias, all text metadata and each tensor. Each table, graph value, native row and frame reads this same saved root; no view performs model arithmetic.

Inspect all stored values, text metadata and tensor storage

Every scalar output, including flattened operation outputs

Exact text evidence from the same record

These are the stored values, shown without display rounding. Each tensor names its axes, dtype and display precision. Empty arrays are omitted rather than padded.

decoder_Raw

RawField=16 · float64 · precision 8 · Captured raw16 in declared field order; token0/token1 cells are integer VALUE, all other cells binary64 WORD.

Zero-based storage indexStored value
097
197
20.5
31
41
51
60.5
70.5
81
90.5
101
110.25
120.25
130
140
150

decoder_TokenIds

B=1 × T=2 · int32 · precision 0 · Both observed input token IDs; EOS is an ordinary explicit lookup row here.

Zero-based storage indexStored value
097
197

decoder_VocabularyIds

Vocab=3 · int32 · precision 0 · Class order and strict-tie ID order: a=97,b=98,EOS=512.

Zero-based storage indexStored value
097
198
2512

decoder_E

Vocab=3 × D=2 · float64 · precision 8 · Authored embedding rows [1,0],[0,1],[0,0] for a,b,EOS.

Zero-based storage indexStored value
01
10
20
31
40
50

decoder_Positions

B=1 × T=2 × D=2 · float64 · precision 8 · Literal P0=[+0,+0], P1=[+0,positionScale]; disclosed absolute position addition.

Zero-based storage indexStored value
00
10
20
30.5

decoder_Embeddings

B=1 × T=2 × D=2 · float64 · precision 8 · Actual E lookup copies before position addition.

Zero-based storage indexStored value
01
10
21
30

decoder_Features

B=1 × T=2 × D=2 · float64 · precision 8 · Actual lookup plus position sums; first block input, retained on its residual skip.

Zero-based storage indexStored value
01
10
21
30.5

decoder_block1_Features

B=1 × T=2 × D=2 · float64 · precision 8 · Actual captured per-position block features; repeated token IDs do not merge positions.

Zero-based storage indexStored value
01
10
21
30.5

decoder_block1_Gains

Gain=5 · float64 · precision 8 · Actual q,k,v,o,f gain words; diagonal slots copy these words and off-diagonal slots are literal +0.

Zero-based storage indexStored value
01
11
21
30.5
40.5

decoder_block1_n1_Gamma

D=2 · float64 · precision 8 · Shared literal feature scales [1,1].

Zero-based storage indexStored value
01
11

decoder_block1_n1_Beta

D=2 · float64 · precision 8 · Shared literal feature offsets [+0,+0].

Zero-based storage indexStored value
00
10

decoder_block1_n1_Statistics

B=1 × T=2 × NormStatistic=10 · float64 · precision 8 · Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

Zero-based storage indexStored value
01
10.5
20.5
3-0.5
40.25
50.25
60.5
70.25
80.5
90.7071067811865476
101.5
110.75
120.25
13-0.25
140.0625
150.0625
160.125
170.0625
180.3125
190.5590169943749475

decoder_block1_n1_Centered

B=1 × T=2 × D=2 · float64 · precision 8 · Actual saved input feature minus feature mean, before division.

Zero-based storage indexStored value
00.5
1-0.5
20.25
3-0.25

decoder_block1_n1_Normalized

B=1 × T=2 × D=2 · float64 · precision 8 · Actual centered/denominator words before gamma multiplication and beta addition.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_n1_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_X

B=1 × T=2 × D=2 · float64 · precision 8 · Active token rows; D=2 input features always retained.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_WQ

D=2 × QueryFeature=2 · float64 · precision 8 · Query columns packed by h*Dk+f from wq{d}{h}{f}.

Zero-based storage indexStored value
01
10
20
31

decoder_block1_attn_WK

D=2 × KeyFeature=2 · float64 · precision 8 · Key columns packed by h*Dk+f from wk{d}{h}{f}.

Zero-based storage indexStored value
01
10
20
31

decoder_block1_attn_WV

D=2 × ValueFeature=2 · float64 · precision 8 · Value columns packed by h*Dv+f from wv{d}{h}{f}.

Zero-based storage indexStored value
01
10
20
31

decoder_block1_attn_QConcat

B=1 × T=2 × QueryFeature=2 · float64 · precision 8 · XWQ; each packed coordinate has two products and one sum.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_KConcat

B=1 × T=2 × KeyFeature=2 · float64 · precision 8 · XWK; each packed coordinate has two products and one sum.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_VConcat

B=1 × T=2 × ValueFeature=2 · float64 · precision 8 · XWV; values are projected separately from queries and keys.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_QSplit

B=1 × T=2 × H=1 × Dk=2 · float64 · precision 8 · QConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_QHeads

B=1 × H=1 × T=2 × Dk=2 · float64 · precision 8 · QSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_KSplit

B=1 × T=2 × H=1 × Dk=2 · float64 · precision 8 · KConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_KHeads

B=1 × H=1 × T=2 × Dk=2 · float64 · precision 8 · KSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_VSplit

B=1 × T=2 × H=1 × Dv=2 · float64 · precision 8 · VConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_VHeads

B=1 × H=1 × T=2 × Dv=2 · float64 · precision 8 · VSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.4472135954999579
3-0.4472135954999579

decoder_block1_attn_raw

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Separate QHeads KHeads transpose products within every batch and head.

Zero-based storage indexStored value
00.9999999999999998
10.6324555320336758
20.6324555320336758
30.39999999999999997

decoder_block1_attn_scores

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · raw/sqrt(Dk); the two-product order matches IV25 for H1,Dk2.

Zero-based storage indexStored value
00.7071067811865474
10.4472135954999578
20.4472135954999578
30.28284271247461895

decoder_block1_attn_allowed

B=1 × H=1 × Query=2 × Key=2 · bool · precision 8 · Causal and/or valid-key mask; shared validity across B and H; every query retained.

Zero-based storage indexStored value
0true
1false
2true
3true

decoder_block1_attn_logits

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Finite score+shift, including forbidden cells; mask applied separately.

Zero-based storage indexStored value
00.7071067811865474
10.4472135954999578
20.4472135954999578
30.28284271247461895

decoder_block1_attn_probabilities

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Stable allowed-key softmax for each B/H/query independently; forbidden probabilities exactly zero.

Zero-based storage indexStored value
01
10
20.5410004505100806
30.4589995494899193

decoder_block1_attn_OHeads

B=1 × H=1 × Query=2 × Dv=2 · float64 · precision 8 · Actual per-head P times VHeads; every product and running sum is traced.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.5878159260409028
3-0.5878159260409028

decoder_block1_attn_C

B=1 × T=2 × JoinedValue=2 · float64 · precision 8 · OHeads permuted to token-major order then joined by c=h*Dv+f; values unchanged.

Zero-based storage indexStored value
00.7071067811865475
1-0.7071067811865475
20.5878159260409028
3-0.5878159260409028

decoder_block1_attn_WO

JoinedValue=2 × D=2 · float64 · precision 8 · wo{h}{f}{d} packed in h,f,d order, preserving parameter identity.

Zero-based storage indexStored value
00.5
10
20
30.5

decoder_block1_attn_Y

B=1 × T=2 × D=2 · float64 · precision 8 · Y=C WO, summing products in ascending joined-feature order from zero; no normalization.

Zero-based storage indexStored value
00.35355339059327373
1-0.35355339059327373
20.2939079630204514
3-0.2939079630204514

decoder_block1_R1

B=1 × T=2 × D=2 · float64 · precision 8 · Exact named-shape addition of decoder_block1_Features and decoder_block1_attn_Y; no broadcasting.

Zero-based storage indexStored value
01.3535533905932737
1-0.35355339059327373
21.2939079630204513
30.2060920369795486

decoder_block1_n2_Gamma

D=2 · float64 · precision 8 · Shared literal feature scales [1,1].

Zero-based storage indexStored value
01
11

decoder_block1_n2_Beta

D=2 · float64 · precision 8 · Shared literal feature offsets [+0,+0].

Zero-based storage indexStored value
00
10

decoder_block1_n2_Statistics

B=1 × T=2 × NormStatistic=10 · float64 · precision 8 · Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

Zero-based storage indexStored value
01
10.5
20.8535533905932737
3-0.8535533905932737
40.7285533905932737
50.7285533905932737
61.4571067811865475
70.7285533905932737
80.9785533905932737
90.9892185757421227
101.5
110.75
120.5439079630204513
13-0.5439079630204514
140.2958358722370566
150.29583587223705676
160.5916717444741133
170.29583587223705665
180.5458358722370567
190.738807060224154

decoder_block1_n2_Centered

B=1 × T=2 × D=2 · float64 · precision 8 · Actual saved input feature minus feature mean, before division.

Zero-based storage indexStored value
00.8535533905932737
1-0.8535533905932737
20.5439079630204513
3-0.5439079630204514

decoder_block1_n2_Normalized

B=1 × T=2 × D=2 · float64 · precision 8 · Actual centered/denominator words before gamma multiplication and beta addition.

Zero-based storage indexStored value
00.8628562094610168
1-0.8628562094610168
20.7361975707912559
3-0.7361975707912561

decoder_block1_n2_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

Zero-based storage indexStored value
00.8628562094610168
1-0.8628562094610168
20.7361975707912559
3-0.7361975707912561

decoder_block1_ffn_W1

D=2 × HiddenFeature=3 · float64 · precision 8 · Shared input-to-hidden weights, f1{d}{m}; M=3 hidden features.

Zero-based storage indexStored value
01
10
20
30
41
50

decoder_block1_ffn_b1

HiddenFeature=3 · float64 · precision 8 · Shared hidden bias, added after the two products.

Zero-based storage indexStored value
00
10
20

decoder_block1_ffn_Z

B=1 × T=2 × HiddenFeature=3 · float64 · precision 8 · Hidden preactivations X W1+b1; no batch or token mixing.

Zero-based storage indexStored value
00.8628562094610168
1-0.8628562094610168
20
30.7361975707912559
4-0.7361975707912561
50

decoder_block1_ffn_Hidden

B=1 × T=2 × HiddenFeature=3 · float64 · precision 8 · ReLU(Z)=max(0,Z), before the second affine layer.

Zero-based storage indexStored value
00.8628562094610168
10
20
30.7361975707912559
40
50

decoder_block1_ffn_W2

HiddenFeature=3 × D=2 · float64 · precision 8 · Shared hidden-to-output weights, f2{m}{d}.

Zero-based storage indexStored value
00.5
10
20
30.5
40
50

decoder_block1_ffn_b2

D=2 · float64 · precision 8 · Shared output bias, added after all three running sums.

Zero-based storage indexStored value
00
10

decoder_block1_ffn_F

B=1 × T=2 × D=2 · float64 · precision 8 · ReLU(X W1+b1) W2+b2, independently per token with shared parameters.

Zero-based storage indexStored value
00.4314281047305084
10
20.36809878539562796
30

decoder_block1_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Exact named-shape addition of decoder_block1_R1 and decoder_block1_ffn_F; no broadcasting.

Zero-based storage indexStored value
01.7849814953237821
1-0.35355339059327373
21.6620067484160792
30.2060920369795486

decoder_block1_NativeArguments

Native=8 × NativeField=2 · float64 · precision 8 · Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

Zero-based storage indexStored value
00.5
10.7071067811865476
20.3125
30.5590169943749475
42
51.4142135623730951
60
71
80
91
10-0.16437088302533887
110.8484272962382063
120.9785533905932737
130.9892185757421227
140.5458358722370567
150.738807060224154

decoder_block1_NativeKinds

Native=8 · int32 · precision 0 · Native kind codes in native occurrence order: sqrt=0, exp=1.

Zero-based storage indexStored value
00
10
20
31
41
51
60
70

decoder_block2_Features

B=1 × T=2 × D=2 · float64 · precision 8 · Actual captured per-position block features; repeated token IDs do not merge positions.

Zero-based storage indexStored value
01.7849814953237821
1-0.35355339059327373
21.6620067484160792
30.2060920369795486

decoder_block2_Gains

Gain=5 · float64 · precision 8 · Actual q,k,v,o,f gain words; diagonal slots copy these words and off-diagonal slots are literal +0.

Zero-based storage indexStored value
01
10.5
21
30.25
40.25

decoder_block2_n1_Gamma

D=2 · float64 · precision 8 · Shared literal feature scales [1,1].

Zero-based storage indexStored value
01
11

decoder_block2_n1_Beta

D=2 · float64 · precision 8 · Shared literal feature offsets [+0,+0].

Zero-based storage indexStored value
00
10

decoder_block2_n1_Statistics

B=1 × T=2 × NormStatistic=10 · float64 · precision 8 · Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

Zero-based storage indexStored value
01.4314281047305084
10.7157140523652542
21.069267442958528
3-1.069267442958528
41.143332864571069
51.143332864571069
62.286665729142138
71.143332864571069
81.393332864571069
91.180395215413494
101.868098785395628
110.934049392697814
120.7279573557182653
13-0.7279573557182654
140.529921911744329
150.5299219117443291
161.059843823488658
170.529921911744329
180.779921911744329
190.8831318767569932

decoder_block2_n1_Centered

B=1 × T=2 × D=2 · float64 · precision 8 · Actual saved input feature minus feature mean, before division.

Zero-based storage indexStored value
01.069267442958528
1-1.069267442958528
20.7279573557182653
3-0.7279573557182654

decoder_block2_n1_Normalized

B=1 × T=2 × D=2 · float64 · precision 8 · Actual centered/denominator words before gamma multiplication and beta addition.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_n1_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_X

B=1 × T=2 × D=2 · float64 · precision 8 · Active token rows; D=2 input features always retained.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_WQ

D=2 × QueryFeature=2 · float64 · precision 8 · Query columns packed by h*Dk+f from wq{d}{h}{f}.

Zero-based storage indexStored value
01
10
20
31

decoder_block2_attn_WK

D=2 × KeyFeature=2 · float64 · precision 8 · Key columns packed by h*Dk+f from wk{d}{h}{f}.

Zero-based storage indexStored value
00.5
10
20
30.5

decoder_block2_attn_WV

D=2 × ValueFeature=2 · float64 · precision 8 · Value columns packed by h*Dv+f from wv{d}{h}{f}.

Zero-based storage indexStored value
01
10
20
31

decoder_block2_attn_QConcat

B=1 × T=2 × QueryFeature=2 · float64 · precision 8 · XWQ; each packed coordinate has two products and one sum.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_KConcat

B=1 × T=2 × KeyFeature=2 · float64 · precision 8 · XWK; each packed coordinate has two products and one sum.

Zero-based storage indexStored value
00.45292772666143105
1-0.45292772666143105
20.4121453289578027
3-0.41214532895780276

decoder_block2_attn_VConcat

B=1 × T=2 × ValueFeature=2 · float64 · precision 8 · XWV; values are projected separately from queries and keys.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_QSplit

B=1 × T=2 × H=1 × Dk=2 · float64 · precision 8 · QConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_QHeads

B=1 × H=1 × T=2 × Dk=2 · float64 · precision 8 · QSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_KSplit

B=1 × T=2 × H=1 × Dk=2 · float64 · precision 8 · KConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.45292772666143105
1-0.45292772666143105
20.4121453289578027
3-0.41214532895780276

decoder_block2_attn_KHeads

B=1 × H=1 × T=2 × Dk=2 · float64 · precision 8 · KSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.45292772666143105
1-0.45292772666143105
20.4121453289578027
3-0.41214532895780276

decoder_block2_attn_VSplit

B=1 × T=2 × H=1 × Dv=2 · float64 · precision 8 · VConcat reshaped without changing flat order; feature=h*F+f.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_VHeads

B=1 × H=1 × T=2 × Dv=2 · float64 · precision 8 · VSplit permuted by axes [0,2,1,3]; every copied source/destination offset is traced.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8242906579156054
3-0.8242906579156055

decoder_block2_attn_raw

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Separate QHeads KHeads transpose products within every batch and head.

Zero-based storage indexStored value
00.820574102314768
10.746688187595941
20.746688187595941
30.6794550887269417

decoder_block2_attn_scores

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · raw/sqrt(Dk); the two-product order matches IV25 for H1,Dk2.

Zero-based storage indexStored value
00.5802335122128363
10.5279882808809828
20.5279882808809828
30.4804473007505278

decoder_block2_attn_allowed

B=1 × H=1 × Query=2 × Key=2 · bool · precision 8 · Causal and/or valid-key mask; shared validity across B and H; every query retained.

Zero-based storage indexStored value
0true
1false
2true
3true

decoder_block2_attn_logits

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Finite score+shift, including forbidden cells; mask applied separately.

Zero-based storage indexStored value
00.5802335122128363
10.5279882808809828
20.5279882808809828
30.4804473007505278

decoder_block2_attn_probabilities

B=1 × H=1 × Query=2 × Key=2 · float64 · precision 8 · Stable allowed-key softmax for each B/H/query independently; forbidden probabilities exactly zero.

Zero-based storage indexStored value
01
10
20.511883007007217
30.4881169929927831

decoder_block2_attn_OHeads

B=1 × H=1 × Query=2 × Dv=2 · float64 · precision 8 · Actual per-head P times VHeads; every product and running sum is traced.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8660422906546005
3-0.8660422906546006

decoder_block2_attn_C

B=1 × T=2 × JoinedValue=2 · float64 · precision 8 · OHeads permuted to token-major order then joined by c=h*Dv+f; values unchanged.

Zero-based storage indexStored value
00.9058554533228621
1-0.9058554533228621
20.8660422906546005
3-0.8660422906546006

decoder_block2_attn_WO

JoinedValue=2 × D=2 · float64 · precision 8 · wo{h}{f}{d} packed in h,f,d order, preserving parameter identity.

Zero-based storage indexStored value
00.25
10
20
30.25

decoder_block2_attn_Y

B=1 × T=2 × D=2 · float64 · precision 8 · Y=C WO, summing products in ascending joined-feature order from zero; no normalization.

Zero-based storage indexStored value
00.22646386333071553
1-0.22646386333071553
20.21651057266365012
3-0.21651057266365015

decoder_block2_R1

B=1 × T=2 × D=2 · float64 · precision 8 · Exact named-shape addition of decoder_block2_Features and decoder_block2_attn_Y; no broadcasting.

Zero-based storage indexStored value
02.011445358654498
1-0.5800172539239893
21.8785173210797292
3-0.01041853568410156

decoder_block2_n2_Gamma

D=2 · float64 · precision 8 · Shared literal feature scales [1,1].

Zero-based storage indexStored value
01
11

decoder_block2_n2_Beta

D=2 · float64 · precision 8 · Shared literal feature offsets [+0,+0].

Zero-based storage indexStored value
00
10

decoder_block2_n2_Statistics

B=1 × T=2 × NormStatistic=10 · float64 · precision 8 · Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order.

Zero-based storage indexStored value
01.4314281047305086
10.7157140523652543
21.2957313062892435
3-1.2957313062892437
41.6789196180980293
51.67891961809803
63.3578392361960594
71.6789196180980297
81.9289196180980297
91.3888555065585584
101.8680987853956277
110.9340493926978138
120.9444679283819154
13-0.9444679283819154
140.8920196677420269
150.8920196677420269
161.7840393354840538
170.8920196677420269
181.142019667742027
191.0686532027472837

decoder_block2_n2_Centered

B=1 × T=2 × D=2 · float64 · precision 8 · Actual saved input feature minus feature mean, before division.

Zero-based storage indexStored value
01.2957313062892435
1-1.2957313062892437
20.9444679283819154
3-0.9444679283819154

decoder_block2_n2_Normalized

B=1 × T=2 × D=2 · float64 · precision 8 · Actual centered/denominator words before gamma multiplication and beta addition.

Zero-based storage indexStored value
00.9329489642158189
1-0.9329489642158191
20.8837927271016323
3-0.8837927271016323

decoder_block2_n2_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4.

Zero-based storage indexStored value
00.9329489642158189
1-0.9329489642158191
20.8837927271016323
3-0.8837927271016323

decoder_block2_ffn_W1

D=2 × HiddenFeature=3 · float64 · precision 8 · Shared input-to-hidden weights, f1{d}{m}; M=3 hidden features.

Zero-based storage indexStored value
01
10
20
30
41
50

decoder_block2_ffn_b1

HiddenFeature=3 · float64 · precision 8 · Shared hidden bias, added after the two products.

Zero-based storage indexStored value
00
10
20

decoder_block2_ffn_Z

B=1 × T=2 × HiddenFeature=3 · float64 · precision 8 · Hidden preactivations X W1+b1; no batch or token mixing.

Zero-based storage indexStored value
00.9329489642158189
1-0.9329489642158191
20
30.8837927271016323
4-0.8837927271016323
50

decoder_block2_ffn_Hidden

B=1 × T=2 × HiddenFeature=3 · float64 · precision 8 · ReLU(Z)=max(0,Z), before the second affine layer.

Zero-based storage indexStored value
00.9329489642158189
10
20
30.8837927271016323
40
50

decoder_block2_ffn_W2

HiddenFeature=3 × D=2 · float64 · precision 8 · Shared hidden-to-output weights, f2{m}{d}.

Zero-based storage indexStored value
00.25
10
20
30.25
40
50

decoder_block2_ffn_b2

D=2 · float64 · precision 8 · Shared output bias, added after all three running sums.

Zero-based storage indexStored value
00
10

decoder_block2_ffn_F

B=1 × T=2 × D=2 · float64 · precision 8 · ReLU(X W1+b1) W2+b2, independently per token with shared parameters.

Zero-based storage indexStored value
00.2332372410539547
10
20.22094818177540806
30

decoder_block2_Output

B=1 × T=2 × D=2 · float64 · precision 8 · Exact named-shape addition of decoder_block2_R1 and decoder_block2_ffn_F; no broadcasting.

Zero-based storage indexStored value
02.2446825997084527
1-0.5800172539239893
22.0994655028551374
3-0.01041853568410156

decoder_block2_NativeArguments

Native=8 × NativeField=2 · float64 · precision 8 · Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

Zero-based storage indexStored value
01.393332864571069
11.180395215413494
20.779921911744329
30.8831318767569932
42
51.4142135623730951
60
71
80
91
10-0.047540980130455046
110.953571394851756
121.9289196180980297
131.3888555065585584
141.142019667742027
151.0686532027472837

decoder_block2_NativeKinds

Native=8 · int32 · precision 0 · Native kind codes in native occurrence order: sqrt=0, exp=1.

Zero-based storage indexStored value
00
10
20
31
41
51
60
70

decoder_U

D=2 × Vocab=3 · float64 · precision 8 · Authored feature-last readout rows [1,0,0],[0,1,0].

Zero-based storage indexStored value
01
10
20
30
41
50

decoder_Bias

Vocab=3 · float64 · precision 8 · Actual biasA,biasB,biasEOS words, added after both feature products.

Zero-based storage indexStored value
00
10
20

decoder_Readout

B=1 × T=2 × Vocab=3 × ReadoutField=4 · float64 · precision 8 · Actual product0,product1,sum,logit per position and class.

Zero-based storage indexStored value
02.2446825997084527
1-0
22.2446825997084527
32.2446825997084527
40
5-0.5800172539239893
6-0.5800172539239893
7-0.5800172539239893
80
9-0
100
110
122.0994655028551374
13-0
142.0994655028551374
152.0994655028551374
160
17-0.01041853568410156
18-0.01041853568410156
19-0.01041853568410156
200
21-0
220
230

decoder_Logits

B=1 × T=2 × Vocab=3 · float64 · precision 8 · Actual final readout logits before stable class softmax.

Zero-based storage indexStored value
02.2446825997084527
1-0.5800172539239893
20
32.0994655028551374
4-0.01041853568410156
50

decoder_ClassMaxima

B=1 × T=2 · float64 · precision 8 · Actual selected maximum logit per observed position.

Zero-based storage indexStored value
02.2446825997084527
12.0994655028551374

decoder_ClassShifted

B=1 × T=2 × Vocab=3 · float64 · precision 8 · Actual direct exp arguments, each saved once as logit minus row maximum.

Zero-based storage indexStored value
00
1-2.824699853632442
2-2.2446825997084527
30
4-2.109884038539239
5-2.0994655028551374

decoder_ClassTerms

B=1 × T=2 × Vocab=3 · float64 · precision 8 · Actual native exp outputs; no log native exists in this family.

Zero-based storage indexStored value
01
10.05932646077911259
20.10596116714203357
31
40.12125202618024761
50.12252189835948703

decoder_ClassDenominators

B=1 × T=2 · float64 · precision 8 · Final ordered +0 then term0,term1,term2 running sums.

Zero-based storage indexStored value
01.1652876279211462
11.2437739245397348

decoder_Probabilities

B=1 × T=2 × Vocab=3 · float64 · precision 8 · Actual term/final denominator probabilities at every observed position.

Zero-based storage indexStored value
00.8581572274855295
10.050911431098732265
20.09093134141573832
30.804004634821441
40.09748719103040979
50.09850817414814908

decoder_ArgmaxIndices

B=1 × T=2 · int32 · precision 0 · Smallest class index on exact actual-logit ties.

Zero-based storage indexStored value
00
10

decoder_ArgmaxIds

B=1 × T=2 · int32 · precision 0 · Actual selected token IDs in observed-position order.

Zero-based storage indexStored value
097
197

decoder_SelectedProbabilities

B=1 × T=2 · float64 · precision 8 · Unchanged copies of the actual selected class probabilities.

Zero-based storage indexStored value
00.8581572274855295
10.804004634821441

decoder_NativeArguments

Native=22 × NativeField=2 · float64 · precision 8 · Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing.

Zero-based storage indexStored value
00.5
10.7071067811865476
20.3125
30.5590169943749475
42
51.4142135623730951
60
71
80
91
10-0.16437088302533887
110.8484272962382063
120.9785533905932737
130.9892185757421227
140.5458358722370567
150.738807060224154
161.393332864571069
171.180395215413494
180.779921911744329
190.8831318767569932
202
211.4142135623730951
220
231
240
251
26-0.047540980130455046
270.953571394851756
281.9289196180980297
291.3888555065585584
301.142019667742027
311.0686532027472837
320
331
34-2.824699853632442
350.05932646077911259
36-2.2446825997084527
370.10596116714203357
380
391
40-2.109884038539239
410.12125202618024761
42-2.0994655028551374
430.12252189835948703

decoder_NativeKinds

Native=22 · int32 · precision 0 · Native kind codes in native occurrence order: sqrt=0, exp=1.

Zero-based storage indexStored value
00
10
20
31
41
51
60
70
80
90
100
111
121
131
140
150
161
171
181
191
201
211

Check your understanding

Use the inputs stated in each question. Live questions use the current calculation. Each option pairs a value or conclusion with its mechanism. Editing a raw input, resetting or selecting a trace step clears graded answers; local inspection selectors preserve them.

1. What actually enters block 2 in this two-block decoder, including when both observed IDs are 97?
2. Fixed case: token0=token1=97 (a), E(a)=[1,0], P0=[0,0], P1=[0,1/2]. What is feature coordinate 1 of the positioned input X0 at position 1, before either block?
3. For B=1, T=2 and D=2, W1 has shape [2,3] and W2 has shape [3,2]. What shape does the actual FFN hidden activation tensor have?
4. Hold all gains, biases, positionScale and token0 fixed. If only token1 changes, can the final logits at position 0 change in this toy?
5. Current WHOLE saved root: token0=97, token1=97, positionScale=0.5, q1=1, k1=1, v1=1, o1=0.5, f1=0.5, q2=1, k2=0.5, v2=1, o2=0.25, f2=0.25, biasA=0, biasB=0, biasEOS=0. Class order is [97,98,512]. Position 0 logits=[2.2446825997084527, -0.5800172539239893, 0], probabilities=[0.8581572274855295, 0.050911431098732265, 0.09093134141573832]; position 1 logits=[2.0994655028551374, -0.01041853568410156, 0], probabilities=[0.804004634821441, 0.09748719103040979, 0.09850817414814908]. Which public token ID supplies the next-token recommendation from the LAST observed row? Use exact saved logits and the smallest-ID exact-tie rule, independently of the selected trace step.

Exactly five corrective questions use fully stated fixed cases or the current whole root. Expand storage or operation details without changing grades. Focus a table region to scroll it with the keyboard; token menus, numeric fields, trace controls, details and reset use native keyboard controls. This authored forward-only toy performs no training, sampling or token appending.

Start with the two token menus and Position 1, feature 1 addition. Leave both tokens at a/97 and compare the embedding, position and X0 rows. Then expand Block 1 gains, Block 2 gains or Three-class readout biases to edit the remaining parameters. There are sixteen inputs: two token choices and fourteen numeric operands. To follow the simpler worksheet below, change only o1, f1, o2 and f2 to zero. Reset example restores the nonzero default.

Use Previous step, Calculation step and Next step to inspect saved operands, equation and outputs. The eight-stage graph, both block tables and both readout rows continue to show the complete current calculation. Open a block’s storage details for every matrix, normalization statistic and three-coordinate hidden row; open the remaining root storage, ordered native ledger or complete operation fallback for the rest. The inspector exposes all stored values and metadata without display rounding. A negative zero is printed as -0; it is a distinct floating-point word even though its arithmetic value equals zero. Focus a table region to scroll it with the keyboard.

An empty, nonfinite or out-of-range numeric draft withholds results, trace, inspector and questions until repaired or reset; the last valid input is retained internally. Editing, resetting or choosing a trace step clears graded answers. Choosing a step changes the explanation, while the fifth question still asks about the current whole calculation’s last observed row. Expanding storage details leaves answers in place. All five questions and their corrective feedback are in the lab above; there is no second question set below.

Review IV-43 — End-to-End Tiny Language-Model Objective for the earlier end-to-end language-model objective and IV-47 — Complete Autoregressive Generation Trace for the separate generation loop. Book II’s II.9 — Matrix × vector and II.10 — Matrix × matrix as composition explain matrix products; VII.6 — Logits and softmax explains logits and softmax. Book III’s III-16 — Multiclass Classification and Softmax Regression connects class scores to probabilities, and III-41 — Composition and Learned Representations explains composition of representations.

Names become rows; rows become new rows

A token ID is an integer name, not a numerical measurement: ID98 is not “one unit more meaningful” than ID97. An embedding looks up a small vector of features for that name. Our fixed vocabulary, in class order, is:

Class index cPublic IDLabelEmbedding row E[c]
097a(1,0)
198b(0,1)
2512EOS(0,0)

EOS means end of sequence. Here an EOS supplied as an observed input has an ordinary explicit embedding. A generation wrapper may stop when it emits EOS, but a supplied EOS does not secretly stop this forward calculation. There is no tokenization, vocabulary expansion or automatic EOS insertion here.

Lookup both default IDs97, then add the absolute position rows P[0]=(0,0) and P[1]=(0,1/2). The input features are X[0]=(1,0)+(0,0)=(1,0) and X[1]=(1,0)+(0,1/2)=(1,1/2). The repeated IDs have identical embeddings and different positioned features. This addition occurs once, before block one. It is a different positional choice from IV-43’s rotary position encoding, or RoPE, which rotates query/key pairs; no rotation is performed in this toy.

The whole route is:

observed IDs -> embedding lookup -> add position -> X
X -> block 1 -> Y1 -> block 2 -> Y2
Y2 -> output head -> logits -> class probabilities
last observed row's logits -> recommended next ID

Block two receives the actual per-position Y1 features. It does not look up the original IDs again. One embedding row for a cannot hold two different contextual rows for two occurrences of a. Nor do we convert Y1 into a predicted token between blocks: that would discard the very features the next block needs.

Read dimensions as a promise about the calculation

A tensor is an array whose axes have named meanings. Its shape lists their lengths. B=1 is one sequence in the batch; T=2 is two observed positions; D=2 is two features per position. Indices i and j range over positions0 and1, with i the query and j the key. H=1 is one attention head, meaning one set of query/key comparisons and value mixtures. Its query/key width Dk=2 and value width Dv=2 are separate meanings even though their sizes agree.

QuantityShapeAxis meanings
E; saved positions P[3,2]; [1,2,2]Vocab, D; B, T, D
X, Y1, Y2; each residual and norm output[1,2,2]B, T, D
WQ, WK, WV; WO[2,2] eachD, projected feature; JoinedValue, D
Q, K, V[1,1,2,2]B, H, T, Dk for Q/K or Dv for V
Scores S, allowed mask, attention weights A[1,1,2,2]B, H, Query, Key
Weighted head values[1,1,2,2]B, H, Query, Dv
Joined head values[1,2,2]B, T, H times Dv
W1; hidden rows; W2[2,3]; [1,2,3]; [3,2]D to three hidden features to D
Output matrix U; class bias[2,3]; [3]D, Class; Class
Logits and class probabilities[1,2,3]B, T, Vocab (class)

The tables below suppress the singleton B and H axes for readability; they do not remove those axes from the computation. These are row-feature products: a row of length2 times a matrix [2,3] produces a row of length3. Book II’s column form uses the transposed weights. A transpose exchanges axes; it does not change the token order.

The sixteen raw inputs, in order, are token0, token1, positionScale, q1, k1, v1, o1, f1, q2, k2, v2, o2, f2, biasA, biasB, biasEOS. Tokens must be integers from the fixed table. Position scale is in [0,1]; each of the ten gains is in [-1,1]; each class bias is in [-2,2]. All are finite numbers. A gain multiplies a fixed matrix; these controls do not expose arbitrary full matrices or trained weights. The two layers have independent gains despite sharing a block structure.

At the default, positionScale=1/2, layer one’s gains (q1,k1,v1,o1,f1)=(1,1,1,1/2,1/2), layer two’s gains (q2,k2,v2,o2,f2)=(1,1/2,1,1/4,1/4), and all three head biases are zero. Invalid inputs must be rejected, including a field whose gain would otherwise make its numerical contribution zero; zero gain is not permission to omit validation.

What one block does, and why

Pre-normalization means normalizing features before each branch. For one input row (x,y), LayerNorm computes the sum x+y, mean mu=(x+y)/2, centered values (x-mu,y-mu), both squares, their sum, and the population variance sigma²=((x-mu)²+(y-mu)²)/2. Add epsilon=1/4 inside the square root. Divide each centered feature by sqrt(sigma²+1/4), multiply by its scale gamma=1 and add its offset beta=0. Statistics are over the two features of this one row, never over both token positions. Epsilon prevents division by zero, including for an EOS row with equal features.

A query Q describes a comparison request, a key K is what gets compared, and a value V is what gets mixed. These names describe arithmetic roles, not thoughts. In layer l, where l is1 or2, WQ=q_l I, WK=k_l I, WV=v_l I and WO=o_l I; I is the two-by-two identity matrix. Their expanded matrices are:

WQ = [[q_l,0],[0,q_l]]    WK = [[k_l,0],[0,k_l]]
WV = [[v_l,0],[0,v_l]]    WO = [[o_l,0],[0,o_l]]

Thus, for normalized row (n0,n1), its query is (n0*q_l+n1*0,n0*0+n1*q_l); keys and values use k_l and v_l in the same two-product order. Each diagonal matrix has explicitly zero off-diagonal entries.

Compute every dot product Q[i,0]*K[j,0]+Q[i,1]*K[j,1], then divide by sqrt(Dk)=sqrt(2) to obtain score S[i,j]. A causal mask allows j less than or equal to i. Its two rows are (true,false) and (true,true). The future score S[0,1] is computed, then forbidden from the mixture. It is not replaced by an invented exponential.

Stable softmax converts allowed scores to weights. Find the allowed maximum M, subtract M from each allowed score, exponentiate those differences, add the terms in key order from a zero accumulator (including explicit zero terms for forbidden keys), and divide each allowed term by that denominator. A forbidden term and weight are exactly positive zero. The saved attention logit includes the primitive’s explicit addition of a common +0 shift before softmax; that operation remains in the floating-point graph. Every row here allows its own position; an entirely forbidden row would be invalid, not a uniform distribution. Large attention weight means a larger contribution to this particular value mixture, not an explanation of language-model reasoning.

Mix each value coordinate separately: A[i,0]*V[0,d]+A[i,1]*V[1,d], for coordinate d=0 or1. Move the head axis beside the feature axis and concatenate heads; with one head the values are unchanged, but the axis conversion still matters. Multiply the joined row by WO. This is the attention branch output, not the full block output.

A residual addition keeps the branch’s input available: R=input+attentionOutput, coordinate by coordinate with identical shapes. Normalize R again. The feed-forward network, or FFN, acts separately on each position, using

W1 = [[1,0,0], [0,1,0]]      hidden bias = [0,0,0]
W2 = [[f_l,0], [0,f_l], [0,0]]  output bias = [0,0]

Three hidden coordinates are calculated; the third is not omitted because its weights are zero. ReLU, the rectified linear unit, replaces a negative coordinate by zero and retains a positive one. It returns zero at zero. Finally Y=R+FFN(R normalized) is the second residual addition. Both blocks preserve the [1,2,2] feature shape.

A complete hand case: zero branch outputs still require the branches

Keep every default except set o1=f1=o2=f2=+0. The following are exact-real symbolic calculations. Square roots and exponentials are left symbolic rather than presented as unexecuted computer decimals. All auxiliary letters in this worksheet, such as u, v, r and z, denote single real numbers; each ordered pair is one feature row of length2. Binary64 means the computer’s finite-precision, 64-bit number format. An implementation must retain each primitive’s operation order; algebraically equal expressions need not have identical final bits.

First block: normalize, compare and mix

The positioned rows remain (1,0) and (1,1/2). Their first normalizations are:

PositionSum; meanCentered coordinatesSquares; their sumVariance; variance plus epsilonDenominator; normalized row
01; 1/2(1/2,-1/2)(1/4,1/4); 1/21/4; 1/2sqrt(1/2); (u,-u)
13/2; 3/4(1/4,-1/4)(1/16,1/16); 1/81/16; 5/16sqrt(5/16); (v,-v)

Here u=(1/2)/sqrt(1/2)=1/sqrt(2) and v=(1/4)/sqrt(5/16)=1/sqrt(5), as real identities. Each division is followed by multiplication by1 and addition of0. Do not replace the implementation’s square-root argument with another expression merely because the paper simplifies it.

Since q1=k1=v1=1, all three projections have rows (u,-u) and (v,-v). The four raw dot products are u*u+(-u)*(-u)=2u², u*v+(-u)*(-v)=2uv, v*u+(-v)*(-u)=2vu, and v*v+(-v)*(-v)=2v². Divide each by sqrt(2):

S1 = [[1/sqrt(2), 1/sqrt(5)],
      [1/sqrt(5), sqrt(2)/5]]
allowed = [[true,false], [true,true]]

Row0 uses maximum S1[0,0], allowed shift0, terms (exp(0),0)=(1,0), denominator1 and weights (1,0). In row1, maximum S1[1,0]=v exceeds S1[1,1]. Define r=exp(sqrt(2)/5-v), so the two shifts are 0 and sqrt(2)/5-v, the terms are (1,r), and the denominator is 1+r. The weights are (1/(1+r),r/(1+r)).

Row0’s weighted coordinates are 1*u+0*v=u and 1*(-u)+0*(-v)=-u. Row1’s coordinates are z=u/(1+r)+r*v/(1+r) and (-u)/(1+r)+r*(-v)/(1+r)=-z. Joining the single head gives rows (u,-u) and (z,-z).

WO is now [[0,0],[0,0]]. For either joined row (h,-h), compute the two output coordinates (0+h*0)+(-h)*0 and (0+h*0)+(-h)*0; both are real zero. The initial zero starts each sum; WO has no bias. The first residuals are therefore (1+0,0+0)=(1,0) and (1+0,1/2+0)=(1,1/2).

First block: recompute the second norm and all three FFN coordinates

Normalize those residuals afresh: row0 again has sum1, mean1/2, centered (1/2,-1/2), squares (1/4,1/4), sum1/2, variance1/4, sqrt argument1/2 and output (u,-u). Row1 again has sum3/2, mean3/4, centered (1/4,-1/4), squares (1/16,1/16), sum1/8, variance1/16, sqrt argument5/16 and output (v,-v). These are new normalization operations, not reused saved results.

For either row write h=u or v. The three hidden affines, including their biases, are

hidden0 = h*1 + (-h)*0 + 0 = h
hidden1 = h*0 + (-h)*1 + 0 = -h
hidden2 = h*0 + (-h)*0 + 0 = 0
ReLU(hidden) = (h,0,0)
FFN0 = h*0 + 0*0 + 0*0 + 0 = 0
FFN1 = h*0 + 0*0 + 0*0 + 0 = 0

Each FFN output accumulates its three products in coordinate order from a zero accumulator, then adds its output bias. Each hidden affine instead adds its two products directly before its hidden bias. The second residual gives Y1[0]=(1,0), Y1[1]=(1,1/2). This equality is a result of zero output gains, not of bypassing normalization, attention or the FFN.

Second block: process those features with different keys

The actual Y1 rows enter block two. Its first norm independently repeats the complete statistics above, giving (u,-u) and (v,-v). q2=v2=1, so Q and V retain these rows. k2=1/2, so K rows are (u/2,-u/2) and (v/2,-v/2). Each raw score is the explicit two-product sum h_i*(h_j/2)+(-h_i)*(-h_j/2)=h_i*h_j, with h_0=u and h_1=v. Thus

S2 = [[1/(2*sqrt(2)), 1/(2*sqrt(5))],
      [1/(2*sqrt(5)), sqrt(2)/10]]

Apply the same causal mask. Row0 still has terms (1,0) and weights (1,0). Row1’s maximum is 1/(2*sqrt(5)). Define s=exp(sqrt(2)/10-1/(2*sqrt(5))). Its shifts are0 and that exponent, terms (1,s), denominator 1+s, weights (1/(1+s),s/(1+s)). The joined values are (u,-u) and (w,-w), where w=u/(1+s)+s*v/(1+s). This exponential is a separate occurrence; it is not replaced by a square root of r.

The zero WO again computes both products in both output coordinates, yielding zero attention output. The first residual is X. Its second normalization is another fresh pair of calculations: sums (1,3/2), means (1/2,3/4), centered rows (1/2,-1/2) and (1/4,-1/4), variances (1/4,1/16), square-root arguments (1/2,5/16), and normalized rows (u,-u) and (v,-v). All three hidden affine/ReLU coordinates and both three-product FFN outputs are computed exactly as displayed above, with f2=0. The second residual yields Y2[0]=(1,0), Y2[1]=(1,1/2).

The real zero notation in this derivation does not erase signed-zero intermediates. For example a negative feature times +0 may produce -0 before a later addition. Exact floating-point records must preserve those distinctions; no blanket zero-gain shortcut follows from this hand example.

Head: compute all classes before making one recommendation

The output head converts each final feature row to three scores called logits. With U=[[1,0,0],[0,1,0]] and zero biases, every row (x,y) uses

logit a   = x*1 + y*0 + biasA
logit b   = x*0 + y*1 + biasB
logit EOS = x*0 + y*0 + biasEOS

For row0 these are 1*1+0*0+0=1, 1*0+0*1+0=0, 1*0+0*0+0=0. For row1 they are 1*1+(1/2)*0+0=1, 1*0+(1/2)*1+0=1/2, 1*0+(1/2)*0+0=0. Bias is added after the two products and their sum. An EOS logit of zero remains an eligible class score; it is not a mask.

For row0, the class maximum is1, shifted logits are (0,-1,-1), and exponential terms are (1,exp(-1),exp(-1)). Starting from zero, add the first term, then the second, then the third: ((0+1)+exp(-1))+exp(-1). Divide each term by this denominator. These are two separate exp(-1) evaluations in the prescribed class calculation.

For row1, the maximum is1, shifted logits are (0,-1/2,-1), terms are (1,exp(-1/2),exp(-1)), and the ordered denominator is ((0+1)+exp(-1/2))+exp(-1). Divide each term by it. These formulas give the full stable probabilities without fabricated decimal output.

The winning actual logit is1 for a/ID97 in both rows. Only row1, the last observed position, supplies the next-token recommendation. Row0’s recommendation does not replace the observed second a. Select using the actual logits, with exact ties resolved by the lowest public token ID,97 before98 before512. Rounded printed probabilities never decide the winner: two displayed probabilities can look equal when their underlying logits differ.

Deeper: follow the nonzero default through both complete blocks

The following is an exact-real worksheet, not a captured binary64 trace. Define N(d)=d/sqrt(d²+1), where d is the difference between a row’s two features. Indeed its centered coordinates are (d/2,-d/2), variance d²/4, and square-root argument (d²+1)/4, so its normalized row is (N(d),-N(d)). Actual source must still evaluate the unsimplified operations in order.

Keep u, v, r and z from the first-block attention above, because the default Q/K/V gains are unchanged. Set h_0=u and h_1=z. With o1=1/2, the attention rows become (h_i/2,-h_i/2). The first residual rows are (1+u/2,-u/2) and (1+z/2,1/2-z/2). Their means are1/2 and3/4 and differences are e_0=1+u and e_1=1/2+z. For each i, the second norm centers to (e_i/2,-e_i/2), squares and averages to e_i²/4, adds1/4 and divides by sqrt((e_i²+1)/4). Write a_i=N(e_i). Both a_i are positive.

The three FFN preactivations are (a_i,-a_i,0), ReLU gives (a_i,0,0), and the W2 contractions are (a_i*(1/2)+0*0+0*0, a_i*0+0*(1/2)+0*0)=(a_i/2,0), with zero output biases added. Thus

Y1[0] = (1+u/2+a_0/2, -u/2)
Y1[1] = (1+z/2+a_1/2, 1/2-z/2)

Define their differences d_0=1+u+a_0/2 and d_1=1/2+z+a_1/2. Block two normalizes each actual Y1 row: its mean is (1+a_0/2)/2 at row0 and (3/2+a_1/2)/2 at row1, centered coordinates (d_i/2,-d_i/2), variance d_i²/4, and square-root argument (d_i²+1)/4. Put b_i=N(d_i). Q/V rows are (b_i,-b_i) and K rows are (b_i/2,-b_i/2). The full scaled matrix has entries S2[i,j]=b_i*b_j/sqrt(2), including its computed forbidden future cell.

Here u>v>0 and v<z<u imply d_0>d_1>0 and b_0>b_1>0. Row0 weights are (1,0). For row1 define t=exp((b_1b_1-b_1b_0)/sqrt(2)); its stable terms are (1,t) and weights (1/(1+t),t/(1+t)). Put c_0=b_0 and c_1=(b_0+t*b_1)/(1+t). The mixed rows are (c_i,-c_i); WO=I/4 gives (c_i/4,-c_i/4).

The first residual R2[i]=Y1[i]+(c_i/4,-c_i/4) has unchanged row mean and difference k_i=d_i+c_i/2. Its second norm centers to (k_i/2,-k_i/2), variance k_i²/4, square-root argument (k_i²+1)/4, and output (n_i,-n_i), where n_i=N(k_i)>0. The three FFN preactivations are (n_i,-n_i,0), activations (n_i,0,0), and two full W2 contractions give (n_i/4,0). Adding the second residual gives

Y2[0] = (1+u/2+a_0/2+b_0/4+n_0/4, -u/2-b_0/4)
Y2[1] = (1+z/2+a_1/2+c_1/4+n_1/4, 1/2-z/2-c_1/4)

Call each row (x_i,y_i). The head’s two-product contractions plus zero biases give (x_i,y_i,0). Since x_i>1 and y_i<1/2, the real maximum is x_i. Stable shifts are (0,y_i-x_i,-x_i), terms (1,exp(y_i-x_i),exp(-x_i)), and denominator accumulated in that order. Divide all three terms by that denominator. The exact-real winner is a/97 at both positions. This argument establishes the symbolic worksheet, not a word-level comparison of actual implementations.

Read the complete Python calculation

The two panels contain the actual repository files, in dependency order. decoder_reference.py owns the scalar mathematics and the complete helper records; iv59.py owns the full chapter result and command-line entry. Keep the files adjacent. The entry file locates its helper using Path(__file__).resolve().with_name('decoder_reference.py'), so helper lookup is relative to the file rather than the terminal’s current directory. It loads that one project file through importlib.util; it does not change sys.path or import another chapter, the TypeScript implementation or the independent authority. NumPy and Python’s standard library are external dependencies of this two-project-file reference.

Read _norm alongside the saved decoder_block1_n1_0_0_statistics frame: total, mean, centered0/1, square0/1, square_sum, variance, argument and denominator follow the worksheet’s order. _two_products records both feature products before their sum and optional bias. _softmax saves the actual maximum, allowed shifts, exponential terms, ordered denominator and divisions. _accumulate_rows multiplies and immediately adds each contribution; _residual adds the branch to its same-position input. _evaluate_decoder_mechanics calls _decoder_block_mechanics twice, passing actual block-one output features to block two.

NumPy’s _storage arrays hold already-computed scalar results in an explicit [1,rows,cols] shape, filled by indexed writes. NumPy does not perform a matrix contraction, reduction or broadcast here. Python math.sqrt and math.exp supply the only elementary native functions. A native occurrence records its identity, kind, argument and result, even when another occurrence has the same argument. _bind_block and _head_binding project the saved scalar captures into the adopted tensor/frame metadata; they do not rerun the floating-point calculation for the view. Python’s private mechanism captures and public saved frames are different representations of the same computed scalars.

Reference interfaces, input errors and later checking

The helper’s public names are decoder_state(value), decoder_trace(), decoder_block(features,gains,trace,prefix) and evaluate_decoder(value,trace,prefix). The chapter entry adds derive_iv59(value) and the zero-argument Python function run(). The reusable block accepts one, two or three positions with two features each; this chapter always supplies two positions. The five block gains are exactly q, k, v, o and f. Prefixes start with an ASCII letter and contain only ASCII letters, digits or underscores.

The declared command-line interface selects the complete default with no argument, a complete replacement state with one JSON argument, one JSON document from stdin with -, or explicit checks with --self-check. A replacement must contain all sixteen fields; it is not merged with defaults. Known JSON/input faults produce an unavailable JSON record; command misuse prints usage and returns exit status 2. Duplicate JSON fields, nonfinite constants and overflowing numeric literals are rejected. The parser preserves the sign of -0. Python booleans are rejected as numeric inputs, and bounded integer domains are checked before unsafe conversion of a huge integer to float. Unknown resource or programmer errors escape rather than being disguised as a numerical answer.

Ordinary imports and queries invoke no self-check. The explicit source_self_check() dispatcher calls helper check_mechanism() and check_public(), then entry-file check_root(), check_boundaries() and check_cli(). Public/root checks use the explicit _check_native_copies(...) helper. These source-supplied checks refuse optimized Python (-O), where assertions would be disabled. These checks are not the independent mathematical authority.

Scalar helper: decoder_reference.py

Read the complete executable Python / NumPy source

This is the actual reference file, imported directly from the repository. Comments explain each operation. It is provided for later execution; no validation run is claimed.

"""Independent IV59 scalar FIRST, with owner-adopted public bindings.

All execution and checks are UNRUN. Saved scalar captures drive serialization.
NumPy is used only for explicitly indexed result storage, never contractions.
"""
import math
import re
from types import MappingProxyType

import numpy as np


class NumericalFault(Exception):
    def __init__(self, code, reason):
        super().__init__(reason)
        self.code = code
        self.reason = reason


class _FrozenDict(dict):
    def _readonly(self, *args, **kwargs):
        raise TypeError("Frozen trace record.")
    __setitem__ = __delitem__ = clear = pop = popitem = setdefault = update = __ior__ = _readonly


class _FrozenList(list):
    def _readonly(self, *args, **kwargs):
        raise TypeError("Frozen trace array.")
    __setitem__ = __delitem__ = append = clear = extend = insert = pop = remove = reverse = sort = __iadd__ = __imul__ = _readonly


def _freeze(value):
    if type(value) in (dict, _FrozenDict):
        return _FrozenDict({key: _freeze(child) for key, child in value.items()})
    if type(value) in (list, tuple, _FrozenList):
        return _FrozenList(_freeze(child) for child in value)
    if value is None or type(value) in (str, bool, int, float):
        if type(value) is float and not math.isfinite(value):
            raise TypeError("Trace values must be finite, plain JSON data.")
        return value
    raise TypeError("Copy typed arrays to plain arrays before tracing.")



DEFAULT_IV59 = _freeze(dict(
    token0=97, token1=97, positionScale=0.5,
    q1=1.0, k1=1.0, v1=1.0, o1=0.5, f1=0.5,
    q2=1.0, k2=0.5, v2=1.0, o2=0.25, f2=0.25,
    biasA=0.0, biasB=0.0, biasEOS=0.0))
_FIELDS = tuple(DEFAULT_IV59)
_GAIN_FIELDS = ("q", "k", "v", "o", "f")
_IDS = (97, 98, 512)


def _finite(value, name):
    if not math.isfinite(value):
        raise NumericalFault("NONFINITE", name + " must be finite.")
    return value


def _capture_record(value, fields, label):
    # Exact built-ins exclude custom reflection/getitem/accessor side effects.
    if type(value) not in (dict, _FrozenDict):
        raise NumericalFault("INVALID_INPUT", label + " must be a plain object.")
    keys = tuple(value)
    if len(keys) != len(fields) or any(type(key) is not str for key in keys) or set(keys) != set(fields):
        raise NumericalFault("INVALID_INPUT", label + " must have exactly " + ", ".join(fields) + " as own fields.")
    captured = {key: value[key] for key in fields}
    for key in fields:
        item = captured[key]
        if type(item) not in (int, float) or (type(item) is float and not math.isfinite(item)):
            raise NumericalFault("NONFINITE", label + "." + key + " must be an actual finite number.")
    return captured


def decoder_state(value):
    """Capture raw16 once; check every number before any domain or conversion."""
    captured = _capture_record(value, _FIELDS, "state")
    for key in _FIELDS:
        item = captured[key]
        if key in ("token0", "token1"):
            if item not in _IDS or (type(item) is float and not item.is_integer()):
                raise NumericalFault("INVALID_INPUT", key + " must be an integer token ID in {97,98,512}.")
        else:
            lower, upper = ((0, 1) if key == "positionScale" else
                            (-2, 2) if key.startswith("bias") else (-1, 1))
            if not lower <= item <= upper:
                raise NumericalFault("INVALID_INPUT", f"{key} must be between {lower} and {upper}.")
    return _freeze({key: int(captured[key]) if key in ("token0", "token1") else float(captured[key])
                    for key in _FIELDS})


def _block_inputs(features, gains, prefix):
    if type(features) not in (list, _FrozenList):
        raise NumericalFault("INVALID_INPUT", "features must be an ordinary dense array.")
    if len(features) not in (2, 4, 6):
        raise NumericalFault("INVALID_INPUT", "features must contain 2, 4 or 6 words for B=1,T=1..3,D=2.")
    captured = list(features)
    for i, item in enumerate(captured):
        if type(item) not in (int, float) or (type(item) is float and not math.isfinite(item)):
            raise NumericalFault("NONFINITE", f"features[{i}] must be an actual finite number.")
    for i, item in enumerate(captured):
        if not -16 <= item <= 16:
            raise NumericalFault("INVALID_INPUT", f"features[{i}] must be between -16 and 16.")
    captured_gains = _capture_record(gains, _GAIN_FIELDS, "gains")
    for key in _GAIN_FIELDS:
        if not -1 <= captured_gains[key] <= 1:
            raise NumericalFault("INVALID_INPUT", f"gains.{key} must be between -1 and 1.")
    _prefix(prefix)
    return [float(item) for item in captured], {key: float(captured_gains[key]) for key in _GAIN_FIELDS}


def _prefix(prefix):
    if type(prefix) is not str or re.fullmatch(r"[A-Za-z][A-Za-z0-9_]*", prefix) is None:
        raise NumericalFault("INVALID_INPUT", "prefix must start with an ASCII letter and contain only ASCII letters, digits or underscores.")


class _MechanismTrace:
    """Private captures; labels and schema are NOT the public adopted inventory."""
    def __init__(self):
        self.steps = []
        self.native = []
        self._ids = set()

    def add(self, identifier, inputs, outputs):
        if type(identifier) is not str or not identifier or identifier in self._ids:
            raise NumericalFault("INVALID_INPUT", "Trace IDs must be nonempty and unique.")
        before, after = dict(inputs), dict(outputs)
        for record in (before, after):
            for key, value in record.items():
                if type(key) is not str or type(value) not in (int, float):
                    raise NumericalFault("INVALID_INPUT", "Capture scalar data only.")
                _finite(value, identifier + "/" + key)
        if len(self.steps) >= 512:
            raise NumericalFault("UNSUPPORTED_SIZE", "At most 512 operations are supported.")
        self._ids.add(identifier)
        self.steps.append((identifier, MappingProxyType(before), MappingProxyType(after)))

    def leaf(self, identifier, kind, argument):
        _finite(argument, identifier + " argument")
        lower, upper = (0.25, 4096.0) if kind == "sqrt" else (-256.0, 0.0)
        if not lower <= argument <= upper:
            raise NumericalFault("INVALID_INPUT", "Native argument outside authored scope.")
        if any(record["id"] == identifier for record in self.native):
            raise NumericalFault("INVALID_INPUT", "Native capture ID must be unique.")
        output = _finite(math.sqrt(argument) if kind == "sqrt" else math.exp(argument), identifier)
        if output <= 0:
            raise NumericalFault("NONFINITE", "Native result must be positive.")
        self.native.append(MappingProxyType(dict(id=identifier, kind=kind, input=argument, output=output)))
        return output


def decoder_trace():
    """Create the adopted collector, with no implicit self-check."""
    return _PublicTrace()


def _norm(features, trace, prefix):
    result = []
    for t in range(len(features) // 2):
        x0, x1 = features[2 * t:2 * t + 2]
        total = _finite(x0 + x1, "feature sum")
        mean = _finite(total / 2.0, "feature mean")
        centered0, centered1 = _finite(x0 - mean, "centered0"), _finite(x1 - mean, "centered1")
        square0, square1 = _finite(centered0 * centered0, "square0"), _finite(centered1 * centered1, "square1")
        square_sum = _finite(square0 + square1, "square sum")
        variance = _finite(square_sum / 2.0, "population variance")
        argument = _finite(variance + 0.25, "variance plus epsilon")
        denominator = trace.leaf(f"{prefix}_{t}_sqrt", "sqrt", argument)
        trace.add(f"{prefix}_{t}_statistics", dict(x0=x0, x1=x1, epsilon=0.25),
                  dict(sum=total, mean=mean, centered0=centered0, centered1=centered1,
                       square0=square0, square1=square1, squareSum=square_sum,
                       variance=variance, variancePlusEpsilon=argument, denominator=denominator))
        for d, source in enumerate((centered0, centered1)):
            normalized = _finite(source / denominator, "normalized")
            scaled = _finite(1.0 * normalized, "gamma times normalized")
            value = _finite(scaled + 0.0, "plus beta")
            result.append(value)
            trace.add(f"{prefix}_{t}_feature_{d}", dict(source=source, denominator=denominator, gamma=1.0, beta=0.0),
                      dict(normalized=normalized, scaled=scaled, value=value))
    return result


def _two_products(features, weights, trace, prefix, bias=None, cols=2):
    result = []
    for t in range(len(features) // 2):
        x0, x1 = features[2 * t:2 * t + 2]
        for d in range(cols):
            w0, w1 = weights[d], weights[cols + d]
            product0, product1 = _finite(x0 * w0, "product0"), _finite(x1 * w1, "product1")
            total = _finite(product0 + product1, "two product sum")
            outputs = dict(product0=product0, product1=product1, sum=total)
            inputs = dict(x0=x0, x1=x1, w0=w0, w1=w1)
            value = total
            if bias is not None:
                inputs["bias"] = bias[d]
                value = _finite(total + bias[d], "bias last")
            outputs["value"] = value
            trace.add(f"{prefix}_{t}_{d}", inputs, outputs)
            result.append(value)
    return result


def _softmax(logits, allowed, trace, prefix, positive_zero=True):
    candidates = [value for value, keep in zip(logits, allowed) if keep]
    maximum = candidates[0]
    for value in candidates[1:]:
        # Match Math.max's +0 preference; the shifted native argument keeps sign.
        if value > maximum or (positive_zero and value == 0.0 and maximum == 0.0 and math.copysign(1.0, value) > 0.0):
            maximum = value
    terms = []
    shifted = {}
    denominator = 0.0
    running = []
    for j, (value, keep) in enumerate(zip(logits, allowed)):
        term = 0.0
        if keep:
            argument = _finite(value - maximum, "allowed shifted logit")
            shifted[f"shifted{j}"] = argument
            term = trace.leaf(f"{prefix}_exp_{j}", "exp", argument)
        terms.append(term)
    for term in terms:
        denominator = _finite(denominator + term, "softmax ordered denominator")
        running.append(denominator)
    probabilities = [_finite(term / denominator, "probability") for term in terms]
    inputs = {f"logit{j}": value for j, value in enumerate(logits)}
    inputs.update({f"allowed{j}": int(keep) for j, keep in enumerate(allowed)})
    outputs = dict(max=maximum, denominator=denominator, **shifted)
    outputs.update({f"term{j}": term for j, term in enumerate(terms)})
    outputs.update({f"p{j}": probability for j, probability in enumerate(probabilities)})
    outputs.update({f"running{j}": value for j, value in enumerate(running)})
    trace.add(prefix, inputs, outputs)
    return probabilities


def _accumulate_rows(features, width, weights, cols, trace, prefix, bias=None):
    result = []
    for t in range(len(features) // width):
        for d in range(cols):
            running = 0.0
            inputs, outputs = {}, {}
            for k in range(width):
                value, weight = features[t * width + k], weights[k * cols + d]
                inputs[f"x{k}"], inputs[f"w{k}"] = value, weight
                product = _finite(value * weight, "ordered product")
                running = _finite(running + product, "ordered running sum")
                outputs[f"product{k}"], outputs[f"running{k}"] = product, running
            value = running
            if bias is not None:
                inputs["bias"] = bias[d]
                value = _finite(running + bias[d], "output bias last")
            outputs["value"] = value
            trace.add(f"{prefix}_{t}_{d}", inputs, outputs)
            result.append(value)
    return result


def _residual(left, right, trace, prefix):
    result = []
    for i in range(len(left)):
        value = _finite(left[i] + right[i], "residual")
        trace.add(f"{prefix}_{i}", dict(left=left[i], right=right[i]), dict(value=value))
        result.append(value)
    return result


def _storage(values, rows, cols):
    """No numerical NumPy operation: store already computed Python scalars."""
    stored = np.empty((1, rows, cols), dtype=np.float64)
    for t in range(rows):
        for d in range(cols):
            stored[0, t, d] = values[t * cols + d]
    return stored


def _decoder_block_mechanics(features, gains, trace, prefix):
    """Original independent scalar graph; public metadata is a copy projection."""
    count = len(features) // 2
    norm1 = _norm(features, trace, prefix + "_ln1")
    matrices = {key: [gains[key], 0.0, 0.0, gains[key]] for key in ("q", "k", "v", "o")}
    q = _two_products(norm1, matrices["q"], trace, prefix + "_Q")
    k = _two_products(norm1, matrices["k"], trace, prefix + "_K")
    v = _two_products(norm1, matrices["v"], trace, prefix + "_V")
    # H=1 split is still an actual copy with an explicit coordinate capture.
    heads = []
    for label, source in (("Q", q), ("K", k), ("V", v)):
        copied = []
        for i, value in enumerate(source):
            copied.append(value)
            trace.add(f"{prefix}_{label}_split_{i}", dict(source=value), dict(value=value))
        heads.append(copied)
    q, k, v = heads
    divisor = trace.leaf(prefix + "_attention_sqrt", "sqrt", 2.0)
    raw, scores, logits, allowed = [], [], [], []
    for i in range(count):
        for j in range(count):
            product0 = _finite(q[2 * i] * k[2 * j], "score product0")
            product1 = _finite(q[2 * i + 1] * k[2 * j + 1], "score product1")
            dot = _finite(product0 + product1, "raw score")
            score = _finite(dot / divisor, "scaled score")
            raw.append(dot)
            scores.append(score)
            trace.add(f"{prefix}_score_{i}_{j}", dict(q0=q[2*i], q1=q[2*i+1], k0=k[2*j], k1=k[2*j+1], divisor=divisor),
                      dict(product0=product0, product1=product1, raw=dot, score=score))
    probabilities = []
    for i in range(count):
        row, mask = [], []
        for j in range(count):
            row.append(_finite(scores[i * count + j] + 0.0, "score plus zero common shift"))
            mask.append(j <= i)
        logits.extend(row)
        allowed.extend(mask)
        probabilities.extend(_softmax(row, mask, trace, f"{prefix}_attention_row_{i}"))
    mixed = []
    for i in range(count):
        for d in range(2):
            running = 0.0
            inputs, outputs = {}, {}
            for j in range(count):
                probability, value = probabilities[i * count + j], v[2 * j + d]
                inputs[f"p{j}"], inputs[f"v{j}"] = probability, value
                product = _finite(probability * value, "including forbidden zero product")
                running = _finite(running + product, "attention running sum")
                outputs[f"product{j}"], outputs[f"running{j}"] = product, running
            outputs["value"] = running
            trace.add(f"{prefix}_mix_{i}_{d}", inputs, outputs)
            mixed.append(running)
    joined = []
    for i, value in enumerate(mixed):
        joined.append(value)
        trace.add(f"{prefix}_join_{i}", dict(source=value), dict(value=value))
    attention = _accumulate_rows(joined, 2, matrices["o"], 2, trace, prefix + "_WO")
    residual1 = _residual(features, attention, trace, prefix + "_residual1")
    norm2 = _norm(residual1, trace, prefix + "_ln2")
    w1, w2 = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0], [gains["f"], 0.0, 0.0, gains["f"], 0.0, 0.0]
    preactivation = _two_products(norm2, w1, trace, prefix + "_ffn_hidden", [0.0, 0.0, 0.0], 3)
    hidden = []
    for i, value in enumerate(preactivation):
        activation = value if value > 0.0 else 0.0
        hidden.append(activation)
        trace.add(f"{prefix}_relu_{i}", dict(preactivation=value), dict(activation=activation))
    ffn = _accumulate_rows(hidden, 3, w2, 2, trace, prefix + "_ffn_output", [0.0, 0.0])
    output = _residual(residual1, ffn, trace, prefix + "_residual2")
    return dict(input=list(features), norm1=norm1, matrices=matrices, Q=q, K=k, V=v,
                raw=raw, scores=scores, logits=logits, allowed=allowed, probabilities=probabilities,
                mixed=mixed, joined=joined, attention=attention, residual1=residual1,
                norm2=norm2, W1=w1, W2=w2, b1=[0.0]*3, b2=[0.0]*2,
                preactivation=preactivation, hidden=hidden, ffn=ffn, output=output,
                storage=_storage(output, count, 2))


def _evaluate_decoder_mechanics(state, trace, prefix):
    features, embedding, positions = [], [], []
    table = {97: (1.0, 0.0), 98: (0.0, 1.0), 512: (0.0, 0.0)}
    for t in range(2):
        token = state[f"token{t}"]
        for d in range(2):
            looked_up = table[token][d]
            position = state["positionScale"] if (t, d) == (1, 1) else 0.0
            value = _finite(looked_up + position, "embedding plus position")
            embedding.append(looked_up)
            positions.append(position)
            features.append(value)
            trace.add(f"{prefix}_position_{t}_{d}", dict(token=token, embedding=looked_up, position=position), dict(value=value))
    block1 = _decoder_block_mechanics(features, {key: state[key + "1"] for key in _GAIN_FIELDS}, trace, prefix + "_block1")
    block2 = _decoder_block_mechanics(block1["output"], {key: state[key + "2"] for key in _GAIN_FIELDS}, trace, prefix + "_block2")
    readout = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
    bias = [state["biasA"], state["biasB"], state["biasEOS"]]
    logits = _two_products(block2["output"], readout, trace, prefix + "_readout", bias, 3)
    probabilities, winners = [], []
    for t in range(2):
        row = logits[3*t:3*t+3]
        distribution = _softmax(row, [True, True, True], trace, f"{prefix}_class_row_{t}", positive_zero=False)
        probabilities.extend(distribution)
        best = 0
        for index in range(1, 3):
            if row[index] > row[best]:
                best = index
        winner = dict(index=best, token=_IDS[best], probability=distribution[best])
        winners.append(winner)
        trace.add(f"{prefix}_winner_{t}", {f"logit{j}": row[j] for j in range(3)}, winner)
    return dict(embedding=embedding, positions=positions, features=features, block1=block1, block2=block2,
                U=readout, bias=bias, logits=logits, probabilities=probabilities,
                winners=winners, next=winners[-1].copy(), storage=_storage(logits, 2, 3))


def check_mechanism():
    """Explicit bounded FIRST checks only; these do NOT admit public records."""
    if not __debug__:
        raise RuntimeError("Explicit mechanism self-check refuses optimized Python (-O).")
    import struct

    def words(values):
        return [struct.pack(">d", value) for value in values]

    default = decoder_state(dict(DEFAULT_IV59))
    trace = _MechanismTrace()
    result = _evaluate_decoder_mechanics(default, trace, "default")
    assert result["features"] == [1.0, 0.0, 1.0, 0.5]
    assert words(result["block2"]["input"]) == words(result["block1"]["output"])
    assert words(result["block1"]["storage"][0].flat) == words(result["block1"]["output"])
    assert result["block1"]["input"] != result["block2"]["input"]
    assert [winner["token"] for winner in result["winners"]] == [97, 97]
    assert result["next"] == result["winners"][-1] and result["next"] is not result["winners"][-1]
    assert result["block1"]["W1"] == [1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
    assert result["block1"]["W2"] == [0.5, 0.0, 0.0, 0.5, 0.0, 0.0]
    assert result["block2"]["W2"] == [0.25, 0.0, 0.0, 0.25, 0.0, 0.0]
    for block in (result["block1"], result["block2"]):
        assert block["allowed"] == [True, False, True, True]
        assert words(block["probabilities"][:2]) == words([1.0, 0.0])
        assert len(block["raw"]) == 4 and len(block["preactivation"]) == 6
        assert words(block["preactivation"][2::3]) == words([0.0, 0.0])
        assert words(block["hidden"][2::3]) == words([0.0, 0.0])
    frames = {identifier: (inputs, outputs) for identifier, inputs, outputs in trace.steps}
    first = frames["default_block1_ln1_0_statistics"][1]
    assert first["sum"] == 1.0 and first["mean"] == 0.5
    assert first["centered0"] == 0.5 and first["centered1"] == -0.5
    assert first["variancePlusEpsilon"] == 0.5
    second = frames["default_block1_ln1_1_statistics"][1]
    assert second["sum"] == 1.5 and second["mean"] == 0.75
    assert second["centered0"] == 0.25 and second["centered1"] == -0.25
    assert second["variancePlusEpsilon"] == 0.3125
    assert frames["default_block1_mix_0_0"][1]["product1"] == 0.0
    native_ids = [leaf["id"] for leaf in trace.native]
    assert len(set(native_ids)) == len(native_ids)
    for leaf in trace.native:
        if leaf["kind"] == "sqrt":
            assert 0.25 <= leaf["input"] <= 4096.0
            expected = math.sqrt(leaf["input"])
        else:
            assert -256.0 <= leaf["input"] <= 0.0
            expected = math.exp(leaf["input"])
        assert words([leaf["output"]]) == words([expected])
    for layer in (1, 2):
        leaf = next(item for item in trace.native if item["id"] == f"default_block{layer}_attention_sqrt")
        for i in range(2):
            for j in range(2):
                copied = frames[f"default_block{layer}_score_{i}_{j}"][0]["divisor"]
                assert words([copied]) == words([leaf["output"]])

    zero = dict(default, o1=0.0, f1=0.0, o2=0.0, f2=0.0)
    zero_trace = _MechanismTrace()
    identity = _evaluate_decoder_mechanics(zero, zero_trace, "zero")
    for key in ("block1", "block2"):
        assert words(identity[key]["output"]) == words([1.0, 0.0, 1.0, 0.5])
        assert len(identity[key]["hidden"]) == 6
    assert words(identity["logits"]) == words([1.0, 0.0, 0.0, 1.0, 0.5, 0.0])
    for t, arguments in enumerate(((0.0, -1.0, -1.0), (0.0, -0.5, -1.0))):
        terms = [math.exp(argument) for argument in arguments]
        denominator = ((0.0 + terms[0]) + terms[1]) + terms[2]
        expected = [term / denominator for term in terms]
        assert words(identity["probabilities"][3*t:3*t+3]) == words(expected)
    assert len(zero_trace.native) == len(trace.native)
    assert len(zero_trace.steps) == len(trace.steps)

    # A changed future token cannot change any first-row result in either block.
    future_trace = _MechanismTrace()
    future = _evaluate_decoder_mechanics(dict(default, token1=98), future_trace, "future")
    assert words(future["logits"][:3]) == words(result["logits"][:3])
    assert words(future["block2"]["output"][:2]) == words(result["block2"]["output"][:2])
    tied = _evaluate_decoder_mechanics(dict(zero, token0=512, token1=512, positionScale=0.0), _MechanismTrace(), "tie")
    assert words(tied["logits"]) == words([0.0] * 6)
    assert [winner["index"] for winner in tied["winners"]] == [0, 0]
    assert [winner["token"] for winner in tied["winners"]] == [97, 97]
    for length in (2, 4, 6):
        features = [16.0, -16.0] * (length // 2)
        gains = dict(q=-1.0, k=1.0, v=-1.0, o=0.0, f=0.0)
        captured, checked_gains = _block_inputs(features, gains, "bounded")
        block = _decoder_block_mechanics(captured, checked_gains, _MechanismTrace(), "bounded")
        assert words(block["output"]) == words(features)
        assert len(block["hidden"]) == (length // 2) * 3
    captured, gains = _block_inputs([-0.0, 0.0], dict(q=-0.0, k=1, v=1, o=0, f=0), "signed")
    assert words([captured[0], gains["q"]]) == words([-0.0, -0.0])
    detached = _MechanismTrace()
    before, after = dict(x=-0.0), dict(y=1.0)
    detached.add("capture", before, after)
    before["x"], after["y"] = 8.0, 9.0
    assert words([detached.steps[0][1]["x"]]) == words([-0.0])
    assert detached.steps[0][2]["y"] == 1.0

    signed_trace = _MechanismTrace()
    _softmax([-0.0, 0.0, -1.0], [True, True, True], signed_trace, "signed_max")
    assert words([signed_trace.steps[0][2]["max"]]) == words([0.0])
    assert words([signed_trace.native[0]["input"]]) == words([-0.0])
    assert words([signed_trace.native[1]["input"]]) == words([0.0])


# Public binding projects the independent FIRST captures; it never recomputes floats.

def _numeric(value, label):
    if type(value) is int:
        # Compare before conversion: huge Python integers must not raise OverflowError.
        if not -1.7976931348623157e308 <= value <= 1.7976931348623157e308:
            raise NumericalFault("NONFINITE", label + " must be an actual finite number.")
        return value if -9007199254740991 <= value <= 9007199254740991 else float(value)
    if type(value) is not float or not math.isfinite(value):
        raise NumericalFault("NONFINITE", label + " must be an actual finite number.")
    return value


def _trace_entries(value):
    """Capture trusted items once, then use JavaScript's canonical-index order."""
    if type(value) in (list, str):
        entries = [(str(index), item) for index, item in enumerate(value)]
    elif type(value) in (int, float, bool):
        entries = []
    else:
        entries = list(value.items())  # Preserve trusted observers and their exception identity.
    indices, rest = [], []
    for key, item in entries:
        if type(key) is not str:
            raise TypeError("Trusted trace operand keys must be strings.")
        index = (bool(key) and len(key) <= 10 and all(c in "0123456789" for c in key)
                 and (key == "0" or key[0] != "0") and int(key) < 4294967295)
        (indices if index else rest).append((key, item))
    return sorted(indices, key=lambda pair: int(pair[0])) + rest


class _PublicTrace:
    """Frozen observer container, mutable collector, immutable saved frames."""
    __slots__ = ("outputs", "steps", "_ids")

    def __init__(self):
        object.__setattr__(self, "outputs", {})
        object.__setattr__(self, "steps", [])
        object.__setattr__(self, "_ids", set())

    def __setattr__(self, name, value):
        raise TypeError("Frozen trace observer.")

    def __delattr__(self, name):
        raise TypeError("Frozen trace observer.")

    def add(self, identifier, label, equation, explanation, inputs, outputs):
        if type(identifier) is not str or not identifier or identifier in self._ids:
            raise NumericalFault("INVALID_INPUT", "Trace IDs must be nonempty and unique.")
        before = {key: _numeric(value, identifier + ".inputs." + key) for key, value in _trace_entries(inputs)}
        after = {key: _numeric(value, identifier + ".outputs." + key) for key, value in _trace_entries(outputs)}
        if len(self.steps) >= 512:
            raise NumericalFault("UNSUPPORTED_SIZE", "At most 512 operations are supported.")
        frame = _freeze(dict(id=identifier, label=label, equation=equation, explanation=explanation,
                             inputs=before, outputs=after))
        self.steps.append(frame)
        self._ids.add(identifier)
        for key, value in after.items():
            alias = identifier + "_" + key
            # The actual ordinary JS object ignores numeric assignments to its inherited setter.
            if alias != "__proto__":
                self.outputs[alias] = value


_STAT_FIELDS = ("sum", "mean", "centered0", "centered1", "square0", "square1", "squareSum",
                "variance", "variancePlusEpsilon", "denominator")


def _tensor(identifier, shape, axes, values, provenance, dtype="float64"):
    return dict(id=identifier, shape=list(shape), axes=list(axes), dtype=dtype, values=list(values),
                provenance=provenance, precision=0 if dtype == "int32" else 8)


def _native_tensors(prefix, natives):
    return [
        _tensor(prefix + "_NativeArguments", [len(natives), 2], ["Native", "NativeField"],
                [value for leaf in natives for value in (leaf["input"], leaf["output"])],
                "Ordered actual native input,output words; IDs and kinds are recorded in texts.nativeIds and texts.nativeKinds. No native evaluation occurs while serializing."),
        _tensor(prefix + "_NativeKinds", [len(natives)], ["Native"],
                [0 if leaf["kind"] == "sqrt" else 1 for leaf in natives],
                "Native kind codes in native occurrence order: sqrt=0, exp=1.", "int32"),
    ]


def _native_texts(natives):
    return dict(nativeIds=[leaf["id"] for leaf in natives], nativeKinds=[leaf["kind"] for leaf in natives],
                nativeFields=["input", "output"])


def _norm_binding(mechanism, captures, trace, prefix, stage):
    T = len(mechanism["input"]) // 2
    private = prefix + ("_ln1" if stage == 1 else "_ln2")
    public = prefix + f"_n{stage}"
    statistics, centered, normalized = [], [], []
    for t in range(T):
        before, after = captures[f"{private}_{t}_statistics"]
        trace.add(f"{public}_0_{t}_statistics", f"0_{t}: feature-only mean and population variance",
                  "sum=x0+x1; mean=sum/2; centered=x-mean; squareSum=centered0²+centered1²; variance=squareSum/2; denominator=sqrt(variance+epsilon)",
                  "Only these two features contribute. Epsilon is inside the square root; no batch or token statistics are mixed.",
                  dict(before), dict(after))
        statistics.extend(after[key] for key in _STAT_FIELDS)
        centered.extend((after["centered0"], after["centered1"]))
        for d in range(2):
            before, after = captures[f"{private}_{t}_feature_{d}"]
            trace.add(f"{public}_0_{t}_feature_{d}", f"0_{t}: affine feature {d}",
                      "normalized=source/denominator; scaled=gamma*normalized; value=scaled+beta",
                      "The source is the saved centered feature. Gamma and beta may change output mean and variance.",
                      dict(d=d, **before), dict(after))
            normalized.append(after["normalized"])
    shape, axes = [1, T, 2], ["B", "T", "D"]
    return [
        _tensor(public + "_Gamma", [2], ["D"], [1.0, 1.0], "Shared literal feature scales [1,1]."),
        _tensor(public + "_Beta", [2], ["D"], [0.0, 0.0], "Shared literal feature offsets [+0,+0]."),
        _tensor(public + "_Statistics", [1, T, 10], ["B", "T", "NormStatistic"], statistics,
                "Actual sum,mean,centered0,centered1,square0,square1,squareSum,variance,variancePlusEpsilon,denominator in token order."),
        _tensor(public + "_Centered", shape, axes, centered, "Actual saved input feature minus feature mean, before division."),
        _tensor(public + "_Normalized", shape, axes, normalized, "Actual centered/denominator words before gamma multiplication and beta addition."),
        _tensor(public + "_Output", shape, axes, mechanism[f"norm{stage}"], "Actual per-position feature LayerNorm affine output; gamma=[1,1], beta=[0,0], epsilon=1/4."),
    ]


def _block_natives(captured, prefix, T):
    names = {f"{prefix}_ln1_{t}_sqrt": f"{prefix}_n1_0_{t}_sqrt" for t in range(T)}
    names[prefix + "_attention_sqrt"] = prefix + "_attn_sqrt"
    for i in range(T):
        for j in range(i + 1):
            names[f"{prefix}_attention_row_{i}_exp_{j}"] = f"{prefix}_attn_exp_0_0_{i}_{j}"
    names.update({f"{prefix}_ln2_{t}_sqrt": f"{prefix}_n2_0_{t}_sqrt" for t in range(T)})
    return [dict(id=names[leaf["id"]], kind=leaf["kind"], input=leaf["input"], output=leaf["output"])
            for leaf in captured]


def _residual_binding(mechanism, captures, trace, prefix, stage, left_id, right_id):
    T = len(mechanism["input"]) // 2
    identifier = prefix + ("_R1" if stage == 1 else "_Output")
    for t in range(T):
        for d in range(2):
            before, after = captures[f"{prefix}_residual{stage}_{2*t+d}"]
            trace.add(f"{prefix}_r{stage}_0_{t}_{d}", f"{identifier}[0,{t},{d}]: skip plus branch", "value=skip+branch",
                      "The unchanged same-shape primitive performs this actual feature addition. Both residuals are always on; no broadcasting or zero-gain bypass occurs.",
                      dict(b=0, t=t, d=d, skip=before["left"], branch=before["right"]), dict(after))
    return _tensor(identifier, [1, T, 2], ["B", "T", "D"],
                   mechanism["residual1" if stage == 1 else "output"],
                   f"Exact named-shape addition of {left_id} and {right_id}; no broadcasting.")


def _bind_block(features, gains, mechanism, captured, trace, prefix):
    T = len(features) // 2
    captures = {identifier: (before, after) for identifier, before, after in captured.steps}
    natives = _block_natives(captured.native, prefix, T)
    tensors = [
        _tensor(prefix + "_Features", [1, T, 2], ["B", "T", "D"], features,
                "Actual captured per-position block features; repeated token IDs do not merge positions."),
        _tensor(prefix + "_Gains", [5], ["Gain"], [gains[key] for key in _GAIN_FIELDS],
                "Actual q,k,v,o,f gain words; diagonal slots copy these words and off-diagonal slots are literal +0."),
    ]
    tensors.extend(_norm_binding(mechanism, captures, trace, prefix, 1))
    a = prefix + "_attn"
    setup = dict(B=1, T=T, H=1, Dk=2, Dv=2)
    for name in ("x000", "x001", "x010", "x011", "x020", "x021", "x100", "x101", "x110", "x111", "x120", "x121"):
        setup[name] = 0.0
    for kind in ("q", "k", "v"):
        for name in ("000", "001", "010", "011", "100", "101", "110", "111"):
            setup["w" + kind + name] = gains[kind] if name in ("000", "101") else 0.0
    setup.update(mode=1, valid0=1, valid1=1, valid2=1, shift=0.0)
    for name in ("000", "001", "010", "011", "100", "101", "110", "111"):
        setup["wo" + name] = gains["o"] if name in ("000", "011") else 0.0
    for t in range(T):
        for d in range(2):
            setup[f"x0{t}{d}"] = mechanism["norm1"][2*t+d]
    trace.add(a + "_setup", "Validate every scalar slot, then select active dimensions",
              "D=2; X[B,T,2]; WQ,WK[2,H*Dk]; WV[2,H*Dv]",
              "All inactive fields remain finite and bounded. Parameter names identify input d, head h and feature f, so changing width never relabels a head’s weights.",
              setup, dict(B=1, T=T, D=2, H=1, Dk=2, Dv=2))
    for kind in ("Q", "K", "V"):
        for t in range(T):
            for f in range(2):
                before, after = captures[f"{prefix}_{kind}_{t}_{f}"]
                trace.add(f"{a}_project_{kind}_0_{t}_0_{f}", f"{kind}[0,{t},head 0,feature {f}]: both input contributions",
                          "product0=x0*w0; product1=x1*w1; value=product0+product1",
                          "One token row times the packed column h*F+f, keeping both input-feature rows. Weights are hand-set; no bias, activation or learning is hidden.",
                          dict(b=0, t=t, h=0, f=f, **before),
                          dict(product0=after["product0"], product1=after["product1"], value=after["value"]))
    for kind in ("Q", "K", "V"):
        trace.add(f"{a}_reshape_{kind}", f"{kind}: reshape the packed feature axis",
                  "[B,T,H*F] → [B,T,H,F]; feature=h*F+f",
                  "Reshaping preserves every flat value and its order. H counts attention heads; F counts features within each head. No projection feature is dropped.",
                  dict(B=1, T=T, H=1, F=2, features=2, elements=2*T), dict(elements=2*T))
        for t in range(T):
            for f in range(2):
                before, after = captures[f"{prefix}_{kind}_split_{2*t+f}"]
                trace.add(f"{a}_permute_{kind}_0_0_{t}_{f}", f"{kind}: copy [0,{t},0,{f}] to [0,0,{t},{f}]",
                          "axes [0,2,1,3]; destination[b,h,t,f]=source[b,t,h,f]",
                          "Moving the head axis is a declared permutation, separate from reshape. The recorded offsets are actual row-major flat indices; this indexed value is copied unchanged.",
                          dict(b=0, h=0, t=t, f=f, feature=f, sourceOffset=2*t+f, destinationOffset=2*t+f, sourceValue=before["source"]), dict(after))
    for i in range(T):
        for j in range(T):
            before, after = captures[f"{prefix}_score_{i}_{j}"]
            trace.add(f"{a}_score_0_0_{i}_{j}", f"Batch 0, head 0: query {i} against key {j}",
                      "product0=q0*k0; product1=q1*k1; raw=product0+product1; score=raw/sqrt(Dk)",
                      "Matching features are multiplied inside this batch and head only. Dk, not H or T or Dv, supplies the scaling width. Signed scores are not probabilities.",
                      dict(b=0, h=0, i=i, j=j, Dk=2, divisor=before["divisor"], q0=before["q0"], k0=before["k0"], q1=before["q1"], k1=before["k1"]), dict(after))
    for i in range(T):
        before, after = captures[f"{prefix}_attention_row_{i}"]
        inputs = dict(b=0, h=0, i=i, mode=1, shift=0.0)
        inputs.update({f"score{j}": mechanism["scores"][i*T+j] for j in range(T)})
        inputs.update({f"allowed{j}": before[f"allowed{j}"] for j in range(T)})
        outputs = dict(max=after["max"], denominator=after["denominator"])
        outputs.update({f"shifted{j}": after[f"shifted{j}"] for j in range(i+1)})
        outputs.update({f"term{j}": after[f"term{j}"] for j in range(T)})
        outputs.update({f"p{j}": after[f"p{j}"] for j in range(T)})
        trace.add(f"{a}_row_0_0_{i}", f"Batch 0, head 0, query {i}: key-axis stable softmax",
                  "logit_j=score_j+shift; max=max(allowed logits); term_j=allowed_j?exp(logit_j-max):0; denominator=sum_j term_j; p_j=term_j/denominator",
                  "Each head has its own probabilities. Key validity is shared across batches and heads; queries remain. Forbidden terms are exactly zero, without an infinity sentinel or invented shifted value. Allowed terms can underflow; a large common shift can change low bits.", inputs, outputs)
    for i in range(T):
        for f in range(2):
            before, after = captures[f"{prefix}_mix_{i}_{f}"]
            outputs = {f"product{j}": after[f"product{j}"] for j in range(T)}
            outputs.update({f"running{j}": after[f"running{j}"] for j in range(T)})
            outputs["value"] = after["value"]
            trace.add(f"{a}_head_mix_0_0_{i}_{f}", f"OHeads[0,0,{i},{f}]: this head’s weighted values",
                      "product_j=p_j*v_j; running starts at 0; running_j=previous+product_j; value=last running sum",
                      "Use the real probability row and values in the same head and batch. Compute each product, then immediately accumulate in ascending key order, including actual zero times V for forbidden keys. No averaging across heads or extra division.",
                      dict(b=0, h=0, i=i, f=f, **before), outputs)
    for t in range(T):
        for f in range(2):
            before, after = captures[f"{prefix}_join_{2*t+f}"]
            trace.add(f"{a}_concat_0_{t}_0_{f}", f"Join head 0, feature {f} into C[0,{t},{f}]", "C[b,t,h*Dv+f]=OHeads[b,h,t,f]",
                      "Copy one actual head output unchanged. Concatenate in head order then within-head feature order; never average heads or mix batches.",
                      dict(b=0, t=t, h=0, f=f, concatFeature=f, sourceOffset=2*t+f, destinationOffset=2*t+f, sourceValue=before["source"]), dict(after))
    for t in range(T):
        for d in range(2):
            before, after = captures[f"{prefix}_WO_{t}_{d}"]
            inputs = dict(b=0, t=t, d=d, c0=before["x0"], w0=before["w0"], c1=before["x1"], w1=before["w1"])
            outputs = {key: after[key] for key in ("product0", "product1", "running0", "running1", "value")}
            trace.add(f"{a}_output_0_{t}_{d}", f"Y[0,{t},{d}]: explicit output projection",
                      "product_c=C_c*WO[c,d]; running starts at 0; running_c=previous+product_c; Y=last running sum",
                      "WO rows preserve named head/feature identity when Dv changes. Every joined feature contributes one recorded product and running sum. Y may be signed; no output softmax, bias, residual, dropout or normalization is added.", inputs, outputs)
    tensors.extend(_attention_tensors(mechanism, a, T))
    tensors.append(_residual_binding(mechanism, captures, trace, prefix, 1, prefix + "_Features", a + "_Y"))
    tensors.extend(_norm_binding(mechanism, captures, trace, prefix, 2))
    tensors.extend(_ffn_binding(mechanism, captures, trace, prefix, T))
    output = _residual_binding(mechanism, captures, trace, prefix, 2, prefix + "_R1", prefix + "_ffn_F")
    tensors.extend([output, *_native_tensors(prefix, natives)])
    texts = dict(**_native_texts(natives), gainFields=list(_GAIN_FIELDS), normStatisticFields=list(_STAT_FIELDS),
        featurePolicy="One batch, one to three positions, two features per position. Block output keeps B,T,D axes and feeds the next block directly; it is never a token lookup.",
        kernelPolicy="Unchanged p07 featureNorm, p06 projectHeads/attendHeads/joinHeads, p07 feedForward and sameShapeAdd perform all scalar arithmetic. All inactive attention state slots are explicit +0 except validity=1; active dimensions are B1,H1,Dk2,Dv2,mode1,shift+0. Every matrix coordinate and all three FFN hidden coordinates are computed at every gain.",
        nativePolicy="Occurrence order is LN1 sqrt by token, one sqrt(Dk), allowed attention exp by query/key, then LN2 sqrt by token. LN arguments/outputs and attention divisor/terms copy actual primitive records. Old stableSoftmax trace shifted values repeat the same subtraction of immutable logit and max operands as its exp arguments: functional reconstruction, not a physical instruction trace. Masked cells have no exp occurrence. No native math occurs in serialization.",
        zeroPolicy="Feature words, gain words, arithmetic results and every copy retain binary64 WORD, including allowed -0. Diagonal weights copy gains; every off-diagonal or inactive weight is literal +0. Dimensions, indices, mask decisions and native kind codes use VALUE.",
        limitsPolicy="Forward-only authored toy. No differentiated loss, training, optimizer, dropout, sampling, KV cache, physical timing or production-model claim. Public input features are bounded [-16,16], gains [-1,1]; epsilon=1/4, gamma=[1,1], beta=[0,0], width-three ReLU FFN.")
    return _freeze(dict(features=features, gains=gains, output=output, natives=natives, tensors=tensors, texts=texts))


def _attention_tensors(m, prefix, T):
    shape, axes = [1, T, 2], ["B", "T", "D"]
    result = [_tensor(prefix + "_X", shape, axes, m["norm1"], "Active token rows; D=2 input features always retained.")]
    for kind, feature, provenance in (
        ("Q", "QueryFeature", "Query columns packed by h*Dk+f from wq{d}{h}{f}."),
        ("K", "KeyFeature", "Key columns packed by h*Dk+f from wk{d}{h}{f}."),
        ("V", "ValueFeature", "Value columns packed by h*Dv+f from wv{d}{h}{f}.")):
        result.append(_tensor(prefix + "_W" + kind, [2, 2], ["D", feature], m["matrices"][kind.lower()], provenance))
    for kind, feature, provenance in (
        ("Q", "QueryFeature", "XWQ; each packed coordinate has two products and one sum."),
        ("K", "KeyFeature", "XWK; each packed coordinate has two products and one sum."),
        ("V", "ValueFeature", "XWV; values are projected separately from queries and keys.")):
        result.append(_tensor(prefix + "_" + kind + "Concat", shape, ["B", "T", feature], m[kind], provenance))
    for kind in ("Q", "K", "V"):
        width = "Dv" if kind == "V" else "Dk"
        result.extend([
            _tensor(prefix + "_" + kind + "Split", [1, T, 1, 2], ["B", "T", "H", width], m[kind],
                    kind + "Concat reshaped without changing flat order; feature=h*F+f."),
            _tensor(prefix + "_" + kind + "Heads", [1, 1, T, 2], ["B", "H", "T", width], m[kind],
                    kind + "Split permuted by axes [0,2,1,3]; every copied source/destination offset is traced."),
        ])
    shape, axes = [1, 1, T, T], ["B", "H", "Query", "Key"]
    for key, provenance, dtype in (
        ("raw", "Separate QHeads KHeads transpose products within every batch and head.", "float64"),
        ("scores", "raw/sqrt(Dk); the two-product order matches IV25 for H1,Dk2.", "float64"),
        ("allowed", "Causal and/or valid-key mask; shared validity across B and H; every query retained.", "bool"),
        ("logits", "Finite score+shift, including forbidden cells; mask applied separately.", "float64"),
        ("probabilities", "Stable allowed-key softmax for each B/H/query independently; forbidden probabilities exactly zero.", "float64")):
        result.append(_tensor(prefix + "_" + key, shape, axes, m[key], provenance, dtype))
    result.extend([
        _tensor(prefix + "_OHeads", [1, 1, T, 2], ["B", "H", "Query", "Dv"], m["mixed"], "Actual per-head P times VHeads; every product and running sum is traced."),
        _tensor(prefix + "_C", [1, T, 2], ["B", "T", "JoinedValue"], m["joined"], "OHeads permuted to token-major order then joined by c=h*Dv+f; values unchanged."),
        _tensor(prefix + "_WO", [2, 2], ["JoinedValue", "D"], m["matrices"]["o"], "wo{h}{f}{d} packed in h,f,d order, preserving parameter identity."),
        _tensor(prefix + "_Y", [1, T, 2], ["B", "T", "D"], m["attention"], "Y=C WO, summing products in ascending joined-feature order from zero; no normalization."),
    ])
    return result


def _ffn_binding(m, captures, trace, prefix, T):
    f = prefix + "_ffn"
    for t in range(T):
        for hidden in range(3):
            before, after = captures[f"{prefix}_ffn_hidden_{t}_{hidden}"]
            trace.add(f"{f}_hidden_0_{t}_{hidden}", f"Hidden affine [0,{t},{hidden}]",
                      "product0=x0*w0; product1=x1*w1; sum=product0+product1; preactivation=sum+bias",
                      "The same W1 and b1 apply separately to each token. Add bias after the two input products; no token sum occurs.",
                      dict(b=0, t=t, m=hidden, **before),
                      dict(product0=after["product0"], product1=after["product1"], sum=after["sum"], preactivation=after["value"]))
    for t in range(T):
        for hidden in range(3):
            before, after = captures[f"{prefix}_relu_{3*t+hidden}"]
            trace.add(f"{f}_relu_0_{t}_{hidden}", f"ReLU [0,{t},{hidden}]", "activation=max(0,preactivation)",
                      "ReLU means rectified linear unit: keep a positive value and replace a nonpositive value with zero, including zero itself.",
                      dict(b=0, t=t, m=hidden, **before), dict(after))
    for t in range(T):
        for d in range(2):
            before, after = captures[f"{prefix}_ffn_output_{t}_{d}"]
            inputs = dict(b=0, t=t, d=d)
            for hidden in range(3):
                inputs[f"h{hidden}"] = before[f"x{hidden}"]
                inputs[f"w{hidden}"] = before[f"w{hidden}"]
            inputs["bias"] = before["bias"]
            outputs = {f"product{hidden}": after[f"product{hidden}"] for hidden in range(3)}
            outputs.update({f"running{hidden}": after[f"running{hidden}"] for hidden in range(3)})
            outputs.update(sum=after["running2"], value=after["value"])
            trace.add(f"{f}_output_0_{t}_{d}", f"FFN output [0,{t},{d}]",
                      "product_m=h_m*w_m; running starts at 0; running_m=previous+product_m; sum=running2; value=sum+bias",
                      "Multiply then immediately accumulate hidden features in ascending order 0,1,2. Add b2 last. Output may be signed; there is no softmax or residual inside the FFN.", inputs, outputs)
    return [
        _tensor(f + "_W1", [2, 3], ["D", "HiddenFeature"], m["W1"], "Shared input-to-hidden weights, f1{d}{m}; M=3 hidden features."),
        _tensor(f + "_b1", [3], ["HiddenFeature"], m["b1"], "Shared hidden bias, added after the two products."),
        _tensor(f + "_Z", [1, T, 3], ["B", "T", "HiddenFeature"], m["preactivation"], "Hidden preactivations X W1+b1; no batch or token mixing."),
        _tensor(f + "_Hidden", [1, T, 3], ["B", "T", "HiddenFeature"], m["hidden"], "ReLU(Z)=max(0,Z), before the second affine layer."),
        _tensor(f + "_W2", [3, 2], ["HiddenFeature", "D"], m["W2"], "Shared hidden-to-output weights, f2{m}{d}."),
        _tensor(f + "_b2", [2], ["D"], m["b2"], "Shared output bias, added after all three running sums."),
        _tensor(f + "_F", [1, T, 2], ["B", "T", "D"], m["ffn"], "ReLU(X W1+b1) W2+b2, independently per token with shared parameters."),
    ]


def decoder_block(features, gains, trace, prefix):
    """Adopted helper, scalar FIRST plus complete metadata/copy projection."""
    features, gains = _block_inputs(features, gains, prefix)
    captured = _MechanismTrace()
    mechanism = _decoder_block_mechanics(features, gains, captured, prefix)
    return _bind_block(features, gains, mechanism, captured, trace, prefix)


def _head_binding(mechanism, captures, captured_natives, trace, prefix):
    logits, probabilities = mechanism["logits"], mechanism["probabilities"]
    maxima, shifted, terms, denominators, readout = [], [], [], [], []
    for t in range(2):
        for c in range(3):
            before, after = captures[f"{prefix}_readout_{t}_{c}"]
            trace.add(f"{prefix}_readout_{t}_{c}", f"Readout at position {t}, class {c}",
                      "product0=x0*u0; product1=x1*u1; sum=product0+product1; logit=sum+bias",
                      "Both final block features contribute through actual products for every class, including zero weights. Add that class bias last. U is hand-set, not trained.",
                      dict(t=t, c=c, x0=before["x0"], x1=before["x1"], u0=before["w0"], u1=before["w1"], bias=before["bias"]),
                      dict(product0=after["product0"], product1=after["product1"], sum=after["sum"], logit=after["value"]))
            readout.extend((after["product0"], after["product1"], after["sum"], after["value"]))
    for t in range(2):
        before, after = captures[f"{prefix}_class_row_{t}"]
        maximum = after["max"]
        maxima.append(maximum)
        trace.add(f"{prefix}_classMax_{t}", f"Stable class maximum at position {t}",
                  "max=logit0; scan class1,class2; replace only on strict greater",
                  "The maximum is selected from the actual saved logits. Class order is a,b,EOS with ascending IDs 97,98,512.",
                  {f"logit{c}": logits[3*t+c] for c in range(3)}, dict(max=maximum))
        for c in range(3):
            argument, term = after[f"shifted{c}"], after[f"term{c}"]
            shifted.append(argument)
            terms.append(term)
            trace.add(f"{prefix}_classExp_{t}_{c}", f"Stable class exponential at position {t}, class {c}",
                      "shifted=logit-max; term=exp(shifted)",
                      "Save the exact argument and output at this native exp call. The argument is nonpositive; there is no logarithm or hidden loss.",
                      dict(logit=logits[3*t+c], max=maximum), dict(shifted=argument, term=term))
        for c in range(3):
            previous = 0.0 if c == 0 else after[f"running{c-1}"]
            trace.add(f"{prefix}_classSum_{t}_{c}", f"Ordered class denominator at position {t}, class {c}", "sum=previous+term",
                      "Start from literal +0 and immediately add terms in class order 0,1,2. Keep this actual running sum; do not simplify equal terms.",
                      dict(previous=previous, term=after[f"term{c}"]), dict(sum=after[f"running{c}"]))
        denominators.append(after["denominator"])
        for c in range(3):
            trace.add(f"{prefix}_classProbability_{t}_{c}", f"Class probability at position {t}, class {c}", "probability=term/denominator",
                      "Divide the saved class term by the final saved ordered denominator. Display rounding is never an operand.",
                      dict(term=after[f"term{c}"], denominator=after["denominator"]), dict(probability=probabilities[3*t+c]))
        winner = mechanism["winners"][t]
        inputs = {f"logit{c}": logits[3*t+c] for c in range(3)}
        inputs.update({f"probability{c}": probabilities[3*t+c] for c in range(3)})
        trace.add(f"{prefix}_argmax_{t}", f"Greedy recommendation from position {t}",
                  "index=first maximum logit; tokenId=IDS[index]; probability=probabilities[index]",
                  "Strict-greater scanning retains the smallest actual token ID on an exact logit tie. This row recommends the next token after this observed prefix; it does not append it.",
                  inputs, dict(index=winner["index"], tokenId=winner["token"], probability=winner["probability"]))
    natives = []
    for leaf in captured_natives:
        # Only readout leaves are supplied; each name is a direct occurrence copy.
        suffix = leaf["id"].removeprefix(prefix + "_class_row_")
        t, c = suffix.split("_exp_")
        natives.append(dict(id=f"{prefix}_readout_exp_{t}_{c}", kind=leaf["kind"], input=leaf["input"], output=leaf["output"]))
    return dict(readout=readout, maxima=maxima, shifted=shifted, terms=terms, denominators=denominators, natives=natives)


def evaluate_decoder(value, trace, prefix):
    """All actual scalar values are captured before metadata projection."""
    state = decoder_state(value)
    _prefix(prefix)
    captured = _MechanismTrace()
    mechanism = _evaluate_decoder_mechanics(state, captured, prefix)
    captures = {identifier: (before, after) for identifier, before, after in captured.steps}
    for t in range(2):
        token_id = state[f"token{t}"]
        row = _IDS.index(token_id)
        for d in range(2):
            before, after = captures[f"{prefix}_position_{t}_{d}"]
            trace.add(f"{prefix}_embedding_{t}_{d}", f"Observed position {t}, feature {d}: lookup then add position", "feature=embedding+position",
                      "Look up this observed token ID in the authored E table and add the displayed absolute-position coordinate. An observed EOS has its explicit zero row; no token is generated or silently stopped.",
                      dict(t=t, d=d, tokenId=token_id, row=row, embedding=before["embedding"], position=before["position"]), dict(feature=after["value"]))
    blocks = []
    for layer in (1, 2):
        block_prefix = prefix + f"_block{layer}"
        block_capture = _MechanismTrace()
        block_capture.steps = [frame for frame in captured.steps if frame[0].startswith(block_prefix + "_")]
        block_capture.native = [leaf for leaf in captured.native if leaf["id"].startswith(block_prefix + "_")]
        m = mechanism[f"block{layer}"]
        gains = {key: state[key + str(layer)] for key in _GAIN_FIELDS}
        blocks.append(_bind_block(m["input"], gains, m, block_capture, trace, block_prefix))
    block1, block2 = blocks
    head = _head_binding(mechanism, captures, [leaf for leaf in captured.native if leaf["id"].startswith(prefix + "_class_row_")], trace, prefix)
    natives = [*block1["natives"], *block2["natives"], *head["natives"]]
    indices = [winner["index"] for winner in mechanism["winners"]]
    ids = [winner["token"] for winner in mechanism["winners"]]
    selected = [winner["probability"] for winner in mechanism["winners"]]
    tensors = _evaluation_tensors(state, mechanism, block1, block2, head, natives, prefix, indices, ids, selected)
    texts = _evaluation_texts(natives)
    return _freeze(dict(state=state, features=mechanism["features"], block1=block1, block2=block2,
                        logits=mechanism["logits"], probabilities=mechanism["probabilities"], argmaxIndices=indices,
                        argmaxIds=ids, selectedProbabilities=selected, nextTokenId=ids[1], nextTokenProbability=selected[1],
                        natives=natives, tensors=tensors, texts=texts))


def _evaluation_tensors(state, m, block1, block2, head, natives, p, indices, ids, selected):
    return [
        _tensor(p + "_Raw", [16], ["RawField"], [state[key] for key in _FIELDS], "Captured raw16 in declared field order; token0/token1 cells are integer VALUE, all other cells binary64 WORD."),
        _tensor(p + "_TokenIds", [1, 2], ["B", "T"], [state["token0"], state["token1"]], "Both observed input token IDs; EOS is an ordinary explicit lookup row here.", "int32"),
        _tensor(p + "_VocabularyIds", [3], ["Vocab"], _IDS, "Class order and strict-tie ID order: a=97,b=98,EOS=512.", "int32"),
        _tensor(p + "_E", [3, 2], ["Vocab", "D"], [1.0, 0.0, 0.0, 1.0, 0.0, 0.0], "Authored embedding rows [1,0],[0,1],[0,0] for a,b,EOS."),
        _tensor(p + "_Positions", [1, 2, 2], ["B", "T", "D"], m["positions"], "Literal P0=[+0,+0], P1=[+0,positionScale]; disclosed absolute position addition."),
        _tensor(p + "_Embeddings", [1, 2, 2], ["B", "T", "D"], m["embedding"], "Actual E lookup copies before position addition."),
        _tensor(p + "_Features", [1, 2, 2], ["B", "T", "D"], m["features"], "Actual lookup plus position sums; first block input, retained on its residual skip."),
        *block1["tensors"], *block2["tensors"],
        _tensor(p + "_U", [2, 3], ["D", "Vocab"], m["U"], "Authored feature-last readout rows [1,0,0],[0,1,0]."),
        _tensor(p + "_Bias", [3], ["Vocab"], m["bias"], "Actual biasA,biasB,biasEOS words, added after both feature products."),
        _tensor(p + "_Readout", [1, 2, 3, 4], ["B", "T", "Vocab", "ReadoutField"], head["readout"], "Actual product0,product1,sum,logit per position and class."),
        _tensor(p + "_Logits", [1, 2, 3], ["B", "T", "Vocab"], m["logits"], "Actual final readout logits before stable class softmax."),
        _tensor(p + "_ClassMaxima", [1, 2], ["B", "T"], head["maxima"], "Actual selected maximum logit per observed position."),
        _tensor(p + "_ClassShifted", [1, 2, 3], ["B", "T", "Vocab"], head["shifted"], "Actual direct exp arguments, each saved once as logit minus row maximum."),
        _tensor(p + "_ClassTerms", [1, 2, 3], ["B", "T", "Vocab"], head["terms"], "Actual native exp outputs; no log native exists in this family."),
        _tensor(p + "_ClassDenominators", [1, 2], ["B", "T"], head["denominators"], "Final ordered +0 then term0,term1,term2 running sums."),
        _tensor(p + "_Probabilities", [1, 2, 3], ["B", "T", "Vocab"], m["probabilities"], "Actual term/final denominator probabilities at every observed position."),
        _tensor(p + "_ArgmaxIndices", [1, 2], ["B", "T"], indices, "Smallest class index on exact actual-logit ties.", "int32"),
        _tensor(p + "_ArgmaxIds", [1, 2], ["B", "T"], ids, "Actual selected token IDs in observed-position order.", "int32"),
        _tensor(p + "_SelectedProbabilities", [1, 2], ["B", "T"], selected, "Unchanged copies of the actual selected class probabilities."),
        *_native_tensors(p, natives),
    ]


def _evaluation_texts(natives):
    return dict(**_native_texts(natives), rawFields=list(_FIELDS), vocabularyLabels=["a", "b", "EOS"],
        gainFields=list(_GAIN_FIELDS), normStatisticFields=list(_STAT_FIELDS), readoutFields=["product0", "product1", "sum", "logit"],
        inputPolicy="Exact own-data raw16 on a plain/null-prototype object: all descriptors, then all actual finite numbers, then domains in raw order, then ASCII prefix. Tokens are integer members {97,98,512}; positionScale [0,1]; ten gains [-1,1]; three biases [-2,2]. No coercion, clamping, partial defaults or skipped inactive computation.",
        architecturePolicy="B1,T2,D2,H1,Dk2,Dv2. Look up both observed IDs, add absolute positions, compute two distinct pre-norm causal blocks on actual per-position features, then compute all three readout logits and class probabilities at both positions. Block2 consumes block1 output words, never token IDs or re-embedded values.",
        headPolicy="U rows [1,0,0],[0,1,0]; each logit uses two products, sum, bias last. Stable class softmax saves exp arguments/outputs, ordered +0 term sum and divisions. Greedy strict-greater scan over ascending IDs keeps the smallest token ID on exact logit ties. Only the last observed row supplies nextTokenId and nextTokenProbability; no token is appended.",
        nativePolicy="Both complete block-native ledgers precede output-head exp occurrences in token/class order. LN sqrt and attention sqrt(Dk) save actual outputs. Old attention shifted arguments repeat the identical immutable-operand subtraction used internally by stableSoftmax: functional word reconstruction, not a physical instruction trace. Output-head exp arguments are captured directly. No log, sin, cos or native call during serialization.",
        numericPolicy="Separate finite binary64 scalar operations retain primitive order without contraction or reassociation. Every numeric operand/result/copy uses WORD including admitted -0, except explicit token IDs, indices, dimensions, mask decisions, kind codes and counts use VALUE. Display precision8 is presentation only. Root Raw token cells are VALUE and its other fourteen cells are WORD.",
        nativeAdmissionPolicy="Declared future independent policy: positive finite sqrt outputs with argument [1/4,4096] and exp outputs with argument [-256,0], at most four ordered binary64 word steps from an independently isolated RN-even reference. Admit each complete TS/canonical record separately, then require exact scalar/copy words inside it. This is neither bit-exact libm parity nor validation evidence.",
        limitsPolicy="Authored forward-only toy with hand-set embeddings, gains, norms, FFN and readout. Two blocks are neither two generated tokens nor two optimizer steps. An observed EOS is an input embedding; generated-EOS stopping is not implemented. No loss, gradient, training, sampling, cache, latency, production intelligence or physical-trace claim. Runtime validation remains deferred under the FluxGeo hold.",
        provenance="Owner-chosen IV59 toy within the human full-book source authorization; these concrete model choices are not attributed to the human or the dossier. No external model or dataset.")


def _check_native_copies(natives, tensors, texts, frames, prefix):
    if not __debug__:
        raise RuntimeError("Explicit native-copy self-check refuses optimized Python (-O).")
    import struct

    def word(value):
        return struct.pack(">d", value)

    table = {record["id"]: record for record in tensors}
    arguments = table[prefix + "_NativeArguments"]["values"]
    kinds = table[prefix + "_NativeKinds"]["values"]
    assert texts["nativeFields"] == ["input", "output"]
    assert texts["nativeIds"] == [leaf["id"] for leaf in natives]
    assert texts["nativeKinds"] == [leaf["kind"] for leaf in natives]
    assert len(arguments) == 2 * len(natives) and len(kinds) == len(natives)
    for n, leaf in enumerate(natives):
        assert tuple(leaf) == ("id", "kind", "input", "output")
        assert word(arguments[2*n]) == word(leaf["input"])
        assert word(arguments[2*n+1]) == word(leaf["output"])
        assert kinds[n] == (0 if leaf["kind"] == "sqrt" else 1)
        identifier = leaf["id"]
        if leaf["kind"] == "sqrt" and "_attn_sqrt" not in identifier:
            statistics_id = identifier.removesuffix("_sqrt") + "_statistics"
            frame = frames[statistics_id]
            assert word(leaf["input"]) == word(frame["outputs"]["variancePlusEpsilon"])
            assert word(leaf["output"]) == word(frame["outputs"]["denominator"])
            norm_prefix, t = identifier.removesuffix("_sqrt").rsplit("_0_", 1)
            row = table[norm_prefix + "_Statistics"]["values"][10*int(t):10*int(t)+10]
            assert word(row[8]) == word(leaf["input"]) and word(row[9]) == word(leaf["output"])
            for d in range(2):
                copied = frames[f"{norm_prefix}_0_{t}_feature_{d}"]["inputs"]["denominator"]
                assert word(copied) == word(leaf["output"])
        elif leaf["kind"] == "sqrt":
            attention = identifier.removesuffix("_sqrt")
            assert leaf["input"] == 2.0
            for key, frame in frames.items():
                if key.startswith(attention + "_score_"):
                    assert word(frame["inputs"]["Dk"]) == word(leaf["input"])
                    assert word(frame["inputs"]["divisor"]) == word(leaf["output"])
        elif "_readout_exp_" in identifier:
            evaluation, coordinates = identifier.split("_readout_exp_")
            t, c = (int(index) for index in coordinates.split("_"))
            frame = frames[f"{evaluation}_classExp_{t}_{c}"]
            assert word(frame["outputs"]["shifted"]) == word(leaf["input"])
            assert word(frame["outputs"]["term"]) == word(leaf["output"])
            assert word(table[evaluation + "_ClassShifted"]["values"][3*t+c]) == word(leaf["input"])
            assert word(table[evaluation + "_ClassTerms"]["values"][3*t+c]) == word(leaf["output"])
            assert word(frames[f"{evaluation}_classSum_{t}_{c}"]["inputs"]["term"]) == word(leaf["output"])
            assert word(frames[f"{evaluation}_classProbability_{t}_{c}"]["inputs"]["term"]) == word(leaf["output"])
        else:
            attention, coordinates = identifier.split("_exp_0_0_")
            i, j = (int(index) for index in coordinates.split("_"))
            frame = frames[f"{attention}_row_0_0_{i}"]
            assert frame["inputs"][f"allowed{j}"] == 1
            assert word(frame["outputs"][f"shifted{j}"]) == word(leaf["input"])
            assert word(frame["outputs"][f"term{j}"]) == word(leaf["output"])


def check_public():
    """Explicit complete helper/native/copy checks; not an independent oracle."""
    if not __debug__:
        raise RuntimeError("Explicit public-helper self-check refuses optimized Python (-O).")
    import struct

    def words(values):
        return [struct.pack(">d", value) for value in values]

    ordered = decoder_trace()
    operands = {"2": -0.0, "1": 1.0, "01": 2.0, "4294967295": 3.0, "4294967294": 4.0}
    ordered.add("order", "", "", "", operands, operands)
    expected_keys = ["1", "2", "4294967294", "01", "4294967295"]
    assert list(ordered.steps[0]["inputs"]) == list(ordered.steps[0]["outputs"]) == expected_keys
    assert list(ordered.outputs) == ["order_" + key for key in expected_keys]
    assert words([ordered.steps[0]["inputs"]["2"]]) == words([-0.0])
    reused = decoder_trace()
    reused.add("frozen", "", "", "", ordered.steps[0]["inputs"], ordered.steps[0]["outputs"])
    assert list(reused.steps[0]["inputs"]) == expected_keys
    assert words(reused.steps[0]["inputs"].values()) == words(ordered.steps[0]["inputs"].values())
    proto = decoder_trace()
    proto.add("__proto", "", "", "", {}, {"_": 1.0})
    assert proto.outputs == {} and proto.steps[0]["outputs"] == {"_": 1.0}
    proto.add("ordinary", "", "", "", {}, {"__proto__": 2.0})
    assert proto.outputs == {"ordinary___proto__": 2.0}
    large = decoder_trace()
    large.add("large", "", "", "", {"x": 2**53 + 1, "y": 10**300}, {"z": -0.0})
    assert words(large.steps[0]["inputs"].values()) == words([9007199254740992.0, 1e300])
    for huge in (10**400, -(10**400)):
        for side in ("inputs", "outputs"):
            try:
                large.add("bad", "", "", "", {"x": huge} if side == "inputs" else {}, {"x": huge} if side == "outputs" else {})
            except NumericalFault as error:
                assert error.code == "NONFINITE" and str(error) == "bad." + side + ".x must be an actual finite number."
            else:
                raise AssertionError("Huge trace integer must fail before conversion.")
    assert len(large.steps) == 1

    gains = dict(q=-0.0, k=0.5, v=-1.0, o=0.0, f=0.0)
    for T, frame_count, alias_count, native_count in ((1, 42, 127, 4), (2, 82, 266, 8), (3, 124, 426, 13)):
        features = [16.0, -16.0] * T
        trace = decoder_trace()
        block = decoder_block(features, gains, trace, "bounded")
        assert tuple(block) == ("features", "gains", "output", "natives", "tensors", "texts")
        assert len(trace.steps) == frame_count and len(trace.outputs) == alias_count
        assert len(block["tensors"]) == 47 and len(block["natives"]) == native_count
        assert len(block["texts"]) == 10 and tuple(block["gains"]) == _GAIN_FIELDS
        assert block["output"]["id"] == "bounded_Output"
        assert block["output"] == block["tensors"][44]
        assert words(block["output"]["values"]) == words(features)
        assert words(block["features"]) == words(features)
        features[0] = 3.0
        assert block["features"][0] == 16.0
        table = {record["id"]: record for record in block["tensors"]}
        frames = {frame["id"]: frame for frame in trace.steps}
        assert len(table) == 47 and len(frames) == frame_count
        assert tuple(block["texts"]) == ("nativeIds", "nativeKinds", "nativeFields", "gainFields", "normStatisticFields",
                                         "featurePolicy", "kernelPolicy", "nativePolicy", "zeroPolicy", "limitsPolicy")
        for record in block["tensors"]:
            assert tuple(record) == ("id", "shape", "axes", "dtype", "values", "provenance", "precision")
            assert len(record["shape"]) == len(record["axes"])
            assert record["precision"] == (0 if record["dtype"] == "int32" else 8)
        mask = table["bounded_attn_allowed"]
        assert mask["dtype"] == "bool" and mask["precision"] == 8
        assert mask["values"] == [j <= i for i in range(T) for j in range(T)]
        assert all(type(value) is bool for value in mask["values"])
        assert words(table["bounded_attn_WQ"]["values"]) == words([-0.0, 0.0, 0.0, -0.0])
        for stage in (1, 2):
            p = f"bounded_n{stage}"
            for t in range(T):
                statistics = frames[f"{p}_0_{t}_statistics"]["outputs"]
                assert words(table[p + "_Statistics"]["values"][10*t:10*t+10]) == words(statistics.values())
                for d in range(2):
                    frame = frames[f"{p}_0_{t}_feature_{d}"]
                    assert words([frame["inputs"]["source"]]) == words([table[p + "_Centered"]["values"][2*t+d]])
                    assert words([frame["outputs"]["normalized"]]) == words([table[p + "_Normalized"]["values"][2*t+d]])
                    assert words([frame["outputs"]["value"]]) == words([table[p + "_Output"]["values"][2*t+d]])
        for i in range(T):
            row = frames[f"bounded_attn_row_0_0_{i}"]["outputs"]
            for j in range(T):
                probability = table["bounded_attn_probabilities"]["values"][i*T+j]
                assert words([probability]) == words([row[f"p{j}"]])
                if j > i:
                    assert f"shifted{j}" not in row
                    assert words([probability, row[f"term{j}"]]) == words([0.0, 0.0])
            for d in range(2):
                mixed = frames[f"bounded_attn_head_mix_0_0_{i}_{d}"]["outputs"]["value"]
                assert words([mixed]) == words([table["bounded_attn_OHeads"]["values"][2*i+d]])
                assert words([mixed]) == words([table["bounded_attn_C"]["values"][2*i+d]])
                for suffix, source in (("r1", "R1"), ("r2", "Output")):
                    assert words([frames[f"bounded_{suffix}_0_{i}_{d}"]["outputs"]["value"]]) == words([table["bounded_" + source]["values"][2*i+d]])
            for hidden in range(3):
                index = 3*i+hidden
                assert words([frames[f"bounded_ffn_hidden_0_{i}_{hidden}"]["outputs"]["preactivation"]]) == words([table["bounded_ffn_Z"]["values"][index]])
                assert words([frames[f"bounded_ffn_relu_0_{i}_{hidden}"]["outputs"]["activation"]]) == words([table["bounded_ffn_Hidden"]["values"][index]])
        for frame in trace.steps:
            assert tuple(frame) == ("id", "label", "equation", "explanation", "inputs", "outputs")
            for key, value in frame["outputs"].items():
                assert words([value]) == words([trace.outputs[frame["id"] + "_" + key]])
        _check_native_copies(block["natives"], block["tensors"], block["texts"], frames, "bounded")
        try:
            block["output"]["values"][0] = 0.0
        except TypeError:
            pass
        else:
            raise AssertionError("Saved tensor must be immutable.")

    trace = decoder_trace()
    evaluated = evaluate_decoder(DEFAULT_IV59, trace, "observed")
    assert tuple(evaluated) == ("state", "features", "block1", "block2", "logits", "probabilities", "argmaxIndices", "argmaxIds",
                                "selectedProbabilities", "nextTokenId", "nextTokenProbability", "natives", "tensors", "texts")
    assert len(trace.steps) == 196 and len(trace.outputs) == 592
    assert len(evaluated["tensors"]) == 115 and len(evaluated["texts"]) == 16
    assert sum(len(record["values"]) for record in evaluated["tensors"]) == 640
    assert words(evaluated["block2"]["features"]) == words(evaluated["block1"]["output"]["values"])
    assert evaluated["argmaxIds"] == [97, 97]
    assert evaluated["nextTokenId"] == evaluated["argmaxIds"][1]
    assert words([evaluated["nextTokenProbability"]]) == words([evaluated["selectedProbabilities"][1]])
    frames = {frame["id"]: frame for frame in trace.steps}
    _check_native_copies(evaluated["natives"], evaluated["tensors"], evaluated["texts"], frames, "observed")
    assert [frame["id"] for frame in trace.steps if "_readout_" in frame["id"]] == [f"observed_readout_{t}_{c}" for t in range(2) for c in range(3)]
    assert next(i for i, frame in enumerate(trace.steps) if "_classMax_" in frame["id"]) > next(i for i, frame in enumerate(trace.steps) if frame["id"] == "observed_readout_1_2")

    # A fabricated logit row isolates strict-FIRST head max, even if unreachable by a particular preset.
    for first, second in ((-0.0, 0.0), (0.0, -0.0)):
        capture = _MechanismTrace()
        _softmax([first, second, -1.0], [True]*3, capture, "head", positive_zero=False)
        assert words([capture.steps[0][2]["max"]]) == words([first])
    # Serialization must consume captures even when native evaluation is disabled.
    source = [1.0, 0.0, 1.0, 0.5]
    capture = _MechanismTrace()
    mechanism = _decoder_block_mechanics(source, gains, capture, "serialized")
    saved_sqrt, saved_exp = math.sqrt, math.exp
    def forbidden(argument):
        raise AssertionError("Native evaluation during serialization.")
    try:
        math.sqrt = math.exp = forbidden
        projected = _bind_block(source, gains, mechanism, capture, decoder_trace(), "serialized")
        assert len(projected["tensors"]) == 47
    finally:
        math.sqrt, math.exp = saved_sqrt, saved_exp

Chapter result and CLI: iv59.py

Read the complete executable Python / NumPy source

This is the actual reference file, imported directly from the repository. Comments explain each operation. It is provided for later execution; no validation run is claimed.

"""IV59 adopted full-root canonical entrypoint; all checks UNRUN.

No implicit checks. Project closure: this file + adjacent decoder_reference.py.
"""
import importlib.util
import json
import math
from pathlib import Path
import sys

_spec = importlib.util.spec_from_file_location(
    "_p15_iv59_decoder_reference", Path(__file__).resolve().with_name("decoder_reference.py"))
if _spec is None or _spec.loader is None:
    raise ImportError("Cannot load adjacent decoder_reference.py")
_reference = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(_reference)

DEFAULT_IV59 = _reference.DEFAULT_IV59
NumericalFault = _reference.NumericalFault
decoder_state = _reference.decoder_state
decoder_trace = _reference.decoder_trace
decoder_block = _reference.decoder_block
evaluate_decoder = _reference.evaluate_decoder


def derive_iv59(value):
    try:
        state = decoder_state(value)
        trace = decoder_trace()
        trace.add("setup", "Capture the complete two-block decoder toy",
                  "X0=E[observedIds]+P; Y1=block1(X0); Y2=block2(Y1); logits=Y2*U+bias; probabilities=stableClassSoftmax(logits)",
                  "Sixteen actual finite inputs are captured before domains. Both observed positions traverse both pre-norm blocks, every width-three FFN coordinate and the same three-class readout. These owner-authored parameters are hand-set; no training or generation step is hidden.",
                  dict(state), dict(state, B=1, T=2, D=2, H=1, Dk=2, Dv=2, M=3, Vocab=3, blockCount=2, rawInputCount=16))
        evaluated = evaluate_decoder(state, trace, "decoder")
        summary = dict(nextTokenId=evaluated["nextTokenId"], nextTokenProbability=evaluated["nextTokenProbability"],
                       blockCount=2, observedPositions=2, featureWidth=2, hiddenWidth=3, vocabularySize=3,
                       sqrtCalls=sum(leaf["kind"] == "sqrt" for leaf in evaluated["natives"]),
                       expCalls=sum(leaf["kind"] == "exp" for leaf in evaluated["natives"]),
                       nativeElementaryCalls=len(evaluated["natives"]), frames=len(trace.steps)+1, tensorCount=len(evaluated["tensors"]))
        trace.add("finish", "Recommend from the last observed position",
                  "nextTokenId=argmaxIds[1]; nextTokenProbability=selectedProbabilities[1]",
                  "Copy the selected ID and probability from position one, after both actual blocks. Position zero remains inspectable. Counts describe the declared source graph; they measure neither hardware work nor training, and no token is appended.",
                  dict(lastPosition=1, index=evaluated["argmaxIndices"][1], tokenId=evaluated["argmaxIds"][1], probability=evaluated["selectedProbabilities"][1]), summary)
        texts = dict(evaluated["texts"],
            graphStages=["Observed token IDs", "Embedding lookup", "Absolute position addition", "Pre-norm causal block 1", "Pre-norm causal block 2", "Three-class readout", "Stable class probabilities", "Last-row greedy recommendation"],
            graphTensorIds=["decoder_TokenIds", "decoder_Embeddings", "decoder_Features", "decoder_block1_Output", "decoder_block2_Output", "decoder_Logits", "decoder_Probabilities", "decoder_ArgmaxIds"],
            block1NativeIds=evaluated["block1"]["texts"]["nativeIds"], block1NativeKinds=evaluated["block1"]["texts"]["nativeKinds"],
            block2NativeIds=evaluated["block2"]["texts"]["nativeIds"], block2NativeKinds=evaluated["block2"]["texts"]["nativeKinds"],
            tracePolicy="Every actual primitive frame is retained with prefixed block IDs and unchanged kernel label, equation, explanation and operand-key order. The local factory captures finite inputs/outputs once, checks nonempty unique IDs before operands and the 512 cap after operands, then freezes detached frames. Every frame output appears as frameId_key in root outputs; no alias recomputes arithmetic.",
            summaryPolicy="nextTokenId is the last observed row selected token ID (VALUE); nextTokenProbability is its unchanged actual probability word. All other primary summaries are integer VALUE source counts. Root nativeIds/nativeKinds bind decoder_NativeArguments input/output rows and decoder_NativeKinds codes; block native tensors/texts bind the identical occurrences again.",
            validationPolicy="SOURCE IMPLEMENTATION ONLY. All tests, independent executable authority, canonical parity, typecheck, build, browser, accessibility and offline checks are UNRUN under the human FluxGeo hold. Source adoption and validation belong to the owner; this record is not runtime acceptance.")
        outputs = dict(summary)
        for step in trace.steps:
            for key, entry in step["outputs"].items():
                alias = step["id"] + "_" + key
                if alias in outputs:
                    raise RuntimeError("IV59 output aliases must be unique.")
                outputs[alias] = entry
        return _reference._freeze(dict(status="defined", outputs=outputs, steps=trace.steps, tensors=evaluated["tensors"], texts=texts))
    except NumericalFault as fault:
        return _reference._freeze(dict(status="unavailable", code=fault.code, reason=fault.reason))


class _ParseFault(ValueError):
    pass


def _pairs(pairs):
    result = {}
    for key, value in pairs:
        if key in result:
            raise _ParseFault("Duplicate JSON field: " + key)
        result[key] = value
    return result


def _constant(value):
    raise _ParseFault("Nonfinite JSON constant: " + value)


def _integer(source):
    if source == "-0":
        return -0.0
    # Raw16 cannot admit an integer this large; avoid interpreter digit limits.
    if len(source.lstrip("-")) > 309:
        raise _ParseFault("JSON integer exceeds the bounded numeric domain.")
    return int(source)


def _number(source):
    value = float(source)
    if not math.isfinite(value):
        raise _ParseFault("JSON number must be finite.")
    return value


def strict_json(source):
    try:
        return json.loads(source, object_pairs_hook=_pairs, parse_constant=_constant,
                          parse_int=_integer, parse_float=_number)
    except json.JSONDecodeError as fault:
        raise _ParseFault(str(fault)) from fault


def source_self_check():
    if not __debug__:
        raise RuntimeError("Explicit IV59 self-check refuses optimized Python (-O).")
    _reference.check_mechanism()
    _reference.check_public()
    check_root()
    check_boundaries()
    check_cli()


def run():
    """Zero Python arguments; process argv selects default/JSON/stdin/check."""
    args = sys.argv[1:]
    if args == ["--self-check"]:
        source_self_check()
        print("IV59 canonical explicit self-checks completed; independent owner admission is separate.")
        return 0
    if len(args) > 1 or (args and args[0].startswith("--")):
        print("Usage: iv59.py [JSON|-|--self-check]", file=sys.stderr)
        return 2
    if not args:
        value = dict(DEFAULT_IV59)
    else:
        source = sys.stdin.read() if args[0] == "-" else args[0]
        try:
            value = strict_json(source)
        except _ParseFault as fault:
            print(json.dumps(dict(status="unavailable", code="INVALID_INPUT", reason=str(fault)), allow_nan=False))
            return 0
    print(json.dumps(derive_iv59(value), allow_nan=False))
    return 0


# Explicit check definitions follow; ordinary imports/queries never call them.


def check_boundaries():
    if not __debug__:
        raise RuntimeError("Explicit boundary self-check refuses optimized Python (-O).")
    import struct

    def fault(operation, code, *args):
        try:
            operation(*args)
        except NumericalFault as caught:
            assert caught.code == code
        else:
            raise AssertionError("Expected " + code)

    default = dict(DEFAULT_IV59)
    for value in (None, [], True, {}, dict(default, extra=1),
                  dict(default, token1=97.5), dict(default, token0=0),
                  dict(default, positionScale=-0.5), dict(default, q1=2),
                  dict(default, biasA=3), dict(default, q2=10**400)):
        fault(decoder_state, "INVALID_INPUT", value)
    for value in (dict(default, token0=True), dict(default, token1="97"),
                  dict(default, q1=float("nan")), dict(default, biasEOS=float("inf"))):
        fault(decoder_state, "NONFINITE", value)
    for value, code, reason in (
        (dict(default, token0=0, biasEOS=float("inf")), "NONFINITE", "state.biasEOS must be an actual finite number."),
        (dict(default, q1=2, biasA="0"), "NONFINITE", "state.biasA must be an actual finite number."),
        (dict(default, q1=10**400), "INVALID_INPUT", "q1 must be between -1 and 1.")):
        result = derive_iv59(value)
        assert tuple(result) == ("status", "code", "reason")
        assert result == dict(status="unavailable", code=code, reason=reason)
    class Record(dict):
        def __getitem__(self, key):
            raise AssertionError("Custom access must not run.")
    fault(decoder_state, "INVALID_INPUT", Record(default))
    state = decoder_state(dict(default, q1=-0.0, biasA=-0.0))
    assert struct.pack(">d", state["q1"]) == struct.pack(">d", -0.0)
    assert struct.pack(">d", state["biasA"]) == struct.pack(">d", -0.0)
    gains = dict(q=1, k=1, v=1, o=1, f=1)
    for features in ([], [1], [1, 2, 3], [1]*8, (1, 2)):
        fault(decoder_block, "INVALID_INPUT", features, gains, decoder_trace(), "block")
    for features in ([17, 0], [10**400, 0]):
        fault(decoder_block, "INVALID_INPUT", features, gains, decoder_trace(), "block")
    for bad in ({}, dict(gains, k=2), dict(gains, extra=0)):
        fault(decoder_block, "INVALID_INPUT", [1, 0], bad, decoder_trace(), "block")
    for features in ([True, 0], [float("nan"), 0], [0, float("inf")]):
        fault(decoder_block, "NONFINITE", features, gains, decoder_trace(), "block")
    for bad in (dict(gains, q=True), dict(gains, f=float("inf"))):
        fault(decoder_block, "NONFINITE", [1, 0], bad, decoder_trace(), "block")
    # Exact built-ins reject Python accessor analogues without evaluating them.
    class FeatureList(list):
        def __iter__(self):
            raise AssertionError("Custom list access must not run.")
    class Accessors:
        @property
        def token0(self):
            raise AssertionError("Descriptor must not run.")
    fault(decoder_state, "INVALID_INPUT", Accessors())
    fault(decoder_block, "INVALID_INPUT", FeatureList([1, 0]), gains, decoder_trace(), "block")
    fault(decoder_block, "INVALID_INPUT", [17, 0], Accessors(), decoder_trace(), "bad-prefix")
    fault(decoder_block, "NONFINITE", [0, float("inf")], Accessors(), decoder_trace(), "bad-prefix")
    fault(decoder_block, "NONFINITE", [1, 0], dict(gains, q=2, f=False), decoder_trace(), "bad-prefix")
    fault(decoder_block, "INVALID_INPUT", [1, 0], dict(gains, q=2), decoder_trace(), "bad-prefix")
    for prefix in ("", "1block", "é", "a-b", "a\n", None):
        fault(decoder_block, "INVALID_INPUT", [1, 0], gains, decoder_trace(), prefix)
        fault(evaluate_decoder, "INVALID_INPUT", default, decoder_trace(), prefix)
    assert tuple(decoder_block([1, 0], gains, decoder_trace(), "block")) == ("features", "gains", "output", "natives", "tensors", "texts")
    assert derive_iv59(default)["status"] == "defined"
    assert derive_iv59({})["code"] == "INVALID_INPUT"
    trace = decoder_trace()
    trace.add("same", "label", "equation", "explanation", dict(x=1.0), dict(y=2.0))
    fault(trace.add, "INVALID_INPUT", "same", "label", "equation", "explanation", dict(x=1.0), dict(y=2.0))
    for i in range(511):
        trace.add("frame" + str(i), "label", "equation", "explanation", dict(x=1.0), dict(y=2.0))
    fault(trace.add, "UNSUPPORTED_SIZE", "full", "label", "equation", "explanation", dict(x=1.0), dict(y=2.0))
    assert len(trace.steps) == 512
    # Trusted observer getters are captured once; duplicate-ID and full-cap precedence differ.
    marker = RuntimeError("observer sentinel")
    class Observed:
        def __init__(self):
            self.reads = 0
        def items(self):
            self.reads += 1
            return [("x", -0.0)]
    class Throwing:
        def items(self):
            raise marker
    observed = Observed()
    fresh = decoder_trace()
    fresh.add("once", "label", "equation", "explanation", observed, dict(y=1.0))
    assert observed.reads == 1
    assert struct.pack(">d", fresh.steps[0]["inputs"]["x"]) == struct.pack(">d", -0.0)
    fault(fresh.add, "INVALID_INPUT", "once", "label", "equation", "explanation", Throwing(), {})
    fault(trace.add, "NONFINITE", "fullFinite", "label", "equation", "explanation", dict(x=float("nan")), {})
    for observer in (fresh, trace):
        try:
            observer.add("explode", "label", "equation", "explanation", Throwing(), {})
        except RuntimeError as caught:
            assert caught is marker
        else:
            raise AssertionError("Observer error must escape before capacity.")
    for value in (10**400, -(10**400)):
        fault(fresh.add, "NONFINITE", "hugeInput", "label", "equation", "explanation", dict(x=value), {})
        fault(fresh.add, "NONFINITE", "hugeOutput", "label", "equation", "explanation", {}, dict(y=value))
        fault(trace.add, "NONFINITE", "hugeBeforeCap", "label", "equation", "explanation", dict(x=value), {})
    fresh.add("finiteInteger", "label", "equation", "explanation", dict(x=10**300, z=-0.0), dict(y=-(10**300), count=2))
    assert type(fresh.steps[-1]["inputs"]["x"]) is float
    assert math.isfinite(fresh.steps[-1]["inputs"]["x"])
    assert fresh.steps[-1]["outputs"]["count"] == 2
    assert struct.pack(">d", fresh.steps[-1]["inputs"]["z"]) == struct.pack(">d", -0.0)
    try:
        fresh.steps = []
    except TypeError:
        pass
    else:
        raise AssertionError("Observer container must be immutable.")
    saved = globals()["evaluate_decoder"]
    try:
        for marker in (MemoryError("resource"), RuntimeError("unknown"), TypeError("programmer")):
            def explode(value, trace, prefix):
                raise marker
            globals()["evaluate_decoder"] = explode
            try:
                derive_iv59(default)
            except BaseException as caught:
                assert caught is marker
            else:
                raise AssertionError("Unknown failure must escape identity.")
    finally:
        globals()["evaluate_decoder"] = saved


def check_cli():
    if not __debug__:
        raise RuntimeError("Explicit CLI self-check refuses optimized Python (-O).")
    import contextlib
    import io

    import struct
    for literal in ("-0", "-0.0"):
        parsed = strict_json(literal)
        assert type(parsed) is float and struct.pack(">d", parsed) == struct.pack(">d", -0.0)
    parsed = strict_json('{"q1":-0}')
    assert struct.pack(">d", parsed["q1"]) == struct.pack(">d", -0.0)
    for literal in ("1e999", "-1e999", "NaN", "Infinity", "-Infinity", "{", '{"x":{"a":1,"a":2}}', "9"*5000):
        try:
            strict_json(literal)
        except _ParseFault:
            pass
        else:
            raise AssertionError("Expected actual known parse carrier.")

    saved_argv, saved_stdin = sys.argv, sys.stdin
    saved_check, saved_parser, saved_derive = source_self_check, strict_json, derive_iv59

    def invoke(args, stdin=""):
        sys.argv, sys.stdin = ["iv59.py", *args], io.StringIO(stdin)
        output, error = io.StringIO(), io.StringIO()
        with contextlib.redirect_stdout(output), contextlib.redirect_stderr(error):
            code = run()
        return code, output.getvalue(), error.getvalue()

    def forbidden():
        raise AssertionError("Ordinary query ran a check.")

    try:
        globals()["source_self_check"] = forbidden
        for args, stdin in (([], ""), ([json.dumps(dict(DEFAULT_IV59))], ""),
                            (["-"], json.dumps(dict(DEFAULT_IV59)))):
            code, output, error = invoke(args, stdin)
            assert code == 0 and not error
            assert json.loads(output)["status"] == "defined"
        for source in ("{", "{}", "null", "true", '{"token0":97,"token0":98}',
                       '{"q1":NaN}', '{"q1":Infinity}', '{"q1":1e999}', "9"*5000):
            code, output, error = invoke([source])
            assert code == 0 and not error and json.loads(output)["code"] == "INVALID_INPUT"
        for args in (["--unknown"], ["{}", "{}"], ["--self-check", "{}"]):
            code, output, error = invoke(args)
            assert code == 2 and not output and "Usage:" in error
        received = []
        def query(value):
            received.append(value)
            return dict(status="unavailable", code="SENTINEL", reason="test capture")
        globals()["derive_iv59"] = query
        code, output, error = invoke(["{}"])
        assert code == 0 and not error and received == [{}]
        # The explicit check branch must propagate failures, outside parse catch.
        marker = RuntimeError("explicit check sentinel")
        def failed_check():
            raise marker
        globals()["source_self_check"] = failed_check
        try:
            invoke(["--self-check"])
        except RuntimeError as caught:
            assert caught is marker
        else:
            raise AssertionError("Explicit check error was swallowed.")
        for marker in (MemoryError("parse resource"), RuntimeError("parse unknown"),
                       ValueError("parse unknown value"), json.JSONDecodeError("injected outside actual parser", "", 0)):
            def failed_parser(source):
                raise marker
            globals()["strict_json"] = failed_parser
            try:
                invoke(["{}"])
            except BaseException as caught:
                assert caught is marker
            else:
                raise AssertionError("Unknown parser failure was swallowed.")
    finally:
        sys.argv, sys.stdin = saved_argv, saved_stdin
        globals()["source_self_check"], globals()["strict_json"], globals()["derive_iv59"] = saved_check, saved_parser, saved_derive



def check_root():
    """Explicit whole-root shape/alias/native/selection checks; UNRUN source."""
    if not __debug__:
        raise RuntimeError("Explicit root self-check refuses optimized Python (-O).")
    import struct

    def words(values):
        return [struct.pack(">d", value) for value in values]

    default = dict(DEFAULT_IV59)
    for state in (default, dict(default, o1=0.0, f1=0.0, o2=0.0, f2=0.0),
                  dict(default, token0=512, token1=98, positionScale=-0.0, q1=-0.0, biasEOS=-0.0)):
        root = derive_iv59(state)
        assert tuple(root) == ("status", "outputs", "steps", "tensors", "texts")
        assert root["status"] == "defined"
        assert (len(root["steps"]), len(root["tensors"]), len(root["outputs"]), len(root["texts"])) == (198, 115, 642, 25)
        assert sum(len(record["values"]) for record in root["tensors"]) == 640
        summary_keys = ("nextTokenId", "nextTokenProbability", "blockCount", "observedPositions", "featureWidth", "hiddenWidth", "vocabularySize",
                        "sqrtCalls", "expCalls", "nativeElementaryCalls", "frames", "tensorCount")
        assert tuple(root["outputs"])[:12] == summary_keys
        assert list(root["outputs"].values())[2:12] == [2, 2, 2, 3, 3, 10, 12, 22, 198, 115]
        frames = {frame["id"]: frame for frame in root["steps"]}
        table = {record["id"]: record for record in root["tensors"]}
        expected_aliases = []
        for frame in root["steps"]:
            assert tuple(frame) == ("id", "label", "equation", "explanation", "inputs", "outputs")
            for key, value in frame["outputs"].items():
                alias = frame["id"] + "_" + key
                expected_aliases.append(alias)
                assert words([value]) == words([root["outputs"][alias]])
        assert tuple(root["outputs"])[12:] == tuple(expected_aliases)
        assert tuple(frames["setup"]["inputs"]) == tuple(DEFAULT_IV59)
        assert tuple(frames["setup"]["outputs"]) == tuple(DEFAULT_IV59) + ("B", "T", "D", "H", "Dk", "Dv", "M", "Vocab", "blockCount", "rawInputCount")
        assert tuple(frames["finish"]["outputs"]) == summary_keys
        assert tuple(root["texts"])[16:] == ("graphStages", "graphTensorIds", "block1NativeIds", "block1NativeKinds", "block2NativeIds", "block2NativeKinds", "tracePolicy", "summaryPolicy", "validationPolicy")
        assert words(table["decoder_Raw"]["values"][2:]) == words([state[key] for key in tuple(DEFAULT_IV59)[2:]])
        assert table["decoder_Raw"]["values"][:2] == [state["token0"], state["token1"]]
        assert words(table["decoder_block2_Features"]["values"]) == words(table["decoder_block1_Output"]["values"])
        for t in range(2):
            for c in range(3):
                readout = frames[f"decoder_readout_{t}_{c}"]["outputs"]
                assert words(table["decoder_Readout"]["values"][4*(3*t+c):4*(3*t+c)+4]) == words(readout.values())
                assert words([table["decoder_Logits"]["values"][3*t+c]]) == words([readout["logit"]])
                assert words([table["decoder_Probabilities"]["values"][3*t+c]]) == words([frames[f"decoder_classProbability_{t}_{c}"]["outputs"]["probability"]])
            selected = frames[f"decoder_argmax_{t}"]["outputs"]
            assert selected["index"] == table["decoder_ArgmaxIndices"]["values"][t]
            assert selected["tokenId"] == table["decoder_ArgmaxIds"]["values"][t]
            assert words([selected["probability"]]) == words([table["decoder_SelectedProbabilities"]["values"][t]])
            assert words([selected["probability"]]) == words([table["decoder_Probabilities"]["values"][3*t+selected["index"]]])
        assert root["outputs"]["nextTokenId"] == frames["finish"]["inputs"]["tokenId"] == table["decoder_ArgmaxIds"]["values"][1]
        assert words([root["outputs"]["nextTokenProbability"]]) == words([frames["finish"]["inputs"]["probability"]]) == words([table["decoder_SelectedProbabilities"]["values"][1]])
        arguments = table["decoder_NativeArguments"]["values"]
        natives = [dict(id=identifier, kind=kind, input=arguments[2*i], output=arguments[2*i+1])
                   for i, (identifier, kind) in enumerate(zip(root["texts"]["nativeIds"], root["texts"]["nativeKinds"]))]
        _reference._check_native_copies(natives, root["tensors"], root["texts"], frames, "decoder")
        for layer, start in ((1, 0), (2, 8)):
            p = f"decoder_block{layer}"
            assert root["texts"][f"block{layer}NativeIds"] == root["texts"]["nativeIds"][start:start+8]
            assert root["texts"][f"block{layer}NativeKinds"] == root["texts"]["nativeKinds"][start:start+8]
            assert words(table[p + "_NativeArguments"]["values"]) == words(arguments[2*start:2*(start+8)])
        # JSON projection must retain -0 words and ordered fields, without native calls.
        decoded = strict_json(json.dumps(root, allow_nan=False))
        assert tuple(decoded) == tuple(root)
        assert words(decoded["tensors"][0]["values"][2:]) == words(root["tensors"][0]["values"][2:])
    # Different native backends need independent whole-record admission later.
    saved = _reference.check_mechanism, _reference.check_public, globals()["check_root"], globals()["check_boundaries"], globals()["check_cli"]
    def forbidden():
        raise AssertionError("Ordinary query ran an explicit check.")
    try:
        _reference.check_mechanism = _reference.check_public = forbidden
        globals()["check_root"] = globals()["check_boundaries"] = globals()["check_cli"] = forbidden
        assert derive_iv59(DEFAULT_IV59)["status"] == "defined"
    finally:
        _reference.check_mechanism, _reference.check_public, globals()["check_root"], globals()["check_boundaries"], globals()["check_cli"] = saved


if __name__ == "__main__":
    raise SystemExit(run())

Why the saved values need independent checking

For this fixed two-position graph, the source inventory declares 115 tensors containing 640 saved cells, 198 operation frames and 22 native occurrences: ten square roots and twelve exponentials. Each block contributes first-norm square roots, one attention sqrt(2), only the allowed-key exponentials and second-norm square roots; six readout exponentials follow the two blocks. These are counts of the declared graph and saved evidence, not measured hardware work or speed.

The attention ledger reconstructs an exponential argument by repeating the same subtraction of immutable logit and maximum words used inside the older softmax primitive. Its output is the primitive’s saved term. The readout instead captures the argument directly at its exp call. Neither record is a physical processor trace, and serializing either record evaluates no new square root or exponential. Attention’s maximum prefers +0 on a tied signed zero; the readout’s strict-greater maximum scan retains the first maximum’s word. That distinction can matter even when the printed mathematical values compare equal.

The independent strategy separates the paper identities from binary64 checking. A square-root reference brackets the exact input’s root using integer square roots and rational endpoints; an exponential reference uses high-precision decimal neighboring bounds. Both must isolate a round-to-nearest, ties-to-even binary64 word or report an inconclusive reference. The declared leaf policy admits a positive finite native result within four ordered binary64 word steps of that reference, with square-root arguments in [1/4,4096] and exponential arguments in [-256,0]. After admitting each actual TypeScript or Python record’s own leaves, the authority must check every scalar operation and every saved copy exactly, including signed zero. This policy is not a claim that different native libraries return identical words.

What changes, what stays causal, and what this toy cannot show

Changing token1 changes its lookup row, its positioned features and the last row’s calculation. It cannot affect row0 through causal attention: row0 never mixes key1, and feature normalization/FFNs operate separately on positions. The future score is still computed, but multiplying a forbidden value into an allowed mixture is not permitted. Changing token0 can affect both positions because both may attend to key0.

Changing positionScale changes only the added second-position feature initially; the blocks then process that actual difference. At scale0, equal IDs start from equal rows, but that does not make re-embedding between blocks a valid implementation in general. Changing q or k changes scores; changing v changes mixed values; changing o changes the attention contribution to the residual; changing f changes the FFN contribution. Changing a head bias changes logits after both blocks and cannot change the earlier features. These are different places in the graph, not interchangeable ways to “make attention stronger.”

This forward-only lesson introduces no loss, parameter update, training curve, sampling, cache or finite-difference claim. Its one head does not demonstrate grouped-query attention. Its hand-set scores do not establish language ability or explanation quality. Stable softmax prevents avoidable exponential overflow by shifting at the actual maximum; it does not turn rounded display numbers into exact arithmetic. The symbolic worksheet explains real arithmetic; its equalities do not promise identical computer bits when square roots or exponentials are evaluated by different numerical libraries.

Keep the route in mind

  • IDs gather embeddings once; position is added once, using this toy’s absolute table.
  • Two blocks transform per-position features, and block two consumes the actual Y1 rows.
  • Each block computes both normalizations, causal attention, all three FFN coordinates and both residuals, including at zero output gains.
  • The head scores every class at every observed row; the last row recommends one next ID from actual logits with an explicit tie rule.

Next, encoder and cross-attention variants will change which source supplies queries, keys and values, and which positions are allowed. That requires a new origin-and-mask explanation; renaming this causal self-attention diagram would not supply it.