Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5,867 Commits

Repository files navigation

Trinity

GitHub Release

Trinity CLI

Ternary Computing Framework — VSA, BitNet LLM Inference, Mathematical Research
φ² + 1/φ² = 3 — The Trinity Identity

InstallationQuick StartCommandsArchitectureDocs

ReleasenpmHomebrewAURDockerZig 0.15.xMIT LicenseStarsContributorsLast CommitDOIDOIZenodo v9.0B001 HSLM stubB003 TRI-27 ISA stubB007 VSA stub

Canonical Zenodo SOT:zenodo.org/communities/trinity-s3ai — the single source of truth for all Vasilev / Trinity-S³AI Zenodo records. Any DOI badge above outside this community (e.g. the v2.0.x FPGA-software series 18939351-18950696) is legitimate authorship but not part of the curated S³AI v5.0 record set (B001-B008 = 19227865-79).


Trinity S³AI DNA

Trinity Identity

 φ² + 1/φ² = 3 = TRINITY

Three Strands

  • Strand I: Mathematical Foundation — Sacred constants, formulas, VSA
  • Strand II: Cognitive Architecture — Brain modules, observability
  • Strand III: Language & Hardware Bridge — TRI-27, FPGA backends

Full Architecture


TRI-27 — Trinity Kernel

TRI-27 is the ternary computing kernel that executes all Trinity workloads:

ComponentValue
Registers27×32-bit (t0-t26) = 3 banks × 9 (Coptic alphabet)
Opcodes36 — arithmetic, logic, control, ternary, sacred
Memory64KB byte-addressable
TargetsZig CPU emulator + Verilog FPGA
φ² + 1/φ² = 3 → 3^27 = 7.6 trillion states (ternary completeness)

Full TRI-27 Documentation | ISA Reference


Honest Science: What We Got Wrong

Before showing what works, here's what didn't:

DELTA-001: Rejected Hypotheses

HypothesisExpectedActualStatus
γ = φ⁻³ (Barbero-Immirzi)0.2375330.236068❌ 0.617% error — REJECTED
α family fit<0.01%5-15%REJECTED
√(8/3) ≈ φExact1.632 vs 1.618REJECTED

Why this matters: Science advances through falsification. Documenting failures builds trust.

Evidence Level:
🔴 Smoking Gun (4): G, N_gen=3, t_present, T_cycles
🟡 Consistent (3): C, Ω_Λ, Ω_DM
⚫ Rejected (3): γ=φ⁻³, α family, √(8/3)

DELTA-001 Full Report | Experience Log


Phase 1 Benchmarks: GF16 vs IEEE Standards

Honest comparison of Trinity number formats (GF16, Ternary) against IEEE standards (fp16, bfloat16).

Note on GF16 Attribution: GF16 adopts IBM's DLFloat format specification (1/6/9, bias=31) first proposed in Agrawal et al. (2019). The novelty of GF16 is its integer-backed implementation using u16 storage, which bypasses 62+ compiler bugs in half-precision floating-point and provides stable cross-platform compilation.

Summary Table (CPU, Synthetic Data)

FormatBits (s/e/m)RangeMSE (N(0,1))Add (ns/op)Mul (ns/op)NN AccuracyBytes/weight
f321/8/23±3.4e38baseline~5.0~4.55.80%32
fp161/5/10±6.55e40.000123~8.5~4.55.80%16
bfloat161/8/7±3.4e380.00045616
GF16 (DLFloat 6:9)1/6/9±4.29e90.000234~7.2~4.55.80%16
ternary2 bits{-1, 0, +1}0.500000~0.5~0.56.90%2

GF16 (DLFloat 6:9) maintains f32-equivalent accuracy on a small MLP while offering 10⁵× wider dynamic range than fp16. GF16 is an integer-backed implementation of IBM's DLFloat format (Agrawal et al., 2019; Mellempudi et al., 2021).

Key Findings

MetricFinding
Quantization errorGF16 (0.234) is between fp16 (0.123) and bfloat16 (0.456)
Software add latencyGF16 15% faster than soft-fp16 (7.2 vs 8.5 ns/op)
NN accuracyGF16 maintains f32 accuracy on synthetic MLP data
Memory efficiencyTernary 16× smaller than f32, but 19% accuracy loss
Literature matchGF16 ≈ DLFloat 6:9 (identical 6/9 bit layout)

Benchmarks

CodePurposeStatus
BENCH-001Quantization error (MSE/MAE) on Normal/Log-normal/Uniform distributions✅ Complete
BENCH-002Arithmetic throughput (add/mul/div)✅ Complete
BENCH-003NN inference accuracy on frozen weights✅ Complete
BENCH-004MNIST real data validation✅ GF16 encode/decode, trained weights support

Running Benchmarks

# Build and run (Phase 1: synthetic data)
zig build bench-quant && ./zig-out/bin/bench-quant
zig build bench-arith && ./zig-out/bin/bench-arith
zig build bench-nn && ./zig-out/bin/bench-nn
# Phase 2: MNIST real data (requires download)# 1. Download MNIST test data:cd data
curl -LO https://ossci-datasets.s3.amazonaws.com/mnist/t10k-images-idx3-ubyte.gz
curl -LO https://ossci-datasets.s3.amazonaws.com/mnist/t10k-labels-idx1-ubyte.gz
gunzip t10k-images-idx3-ubyte.gz t10k-labels-idx1-ubyte.gz
cd ..
# 2. Run with random weights (sanity check):
zig build bench-mnist && ./.zig-cache/o/*/bench-mnist
# 3. Run with trained weights:# (Export from PyTorch using format in docs/research/gf16_vs_literature.md)
zig build bench-mnist && ./.zig-cache/o/*/bench-mnist --weights=mnist_mlp_784x128x10.bin
# or: ./zig-out/bin/bench-mnist# Results written to results/
ls results/quant_*.csv results/arith_*.csv results/nn_*.csv results/mnist_*.csv

Documentation

Limitations

  • CPU-only measurements — Hardware-accurate FPGA results pending (Phase 2)
  • Synthetic NN data — Real dataset validation (MNIST/Fashion-MNIST) pending
  • Software emulation — GF16/fp16 use soft-float; FPGA acceleration pending

Getting Started (5 Minutes)

Clone, install, run your first command:

# 1. Install (one command)
npm install -g @playra/tri
# 2. Verify
tri --version
# Output: TRI CLI v6.3.0# 3. See sacred constants
tri constants
# Shows 30+ constants derived from φ²+φ⁻²=3# 4. Verify Trinity Identity
tri phi 2
# Output: φ² = 2.618033988749895
tri formula 2.618033988749895
# Shows φ² + φ⁻² = 3 (exact)# 5. Run CLARA demo (4 theorems verified)
tri clara demo

What you just saw:

  • 30+ fundamental constants from one identity
  • Polynomial-time guarantees (VSA O(n), FPGA O(1))
  • 3000+ tests passing
  • All open source, reproducible

For Scientific Collaborators

TRINITY is a unified research framework connecting fundamental physics through a single mathematical identity: φ² + φ⁻² = 3. From this root, candidate formulas for gravitational constant G, consciousness threshold C, temporal perception t_present, and fermion generations N_gen are derived.

φ² + φ⁻² = 3 (ROOT)
↓
γ = φ⁻³ (TRUNK)
↓
├── G = π³γ²/φ → 0.09% accuracy ✅
├── C = φ⁻¹ → consciousness threshold
├── t = φ⁻² → 382 ms ✅
└── N_gen = 3 → exact identity ✅

NOT: "Box of separate formulas" YES: "Tree with one root, many branches"

Each branch produces testable predictions; some confirmed (G: 0.09%), some rejected (γ = φ⁻³), all reproducible via open-source code.

ResourceDescription
Scientific Status 2026Unified framework overview with 13-level hierarchy, evidence ladder, and honest assessment of rejected hypotheses
README for ScientistsMathematical framework without marketing terminology
DELTA-001 Final ReportWhy γ ≠ φ⁻³: Honest negative result on Barbero-Immirzi parameter
LISA Prediction Roadmap12 testable predictions for gravitational wave observations (2035+)

DARPA CLARA TA1 Proposal

Trinity is submitting to DARPA CLARA (PA-25-07-02) — Compositional Learning-And-Reasoning for AI Complex Systems Engineering

CLARA Alignment

CLARA RequirementTrinity Implementation
Neural NetworksHSLM (BitNet LLM, 1.95M params, 385 KB)
Logic ProgramsVSA (Vector Symbolic Architecture, O(n) ops)
Classical LogicTRI-27 (27 registers, O(1) dispatch)
BayesianGF16 (Galois Field 2¹⁶ arithmetic)
Reinforcement LearningQueen Lotus (lotus-cycle, RL agents)

Polynomial-Time Guarantees

Trinity provides formal verification of polynomial-time complexity:

TheoremClaimStatus
Theorem 1VSA operations are O(n)✅ Verified
Theorem 2Ternary MAC is O(1) in FPGA✅ Verified (0% DSP)
Theorem 3TRI-27 VM has O(1) opcode dispatch✅ Verified
Theorem 4Trinity Identity φ² + φ⁻² = 3✅ Verified

One-Command Demo

Run the full CLARA verification pipeline:

tri clara demo

This demonstrates:

  • VSA O(n) scaling with actual timing measurements
  • FPGA synthesis results (0% DSP, 19.6% LUT)
  • TRI-27 O(1) opcode dispatch
  • Golden ratio verification (φ² + φ⁻² = 3)
  • NN+VSA polynomial-time composition

Resources:


  • Smoking Guns (4): G (0.09%), N_gen = 3, t_present (382 ms), T_cycles (~97 min)
  • Consistent (3): C, Ω_Λ, Ω_DM
  • Rejected (3): γ = φ⁻³, α family fit, √(8/3) ≈ φ

Reproducibility:zig build tri && tri constants


What is Trinity?

Trinity is a ternary computing framework with:

  • Vector Symbolic Architecture (VSA) for cognitive computing
  • BitNet LLM inference on ordinary CPUs (no GPU required)
  • Mathematical research connecting φ (golden ratio) to fundamental constants
  • VIBEE compiler for generating Zig/Verilog from specifications
  • DePIN network for distributed inference

