Skip to content

feat(hslm): Fully Ternary Transformer — 0 floating point operations #329

Description

@gHashTag

Fully Ternary Transformer — 0 FP Operations

Overview

Transform HSLM from "ternary weights + f32 everything else" to fully ternary: 0 floating-point operations, 25K+ tok/s on FPGA.

Current: ternary weights, sparse matmul (branchless 9.2x), φ-RoPE, STE, packed trits. But activations, attention, gradients = f32.

Goal: Every operation is ternary {-1, 0, +1}. Zero FPU. Pure integer arithmetic.

Dependency Graph

Level 0 (parallel): A, B, C, F, G, H, I  (7 issues)
Level 1 (needs L0):  D (needs B), E (needs D)
Level 2 (needs L1):  J (needs B+C+D+E)
Level 3 (needs L2):  K (needs J), L (needs all)

Sub-Issues

Compiler Fork: #342

Total: ~1,480 LOC new code + 29 tests across 10 new files + 4 edited files

Expected Results

Config Params Memory FPGA DSP FPU Speed
Baseline f32 1.95M×32b 7.8 MB 240 yes 1 tok/s
Ternary weights 1.95M×2b 488 KB 0 yes 5K tok/s
+ Trit embed -175K 485 KB 0 yes 5K tok/s
+ Ternary act same 488 KB 0 0 15K tok/s
+ Ternary attn same 488 KB 0 0 20K tok/s
Full ternary 1.7M×2b 425 KB 0 0 25K+ tok/s

Novel claim: "First fully ternary transformer with zero floating-point operations"

New tri CLI Commands

tri hslm benchmark-f16       tri hslm trit-encode
tri hslm trit-pe              tri hslm quantize-act
tri hslm ternary-attn         tri hslm terngrad
tri hslm sparsity             tri hslm phi-scale
tri hslm lr-schedule          tri hslm inference --ternary
tri export --full-ternary

Experiments (after implementation)

Run Config Purpose
T1 --trit-embed Isolate 121x embedding compression
T2 --full-ternary Full pipeline end-to-end
T3 --ternary-act --threshold 0.5 Isolate activation quantization
T4 --phi-scale --ternary-schedule --cycles 3 φ training dynamics

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions