Weights of minus phi, zero and plus phi
You will learn
How a ternary weight is stored in 2 bits, what the fourth code is for, and what the spec does not claim about phi.
Ternary networks such as BitNet keep each weight as minus one, zero or plus one times a scale, so a multiply becomes an add, a subtract or nothing. gfternary.t27 fixes that scale at phi, about 1.618, and stores the three values in 2 bits: 00 is zero, 01 is plus phi, 10 is minus phi. Two bits have a fourth code, 11, and the spec folds it to zero instead of leaving it undefined. The spec also says what it does not claim: that a phi scale beats plain integer ternary weights is an open conjecture, and it names the measured gap that would falsify it. The player compiles it in your browser; most checks it cannot run here, and each skip says why.
Try it
Run the tests and read why the skips were skipped; then find the code that folds to zero and the line that folds it. The golden ratio can also size a format: in the spec frame, find golden_section and read how gft4 splits 4 positions between sign, trits and mantissa.

Two-bit ternary weights {-phi, 0, +phi} as a t27 spec, compiled by t27c as WebAssembly in your browser. Seven backends; every test the page cannot run says why.
specs/numeric/gft4.t27
// SPDX-License-Identifier: Apache-2.0
// gft4.t27 -- GF-T4: the golden-ratio ternary ladder, 4-bit class.
//
// TWO AXES, FOUR FAMILIES. GF and GF-T are derived from the golden ratio; BNF and
// TNF are derived from the theorems, as the optimisation result for ternary
// networks. They are not renamings of each other and they answer different
// questions.
//
// GF-T applies GF's rule to POSITIONS, and a trit is a position -- the golden
// section divides the payload the way it divides a segment:
//
// E_t = round((N-1)/phi^2) = 1, M = N - 1 - E_t = 2
//
// Every rung lands exactly: 1 + 1 + 2 = 4, no position unspent. The ratio
// E_t/M = 0.5000 against 1/phi = 0.6180, a phi-distance of 0.1180
// which falls toward zero up the ladder, by construction, exactly as in GF.
//
// What this buys and what it costs, measured against TNF4 on the reference
// oracle: GF-T's exponent spans 1 binades either side where TNF sizes its own
// for the range a workload actually visits. GF-T pays for that in mantissa. At 64
// bits GF-T takes 1.3e8 times the range for 1.2e5 times the error -- neither
// dominates, and the corollary on the pair (M_eff, binades) forbids ranking them
// without naming a workload.
//
// Supersedes the ad-hoc parameters this rung carried before 2026-08-09, where the
// exponent was sized at roughly log2(N) trits with no documented rule and left
// positions unspent.
//
// layout: [ sign(1) | E = 1 balanced-ternary trits | M = 2 binary bits ]
// value = (-1)^sign * (1 + M/2^2) * 2^e, e in [-1,+1]
module triformat_gft4 {
use base::types;
const SIGN_BITS: u32 = 1;
const EXP_TRITS: u32 = 1; // round((N-1)/phi^2)
const MANT_BITS: u32 = 2; // the remaining positions, all of them
const EXP_OFFSET: u32 = 1;
const OFFSET_MAX: u32 = 2;
fn is_finite(offset: u32) -> bool { return offset != OFFSET_MAX; }
fn exp_values() -> u32 { return 3; }
// ---- Tests / invariants ----
// The golden section is the rule; this asserts it rather than remembering it.
test golden_section {
assert(SIGN_BITS + EXP_TRITS + MANT_BITS == 4, "1 + E_t + M = N, every position spent");
assert(EXP_TRITS * 1000 / MANT_BITS == 500, "E_t/M holds the golden section");
}
test balanced_offsets {
assert(EXP_OFFSET * 2 == OFFSET_MAX, "balanced: offset_max = 2 * exp_offset");
}
}
All lessons
Module 1 · Lab: our own research
A number format of our own, an honest scoreboard, and a model's tables multiplied on the board.
Module 2 · AI numbers: the MX block
How AI chips keep weights in a few bits: one shared scale per block, the scale byte itself, and what one outlier does to its neighbours.
Module 3 · Ternary weights
Weights that are only minus, zero or plus a scale, the five rules a ternary alphabet must pass, and a test pass that checked nothing.
Module 4 · The Ternary Network Float
A rule the compiler enforces before any test runs, and a 17-bit float whose exponent is four balanced trits.
Module 5 · Arithmetic on signed numbers
Multiply two signed numbers, add them when their signs differ, and do both at once in a multiply-accumulate.
Module 6 · Parts of a neuron
A ReLU that bends at zero, a power of two for softmax, and an argmax that names the answer.
Module 7 · Learning from a mistake
A loss that prices a wrong guess in bits, one step that moves a weight against its gradient, and the hidden layer that XOR needs.
Module 8 · BitNet: ternary networks
A threshold that squeezes a sum back to three values, one neuron that becomes a different function when its weights change, and a neuron that reads its inputs 27 trits at a time.
Module 9 · The ternary MAC as a chip
The 27-trit dot product as wires with no register, the same sum added into a register on every clock, and a small whole network to close the course.