Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .trinity/seals/ml_eval_hslm.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"built_by": "t27c-bootstrap@0.5.2+fd332dfd5",
"built_by": "t27c-bootstrap@0.5.2+78e57be99",
"closure": [
{
"spec": "specs/base/types.t27",
"spec_hash": "sha256:3c2fb2a2edf20e90bc76798fb5d12690b2f60fc0f5bbf2f6052936e22d6e62e2"
},
{
"spec": "specs/ml/train_hslm.t27",
"spec_hash": "sha256:fa8490d815bde2815fe9bfa89cb9badab241f580977e59be52fc5902f6f8bb03"
"spec_hash": "sha256:8fd4733d3ff131fc85c947e7e6146666d0f06fdaf3a5e563d7ce2fa70eb61b8d"
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
Expand All @@ -18,7 +18,7 @@
"module": "eval_hslm",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-19T03:39:21Z",
"sealed_at": "2026-10-19T04:28:30Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:09c6729a1509a6ec95616fd50fccf4eb6a3d65dfd22c9aec359e6079a52acec1",
"spec_path": "specs/ml/eval_hslm.t27",
Expand Down
6 changes: 3 additions & 3 deletions .trinity/seals/ml_ngram_hslm.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"built_by": "t27c-bootstrap@0.5.2+fd332dfd5",
"built_by": "t27c-bootstrap@0.5.2+78e57be99",
"closure": [
{
"spec": "specs/base/types.t27",
"spec_hash": "sha256:3c2fb2a2edf20e90bc76798fb5d12690b2f60fc0f5bbf2f6052936e22d6e62e2"
},
{
"spec": "specs/ml/train_hslm.t27",
"spec_hash": "sha256:fa8490d815bde2815fe9bfa89cb9badab241f580977e59be52fc5902f6f8bb03"
"spec_hash": "sha256:8fd4733d3ff131fc85c947e7e6146666d0f06fdaf3a5e563d7ce2fa70eb61b8d"
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
Expand All @@ -18,7 +18,7 @@
"module": "ngram_hslm",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-19T03:39:38Z",
"sealed_at": "2026-10-19T04:28:31Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:d3e31459bc0702d1b59357dad2b4d2ef679fbe95fcda2185adb612a2bdb6f6ed",
"spec_path": "specs/ml/ngram_hslm.t27",
Expand Down
20 changes: 10 additions & 10 deletions .trinity/seals/ml_train_hslm.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"built_by": "t27c-bootstrap@0.5.2+fd332dfd5",
"built_by": "t27c-bootstrap@0.5.2+78e57be99",
"closure": [
{
"spec": "specs/base/types.t27",
Expand All @@ -19,27 +19,27 @@
}
],
"config": "gen=c,rust,verilog,zig;tests=zig",
"gen_hash_c": "sha256:055ae0cc492ffb8d93ec1efb9108717dab776629eac9cf998486dd8e0953303a",
"gen_hash_rust": "sha256:bcfac5e60672f7727a3fb664998569f3d968e383fbbf05bbd13250f1e96ac27f",
"gen_hash_verilog": "sha256:5ee39b8e538963f19568406f921cf018166b44dd9e0cdaf3c5b4b10c0f9ac3c6",
"gen_hash_zig": "sha256:b394cdfcac1611c453707b7eba40039d1daddbf9d17a336b7a28979cb0a076fa",
"gen_hash_c": "sha256:9261d24381b2c2b5506fad987fc13fbfd5e7142a00c5e67fb878e56862102c7f",
"gen_hash_rust": "sha256:78d0634dbb7f15a4fb098e71779d47a69149fe776703d6a791632f608e3315f2",
"gen_hash_verilog": "sha256:b9743c3e95cd4c48765383ea8c8d7a1ffc5551c925e23be9bbae74d7f30e0550",
"gen_hash_zig": "sha256:00a2ae9af248ea9bae037596bf77b759303d460f8eb283cef3b8d6284b879ea5",
"module": "train_hslm",
"ring": 12,
"seal_schema": 2,
"sealed_at": "2026-10-18T13:48:46Z",
"sealed_at": "2026-10-19T04:28:22Z",
"sealed_by": "t27c-bootstrap@0.5.2",
"spec_hash": "sha256:fa8490d815bde2815fe9bfa89cb9badab241f580977e59be52fc5902f6f8bb03",
"spec_hash": "sha256:8fd4733d3ff131fc85c947e7e6146666d0f06fdaf3a5e563d7ce2fa70eb61b8d",
"spec_path": "specs/ml/train_hslm.t27",
"tests": {
"failed": 0,
"failing": [],
"forced": false,
"passed": 20,
"total": 20,
"passed": 21,
"total": 21,
"vacuous": 0
},
"toolchain": {
"test_runner": "sha256:1982ae948e24d00c5d221ccec12dfce1eb01204b53e37b0f857f93b16d64629d",
"test_runner": "sha256:8512b80da533b79289110fca4a65f3336abd7a059ca4b72ea595d5e33ff8ad10",
"zig": "0.16.0"
}
}
44 changes: 43 additions & 1 deletion specs/ml/train_hslm.t27
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
; quantizer (nn/ternary_ste quantize_twn) and the checkpoint header and layout (nn/hslm_data
; write_header, parse_header, the section offsets). They are reached through `use`.
; THE MODEL: ctx 27, vocab 729, embed 243, ff 729, 3 blocks, 3 heads of 81. Every ternary matrix
; (Q, K, V, O, up, down per block, and the output head: 19 matrices, 1771470 trits) has an f64
; (Q, K, V, O, up, down per block, and the output head: 19 matrices; 18 block matrices hold 1771470
; trits and the 243 x 729 output head adds 177147, 1948617 trits in all) has an f64
; shadow; after every update the shadow is requantized with TWN (delta = 0.7 mean |w|, alpha = mean
; |w| over the kept entries), one alpha per matrix. The float parameters (embedding table 729 x 243,
; RMSNorm gains, FFN biases, output bias) are trained directly. NPARAM = 2130138 f64 in one flat
Expand Down Expand Up @@ -2137,6 +2138,40 @@ fn tr_param_count() -> usize {
return tr_build_segments();
}

/// The trits in the ternary matrices, summed from the segment table (0 when the table does not add up to NPARAM)
fn tr_ternary_count() -> usize {
const total : usize = tr_build_segments();
var n : usize = 0;
var s : usize = 0;
while (s < NSEG) {
if (tr_kind_ternary(seg_kind[s])) {
n = n + seg_len[s];
}
s = s + 1;
}
if (total != NPARAM) {
return 0;
}
return n;
}

/// How many segments are ternary matrices (0 when the table does not add up to NPARAM)
fn tr_ternary_matrices() -> usize {
const total : usize = tr_build_segments();
var m : usize = 0;
var s : usize = 0;
while (s < NSEG) {
if (tr_kind_ternary(seg_kind[s])) {
m = m + 1;
}
s = s + 1;
}
if (total != NPARAM) {
return 0;
}
return m;
}

; THE K-POSITION OBJECTIVE, CHECKED. The kinds a gradient check can move: nn/hslm's MAT_* (a ternary
; matrix entry, moved through the nudge as a real weight before the alpha scale, which is the
; quantity gw_* is the gradient of), one embedding table entry, one output bias entry. Central
Expand Down Expand Up @@ -2524,6 +2559,13 @@ test the_parameter_vector_is_the_whole_model
given n = tr_param_count()
then n == 2130138

test the_ternary_matrices_hold_1948617_trits
given m = tr_ternary_matrices()
and n = tr_ternary_count()
then m == 19
and n == 1948617
and n == NUM_BLOCKS * (4 * EMBED_DIM * EMBED_DIM + 2 * EMBED_DIM * FF_DIM) + EMBED_DIM * VOCAB_SIZE

test a_checkpoint_round_trip_on_a_buffer_is_byte_equal
given diff = tr_mslh_roundtrip_diff()
and status = tr_mslh_header_status()
Expand Down
Loading