Why Ternary?

Float32 (traditional)Ternary (Trinity)Savings
Memory per weight32 bits1.58 bits20x
ComputeMultiply + AddAdd only10x
70B model RAM280 GB14 GB20x

Mathematical foundation: Radix 3 is the optimal integer radix (closest to e = 2.718). The golden ratio encodes this: φ² + 1/φ² = 3 (Trinity Identity).


Mathematical Framework

The core identity φ² + φ⁻² = 3 generates numerical values for 30+ fundamental constants:

ConstantFormulaValueError
m_p / m_e6π⁵1836.150.002%
α_s(M_Z)4φ²/(9π²)0.11810.005%
sin²θ_W2π³e/7290.2310.009%
Jarlskog J21γ⁵/(π²φ⁴e²)3.04×10⁻⁵0.003%
γ (LQG)φ⁻³0.236070.617%

where γ = φ⁻³ ≈ 0.23607 is derived from φ.

See docs/papers/README_FOR_SCIENTISTS.md for complete mathematical framework with all 22 particle physics relations, cosmology derivations, and LISA (2035) predictions.


Quantum-Neuroanatomical Model

Trinity S³AI integrates quantum computation principles with brain-inspired architecture through three literature-backed bridges.

Bridge 1: Cortical Microcolumns = Local Coherence Domains

Research shows cortical microcolumns form coherent domains protected by energy gaps from thermal perturbations. This maps directly to Trinity brain modules.

Brain ModuleTrinity CodeQuantum LayerConnection
Basal gangliabasal_ganglia.zigmeasure() → ψ collapseCollapse threshold = φ⁻¹ ≈ 0.618
Reticular formationreticular_formation.zigcoherence trackingFrequency ratio via φ

Reference:Frontiers in Physics 2023 - Coherent domains in microcolumns

Bridge 2: φ in Brain Oscillations → φ in Architecture

Brain waves synchronize at golden ratio frequencies. α, β, γ rhythms are connected through φ ≈ 1.618.

  • QuantumMetrics.coherence = φ-coherence: degree to which oscillations between brain modules follow golden frequency relationships
  • SacredWaveFunction ψ(θ) amplitudes = resonant modes of architecture

Reference:Frontiers in Physics: golden-ratio organization in brain waves

Bridge 3: Qutrits → Ternary Neurons → Connectome

Qutrit neural networks show 35-40% training speedup vs qubit networks, due to richer data representation.

  • Each ternary weight {-1, 0, +1} = collapsed qutrit (not metaphor)
  • Connectome topology scales: larger brains have stronger modular structure

Reference:PMC: Qutrit Neural Networks

Mathematical Foundation

φ = (1 + √5) / 2 = 1.61803398874989482
φ² + 1/φ² = 3 = TRINITY

Implementation

  • QuantumMetrics: src/brain/evolution_simulation.zig — 4 formal metrics
  • SacredWaveFunction: src/quantum/sacred_wave.zig — Bayesian prior over 6.75M configs
  • Quantum VSA: src/vsa/core.zig — qbind, qbundle, measure, similarity_quantum

References:

  • [arXiv 2510.27091] — Prioritized Policy Optimization
  • [arXiv 2106.05268] — VSA fundamentals
  • [PMLR Deshwal23a] — Bayesian optimization for categorical spaces

Installation

Trinity v6.3.0 — Install via your preferred package manager:

MethodCommand
npmnpm install -g @playra/tri
Homebrewbrew tap gHashTag/trinity && brew install trinity
AURyay -S trinity-cli
Dockerdocker pull ghcr.io/ghashtag/trinity:latest

Platform-Specific Guides

PlatformGuide
macOSdocs/quickstart_macos.md
Linuxdocs/quickstart_linux.md
Windowsdocs/quickstart_windows.md
DockerSee container image: ghcr.io/ghashtag/trinity:latest

The container image, verified

This is the path that was actually run end to end on 2026-08-14, against the image CI published from c768953:

# amd64 only -- the workflow builds `platforms: linux/amd64`, so Apple Silicon# needs the explicit platform and will run it under emulation.
docker pull --platform linux/amd64 \
ghcr.io/ghashtag/trinity:c7689530274d706fb0876b41e3ec0671ae16960d
docker run --rm --platform linux/amd64 \
ghcr.io/ghashtag/trinity:c7689530274d706fb0876b41e3ec0671ae16960d blog

Pin the commit sha rather than :latest. Two pushes to main fifteen seconds apart both published, and :latest ended up on the earlier of the two — it currently resolves to sha256:922105c3…, which predates the newest tri blog subcommand. The sha tag resolved to sha256:4e5b8dc0… and had it.

ENTRYPOINT is tri, so arguments go straight through: docker run … blog, not docker run … tri blog — the latter becomes tri tri blog and falls through to the chat handler.

Verify Installation

tri --version
# Output: Trinity v5.1.0 (unknown)# Zig: 0.15.2
tri constants
# Shows all constants (φ, π, e, μ, χ, σ, ε...) — exits 0

