Inside the teacher: how the network of width 1536 is built

Listen to this post20 min

Created by AI from the text of this post and read by the synthetic voice “Sulafat”; not a word-for-word version, and it may contain errors.

The teacher T1536w-K64-v1 is an evaluation network of width 1536. What it achieves in play was covered in the post “The networks of Coherent: main network, teacher and cascade”. This post is about its inside: which parts it consists of, how the threat features are formed, how a position becomes a value and how the engine computes this during the search. Every number comes from the network file, the integer reference, the trainer definition, the source code of the engine with the teacher network or the check reports on them, or is computed from these. As of 5 November 2026.

In brief

The structure at a glance

Schema: per view, the piece features (8 king buckets times 768, at most 32 active) and the threat pairs (86,808 rows) plus the bias give 1,536 values, clamped to 0 to 255. Both views, side to move first, give 3,072 values; then layers of 64 and 64 neurons and 1 output. The output sum is multiplied by 138, divided by (255 × 16,384) and truncated towards zero.
Structure of the teacher network (sketch)

The network looks at each position twice, once from the view of the side to move and once from the view of the other side. Both views use the same weights. Each view sums the rows of its active features into 1,536 values, the accumulator. Both accumulators, the side to move first, give 3,072 inputs for the head. The head has 2 layers of 64 neurons each and one output. At the end there is a value in centipawns from the view of the side to move.

In the name, T stands for teacher, 1536 for the width, w for “widened function-preservingly from its predecessor”, K64 for the width of the head and v1 for the first version.

What the network sees

Pieces. Per view there are 768 piece features: own or opposing, times 6 piece kinds, kings included, times 64 squares. Each piece switches on exactly one feature, so at most 32 in a regular position. Black sees the board mirrored vertically and with swapped colours.

King buckets. The square of the own king selects one of 8 buckets. Each bucket has its own 768 rows for the pieces, together 8 · 768 = 6,144 piece rows. If the own king stands on files e to h, this view computes all squares mirrored (a ↔ h). The bucket table is the same as in the main network.

Table of the king buckets from the view of one side: rank 1: a, b, g, h bucket 0, c to f bucket 1; rank 2: a, b, g, h bucket 2, c to f bucket 3; rank 3 bucket 4; rank 4 bucket 5; ranks 5 and 6 bucket 6; ranks 7 and 8 bucket 7. If the king stands on files e to h, the board is mirrored.
Table of the king buckets (sketch)

What does not go in. Castling rights, en passant, the halfmove counter and repetitions are not given to the network. Whose move it is, it sees only from the order of the two views.

Threat features: pairs of attacker and target

A threat pair has 4 parts: the attacking piece, its square, the attacked square and the piece standing there. A pair is active if a piece stands on the target square and the attacker reaches it. What counts is the attack geometry, irrespective of pins and of whose move it is. For bishop, rook and queen only the first piece in each direction counts. Pawns count with their capture squares, not with the push. The attacked piece can be an opposing or an own piece. A pair on an own piece is a defence.

Position White Kg1, Rd1, Bc4, Pe4; Black Kg8, Qd5, Nf6; White to move. 11 active pairs, 7 on opposing pieces, 4 on own pieces. The black queen on d5 is attacked by pawn, bishop and rook and defended by the knight.
Threat pairs of an example position (calculated)

In the example position 11 pairs are active, 7 on opposing pieces and 4 on own pieces:

AttackerTargetKind
rook d1queen d5attack
bishop c4queen d5attack
pawn e4queen d5attack
queen d5rook d1attack
queen d5bishop c4attack
queen d5pawn e4attack
knight f6pawn e4attack
rook d1king g1defence
queen d5king g8defence
knight f6king g8defence
knight f6queen d5defence

The black queen is attacked three times and defended once. These relations enter the inputs directly as single pairs; without threat features a network sees only which piece stands on which square. In the starting position there are 40 pairs per view, all of them defences.

How many rows. Each combination of attacker (12 pieces), square, reachable target square on an empty board and target piece gets its own row. On an empty board there are 7,504 combinations of attacker, square and target square; pawns never stand on rank 1 or 8 here. On each target square 12 target pieces are possible, on ranks 1 and 8 only 10, because no pawns stand there. 1,620 of the combinations have their target square on rank 1 or 8:

12 · 7,504 − 2 · 1,620 = 86,808 threat rows
pawn: 1,960; knight: 7,856; bishop: 12,992; rook: 20,608; queen: 33,600; king: 9,792
Threat rows per kind of attacker (calculated)

Fine and coarse. In training each pair has two rows: a fine one for exactly this pair and a coarse one for all pairs with the same colour and kind of attacker and target piece on the same target square (2 · 6 · 2 · 6 · 64 = 9,216 coarse rows). On export both are added; the engine only knows 86,808 merged rows. The threat rows do not depend on the king bucket, but they do depend on the mirror: the squares of a pair are mirrored in the same way as the squares of the pieces. 12,166 of the 86,808 rows (14.0 %) are entirely zero after export.

