Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
333 changes: 333 additions & 0 deletions specs/igla/own_model.t27
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
// SPDX-License-Identifier: Apache-2.0
; specs/igla/own_model.t27 -- the one map of "our own model": IGLA CODER, HSLM in t27, and the
; harness that has to run them. 27 cells, one T27F reel, the same workflow as the two topic reels
; (specs/t27f/reel_t27_basics.t27, specs/t27f/reel_gf16_nmse.t27): topic_engine.t27 decides each
; cell's status from what was measured, topic_reel.t27 checks it, reel.t27 and deck.t27 draw it.

; SOURCES, read on MEASURED_ON:
; - gHashTag/igla-coder-gpu at CODER_COMMIT (private): README.md, LEDGER.md,
; results/report_pair_10b.md, research/T27_BENCH.md, research/MODEL_ON_FPGA_PLAN.md.
; - gHashTag/trinity at TRINITY_COMMIT: docs/experiments/FOUND_EXPERIMENTS_SUMMARY.md (the HSLM
; experiment ledger) and data/wave9/worker-2/hslm_step_10000.bin (the one HSLM checkpoint left).
; - gHashTag/trinity-training at TRAINING_COMMIT: src/hslm, 64 Zig files, the HSLM trainer.
; - gHashTag/trinity-fpga at FPGA_COMMIT: 8 tokens on the AX7203, 7682304/7682304 receipts.
; - gHashTag/t27 at SOURCE_COMMIT: the ML specs named per cell.