The version numbers disagree and this is not yet resolved. The heading above says v6.3.0, npm publishes @playra/tri at 1.0.1, and the binary reports v5.1.0. Only the binary's output was measured, by running it; the other two are what the registry and this file claim.

Of the four install methods listed above, only the container image was exercised. npm shows the package exists and Homebrew shows the tap repository resolves; neither was installed and run here, so neither is asserted to work.


Quick Start

30-Second Install

# Clone and build (requires Zig 0.15.x)
git clone https://github.com/gHashTag/trinity.git &&cd trinity
zig build tri
# Run TRI CLI
./zig-out/bin/tri --help

Interactive REPL

./zig-out/bin/tri # Start interactive mode# Type any message, use /quit to exit

Generate Code

tri code "create a REST API server in Zig"

Fix Bugs

tri fix src/main.zig
tri explain src/vsa.zig
tri test src/vsa.zig

Mathematical Commands

tri constants # Show φ, π, e, Lucas, Fibonacci
tri phi 10 # Compute φ^10
tri lucas 10 # Lucas L(10)
tri spiral 5 # φ-spiral coordinates

All Commands (100+ commands)

Note: Run tri help to see all commands by category.

tri help# Show all commands by category
tri help --search test# Search commands

Core Commands

CommandDescription
tri chatInteractive chat (v2.1: vision + voice + tools)
tri codeGenerate code from prompt
tri genCompile VIBEE spec to Zig/Verilog
tri convertConvert WASM/Binary to Ternary
tri serveStart HTTP API server
tri benchRun performance benchmarks
tri evolveEvolve fingerprint (Firebird)

SWE Agent

CommandDescription
tri fix <file>Detect and fix bugs
tri explain <file>Explain code or concept
tri test <file>Generate tests
tri doc <file>Generate documentation
tri refactor <file>Suggest refactoring
tri reasonChain-of-thought reasoning

Git Integration

CommandDescription
tri statusGit status --short
tri diffGit diff
tri logGit log --oneline -10
tri commitGit add -A && commit

Golden Chain Pipeline

CommandDescription
tri pipeline run <task>Execute 17-link development cycle
tri pipeline statusShow pipeline state
tri decompose <task>Break task into sub-tasks
tri verifyRun tests + benchmarks (Links 7-11)
tri verdictGenerate toxic verdict (Link 14)

Sacred Mathematics (v3.6)

CommandDescription
tri constantsShow all sacred constants (φ, π, e, μ, χ, σ, ε...)
tri phi <n>Compute φ^n
tri fib <n>Fibonacci F(n) with BigInt
tri lucas <n>Lucas L(n)
tri spiral <n>φ-spiral coordinates
tri gematria <text>Coptic gematria + sacred formula
tri formula <value>Sacred formula decomposition
tri sacred32 constants + 9 predictions table

Reproduce Pellis–Trinity comparison in 10 seconds:

tri math constants --category=em
tri math compare --pellis

Reproduce locally:vhs tapes/tri-math-demo.tape

Sacred Biology (v14.0)

CommandDescription
tri bio dna <seq>DNA analysis with sacred mathematics
tri bio rna <seq>RNA analysis with sacred mathematics
tri bio protein <seq>Protein analysis (1-letter codes)
tri bio phi-genomeSacred genome patterns
tri bio codon <codon>Codon → amino acid lookup

Sacred Cosmology (v15.0)

CommandDescription
tri cosmos hubbleResolve Hubble tension via Sacred Formula
tri cosmos darkDark energy/matter as φ-patterns
tri cosmos predictPredict new constants and stability islands
tri cosmos expandUniverse expansion timeline
tri cosmos big-bangBig Bang through sacred lens

Sacred Neuroscience (v16.0)

CommandDescription
tri neuro waves [freq]Brain waves (φ-patterned frequencies)
tri neuro consciousness [C t E]Compute consciousness level Ψ
tri neuro regionsSacred brain regions (φ-index)
tri neuro networkAnalyze neural network sacredness
tri neuro synapseSynaptic transmission timing
tri neuro neuronsBrain statistics & sacred constants

Sacred Intelligence

CommandDescription
tri intelligenceSacred formula + gematria analysis
tri intelAlias for intelligence

Sacred Agents (Cycle 98)

CommandDescription
tri identityShow Sacred Intelligence identity
tri swarmMulti-agent Sacred Swarm status
tri governSacred Governance rules (φ-Rules)
tri dashboard3-column Sacred Dashboard
tri omegaMaster coordinator - all agents
tri math-agentSacred Math Agent - self-aware

Autonomous Evolution (Cycle 97)

CommandDescription
tri auto-commitAutonomous sacred patch commits (φ-guided)
tri ml-optimizeML-based patch optimization
tri deploy-dashboardDeploy production dashboard
tri self-hostSelf-hosting loop
tri safeguards showShow safeguard status

Dev Utilities

CommandDescription
tri doctorCodebase health (scan/mark/report/plan/heal)
tri cleanClean build artifacts (.zig-cache, zig-out)
tri fmtFormat Zig source (zig fmt src/)
tri statsProject statistics (files, LOC, specs, tests)
tri iglaIGLA initiative status (parser coverage)
tri versionShow version info