Origin. Threat pairs existed in the project before the teacher, in a research network of width 768. The teacher took over the pair rule and the connection in the engine and generalised them to other widths and heads. A much smaller form of threat features was described in the post “Threat features: interim status of the small form D16”.

The computation in formulas

All values are integers. For a view with king bucket e, active piece features m and active threat pairs p, for each of the 1,536 neurons j:

a[j]  = clamp( b[j] + Σ_m W[e·768 + m][j] + Σ_p D[p][j], 0, 255 )
x     = ( a of the side to move, a of the other side )           3,072 values
h2[k] = clamp( (c2[k] + Σ_i x[i] · V2[k][i]) >> 14, 0, 255 )      k = 1 … 64
h3[k] = clamp( (c3[k] + Σ_i h2[i] · V3[k][i]) >> 14, 0, 255 )     k = 1 … 64
value = trunc( (c4 + Σ_i h3[i] · V4[i]) · 138 / (255 · 16,384) ) centipawns
PartIn → outWeightsBias
piece rows6,144 → 1,5369,437,1841,536
threat rows86,808 → 1,536133,337,088–
layer 23,072 → 64196,60864
layer 364 → 644,09664
output64 → 1641

Together these are 142,976,705 parameters, 99.86 % of them in the first layer. The main network, with width 768, no threat rows and a head of 16 and 32 neurons, has 4,744,529 parameters.

threat rows: 266.7 MB (93.3 %); piece rows: 18.9 MB (6.6 %); layer 2: 0.39 MB (0.1 %); rest: 0.01 MB (below 0.1 %)
Memory per component (calculated)

The flow in the engine

Flow: on each move the search only records piece changes, board and occupancy. When an evaluation is needed, the engine first checks the value cache; on a hit the stored value applies. Otherwise it brings both accumulators up to date from the last finished ply: if a view changed king bucket or mirror, it is rebuilt, the pieces via the refresh cache, the threat pairs completely; otherwise piece rows and the threat pairs of the affected attackers are subtracted and added. Then clamping, head and scaling follow, then the same code as for the main network; the value goes into the value cache.
Flow of one evaluation (sketch)

From scratch, a view sums up to 32 piece rows and all active threat rows, each 1,536 numbers wide. The engine does that only in certain cases; otherwise it updates.

The fastest build has two more aids. A value cache with 65,536 slots per search thread remembers finished evaluations; if a position hits, the stored value applies, and network and update are skipped. The threat rows in 8 bits: almost all rows fit entirely into −127 to 127 and are read from an 8-bit copy that moves half as much memory. The rest carry a marker and are read from the 16-bit table. In the checks neither aid changed a value or the search tree.

After the network, the value takes the same path as with the main network: the adaptation for the teacher network only changes the network computation, the value cache and the smallest allowed budget of the hash table, not the processing afterwards.

16 bits are enough. The accumulator is held in 16-bit numbers. So that the sum including the threat rows fits safely, the export computes conservative bounds of the row sum without bias for each neuron, for positions with at most 32 pieces, and places a fixed zero point in their middle. The engine stores the sum minus the zero point; by these bounds its magnitude stays at most 9,524, while the limit of the 16-bit number is 32,767. Zero point and input bias are added only after widening to 32 bits. In the check with 796,868 search nodes the measured maximum was 3,781.

What it costs. The network file has 285,953,780 bytes. The program with embedded network and 8-bit copy has 423 MB. In the first speed measurement the engine with the teacher computed 1.24 million nodes per second, the same engine with the main network 3.46 million; it was measured on a build that differed only in the output scale. Two later builds became 17.3 % and a further 11.7 % faster, with bit-identical evaluation.

How it was trained

Training target and error per position:

target = 0.5 · result + 0.5 · sigmoid(evaluation / 205)
error  = ( sigmoid(network output) − target )²

Result is the game outcome from the view of the side to move (1, 0.5 or 0), evaluation the search label in centipawns.

Networkmean error on the check set
main network0.015426
K2: width 768 without threat rows, same data0.014967
teacher0.013900
teacher with threat rows switched off0.020629

Measured on all 256,206,514 rows of the check set. For the differences main network against K2, K2 against teacher and main network against teacher, the one-sided 99 % bounds (bootstrap over the data packages) are each clearly above zero. If the threat rows are switched off in the finished teacher, its error becomes larger than that of the main network. Its other weights were trained together with the threat rows. How much the threat rows bring on their own is not measured by this comparison.

Rounding to integers changed the mean error in the engine check by 1.23 · 10^−5, from 0.013892 to 0.013904.

How the engine was checked

What this post does not say

How this was checked