From 77e8a1b59d98e1262eef82fc5c66638604aa38ab Mon Sep 17 00:00:00 2001 From: Dmitriy Vasilev Date: Thu, 30 Apr 2026 01:33:36 +0700 Subject: [PATCH] feat(igla): add IGLA-GF16 architecture verification bench (Module 7) Implements Module 7 from #3: - `zig build bench-igla` prints architecture verification - Parameter count: encoder + predictor + total in MB GF16 - Trinity Identity proof (|phi^2+1/phi^2 - 3| < 1e-12) - Fibonacci proof (144*phi = 233, |err| < 0.1) - Budget check: total <= 16 MB GF16 All 7 modules of IGLA-GF16 now implemented. Closes #3 --- benches/igla_gf16_bench.zig | 44 +++++++++++++++++++++++++++++++++++++ build.zig | 13 +++++++++++ 2 files changed, 57 insertions(+) create mode 100644 benches/igla_gf16_bench.zig diff --git a/benches/igla_gf16_bench.zig b/benches/igla_gf16_bench.zig new file mode 100644 index 0000000..ef4aacd --- /dev/null +++ b/benches/igla_gf16_bench.zig @@ -0,0 +1,44 @@ +const std = @import("std"); +const tc = @import("../src/trinity_constants.zig"); +const jepa = @import("../src/jepa_t.zig"); + +pub fn main() !void { + const writer = std.io.getStdOut().writer(); + + try writer.print("IGLA-GF16 Architecture Verification\n", .{}); + try writer.print("====================================\n\n", .{}); + + try writer.print("Architecture:\n", .{}); + try writer.print(" d_model = {} (Fib(12))\n", .{tc.D_MODEL}); + try writer.print(" n_heads = {} (Fib(6))\n", .{tc.N_HEADS}); + try writer.print(" d_head = {} (d_model/n_heads)\n", .{tc.D_HEAD}); + try writer.print(" d_ffn = {} (Fib(13) = d_model*phi)\n", .{tc.D_FFN}); + try writer.print(" n_layers = {}\n", .{tc.N_LAYERS}); + try writer.print(" vocab = {} (GPT-2 BPE)\n\n", .{tc.VOCAB}); + + const total_mb = jepa.totalMB(); + const encoder_params = jepa.encoderParams(); + const predictor_params = jepa.predictorParams(); + const total_params = jepa.totalParams(); + + try writer.print("Parameter Count:\n", .{}); + try writer.print(" Encoder: {d:>12} params ({d:.1} MB GF16)\n", .{ encoder_params, @as(f64, @floatFromInt(encoder_params)) * 2.0 / 1048576.0 }); + try writer.print(" Predictor: {d:>12} params ({d:.1} MB GF16)\n", .{ predictor_params, @as(f64, @floatFromInt(predictor_params)) * 2.0 / 1048576.0 }); + try writer.print(" Total: {d:>12} params ({d:.1} MB GF16)\n", .{ total_params, total_mb }); + try writer.print(" Budget: 16.0 MB GF16 — {}\n\n", .{if (total_mb <= 16.0) "PASS" else "FAIL"}); + + try writer.print("Trinity Constants:\n", .{}); + try writer.print(" PHI = {d:.16}\n", .{tc.PHI}); + try writer.print(" PHI^2 = {d:.16}\n", .{tc.PHI_SQ}); + try writer.print(" 1/PHI^2 = {d:.16}\n", .{tc.PHI_INV_SQ}); + try writer.print(" Trinity = {d:.16} (should be 3.0)\n", .{tc.TRINITY}); + try writer.print(" ALPHA_PHI = {d:.16} (= phi - 1.5)\n", .{tc.ALPHA_PHI}); + try writer.print(" phi-split = {d:.3} (encoder/predictor)\n\n", .{jepa.PhiSplit}); + + try writer.print("Proofs:\n", .{}); + const trinity_err = @abs(tc.TRINITY - 3.0); + try writer.print(" [1] Trinity Identity |phi^2+1/phi^2 - 3| = {e} {}\n", .{ trinity_err, if (trinity_err < 1e-12) "PASS" else "FAIL" }); + const fib_proof = @as(f64, @floatFromInt(tc.D_MODEL)) * tc.PHI; + const fib_err = @abs(fib_proof - @as(f64, @floatFromInt(tc.D_FFN))); + try writer.print(" [5] Fib proof 144*phi = {d:.2} vs d_ffn={d} |err|={e} {}\n\n", .{ fib_proof, @as(f64, @floatFromInt(tc.D_FFN)), fib_err, if (fib_err < 0.1) "PASS" else "FAIL" }); +} diff --git a/build.zig b/build.zig index 8232949..7a7b27a 100644 --- a/build.zig +++ b/build.zig @@ -164,4 +164,17 @@ pub fn build(b: *std.Build) void { test_step.dependOn(&run_phi_attention_tests.step); test_step.dependOn(&run_trinity_init_tests.step); test_step.dependOn(&run_jepa_t_tests.step); + + const igla_bench_module = b.createModule(.{ + .root_source_file = b.path("benches/igla_gf16_bench.zig"), + .target = target, + .optimize = optimize, + }); + const igla_bench = b.addExecutable(.{ + .name = "igla_gf16_bench", + .root_module = igla_bench_module, + }); + const run_igla_bench = b.addRunArtifact(igla_bench); + const igla_bench_step = b.step("bench-igla", "Run IGLA-GF16 architecture verification (Module 7)"); + igla_bench_step.dependOn(&run_igla_bench.step); }