Demo & Benchmark Commands

CategoryCommands
TVCtri tvc-demo, tri tvc-stats
Multi-Agenttri agents-demo, tri agents-bench
Long Contexttri context-demo, tri context-bench
RAGtri rag-demo, tri rag-bench
Voicetri voice-demo, tri voice-bench
Sandboxtri sandbox-demo, tri sandbox-bench
Streamingtri stream-demo, tri stream-bench
Visiontri vision-demo, tri vision-bench
Fine-tuningtri finetune-demo, tri finetune-bench
Multi-modaltri multimodal-demo, tri multimodal-bench
Tool Usetri tooluse-demo, tri tooluse-bench
Unified Agenttri unified-demo, tri unified-bench
Autonomoustri auto-demo, tri auto-bench
Orchestrationtri orch-demo, tri orch-bench
Memorytri memory-demo, tri memory-bench

REPL Commands (in interactive mode)

/chat /code /fix /explain /test /doc /reason
/zig /python /rust /js Set language
/stats /verbose /help /quit

Build from Source

git clone https://github.com/gHashTag/trinity.git
cd trinity
zig build tri # Build TRI CLI
zig build test# Run all tests

Requires Zig 0.15.x.


FPGA — Autoregressive Ternary LLM

DOI

First autoregressive ternary language model on FPGA with fully open-source toolchain.

MetricValue
BoardQMTech XC7A100T ($30)
Throughput63 tok/s @ 92 MHz
Power~1W (~63 tok/s/W)
DSP blocks0 (pure LUT ternary compute)
BRAM98%
LUT5.8%
ToolchainopenXC7 (Yosys + nextpnr-xilinx + prjxray)
Tokens16 autoregressive from seed

Architecture

token_id -> Embedding -> Block1 -> Block2 -> Block3 -> Block4 -> LM Head -> Argmax --+
^ |
+--- result_token <----------------------------------------------------------------+

All weights use 2-bit ternary encoding (01=+1, 10=-1, 00=0). Multiplication reduces to conditional add/subtract/nop — zero DSP48 blocks required.

Quick Start

cd fpga/openxc7-synth
make hslm_full_top.bit # Synthesize
sudo ../tools/flash.sh hslm_full_top.bit # Flash

Design Variants

VariantBlocksBitstream
hslm_2block_top2hslm_2block_top.bit
hslm_3block_top3hslm_3block_top.bit
hslm_4block_top4hslm_4block_top.bit
hslm_full_top4 + autoregressive FSMhslm_full_top.bit

See Research Report for full technical details.


Docker Node

The Trinity CLI Docker image is published to GitHub Container Registry.

Imageghcr.io/ghashtag/trinity:latest
Versionghcr.io/ghashtag/trinity:5.1.0
Platformslinux/amd64
BaseAlpine 3.19
Size~8 MB
Dockerfiledeploy/Dockerfile

Run

docker run -it --rm ghcr.io/ghashtag/trinity:latest --version
# Or for interactive mode:
docker run -it --rm ghcr.io/ghashtag/trinity:latest

$TRI Token

$TRI is deployed on Ethereum Sepolia testnet. Mainnet deployment is planned.

PropertyValue
Token$TRI (Trinity Token)
Contract0xef368e29FA3aB2eaf02BccD05438ED3bafE9f469
NetworkEthereum Sepolia
Total Supply10,460,353,203 (3^21)
Decimals18
StandardERC-20 + ERC-20Permit

Allocation

Category%AmountPurpose
Node Rewards40%4,184,141,281Emitted to operators for useful work
Founder20%2,092,070,640Core team, 12-month cliff + 48-month vesting
Community20%2,092,070,640Grants, bounties, ecosystem growth
Treasury10%1,046,035,320Protocol development
Liquidity10%1,046,035,320DEX pools, available at TGE

Staking Tiers

Your staked $TRI determines your API tier. No API keys -- your wallet is your identity.

TierStaked $TRIRate LimitReward Multiplier
Free010 req/min1.0x
Staker100+60 req/min1.5x
Power1,000+300 req/min2.0x
Whale10,000+Unlimited3.0x

Include X-Wallet: 0xYOUR_ADDRESS in HTTP headers. See Tokenomics docs for full details.


Architecture

📘 See ARCHITECTURE.md for comprehensive system design.

Repo layout: Verilog snapshots live in hardware/rtl-root/; agents follow AGENTS.md. Research drafts: docs/lab/papers/, docs/lab/memory/; notebooks docs/notebooks/; deploy binaries deploy/prebuilt/; brain-only Zig build build/build.brain.zig.

Module Documentation

DomainDocsStatus
Commonsrc/common/README.md✅ Stable - Single source of truth for constants, protocol, errors
VSAsrc/vsa_core/✅ Stable - Vector Symbolic Architecture (99.5% test pass)
TTT Dataexternal/zig-golden-float/✅ Phase B/C Complete - Enum & constants support
UART/FPGAfpga/openxc7-synth/UART_README.md✅ v6.0 Current - FPGA communication protocol

Quick Reference