; MEASURED on 2026-10-17:
; - test: t27c test-report (built from SOURCE_COMMIT, zig 0.16.0) on the Railway lab, 17 ML specs:
; cross_entropy_loss 5/5, sgd 4/4, adam 4/4, lamb 4/4 pass, 0 vacuous. BLOCKED, never compiled:
; nn/hslm (undeclared 'constants'), hslm/forward_pass ('q_role'), nn/attention
; ('PHI_CUBED_INV'), optimizer/adamw ('allocate_array'), and all nine specs/igla/coder/*.t27.
; ternary_matvec.t27 (the FPGA matvec, outside the 17) passed 4/4.
; - live: GET huggingface.co/api/models/playra/tern-tc-9m and .../tern-tc-9m-t27 returned 200;
; .../tern-tc-100m returned 401, the same as a made-up name, so no 100M is public.
; GET board-production-2dec.up.railway.app/state returned 200 and a made-up path 404; its
; snapshot is dated 2026-10-05, so the board is live and 12 days stale.
; - review: no PR behind any cell has a review, so no DELIVER cell is VERIFIED.
; The engine asks an engineering LEARN step for a source link, a PRACTICE step for a passing test
; and a DELIVER step for a review. So: 1 published, 11 verified, 8 drafts, 7 gaps.

; PERCENT is a second, separate number per cell: an estimate of how much of that part exists, with
; its basis in SOURCES. It never feeds a status. The lens and overall figures are plain means, every
; cell weighted the same; that weighting is a convention, not a measurement.

; THE ANSWER this map gives: HSLM was trained before, in Zig only (64 files); its best runs
; (PPL 2.96 at ctx 27) were wiped by EXP-002 and survive only in the ledger. In t27 the loss and
; three optimizers pass, the forward pass does not compile, and the backward pass, ternary STE,
; data loader, checkpoint I/O, heap and file I/O and `t27c --backend ml` do not exist yet.

; Not claimed: no model quality beyond the numbers in SOURCES; no GIF or MP4, stills only.
; phi^2 + 1/phi^2 = 3 | TRINITY

module own_model;

use t27f::reel::CELL_COUNT;
use t27f::reel::DEMO_COUNT;
use t27f::reel::DEMO_CELL;
use t27f::reel::DEMO_LENS;
use t27f::topic_engine::STATUS_GAP;
use t27f::topic_engine::STATUS_DRAFT;
use t27f::topic_engine::STATUS_VERIFIED;
use t27f::topic_engine::STATUS_PUBLISHED;
use t27f::topic_engine::STAGE_PRACTICE;
use t27f::topic_engine::DOMAIN_ENGINEERING;
use t27f::topic_engine::CONTENT_WORDS;
use t27f::topic_engine::ENGINEERING_WORDS;
use t27f::topic_engine::RESEARCH_WORDS;
use t27f::topic_engine::SALES_WORDS;
use t27f::topic_engine::keyword_hits;
use t27f::topic_engine::route_brief;
use t27f::topic_engine::step_stage;
use t27f::topic_reel::count_status;
use t27f::topic_reel::count_true;
use t27f::topic_reel::statuses_earned;
use t27f::topic_reel::gaps_are_named;
use t27f::topic_reel::slides_fit;
use t27f::topic_reel::stage_slides_bare;

pub const TOPIC_ID : str = "own-model";
pub const SOURCE_REPO : str = "gHashTag/t27";
pub const SOURCE_COMMIT : str = "efe3c9431";
pub const CODER_REPO : str = "gHashTag/igla-coder-gpu";
pub const CODER_COMMIT : str = "f60ac0c623e5ac24d74fdcde2dccb2d8e55e6d83";
pub const TRINITY_COMMIT : str = "ee512359254bcd7438bb6a79c8a4a7f8b554b620";
pub const TRAINING_COMMIT : str = "3e9648c1817a97c5f9b8c727b0f8e2291928eead";
pub const FPGA_COMMIT : str = "b2bd5a30cefe32eb7e57e9f2025626f6f0cf4b25";
/// The realtime harness: the IGLA board's state endpoint, which trinity compiles in the browser.
pub const LIVE_STATE_URL : str = "https://board-production-2dec.up.railway.app/state";
pub const MEASURED_ON : str = "2026-10-17";

/// The brief the engine routes. spec, compiler, fpga are 3 engineering hits; no other list is hit.
pub const BRIEF : str = "Our own model, written in t27: IGLA CODER, HSLM and the harness that runs them. One map per spec, compiler step and fpga receipt, with every gap named.";
/// The domain route_brief gives that brief (see the_domain_is_routed_not_chosen).
pub const DOMAIN : u8 = 2;

pub const LENS_TITLES : [3]str = ["IGLA CODER", "HSLM in t27", "harness"];

pub const TITLES : [27]str = [
"Corpus, 11.7B tokens of code",
"BPE 32K tokenizer with FIM",
"Size ladder 13M to 100M",
"t27 bench, 466 items",
"MultiPL-E pass@1 harness",
"IGLA CODER specs in t27",
"tern-tc-9m on Hugging Face",
"A public 100M model",
"Scale-up to 0.5-1.5B",
"HSLM experiment ledger",
"HSLM Zig trainer",
"The one checkpoint left",
"Loss: cross entropy",
"Optimizers: sgd, adam, lamb",
"Forward pass",
"Backward pass",
"Ternary straight-through",
"Data loader and checkpoint I/O",
"tc engine, C and PyTorch parity",
"FPGA: 8 tokens on the AX7203",
"Live IGLA board",
"Ternary matvec in t27",
"ML specs that compile",
"Heap and file I/O in t27c",
"t27c --backend ml",
"Full model on FPGA, DDR3",
"This map"
];

/// Where each cell's evidence lives; "" is a gap.
pub const SOURCES : [27]str = [
"igla-coder-gpu LEDGER.md (11.7B-token 32K corpus)",
"igla-coder-gpu README.md data.py row",
"igla-coder-gpu LEDGER.md ladder",
"igla-coder-gpu research/T27_BENCH.md",
"igla-coder-gpu results/report_pair_10b.md",
"t27 specs/igla/coder/*.t27: 0 of 9 compile",
"huggingface.co/playra/tern-tc-9m",
"",
"",
"trinity docs/experiments/FOUND_EXPERIMENTS_SUMMARY.md",
"trinity-training src/hslm, 64 Zig files",
"trinity data/wave9/worker-2/hslm_step_10000.bin",
"t27 specs/ml/loss/cross_entropy_loss.t27",
"t27 specs/ml/optimizer/{sgd,adam,lamb}.t27",
"t27 specs/nn/hslm.t27 and specs/hslm/forward_pass.t27",
"t27 specs/nn/hslm.t27 backward placeholders",
"",
"",
"igla-coder-gpu research/MODEL_ON_FPGA_PLAN.md",
"trinity-fpga b2bd5a30, 7682304/7682304 receipts",
"board-production-2dec.up.railway.app/state",
"t27 specs/port/trinity/fpga/openxc7-synth/ternary_matvec.t27",
"t27c test-report on 17 ML specs: 4 compile",
"",
"",
"",
"t27 specs/igla/own_model.t27"
];

/// What would ground each gap; "" for a cell that has its source.
pub const MISSING : [27]str = [
"", "", "", "", "", "", "",
"a public 100M checkpoint: playra/tern-tc-100m answers 401, like a made-up name",
"any run past 100M parameters: none exists",
"", "", "", "", "", "", "",
"a ternary straight-through estimator in any .t27 spec: none exists",
"a t27 reader for token streams and MSLH checkpoints: none exists",
"", "", "", "", "",
"heap allocation and file I/O lowered by t27c: neither exists",
"a t27c backend that lowers a model spec to a training binary: none exists",
"embeddings, head and weights in DDR3 on the board: they stay on the host",
""
];

/// The measurements per cell (see the header for how each was taken).
pub const GROUNDED : [27]bool = [true, true, true, true, true, true, true, false, false, true, true, true, true, true, true, true, false, false, true, true, true, true, true, false, false, false, true];
pub const TEST_PASS : [27]bool = [false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, true, false, false, false, false, false];
pub const REVIEWED : [27]bool = [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false];
pub const LIVE : [27]bool = [false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false];

/// What a host passes the viewer, per cell: the earned status code and the step number as a label.
pub const STATUS : [27]u8 = [4, 4, 4, 3, 3, 3, 3, 0, 0, 4, 4, 4, 4, 4, 3, 3, 0, 0, 4, 4, 5, 4, 3, 0, 0, 0, 3];
pub const LABELS : [27]str = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27"];

/// Percent of each part that exists, estimated from its source (see the header). Never a status.
pub const PCT : [27]u8 = [60, 70, 80, 80, 60, 10, 50, 0, 0, 100, 100, 20, 80, 65, 35, 5, 0, 0, 70, 15, 60, 40, 23, 0, 0, 0, 50];

/// The t27c test-report counts the PRACTICE cells quote.
pub const ML_SPECS_MEASURED : i32 = 17;
pub const ML_SPECS_COMPILING : i32 = 4;
pub const CODER_SPECS : i32 = 9;
pub const CODER_SPECS_COMPILING : i32 = 0;

/// Slide text per demo scene, checked by topic_reel.t27 slides_fit (index scene*4+row).
pub const HEAD : [5]str = [
"Own model: 27 parts",
"Steps 1-9: coder",
"HSLM existed",
"Evidence",
"What is left"
];
pub const ROWS : [20]str = [
"", "", "", "",
"", "", "", "",
"Step 11 of 27: the HSLM trainer",
"64 Zig files; best PPL 2.96 at ctx 27",
"Those checkpoints were wiped",
"In t27: loss and 3 optimizers pass",
"4 of 17 ML specs compile on the lab",
"0 of 9 IGLA CODER specs compile",
"1 published, 11 verified, 8 drafts",
"7 gaps, about 39 percent overall",
"Make nn/hslm.t27 compile",
"Backward pass and ternary STE",
"Loader, checkpoint I/O, --backend ml",
""
];

pub fn step_number(cell: i32) -> i32 {
return cell + 1;
}

/// part of whole, in whole percent, truncated.
pub fn share_pct(part: i32, whole: i32) -> i32 {
return @divTrunc(part * 100, whole);
}

/// Mean PCT of cells [from, from+n), truncated: every cell weighs the same.
pub fn mean_pct(from: i32, n: i32) -> i32 {
var sum : i32 = 0;
var c : i32 = from;
while (c < from + n) {
const p : i32 = @intCast(PCT[@intCast(c)]);
sum = sum + p;
c = c + 1;
}
return @divTrunc(sum, n);
}

test the_domain_is_routed_not_chosen {
assert DOMAIN == DOMAIN_ENGINEERING;
assert keyword_hits(BRIEF, BRIEF.len, ENGINEERING_WORDS, ENGINEERING_WORDS.len) == 3;
assert keyword_hits(BRIEF, BRIEF.len, CONTENT_WORDS, CONTENT_WORDS.len) == 0;
assert keyword_hits(BRIEF, BRIEF.len, RESEARCH_WORDS, RESEARCH_WORDS.len) == 0;
assert keyword_hits(BRIEF, BRIEF.len, SALES_WORDS, SALES_WORDS.len) == 0;
assert route_brief(BRIEF, BRIEF.len) == DOMAIN;
}

test every_step_is_a_cell {
assert CELL_COUNT == 27;
var c : i32 = 0;
while (c < CELL_COUNT) {
const i : usize = @intCast(c);
assert TITLES[i].len > 0;
var want : i32 = 1;
if (step_number(c) >= 10) {
want = 2;
}
const len : i32 = @intCast(LABELS[i].len);
assert len == want;
c = c + 1;
}
assert LENS_TITLES[2].len > 0;
}

test a_gap_is_named_not_filled {
assert gaps_are_named(SOURCES, MISSING, GROUNDED);
assert count_true(GROUNDED) == 20;
var c : i32 = 0;
while (c < CELL_COUNT) {
const i : usize = @intCast(c);
// a gap is drawn as a gap, and only a gap is; a gap is a part that does not exist: 0 percent
assert (STATUS[i] == STATUS_GAP) == (GROUNDED[i] == false);
assert (GROUNDED[i] == false) == (PCT[i] == 0);
assert PCT[i] <= 100;
c = c + 1;
}
}

test a_status_is_earned_not_chosen {
assert statuses_earned(STATUS, DOMAIN, GROUNDED, TEST_PASS, REVIEWED, LIVE);
// the evidence slide's "1 published, 11 verified, 8 drafts" and "7 gaps"
assert count_status(STATUS, STATUS_PUBLISHED) == 1;
assert count_status(STATUS, STATUS_VERIFIED) == 11;
assert count_status(STATUS, STATUS_DRAFT) == 8;
assert count_status(STATUS, STATUS_GAP) == 7;
assert count_true(REVIEWED) == 0;
// every passing test is a PRACTICE step: loss, optimizers, matvec
assert count_true(TEST_PASS) == 3;
var c : i32 = 0;
while (c < CELL_COUNT) {
const i : usize = @intCast(c);
if (TEST_PASS[i]) {
assert step_stage(@intCast(c)) == STAGE_PRACTICE;
}
c = c + 1;
}
// the 9M model is live, but a live page does not stand in for a review
assert LIVE[6];
assert STATUS[6] == STATUS_DRAFT;
// the board is live and was sourced, so it is the one published cell
assert STATUS[20] == STATUS_PUBLISHED;
}

test the_compile_counts_are_the_measured_ones {
// the IGLA CODER specs cell: grounded, none compiles, so it is a draft at 10 percent
assert CODER_SPECS_COMPILING == 0;
assert STATUS[5] == STATUS_DRAFT;
assert TEST_PASS[5] == false;
// the compile cell's percent is the measured share, truncated
const share : i32 = share_pct(ML_SPECS_COMPILING, ML_SPECS_MEASURED);
assert share == 23;
const p22 : i32 = @intCast(PCT[22]);
assert p22 == share;
assert share_pct(CODER_SPECS_COMPILING, CODER_SPECS) == 0;
assert CODER_SPECS <= ML_SPECS_MEASURED;
}

test percent_per_lens_is_a_plain_mean {
assert mean_pct(0, 9) == 45;
assert mean_pct(9, 9) == 45;
assert mean_pct(18, 9) == 28;
// the evidence slide's "about 39 percent overall"
assert mean_pct(0, CELL_COUNT) == 39;
}

test the_camera_is_the_demo_camera {
assert DEMO_COUNT == 5;
// scene 1 shows lens 0, the row HEAD[1] calls "Steps 1-9"
assert DEMO_LENS[1] == 0;
// scenes 2 and 3 focus cell 10, which the focus slide calls "Step 11": the HSLM trainer
assert DEMO_CELL[2] == 10;
assert DEMO_CELL[3] == 10;
assert step_number(DEMO_CELL[2]) == 11;
assert STATUS[10] == STATUS_VERIFIED;
}

test every_slide_fits_every_preset {
assert slides_fit(HEAD, ROWS);
assert stage_slides_bare(ROWS);
}

invariant twenty_seven_parts {
assert CELL_COUNT == 27;
}
Loading