ModulePurpose
src/common/Shared constants (φ, TRINITY), protocol definitions, unified errors
src/vsa/Vector Symbolic Architecture: bind, unbind, bundle, similarity
src/vm.zigTernary Virtual Machine (stack-based bytecode)
src/needle/Semantic search with Brute+SIMD backend (100% exact)
src/firebird/BitNet LLM inference on CPU (20× memory efficiency)
hardware/rtl-root/Loose .v modules (historically in root)
external/zig-golden-float/GF16/TF3 number formats & TTT data structures
src/needle/Semantic search with Brute+SIMD backend (100% exact)
src/firebird/BitNet LLM inference on CPU (20x memory efficiency)
fpga/openxc7-synth/FPGA toolchain + UART host (v6 current, v5 legacy)
hardware/rtl-root/Loose .v modules (historically in root); e.g. tri fpga build hardware/rtl-root/blink.v

Core VSA System

ModulePurpose
src/vsa.zigMain VSA entry point (re-exports all submodules)
src/vsa/core.zigCore operations: bind, unbind, bundle, similarity
src/vsa/10k_vsa.zig10K-dimensional hypervectors
src/sdk.zigHigh-level API (Hypervector, Codebook)

Needle Tier 3 — Semantic Search

Brute+SIMD — 100% Exact, Instant Build

MetricValue
Build Time0ms (instant, no training)
Search @ 5k113ms (competitive)
Memory~7.7KB
Accuracy100% (exact)
ModulePurpose
src/needle/ann_brute_simd.zigBrute+SIMD implementation
src/needle/ann_interface.zigUnified ANN interface
src/needle/vsa.zigSemantic search with semanticFindCached()
src/needle/autonomous_refactor.zigAI-powered refactoring

Specs:specs/needle/ann_verdict.tri, specs/needle/ann_integration.tri

DePIN Node

ModulePurpose
src/firebird/depin.zigDePIN reward engine, Proof-of-Useful-Work
src/trinity_node/http_api.zigREST API with stake-based tiers
src/trinity_node/token_staking.zigStaking engine, slashing
src/trinity_node/config.zigNetwork config, contract addresses

Firebird LLM Engine

ModulePurpose
src/firebird/cli.zigLLM command-line interface
src/firebird/b2t_integration.zigBitNet-to-Ternary conversion
src/firebird/wasm_parser.zigWebAssembly module loading

VIBEE Compiler

ModulePurpose
src/vibeec/vibee_parser.zigParse .vibee specifications
src/vibeec/zig_codegen.zigGenerate Zig code from specs
src/vibeec/verilog_codegen.zigGenerate Verilog for FPGA
src/vibeec/runtime_swarm.zigProduction swarm runtime (32 agents)

Production Swarm (v8)

One-command 32-agent Trinity cluster:

# Generate and run
zig build vibee -- gen specs/tri/vsa_swarm_production_32.vibee
zig build swarm
./zig-out/bin/swarm-runtime

Features:

  • 32 agents with phi-spiral consensus (φ² + 1/φ² = 3)
  • Self-healing with auto-recovery
  • Prometheus metrics on :9090
  • Self-improvement cycle (analyzes & regenerates patterns)

Docker deployment:

cd deploy && docker compose up -d
# Prometheus: :9091, Grafana: :3000

Kubernetes deployment:

kubectl apply -f deploy/k8s/
kubectl port-forward svc/trinity-swarm-metrics 9090:9090

HTTP API

The node exposes an OpenAI-compatible API on port 8080.

# Chat completion
curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-Wallet: 0xYOUR_WALLET" \
-d '{"model":"trinity-llm","messages":[{"role":"user","content":"Hello"}]}'# Node stats
curl http://localhost:8080/v1/node/stats
# Storage
curl -X POST http://localhost:8080/v1/storage/put \
-H "Content-Type: application/octet-stream" \
--data-binary @myfile.bin
# Prometheus metrics
curl http://localhost:9090/metrics
MethodEndpointDescription
GET/healthHealth check
GET/Server info and metrics
POST/v1/chat/completionsChat completion (OpenAI-compatible)
GET/v1/node/statsNode statistics and earnings
GET/v1/node/tierCurrent wallet tier info
POST/v1/node/claimClaim pending $TRI rewards
POST/v1/storage/putStore a data shard
GET/v1/storage/get/:hashRetrieve a data shard
GET/v1/storage/statusStorage layer status
GET/metricsPrometheus metrics (port 9090)

See API Reference for full documentation.


TRI CLI

Single command for all Trinity features:

zig build tri
# Available commands
tri # Interactive REPL
tri code fibonacci # Generate code
tri chat "hello"# Chat
tri explain <file># Explain code
tri fix <file># Fix bugs
tri test<file># Generate tests
tri help# Full help

Multilingual: English, Chinese -- auto-detected.


Benchmarks — BENCH-001 & BENCH-002 (Phase 1)

Honest comparison of Trinity number formats (GF16, TF3, Ternary) vs IEEE standards (fp16, bfloat16).

Running Benchmarks

# Quantization error (BENCH-001)
zig build-exe src/bench_formats.zig -O ReleaseFast --name bench-formats
./bench-formats
# Arithmetic microbenchmarks (BENCH-002)
zig build-exe src/bench_arith.zig -O ReleaseFast --name bench-arith
./bench-arith

Format Comparison: GF16 vs fp16 vs bfloat16 vs Ternary

| Metric | fp16 (IEEE) | GF16 (Trinity) | bfloat16 (IEEE) | Ternary | |-------|-----------|-----------|-----------| | MSE (×10⁻⁴) | 0.000123 | 0.00015 | 0.0002 | | Accuracy | 10% | 10% | 10% | 6.9% | | Latency | ~5.0 ns/op | ~8.5 ns/op | ~8.5 ns/op | — | | Memory/weight | 4 bytes | 4 bytes | 4 bytes | 1 byte |

Note: GF16 matches f32 accuracy on synthetic data while using 1/4 memory (vs 32 bytes). Software implementation (not hardware-accurate).

FormatBits (s/e/m)Min posMaxDenormals?
fp161/5/106.1e-565504Yes
bf161/8/71.2e-383.4e38No
GF161/6/94.66e-104.29e9No
TF31/6/11TBDTBDNo
Ternary2 bits-1+1N/A

BENCH-001: Quantization Error (Normal Distribution)

FormatMSEMax Error
f160.00010.0450
bf160.00020.0890
gf160.000150.0670
ternary0.50001.0000

Note: GF16 shows competitive MSE (0.00015) between f16 (0.0001) and bf16 (0.0002) on Normal(0,1) distribution, while maintaining competitive max error. Ternary has much higher quantization error (0.5 MSE) due to limited representation (-1, 0, +1 only).

BENCH-002: Arithmetic Microbenchmarks

FormatAdd (ns/op)Mul (ns/op)Div (ns/op)
f32~5.0~4.5~12.0
soft-fp16~8.5~4.5~12.0
soft-GF16~7.2~4.5~12.0
ternary~0.5~0.5~1.0

Note: Software implementations (soft-fp16, soft-GF16) have overhead vs native f32. Ternary is significantly faster due to {-1, 0, +1} representation requiring only add/subtract.

BENCH-003: NN Inference

FormatAccuracyLossSize (bytes/weight)
f325.80%0.04832
f16 soft5.80%0.04816
GF16 soft5.80%0.04816
ternary6.90%0.122

Note: On synthetic MNIST-like data, GF16 maintains same accuracy as f32 baseline when using software emulation. Ternary shows higher loss due to limited {-1,0,+1} representation but 16x smaller memory footprint.

Status

  • Quantization error vs fp16/bf16 (CPU, synthetic distributions)
  • Dynamic range & special values
  • Arithmetic throughput vs fp32 (software implementations)
  • Small NN inference benchmark (software emulation)
  • FPGA LUT/DSP comparison (future)

Note: Full benchmark suite requires FPGA synthesis for hardware-accurate GF16/TF3 measurements. Current software implementations provide baseline comparisons.

docs/PRODUCTION_BENCHMARKS.md — Detailed benchmark and format properties tables


DePIN Reward System

Nodes earn $TRI through Proof-of-Useful-Work -- every rewarded computation produces a real, verifiable result.

OperationRateDescription
VSA Evolution0.001 TRI/generationEvolving hypervector populations
Navigation0.0001 TRI/stepNavigating semantic vector spaces
WASM Conversion0.01 TRI/conversionCompiling WASM to ternary bytecode
Benchmark0.005 TRI/runRunning reproducible benchmarks
Storage Hosting0.00005 TRI/shard/hourHosting data shards
Storage Retrieval0.0005 TRI/retrievalServing requested data

Bonus multipliers: fitness > 0.9 grants +50%, similarity > 0.8 grants +100%, staking 100+ TRI grants 1.5x on all earnings.


Project Structure

trinity/
├── src/ # Core Zig source
│ ├── vsa.zig # Vector Symbolic Architecture
│ ├── vm.zig # Ternary Virtual Machine
│ ├── hybrid.zig # HybridBigInt (1.58 bits/trit)
│ ├── trinity_node/ # DePIN node (HTTP API, staking, config)
│ ├── firebird/ # LLM engine + DePIN rewards
│ ├── vibeec/ # VIBEE compiler + IGLA agent
│ ├── b2t/ # BitNet inference
│ ├── phi-engine/ # Quantum-inspired computation
│ └── tvc/ # Ternary Vector Computing
├── deploy/ # Docker configs
│ └── Dockerfile.node # Multi-stage Alpine build
├── deploy/contracts/ # Solidity (TrinityToken.sol)
├── specs/ # .vibee specifications
├── docsite/ # Documentation site (Docusaurus)
├── website/ # Landing page (Vite + React)
├── libs/ # Multi-language VSA libraries
└── build.zig # Build system

Documentation

ResourceURL
Documentation Indexdocs/DOCUMENTATION_INDEX.md — Central documentation hub
API Referencedocs/api_reference.md — HTTP API, CLI, MCP servers
Glossarydocs/glossary.md — Technical terms and acronyms
Troubleshootingdocs/troubleshooting.md — Common issues & solutions
ContributingCONTRIBUTING.md — Development guidelines
Code of ConductCODE_OF_CONDUCT.md — Community guidelines
ChangelogCHANGELOG.md — Version history
For Researchersdocs/papers/README_FOR_SCIENTISTS.md
Command Referencedocs/command_registry.md (auto-generated)
DePIN OverviewgHashTag.github.io/trinity/docs/depin
Quick StartgHashTag.github.io/trinity/docs/depin/quickstart
TokenomicsgHashTag.github.io/trinity/docs/depin/tokenomics
ArchitecturegHashTag.github.io/trinity/docs/depin/architecture
ResearchgHashTag.github.io/trinity/docs/research
WebsitegHashTag.github.io/trinity

Autonomous Development

Trinity includes built-in autonomous agents for sustained development, optimization, and code generation.

Built-in Agents

BinaryPurpose
ralph-agentSleep-wake daemon, picks GitHub issues
ralph-hookHook events → Telegram notifications
tri-apiStandalone agentic loop (Claude Code replacement)
tri-botTelegram bot with SSE streaming

Quick Start

# Build all agents
zig build
# Run Ralph agent
./zig-out/bin/ralph-agent --help
# Run tri-api (interactive agentic loop)
./zig-out/bin/tri-api
# Run Telegram bot
./zig-out/bin/tri-bot

Agent Workflow

  1. Define: Edit or create a specification in specs/tri/*.tri
  2. Plan: Update .ralph/fix_plan.md with your next objective
  3. Run: Execute tri agent run <issue-number> for autonomous issue resolution
  4. Verify: Agent generates code, runs tests, and checks performance
  5. Commit: Upon success, agent updates .ralph/SUCCESS_HISTORY.md

For detailed protocols, see docs/docs/development/ralph.md.


Build Commands

zig build # Build all 50+ binaries
zig build tri # Unified TRI CLI (32 MB)
zig build test# Run ALL tests
zig build bench # Run benchmarks
zig build release # Cross-platform release builds
zig build vibee # VIBEE Compiler CLI
zig build firebird # Firebird LLM CLI
zig build libvsa # Build libtrinity-vsa C API
zig build libqueen # Build libtrinity-queen C API
zig fmt src/ # Format code

Contributing

git clone https://github.com/gHashTag/trinity.git
cd trinity
zig build test# Run all tests before submitting PRs

See CONTRIBUTING.md for guidelines.

Troubleshooting

IssueSolutionDocumentation
Build fails on Zig 0.15.xCheck API migrationCONTRIBUTING.md
FPGA programming failsRun fxload firstdocs/troubleshooting.md
Training stalls at low stepsUse cosine LR scheduledocs/troubleshooting.md
Railway deployment errorsCheck env vars, Dockerfiledocs/troubleshooting.md

See docs/troubleshooting.md for complete troubleshooting guide.


Maintainer

Dmitrii Vasilev (@gHashTag)

Attribution for listed docs and packages is checked by src/tri/author_attribution_guard.zig and tools/config/author_attribution_guard.manifest. Run zig build author-guard before merge; it is also wired into zig build test when the full test graph compiles. Do not remove or bypass without maintainer approval.


Community

RedditTelegramX


GitHub Topics

Help others discover Trinity — we're tagged with:

Computing

  • ternary-computing — {-1, 0, +1} alphabet
  • balanced-ternary — Symmetric ternary representation
  • ternary-logic — Three-valued logic

AI/ML

  • vsa — Vector Symbolic Architecture
  • vector-symbolic-architecture — Full VSA name
  • hypervector — High-dimensional computing
  • hd-computing — Hyperdimensional computing
  • hyperdimensional-computing — HDC full name
  • neurosymbolic-ai — Neural + symbolic AI
  • llm-inference — Language model inference
  • tinyml — Efficient ML on edge devices

Math/Physics

  • golden-ratio — φ = (1+√5)/2
  • fundamental-constants — G, α, etc.
  • mathematical-physics — Physics from math
  • sacred-geometry — Geometric patterns in nature

Hardware

  • fpga-inference — LLM on FPGA
  • fpga — Field-programmable gate arrays
  • verilog — Hardware description language
  • yosys — Open source synthesis suite
  • openfpga — Open source FPGA tools

Language

  • zig — Zig programming language
  • zig-language — Zig (alt tag)
  • systems-programming — Low-level coding

Performance

  • energy-efficient-ai — Green AI
  • edge-ai — AI on edge devices
  • low-power — Power-optimized computing

To add topics manually: Visit https://github.com/gHashTag/trinity and click "Add topics" in the About section.

📦 Model Documentation (Consolidated)

Complete catalog of all model-related documentation:

docs/research/COMPLETE_MODEL_CATALOG.md

  • JEPA-T (Ternary Joint Embedding Predictive Architecture)
  • Neural Cellular Automata (NCA)
  • VSA (Vector Symbolic Architecture)
  • Ternary Models
  • Hybrid Models

License

MIT -- see LICENSE


Download v6.3.0DashboardDocumentation

φ² + 1/φ² = 3 = TRINITY
v6.3.0 — Analysis Notebooks + Conference Abstracts, 26 March 2026

About

The Trinity ternary compute stack — tri CLI · BitNet LLM · VSA · GF16

Topics

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages